|
| 1 | +// 1. Deploy the latest governor contract and sets its ownership to the new multisig safe wallet. |
| 2 | +// 2. Submit a proposal on the old governor to call transferGovernance() on all governable contracts. |
| 3 | +// 3. Submit a proposal on the new governor to call claimGovernance() on all governable contracts. |
| 4 | + |
| 5 | +const { |
| 6 | + isMainnet, |
| 7 | + isFork, |
| 8 | + isRinkeby, |
| 9 | + isSmokeTest, |
| 10 | +} = require("../test/helpers.js"); |
| 11 | +const { |
| 12 | + log, |
| 13 | + deployWithConfirmation, |
| 14 | + withConfirmation, |
| 15 | + executeProposal, |
| 16 | + sendProposal, |
| 17 | +} = require("../utils/deploy"); |
| 18 | +const { proposeArgs } = require("../utils/governor"); |
| 19 | +const { getTxOpts } = require("../utils/tx"); |
| 20 | +const addresses = require("../utils/addresses"); |
| 21 | + |
| 22 | +const deployName = "018_upgrade_governor"; |
| 23 | + |
| 24 | +const runDeployment = async (hre) => { |
| 25 | + console.log(`Running ${deployName} deployment...`); |
| 26 | + |
| 27 | + const { governorAddr } = await hre.getNamedAccounts(); |
| 28 | + |
| 29 | + const cOUSDProxy = await ethers.getContract("OUSDProxy"); |
| 30 | + const cVaultProxy = await ethers.getContract("VaultProxy"); |
| 31 | + const cCompoundStrategyProxy = await ethers.getContract( |
| 32 | + "CompoundStrategyProxy" |
| 33 | + ); |
| 34 | + const cThreePoolStrategyProxy = await ethers.getContract( |
| 35 | + "ThreePoolStrategyProxy" |
| 36 | + ); |
| 37 | + const cAaveStrategyProxy = await ethers.getContract("AaveStrategyProxy"); |
| 38 | + const cBuyback = await ethers.getContract("Buyback"); |
| 39 | + const cOGNStakingProxy = await ethers.getContract("OGNStakingProxy"); |
| 40 | + const cCompensationClaim = await ethers.getContract("CompensationClaims"); |
| 41 | + |
| 42 | + // Deploy a new governor contract. |
| 43 | + // The governor's admin is the guardian account (e.g. the multi-sig). |
| 44 | + // Set a min delay of 60sec for executing proposals. |
| 45 | + const dGovernor = await deployWithConfirmation("Governor", [ |
| 46 | + addresses.mainnet.Guardian, |
| 47 | + 60, |
| 48 | + ]); |
| 49 | + |
| 50 | + // Proposal for tranferring governance from the old to new governor. |
| 51 | + const propTransferDescription = "Transfer governance"; |
| 52 | + const propTransferArgs = await proposeArgs([ |
| 53 | + { |
| 54 | + contract: cOUSDProxy, |
| 55 | + signature: "transferGovernance(address)", |
| 56 | + args: [dGovernor.address], |
| 57 | + }, |
| 58 | + { |
| 59 | + contract: cVaultProxy, |
| 60 | + signature: "transferGovernance(address)", |
| 61 | + args: [dGovernor.address], |
| 62 | + }, |
| 63 | + { |
| 64 | + contract: cCompoundStrategyProxy, |
| 65 | + signature: "transferGovernance(address)", |
| 66 | + args: [dGovernor.address], |
| 67 | + }, |
| 68 | + { |
| 69 | + contract: cThreePoolStrategyProxy, |
| 70 | + signature: "transferGovernance(address)", |
| 71 | + args: [dGovernor.address], |
| 72 | + }, |
| 73 | + { |
| 74 | + contract: cAaveStrategyProxy, |
| 75 | + signature: "transferGovernance(address)", |
| 76 | + args: [dGovernor.address], |
| 77 | + }, |
| 78 | + { |
| 79 | + contract: cBuyback, |
| 80 | + signature: "transferGovernance(address)", |
| 81 | + args: [dGovernor.address], |
| 82 | + }, |
| 83 | + { |
| 84 | + contract: cOGNStakingProxy, |
| 85 | + signature: "transferGovernance(address)", |
| 86 | + args: [dGovernor.address], |
| 87 | + }, |
| 88 | + { |
| 89 | + contract: cCompensationClaim, |
| 90 | + signature: "transferGovernance(address)", |
| 91 | + args: [dGovernor.address], |
| 92 | + }, |
| 93 | + ]); |
| 94 | + |
| 95 | + // Proposal for claiming governance by the new governor. |
| 96 | + const propClaimDescription = "Claim governance"; |
| 97 | + const propClaimArgs = await proposeArgs([ |
| 98 | + { |
| 99 | + contract: cOUSDProxy, |
| 100 | + signature: "claimGovernance()", |
| 101 | + }, |
| 102 | + { |
| 103 | + contract: cVaultProxy, |
| 104 | + signature: "claimGovernance()", |
| 105 | + }, |
| 106 | + { |
| 107 | + contract: cCompoundStrategyProxy, |
| 108 | + signature: "claimGovernance()", |
| 109 | + }, |
| 110 | + { |
| 111 | + contract: cThreePoolStrategyProxy, |
| 112 | + signature: "claimGovernance()", |
| 113 | + }, |
| 114 | + { |
| 115 | + contract: cAaveStrategyProxy, |
| 116 | + signature: "claimGovernance()", |
| 117 | + }, |
| 118 | + { |
| 119 | + contract: cBuyback, |
| 120 | + signature: "claimGovernance()", |
| 121 | + }, |
| 122 | + { |
| 123 | + contract: cOGNStakingProxy, |
| 124 | + signature: "claimGovernance()", |
| 125 | + }, |
| 126 | + { |
| 127 | + contract: cCompensationClaim, |
| 128 | + signature: "claimGovernance()", |
| 129 | + }, |
| 130 | + ]); |
| 131 | + |
| 132 | + if (isMainnet) { |
| 133 | + // On Mainnet, only propose. The enqueue and execution are handled manually via multi-sig. |
| 134 | + log("Sending transfer proposal to old governor..."); |
| 135 | + await sendProposal(propTransferArgs, propTransferDescription, { |
| 136 | + governorAddr, |
| 137 | + }); |
| 138 | + log("Transfer proposal sent."); |
| 139 | + |
| 140 | + log("Sending claim proposal to new governor..."); |
| 141 | + await sendProposal(propClaimArgs, propClaimDescription); |
| 142 | + log("Claim proposal sent."); |
| 143 | + } else if (isFork) { |
| 144 | + // On Fork we can send the proposal then impersonate the guardian to execute it. |
| 145 | + log("Sending and executing transfer proposal..."); |
| 146 | + // Note: we send the proposal to the old governor by passing explicitly its address. |
| 147 | + await executeProposal(propTransferArgs, propTransferDescription, { |
| 148 | + governorAddr, |
| 149 | + }); |
| 150 | + |
| 151 | + log("Sending and executing claim proposal..."); |
| 152 | + await executeProposal(propClaimArgs, propClaimDescription, { |
| 153 | + guardianAddr: addresses.mainnet.Guardian, |
| 154 | + }); |
| 155 | + } |
| 156 | + |
| 157 | + return true; |
| 158 | +}; |
| 159 | + |
| 160 | +const main = async (hre) => { |
| 161 | + console.log(`Running ${deployName} deployment...`); |
| 162 | + if (!hre) { |
| 163 | + hre = require("hardhat"); |
| 164 | + } |
| 165 | + await runDeployment(hre); |
| 166 | + console.log(`${deployName} deploy done.`); |
| 167 | + return true; |
| 168 | +}; |
| 169 | + |
| 170 | +main.id = deployName; |
| 171 | +main.dependencies = ["017_3pool_strategy_update"]; |
| 172 | +main.skip = () => !(isMainnet || isRinkeby || isFork) || isSmokeTest; |
| 173 | + |
| 174 | +module.exports = main; |
0 commit comments