|
| 1 | +const { |
| 2 | + isMainnet, |
| 3 | + isFork, |
| 4 | + isRinkeby, |
| 5 | + isSmokeTest, |
| 6 | +} = require("../test/helpers.js"); |
| 7 | +const { |
| 8 | + log, |
| 9 | + deployWithConfirmation, |
| 10 | + withConfirmation, |
| 11 | + executeProposal, |
| 12 | + sendProposal, |
| 13 | +} = require("../utils/deploy"); |
| 14 | +const { proposeArgs } = require("../utils/governor"); |
| 15 | +const { getTxOpts } = require("../utils/tx"); |
| 16 | + |
| 17 | +const deployName = "017_3pool_strategy_update"; |
| 18 | + |
| 19 | +const runDeployment = async (hre) => { |
| 20 | + console.log(`Running ${deployName} deployment...`); |
| 21 | + const { governorAddr } = await hre.getNamedAccounts(); |
| 22 | + |
| 23 | + // Signers |
| 24 | + const sGovernor = await ethers.provider.getSigner(governorAddr); |
| 25 | + |
| 26 | + const cThreePoolStrategyProxy = await ethers.getContract( |
| 27 | + "ThreePoolStrategyProxy" |
| 28 | + ); |
| 29 | + |
| 30 | + // Deploy Updated 3Pool strategy. |
| 31 | + const dThreePoolStrategy = await deployWithConfirmation("ThreePoolStrategy"); |
| 32 | + |
| 33 | + // Proposal for the governor update the contract |
| 34 | + const propDescription = "Update 3pool implementation"; |
| 35 | + const propArgs = await proposeArgs([ |
| 36 | + { |
| 37 | + contract: cThreePoolStrategyProxy, |
| 38 | + signature: "upgradeTo(address)", |
| 39 | + args: [dThreePoolStrategy.address], |
| 40 | + }, |
| 41 | + ]); |
| 42 | + |
| 43 | + if (isMainnet) { |
| 44 | + // On Mainnet, only propose. The enqueue and execution are handled manually via multi-sig. |
| 45 | + log("Sending proposal to governor..."); |
| 46 | + await sendProposal(propArgs, propDescription); |
| 47 | + log("Proposal sent."); |
| 48 | + } else if (isFork) { |
| 49 | + // On Fork we can send the proposal then impersonate the guardian to execute it. |
| 50 | + log("Sending and executing proposal..."); |
| 51 | + await executeProposal(propArgs, propDescription); |
| 52 | + log("Proposal executed."); |
| 53 | + } else { |
| 54 | + // Hardcoding gas estimate on Rinkeby since it fails for an undetermined reason... |
| 55 | + const gasLimit = isRinkeby ? 1000000 : null; |
| 56 | + await withConfirmation( |
| 57 | + cThreePoolStrategyProxy |
| 58 | + .connect(sGovernor) |
| 59 | + .upgradeTo(dThreePoolStrategy.address, await getTxOpts(gasLimit)) |
| 60 | + ); |
| 61 | + log("Switched implementation of ThreePoolStrategy"); |
| 62 | + } |
| 63 | + |
| 64 | + return true; |
| 65 | +}; |
| 66 | + |
| 67 | +const main = async (hre) => { |
| 68 | + console.log(`Running ${deployName} deployment...`); |
| 69 | + if (!hre) { |
| 70 | + hre = require("hardhat"); |
| 71 | + } |
| 72 | + await runDeployment(hre); |
| 73 | + console.log(`${deployName} deploy done.`); |
| 74 | + return true; |
| 75 | +}; |
| 76 | + |
| 77 | +main.id = deployName; |
| 78 | +main.dependencies = ["014_3pool_strategy"]; |
| 79 | +main.skip = () => !(isMainnet || isRinkeby || isFork) || isSmokeTest; |
| 80 | + |
| 81 | +module.exports = main; |
0 commit comments