From 7ca9120b7b1feb4704b625077a6be34ea1c1a8f1 Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Tue, 25 Feb 2025 16:31:11 -0500 Subject: [PATCH 1/5] feat: support base deployment gas limit had to be set when setting executors on base: kept getting UNPREDICTABLE_GAS_LIMIT error. It should definitely not cost more than 100000 gas to set limit... but this may be a problem on other chains in the future. --- foundry/hardhat.config.js | 10 +++++++- foundry/scripts/README.md | 24 ++++++++++-------- foundry/scripts/deploy-router.js | 14 +++++++++-- foundry/scripts/executors.json | 0 foundry/scripts/roles.json | 43 ++++++++++++++++++++++---------- foundry/scripts/set-executors.js | 2 +- foundry/scripts/set-roles.js | 2 +- 7 files changed, 66 insertions(+), 29 deletions(-) create mode 100644 foundry/scripts/executors.json diff --git a/foundry/hardhat.config.js b/foundry/hardhat.config.js index 8336e9a..3248f29 100644 --- a/foundry/hardhat.config.js +++ b/foundry/hardhat.config.js @@ -17,13 +17,21 @@ module.exports = { }, networks: { - tenderly: { + tenderly_mainnet: { + url: process.env.RPC_URL, + accounts: [process.env.PRIVATE_KEY] + }, + tenderly_base: { url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] }, mainnet: { url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] + }, + base: { + url: process.env.RPC_URL, + accounts: [process.env.PRIVATE_KEY] } }, diff --git a/foundry/scripts/README.md b/foundry/scripts/README.md index fd31e13..bf85db7 100644 --- a/foundry/scripts/README.md +++ b/foundry/scripts/README.md @@ -5,7 +5,8 @@ ## Deploy on a Tenderly fork -1. Make a new [fork](https://dashboard.tenderly.co/) in tenderly dashboard. +1. Make a new [fork](https://dashboard.tenderly.co/) in tenderly dashboard for the + chain that you wish to deploy on. 2. Set the following environment variables: ``` @@ -16,12 +17,12 @@ export PRIVATE_KEY= 3. Fund wallet: `npx hardhat run scripts/fund-wallet-tenderly-fork.js --network tenderly` -## Deploy on mainnet +## Deploy on Ethereum Mainnet or Base 1. Set the following environment variables: ``` -export RPC_URL= +export RPC_URL= export DEPLOY_WALLET= export PRIVATE_KEY= ``` @@ -31,17 +32,18 @@ from being stored in the shell history. ## Deploy Tycho Router -1. Deploy router: `npx hardhat run scripts/deploy-router.js --network tenderly/mainnet` +For each of the following, you must select one of `tenderly_mainnet`, `tenderly_base`, +`mainnet`, or `base` as the network. + +1. Deploy router: `npx hardhat run scripts/deploy-router.js --network NETWORK` 2. Define the accounts to grant roles to in `scripts/roles.json` 3. Export the router address to the environment variable `export ROUTER=` -4. Grant roles: `npx hardhat run scripts/set-roles.js --network tenderly/mainnet` -5. Set executors: `npx hardhat run scripts/set-executors.js --network tenderly/mainnet`. Make sure you change the - DEPLOY_WALLET - to the executor deployer wallet. If you need to deploy executors, follow the instructions below. +4. Grant roles: `npx hardhat run scripts/set-roles.js --network NETWORK` +5. Set executors: `npx hardhat run scripts/set-executors.js --network NETWORK`. Make sure you change the + DEPLOY_WALLET to the executor deployer wallet. If you need to deploy executors, follow the instructions below. ### Deploy executors 1. In `scripts/deploy-executors.js` define the executors to be deployed -2. Deploy executors: `npx hardhat run scripts/deploy-executors.js --network tenderly/mainnet` -3. Fill in the executor addresses in `config/executor_addresses.json`. Note that the naming there needs to match the one - from tycho-indexer. +2. Deploy executors: `npx hardhat run scripts/deploy-executors.js --network NETWORK` +3. Fill in the executor addresses in `config/executors.json` diff --git a/foundry/scripts/deploy-router.js b/foundry/scripts/deploy-router.js index 31ef82a..ea884f1 100644 --- a/foundry/scripts/deploy-router.js +++ b/foundry/scripts/deploy-router.js @@ -4,8 +4,18 @@ const hre = require("hardhat"); async function main() { const network = hre.network.name; - const permit2 = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; - const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; + let permit2; + let weth; + if (network === "mainnet" || network === "tenderly_mainnet") { + permit2 = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; + weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; + } else if (network === "base" || network === "tenderly_base") { + // permit2 address is the same as on mainnet + permit2 = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; + weth = "0x4200000000000000000000000000000000000006"; + } else { + throw new Error(`Unsupported network: ${network}`); + } console.log(`Deploying TychoRouter to ${network} with:`); console.log(`- permit2: ${permit2}`); diff --git a/foundry/scripts/executors.json b/foundry/scripts/executors.json new file mode 100644 index 0000000..e69de29 diff --git a/foundry/scripts/roles.json b/foundry/scripts/roles.json index 04be021..c5609f0 100644 --- a/foundry/scripts/roles.json +++ b/foundry/scripts/roles.json @@ -1,15 +1,32 @@ { - "EXECUTOR_SETTER_ROLE": [ - "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" - ], - "FEE_SETTER_ROLE": [], - "PAUSER_ROLE": [ - "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" - ], - "UNPAUSER_ROLE": [ - "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" - ], - "FUND_RESCUER_ROLE": [ - "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" - ] + "mainnet": { + "EXECUTOR_SETTER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ], + "FEE_SETTER_ROLE": [], + "PAUSER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ], + "UNPAUSER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ], + "FUND_RESCUER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ] + }, + "base": { + "EXECUTOR_SETTER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ], + "FEE_SETTER_ROLE": [], + "PAUSER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ], + "UNPAUSER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ], + "FUND_RESCUER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ] + } } \ No newline at end of file diff --git a/foundry/scripts/set-executors.js b/foundry/scripts/set-executors.js index 95b36c8..421ff0d 100644 --- a/foundry/scripts/set-executors.js +++ b/foundry/scripts/set-executors.js @@ -18,7 +18,7 @@ async function main() { const router = TychoRouter.attach(routerAddress); const executorsFilePath = path.join(__dirname, "../../config/executor_addresses.json"); - const executors = Object.entries(JSON.parse(fs.readFileSync(executorsFilePath, "utf8"))["ethereum"]); + const executors = Object.entries(JSON.parse(fs.readFileSync(executorsFilePath, "utf8"))[network]); // Filter out executors that are already set diff --git a/foundry/scripts/set-roles.js b/foundry/scripts/set-roles.js index 88ba800..3e983c2 100644 --- a/foundry/scripts/set-roles.js +++ b/foundry/scripts/set-roles.js @@ -28,7 +28,7 @@ async function main() { // Iterate through roles and grant them to the corresponding addresses for (const [roleName, roleHash] of Object.entries(roles)) { - const addresses = rolesDict[roleName]; + const addresses = rolesDict[network][roleName]; if (addresses && addresses.length > 0) { console.log(`Granting ${roleName} to the following addresses:`, addresses); const tx = await router.batchGrantRole(roleHash, addresses); From 1bdcbb83e089c012dde3a33f159653a004c43c1d Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Tue, 25 Feb 2025 17:18:54 -0500 Subject: [PATCH 2/5] fix: (deployment) add tenderly keys to json files --- foundry/hardhat.config.js | 4 ++-- foundry/scripts/roles.json | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/foundry/hardhat.config.js b/foundry/hardhat.config.js index 3248f29..626b8d2 100644 --- a/foundry/hardhat.config.js +++ b/foundry/hardhat.config.js @@ -18,11 +18,11 @@ module.exports = { networks: { tenderly_mainnet: { - url: process.env.RPC_URL, + url: process.env.TENDERLY_RPC_URL, accounts: [process.env.PRIVATE_KEY] }, tenderly_base: { - url: process.env.RPC_URL, + url: process.env.TENDERLY_RPC_URL, accounts: [process.env.PRIVATE_KEY] }, mainnet: { diff --git a/foundry/scripts/roles.json b/foundry/scripts/roles.json index c5609f0..9d93835 100644 --- a/foundry/scripts/roles.json +++ b/foundry/scripts/roles.json @@ -13,7 +13,22 @@ "FUND_RESCUER_ROLE": [ "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" ] - }, + }, + "tenderly_mainnet": { + "EXECUTOR_SETTER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ], + "FEE_SETTER_ROLE": [], + "PAUSER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ], + "UNPAUSER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ], + "FUND_RESCUER_ROLE": [ + "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" + ] + }, "base": { "EXECUTOR_SETTER_ROLE": [ "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" @@ -28,5 +43,20 @@ "FUND_RESCUER_ROLE": [ "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" ] + }, + "tenderly_base": { + "EXECUTOR_SETTER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ], + "FEE_SETTER_ROLE": [], + "PAUSER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ], + "UNPAUSER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ], + "FUND_RESCUER_ROLE": [ + "0xb0A77f867Fcec1e9b271Ee17354bC6bBC0dD5662" + ] } } \ No newline at end of file From adfcb3da82564282e5eb311a1504be9f64ce1237 Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Wed, 26 Feb 2025 12:39:54 -0500 Subject: [PATCH 3/5] fix: proper executor address json after merge --- config/executor_addresses.json | 12 ++++++++++++ foundry/scripts/executors.json | 0 2 files changed, 12 insertions(+) delete mode 100644 foundry/scripts/executors.json diff --git a/config/executor_addresses.json b/config/executor_addresses.json index 7ad3bca..18938f0 100644 --- a/config/executor_addresses.json +++ b/config/executor_addresses.json @@ -4,5 +4,17 @@ "uniswap_v3": "0x5C2F5a71f67c01775180ADc06909288B4C329308", "uniswap_v4": "0xF62849F9A0B5Bf2913b396098F7c7019b51A820a", "vm:balancer_v2": "0x543778987b293C7E8Cf0722BB2e935ba6f4068D4" + }, + "tenderly_ethereum": { + "uniswap_v2": "0x00C1b81e3C8f6347E69e2DDb90454798A6Be975E", + "uniswap_v3": "0x5C2F5a71f67c01775180ADc06909288B4C329308", + "uniswap_v4": "0xF62849F9A0B5Bf2913b396098F7c7019b51A820a", + "vm:balancer_v2": "0x543778987b293C7E8Cf0722BB2e935ba6f4068D4" + }, + "base": { + "uniswap_v2": "0x2DaE954eCF457276F90B68Cee68981C0aA07f2ef" + }, + "tenderly_base": { + "uniswap_v3": "0x7c7E06d7317e620a185078e236879D2a87fC8d22" } } \ No newline at end of file diff --git a/foundry/scripts/executors.json b/foundry/scripts/executors.json deleted file mode 100644 index e69de29..0000000 From e5759b94984772078d9324dcce2eaced0d6cc377 Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Wed, 26 Feb 2025 13:01:48 -0500 Subject: [PATCH 4/5] fix: TENDERLY_RPC_URL -> RPC_URL for simplicity and consistency --- foundry/hardhat.config.js | 4 ++-- foundry/scripts/fund-wallet-tenderly-fork.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/foundry/hardhat.config.js b/foundry/hardhat.config.js index 626b8d2..3248f29 100644 --- a/foundry/hardhat.config.js +++ b/foundry/hardhat.config.js @@ -18,11 +18,11 @@ module.exports = { networks: { tenderly_mainnet: { - url: process.env.TENDERLY_RPC_URL, + url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] }, tenderly_base: { - url: process.env.TENDERLY_RPC_URL, + url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] }, mainnet: { diff --git a/foundry/scripts/fund-wallet-tenderly-fork.js b/foundry/scripts/fund-wallet-tenderly-fork.js index bc01ce2..b9fe611 100644 --- a/foundry/scripts/fund-wallet-tenderly-fork.js +++ b/foundry/scripts/fund-wallet-tenderly-fork.js @@ -1,12 +1,12 @@ require("dotenv").config(); const {ethers} = require("hardhat"); -const TENDERLY_RPC_URL = process.env.TENDERLY_RPC_URL; +const RPC_URL = process.env.RPC_URL; const DEPLOY_WALLET = process.env.DEPLOY_WALLET; async function main() { - if (!TENDERLY_RPC_URL || !DEPLOY_WALLET) { - console.error("Missing TENDERLY_RPC_URL or DEPLOY_WALLET in environment variables."); + if (!RPC_URL || !DEPLOY_WALLET) { + console.error("Missing RPC_URL or DEPLOY_WALLET in environment variables."); process.exit(1); } From ac35256c6961b8f8783b8461302594aaeb0eaa95 Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Wed, 26 Feb 2025 13:20:51 -0500 Subject: [PATCH 5/5] fix: rename mainnet -> ethereum we must match what we have in the executors file (which is what tycho-indexer gives us) --- foundry/hardhat.config.js | 4 ++-- foundry/scripts/README.md | 4 ++-- foundry/scripts/roles.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/foundry/hardhat.config.js b/foundry/hardhat.config.js index 3248f29..8969e8a 100644 --- a/foundry/hardhat.config.js +++ b/foundry/hardhat.config.js @@ -17,7 +17,7 @@ module.exports = { }, networks: { - tenderly_mainnet: { + tenderly_ethereum: { url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] }, @@ -25,7 +25,7 @@ module.exports = { url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] }, - mainnet: { + ethereum: { url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] }, diff --git a/foundry/scripts/README.md b/foundry/scripts/README.md index bf85db7..3bd07fd 100644 --- a/foundry/scripts/README.md +++ b/foundry/scripts/README.md @@ -32,8 +32,8 @@ from being stored in the shell history. ## Deploy Tycho Router -For each of the following, you must select one of `tenderly_mainnet`, `tenderly_base`, -`mainnet`, or `base` as the network. +For each of the following, you must select one of `tenderly_ethereum`, `tenderly_base`, +`ethereum`, or `base` as the network. 1. Deploy router: `npx hardhat run scripts/deploy-router.js --network NETWORK` 2. Define the accounts to grant roles to in `scripts/roles.json` diff --git a/foundry/scripts/roles.json b/foundry/scripts/roles.json index 9d93835..3a7ad7a 100644 --- a/foundry/scripts/roles.json +++ b/foundry/scripts/roles.json @@ -1,5 +1,5 @@ { - "mainnet": { + "ethereum": { "EXECUTOR_SETTER_ROLE": [ "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" ], @@ -14,7 +14,7 @@ "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" ] }, - "tenderly_mainnet": { + "tenderly_ethereum": { "EXECUTOR_SETTER_ROLE": [ "0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655" ],