Skip to content

Commit

Permalink
Merge pull request #18 from AngleProtocol/feat/multisig-scripts
Browse files Browse the repository at this point in the history
feat: add all scripts from multisig to governance
  • Loading branch information
GuillaumeNervoXS authored Jan 15, 2024
2 parents 1d5f908 + fb92b6b commit 54bcb30
Show file tree
Hide file tree
Showing 31 changed files with 1,131 additions and 260 deletions.
17 changes: 16 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,19 @@
[submodule "lib/solidity-stringutils"]
path = lib/solidity-stringutils
url = https://github.com/Arachnid/solidity-stringutils
ignore = dirty
ignore = dirty
[submodule "lib/angle-transmuter"]
path = lib/angle-transmuter
url = https://github.com/AngleProtocol/angle-transmuter
[submodule "lib/borrow-contracts"]
path = lib/borrow-contracts
url = https://github.com/AngleProtocol/borrow-contracts
[submodule "lib/new-oz"]
path = lib/new-oz
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/new-oz-upgradeable"]
path = lib/new-oz-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/chainlink"]
path = lib/chainlink
url = https://github.com/smartcontractkit/chainlink
3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ optimizer = true
optimizer_runs = 1000
solc_version = "0.8.23"
ffi = true
fs_permissions = [{ access = "read-write", path = "./scripts/proposals/payload.json"}]

[fuzz]
runs = 10000
Expand Down Expand Up @@ -43,7 +44,7 @@ optimism = { key = "${OPTIMISM_ETHERSCAN_API_KEY}" }
polygon = { key = "${POLYGON_ETHERSCAN_API_KEY}" }
avalanche = { key = "${AVALANCHE_ETHERSCAN_API_KEY}" }
celo = { key = "${CELO_ETHERSCAN_API_KEY}", url = "https://api.celoscan.io/api" }
polygon-zkevm = { key = "${POLYGONZKEVM_ETHERSCAN_API_KEY}", url = "https://api-zkevm.polygonscan.com/api" }
polygon-zkevm = { key = "${POLYGON_ZKEVM_ETHERSCAN_API_KEY}", url = "https://api-zkevm.polygonscan.com/api" }
bsc = { key = "${BSC_ETHERSCAN_API_KEY}"}
base = { key = "${BASE_ETHERSCAN_API_KEY}", url = "https://api.basescan.org/api" }
linea = { key = "${LINEA_ETHERSCAN_API_KEY}" }
Expand Down
197 changes: 197 additions & 0 deletions helpers/createProposal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
#! /bin/bash

function chain_to_uri {
chain=$1

case $chain in
"1")
echo $ETH_NODE_URI_MAINNET
;;
"2")
echo $ETH_NODE_URI_ARBITRUM
;;
"3")
echo $ETH_NODE_URI_POLYGON
;;
"4")
echo $ETH_NODE_URI_GNOSIS
;;
"5")
echo $ETH_NODE_URI_AVALANCHE
;;
"6")
echo $ETH_NODE_URI_BASE
;;
"7")
echo $ETH_NODE_URI_BSC
;;
"8")
echo $ETH_NODE_URI_CELO
;;
"9")
echo $ETH_NODE_URI_POLYGON_ZKEVM
;;
"10")
echo $ETH_NODE_URI_OPTIMISM
;;
"11")
echo $ETH_NODE_URI_LINEA
;;
*)
;;
esac
}

function chain_to_chainId {
chain=$1

case $chain in
"1")
echo "1"
;;
"2")
echo "42161"
;;
"3")
echo "137"
;;
"4")
echo "100"
;;
"5")
echo "43114"
;;
"6")
echo "8453"
;;
"7")
echo "56"
;;
"8")
echo "42220"
;;
"9")
echo "1101"
;;
"10")
echo "10"
;;
"11")
echo "59144"
;;
*)
;;
esac
}

function usage {
echo "bash createProposal.sh <script> <chain>"
echo ""
echo -e "script: path to the script to run"
echo -e "chain: chain(s) to run the script on (separate with commas)"
echo -e "\t1: Ethereum Mainnet"
echo -e "\t2: Arbitrum"
echo -e "\t3: Polygon"
echo -e "\t4: Gnosis"
echo -e "\t5: Avalanche"
echo -e "\t6: Base"
echo -e "\t7: Binance Smart Chain"
echo -e "\t8: Celo"
echo -e "\t9: Polygon ZkEvm"
echo -e "\t10: Optimism"
echo -e "\t11: Linea"
echo ""
}

function main {
command=false
if [[ $# -ne 2 && $# -ne 0 ]]; then
usage
exit 1
fi
if [ $# -eq 2 ]; then
script=$1
chains=$2
command=true
fi

if [ ! -f .env ]; then
echo ".env not found!"
exit 1
fi
source .env

if [ $command != true ]; then
echo ""
echo "What script would you like to run ?"

read script

if [ -z "$script" ]; then
echo "No script provided"
exit 1
fi

echo ""

echo "Which chain(s) would you like to run the script on ? (separate with commas)"
echo "- 1: Ethereum Mainnet"
echo "- 2: Arbitrum"
echo "- 3: Polygon"
echo "- 4: Gnosis"
echo "- 5: Avalanche"
echo "- 6: Base"
echo "- 7: Binance Smart Chain"
echo "- 8: Celo"
echo "- 9: Polygon ZkEvm"
echo "- 10: Optimism"
echo "- 11: Linea"

read chains

if [ -z "$chains" ]; then
echo "No chain provided"
exit 1
fi
fi

mainnet_uri=$(chain_to_uri 1)

chainIds=""
for chain in $(echo $chains | sed "s/,/ /g")
do
if [[ -z $chainIds ]]; then
chainIds="$(chain_to_chainId $chain)"
else
chainIds="$chainIds,$(chain_to_chainId $chain)"
fi
done

echo ""
echo "Running on chains $chainIds"

export CHAIN_IDS=$chainIds
# TODO if the script fails we should abort
FOUNDRY_PROFILE=dev forge script $script

if [ $? -ne 0 ]; then
echo ""
echo "Script failed"
fi

# TODO if the test fails we should abort
testContract="${script}Test"
echo ""
echo "Running test"
FOUNDRY_PROFILE=dev forge test --match-contract $testContract -vvv

echo ""
echo "Would you like to create the proposal ? (yes/no)"
read execute

# if [[ $execute == "yes" ]]; then
# forge script scripts/interaction/Propose.s.sol:Propose --fork-url $mainnet_uri --broadcast
# fi
}

main $@
1 change: 1 addition & 0 deletions lib/angle-transmuter
Submodule angle-transmuter added at 7fd03d
1 change: 1 addition & 0 deletions lib/borrow-contracts
Submodule borrow-contracts added at 407a0e
1 change: 1 addition & 0 deletions lib/chainlink
Submodule chainlink added at 3cf93c
1 change: 1 addition & 0 deletions lib/new-oz
Submodule new-oz added at 01ef44
1 change: 1 addition & 0 deletions lib/new-oz-upgradeable
Submodule new-oz-upgradeable added at fbdb82
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts updated 39 files
+6 −0 contracts/governance/IGovernor.sol
+7 −2 contracts/token/ERC20/extensions/ERC20Wrapper.sol
+10 −10 contracts/utils/math/Math.sol
+4 −4 docs/modules/ROOT/pages/utilities.adoc
+151 −23 package-lock.json
+3 −3 package.json
+1 −7 scripts/generate/templates/EnumerableMap.js
+18 −0 scripts/generate/templates/EnumerableMap.opts.js
+1 −6 scripts/generate/templates/EnumerableSet.js
+10 −0 scripts/generate/templates/EnumerableSet.opts.js
+17 −7 test/helpers/enums.js
+17 −22 test/helpers/erc1967.js
+0 −6 test/helpers/iterate.js
+11 −10 test/helpers/math.js
+1 −1 test/metatx/ERC2771Forwarder.test.js
+41 −36 test/proxy/Clones.behaviour.js
+62 −37 test/proxy/Clones.test.js
+18 −7 test/proxy/ERC1967/ERC1967Proxy.test.js
+64 −74 test/proxy/ERC1967/ERC1967Utils.test.js
+57 −55 test/proxy/Proxy.behaviour.js
+88 −102 test/proxy/beacon/BeaconProxy.test.js
+32 −31 test/proxy/beacon/UpgradeableBeacon.test.js
+33 −55 test/proxy/transparent/ProxyAdmin.test.js
+183 −238 test/proxy/transparent/TransparentUpgradeableProxy.behaviour.js
+22 −18 test/proxy/transparent/TransparentUpgradeableProxy.test.js
+97 −99 test/proxy/utils/Initializable.test.js
+73 −84 test/proxy/utils/UUPSUpgradeable.test.js
+131 −195 test/token/ERC20/ERC20.behavior.js
+100 −95 test/token/ERC20/ERC20.test.js
+132 −135 test/token/ERC20/extensions/ERC20Wrapper.test.js
+2 −1 test/token/ERC721/extensions/ERC721Consecutive.test.js
+237 −263 test/utils/math/Math.test.js
+72 −85 test/utils/math/SafeCast.test.js
+24 −67 test/utils/math/SignedMath.test.js
+7 −7 test/utils/structs/EnumerableMap.behavior.js
+67 −121 test/utils/structs/EnumerableMap.test.js
+12 −6 test/utils/structs/EnumerableSet.behavior.js
+36 −80 test/utils/structs/EnumerableSet.test.js
+2 −1 test/utils/types/Time.test.js
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts-upgradeable
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
"coverage": "FOUNDRY_PROFILE=dev forge coverage --report lcov && yarn lcov:clean && yarn lcov:generate-html",
"compile": "forge build",
"compile:dev": "FOUNDRY_PROFILE=dev forge build",
"deploy": "forge script --skip test --broadcast --verify --slow -vvvv --rpc-url linea scripts/DeploySideChainGovernance.s.sol",
"deploy:fork": "forge script --skip test --slow --fork-url fork --broadcast scripts/DeploySideChainGovernance.s.sol -vvvv",
"create:proposal": "bash helpers/createProposal.sh",
"deploy": "forge script --skip test --broadcast --verify --slow -vvvv --rpc-url polygon scripts/interaction/TimelockExecute.s.sol",
"deploy:test": "FOUNDRY_PROFILE=dev forge script --skip test --broadcast --verify --slow -vvvv --rpc-url gnosis scripts/DeployOnChainGovernance.s.sol",
"deploy:fork": "FOUNDRY_PROFILE=dev forge script --skip test --slow --fork-url fork --broadcast scripts/interaction/TimelockExecute.s.sol -vvvv",
"gas": "yarn test --gas-report",
"fork": "bash helpers/fork.sh",
"run": "docker run -it --rm -v $(pwd):/app -w /app ghcr.io/foundry-rs/foundry sh",
"script:fork": "source .env && forge script --skip test --fork-url fork --broadcast -vvvv",
"test:unit": "forge test -vvv --gas-report --match-path \"test/unit/**/*.sol\"",
"test:invariant": "forge test -vvv --gas-report --match-path \"test/invariant/**/*.sol\"",
"test:fuzz": "forge test -vvv --gas-report --match-path \"test/fuzz/**/*.sol\"",
"test": "FOUNDRY_PROFILE=dev forge test -vv",
"test": "FOUNDRY_PROFILE=dev forge test -vvvv",
"slither": "slither .",
"lcov:clean": "lcov --remove lcov.info -o lcov.info 'test/**' 'scripts/**' 'contracts/transmuter/configs/**' 'contracts/utils/**'",
"lcov:generate-html": "genhtml lcov.info --output=coverage",
Expand All @@ -38,12 +40,12 @@
"url": "https://github.com/AngleProtocol/boilerplate/issues"
},
"devDependencies": {
"@angleprotocol/sdk": "0.20.0",
"@angleprotocol/sdk": "^0.25.0",
"@layerzerolabs/lz-sdk": "^0.0.30",
"prettier": "^2.0.0",
"prettier-plugin-solidity": "^1.1.3",
"solhint": "^3.5.1",
"solhint-plugin-prettier": "^0.0.5"
},
"dependencies": {}
}
}
13 changes: 10 additions & 3 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
oz/=lib/openzeppelin-contracts/contracts/
oz-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
oz/=lib/new-oz/contracts/
oz-upgradeable/=lib/new-oz-upgradeable/contracts/
lz/=lib/solidity-examples/contracts
stringutils/=lib/solidity-stringutils
stringutils/=lib/solidity-stringutils
borrow/=lib/borrow-contracts/contracts
transmuter/=lib/angle-transmuter/contracts
contracts/=contracts
test/=test
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts
@chainlink/=lib/chainlink
16 changes: 0 additions & 16 deletions scripts/BasicScript.s.sol

This file was deleted.

30 changes: 29 additions & 1 deletion scripts/Constants.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ pragma solidity ^0.8.9;

import { ILayerZeroEndpoint } from "lz/lzApp/interfaces/ILayerZeroEndpoint.sol";
import { IVotes } from "oz/governance/extensions/GovernorVotes.sol";
import { ITransmuter } from "transmuter/interfaces/ITransmuter.sol";
import { IAgToken } from "borrow/interfaces/IAgToken.sol";
import { ProxyAdmin } from "oz/proxy/transparent/ProxyAdmin.sol";
import { Ownable } from "oz/access/Ownable.sol";
import { CoreBorrow } from "borrow/coreBorrow/CoreBorrow.sol";
import { ITreasury } from "borrow/interfaces/ITreasury.sol";
import { TimelockController } from "oz/governance/TimelockController.sol";
import { AngleGovernor } from "contracts/AngleGovernor.sol";
import "./Interfaces.s.sol";

enum ContractType {
Timelock,
Expand All @@ -27,6 +36,13 @@ enum ContractType {
FeeDistributor
}

struct SubCall {
uint256 chainId;
address target;
uint256 value;
bytes data;
}

uint256 constant timelockDelay = 1 days;
uint48 constant initialVotingDelay = 1 days;
uint256 constant initialVotingDelayBlocks = 1 days / 12;
Expand All @@ -47,8 +63,20 @@ uint256 constant CHAIN_POLYGON = 137;
uint256 constant CHAIN_GNOSIS = 100;
uint256 constant CHAIN_BNB = 56;
uint256 constant CHAIN_CELO = 42220;
uint256 constant CHAIN_ZKEVMPOLYGON = 1101;
uint256 constant CHAIN_POLYGONZKEVM = 1101;
uint256 constant CHAIN_BASE = 8453;
uint256 constant CHAIN_LINEA = 59144;
uint256 constant CHAIN_MANTLE = 5000;
uint256 constant CHAIN_AURORA = 1313161554;
uint256 constant CHAIN_SOURCE = CHAIN_ETHEREUM;

uint256 constant BASE_18 = 1e18;
uint256 constant BASE_9 = 1e9;

uint64 constant twoPoint5Rate = 782997666703977344;
uint64 constant fourRate = 1243680713969297408;
uint64 constant fourPoint3Rate = 1335019428339023872;

string constant pathProposal = "/scripts/proposals/payload.json";
address constant proposer = 0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185;
address constant whale = 0x41Bc7d0687e6Cea57Fa26da78379DfDC5627C56d;
Loading

0 comments on commit 54bcb30

Please sign in to comment.