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);