Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Nov 18, 2021
0 parents commit 073e20a
Show file tree
Hide file tree
Showing 52 changed files with 23,493 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# AAVE GOVERNANCE
AAVE_GOVERNANCE_ADDRESS = "0xEC568fffba86c094cf06b22134B23074DFE2252c"
AAVE_SHORT_EXECUTOR_ADDRESS = "0xEE56e2B3D491590B5b31738cC34d5232F378a8D5"

# ARC MARKET
ARC_POOL_ADDRESSES_PROVIDER_ADDRESS = "0x6FdfafB66d39cD72CFE7984D3Bbcc76632faAb00"
ARC_PERMISSIONED_POOL_ADDRESS = "0x37D7306019a38Af123e4b245Eb6C28AF552e0bB0"
ARC_POOL_CONFIGURATOR_ADDRESS = "0x4e1c7865e7BE78A7748724Fa0409e88dc14E67aA"
ARC_PERMISSIONED_WETH_GATEWAY_ADDRESS = "0xD51E46B02eCB71357cBdf661E2789EC787d94Af9"
ARC_AAVE_PROTOCOL_DATA_PROVIDER_ADDRESS = "0x71B53fC437cCD988b1b89B1D4605c3c3d0C810ea"
ARC_PERMISSION_MANAGER_ADDRESS = "0xF4a1F5fEA79C3609514A417425971FadC10eCfBE"
ARC_MARKET_MULTISIG_ADDRESS = "0x23c155C1c1ecB18a86921Da29802292f1d282c68"

# ARC TIMELOCK
ARC_TIMELOCK_DELAY = "172800"
ARC_TIMELOCK_GRACE_PERIOD = "432000"
ARC_TIMELOCK_MINIMUM_DELAY = "172800"
ARC_TIMELOCK_MAXIMUM_DELAY = "172800"
ARC_TIMELOCK_GUARDIAN_ADDRESS = "0x33B09130b035d6D7e57d76fEa0873d9545FA7557"

# ARC TIMELOCK VETO DAO
FIREBLOCKS_ADDRESS = "0x686a12A79008246F4dF2f1Ea30d136BD6DE748B4"

# IPFS encoded hash of the AIP text for the proposal submission.
IPFS_ENCODED_HASH = "0x27c7a77c3127ef93b409b291cbf3726ea80b9ce00bc3e2967bc7027b0c89f04b"

# These addresses are used for testing. If not provided, new contracts will be deployed.
ARC_TIMELOCK_ADDRESS = "0xAce1d11d836cb3F51Ef658FD4D353fFb3c301218"
PROPOSAL_PAYLOAD_ADDRESS = "0xA7fC6E204c2069edb0ed5Fed451F419B985eC416"
16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": { "node": true },
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended"
],
"rules": {}
}
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.env
#hardhat files
cache
artifacts
node_modules
dist/
build/
.vscode
.idea
/types
/typechain
temp.txt

deployed-contracts.json

coverage
coverage.json
.coverage_artifacts
.coverage_cache
.coverage_contracts

.DS_Store
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifacts
cache
node_modules
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"printWidth": 100,
"trailingComma": "es5",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"overrides": [
{
"files": "*.sol",
"options": {
"semi": true,
"printWidth": 100
}
}
]
}
34 changes: 34 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
skipFiles: [
'dependencies/utilities/Context.sol',
'dependencies/utilities/Ownable.sol',
'dependencies/utilities/SafeMath.sol',
'dependencies/polygonDependencies/fxportal/FxRoot.sol',
'dependencies/polygonDependencies/fxportal/FxChild.sol',
'dependencies/polygonDependencies/CustomPolygonMapping.sol',
'dependencies/polygonDependencies/PolygonMarketUpdate.sol',
'dependencies/aaveGovernance/Executor.sol',
'dependencies/aaveGovernance/AaveGovernanceV2.sol',
'dependencies/arbitrumDependencies/bridge/interfaces/IBridge.sol',
'dependencies/arbitrumDependencies/bridge/interfaces/IInbox.sol',
'dependencies/arbitrumDependencies/bridge/interfaces/IMessageProvider.sol',
'dependencies/arbitrumDependencies/bridge/interfaces/IOutbox.sol',
'dependencies/arbitrumDependencies/bridge/utils/Context.sol',
'dependencies/arbitrumDependencies/bridge/utils/Ownable.sol',
'dependencies/arbitrumDependencies/bridge/Bridge.sol',
'dependencies/arbitrumDependencies/bridge/Inbox.sol',
'dependencies/arbitrumDependencies/bridge/InboxHelper.sol',
'dependencies/arbitrumDependencies/bridge/Messages.sol',
'dependencies/arbitrumDependencies/bridge/Outbox.sol',
'dependencies/arbitrumDependencies/bridge/OutboxEntry.sol',
'dependencies/arbitrumDependencies/libraries/BytesLib.sol',
'dependencies/arbitrumDependencies/libraries/BytesLib.sol',
'dependencies/arbitrumDependencies/libraries/Cloneable.sol',
'dependencies/arbitrumDependencies/libraries/CloneFactory.sol',
'dependencies/arbitrumDependencies/libraries/Clones.sol',
'dependencies/arbitrumDependencies/libraries/ICloneable.sol',
'dependencies/arbitrumDependencies/libraries/MerkleLib.sol',
'interfaces/IAaveGovernanceBridge.sol',
'interfaces/IAavePolygonGovernance.sol',
],
};
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ethereum/solc:0.7.6 as build-deps

FROM node:14
COPY --from=build-deps /usr/bin/solc /usr/bin/solc
12 changes: 12 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (C) 2020 Aave

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html)
for more details
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
```
.///. .///. //. .// `/////////////-
`++:++` .++:++` :++` `++: `++:......---.`
`/+: -+/` `++- :+/` /+/ `/+/ `++.
/+/ :+/ /+: /+/ `/+/ /+/` `++.
-::/++::` /+: -::/++::` `/+: `++: :++` `++/:::::::::.
-:+++::-` `/+: --++/---` `++- .++- -++. `++/:::::::::.
-++. .++- -++` .++. .++. .++- `++.
.++- -++. .++. -++. -++``++- `++.
`++: :++` .++- :++` :+//+: `++:----------`
-/: :/- -/: :/. ://: `/////////////-
```

# Aave Arc Timelock

This repo contains smart contracts to add a timelock to the Aave Arc governance process. This timelock gives a guardian address the opportunity to cancel an approved governance action prior to its execution.

The core contract is the `TimelockExecutorBase`, an abstract contract that contains the logic to facilitate the queueing, delay, cancellation and/or execution of sets of actions sent by the aave governance contract. This base contract is extended in the `ArcTimelock` contract to manage receiving calls from the governance contract and queuing them within the `TimelockExecutorBase`.

This repo is based on the [governance-crosschain-bridges](https://github.com/aave/governance-crosschain-bridges). The `TimelockExecutorBase` is the same as the `BridgeExecutorBase` contract from this repo, just renamed to meet the usecase. The `governance-crosschain-bridges` repo, is an audited repo, and has 100% test coverage that can be accessed and ran within that repo.

## Getting Started

### Setup

- Clone the repo
- Run `npm install`

Follow the next steps to setup the repository:

- Install `docker` and `docker-compose`
- Create an environment file named `.env` and fill out the environment variables per `example.env`
- Make sure the information included in the environment file `.config.env` is correct.

### Running in Docker

Terminal Window 1
`docker-compose up`

Once Terminal Window 1 Loaded - in a separate terminal window - Terminal Window 2:
`docker-compose exec contracts-env bash`

In Terminal Window 2, run desired scripts from npm package file (i.e `npm run compile`)

### Compile

`npm run compile`

This will compile the available smart contracts.

### Test

All tests will run a fork-based test with the existing deployed versions of aave governance and the aave arc market.

- `test:arc:full:fork` - Runs a full test scenario, executing every action needed for the ARC market launch: deploy the ArcTimelock contract, release the market keys to the ArcTimelock, deploy the AIP payload and submit the governance proposal.

- `test:timelock:full` - The ArcTimelock is set as the ArcMarketAdmin. A proposal is created, queued, voted on, and executed, passing the Aave Governance and the ArcTimelock. It uses a mock proposal to update some market parameters.

- `test:timelock:update"` - The ArcTimelock is set as the ArcMarketAdmin. A proposal is created, queued, voted on, and executed, passing the Aave Governance and the ArcTimelock. It uses a mock proposal to update parameters of the ArcTimelock.

- `test:arc:keys` - Run a simple test scenario for releasing the ARC market keys to the ArcTimelock.


## Arc Timelock

### Deploying parameters

- `ethereumGovernanceExecutor` - the address that will have permission to queue ActionSets. This should be the aave governance executor
- `delay` - the time required to pass after the ActionsSet is queued, before execution
- `gracePeriod` - once execution time passes, you can execute this until the grace period ends
- `minimumDelay` - if the delay is updated by the guardian, it cannot be less than this minimum
- `maximumDelay` - if the delay is updated by the guardian, it cannot be more than this maximum
- `guardian` - the admin address of this contract with the permission to cancel ActionsSets and update the delay value



## License
[BSD-3-Clause](./LICENSE.md)
Binary file not shown.
80 changes: 80 additions & 0 deletions contracts/dependencies/IERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;

/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);

/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);

/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);

/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);

/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);

/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);

/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);

/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
Loading

0 comments on commit 073e20a

Please sign in to comment.