|
| 1 | +// SPDX-License-Identifier: AGPL-3.0-only |
| 2 | +pragma solidity 0.8.20; |
| 3 | + |
| 4 | +import {CommonBase} from "forge-std/Base.sol"; |
| 5 | +import {Script} from "forge-std/Script.sol"; |
| 6 | +import {StdChains} from "forge-std/StdChains.sol"; |
| 7 | +import {StdCheatsSafe} from "forge-std/StdCheats.sol"; |
| 8 | +import {StdUtils} from "forge-std/StdUtils.sol"; |
| 9 | +import {console2} from "forge-std/console2.sol"; |
| 10 | +import {ejectImplant} from "../src/implants/ejectImplant.sol"; |
| 11 | +import {sudoImplant} from "../src/implants/sudoImplant.sol"; |
| 12 | +import {BorgAuth} from "../src/libs/auth.sol"; |
| 13 | +import {SnapShotExecutor} from "../src/libs/governance/snapShotExecutor.sol"; |
| 14 | +import {IGnosisSafe} from "../test/libraries/safe.t.sol"; |
| 15 | + |
| 16 | +contract YearnBorgReplaceSnapShotExecutorScript is Script { |
| 17 | + |
| 18 | + // Warning: review and update the following before run |
| 19 | + |
| 20 | + IGnosisSafe ychadSafe = IGnosisSafe(0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52); // ychad.eth |
| 21 | + |
| 22 | + ejectImplant eject = ejectImplant(0xe44f5c9EAFB87731906AB87156E4F4cB3fa0Eb74); |
| 23 | + sudoImplant sudo = sudoImplant(0x6766b727aa1489443b34A02ee89c34f39748600b); |
| 24 | + SnapShotExecutor oldSnapShotExecutor = SnapShotExecutor(0x77691936fb6337d4B71dc62643b05b6bBE19285c); |
| 25 | + |
| 26 | + // Configs: SnapShowExecutor |
| 27 | + // Reuse the old one's parameters if we are just upgrading it to a newer version |
| 28 | + uint256 snapShotWaitingPeriod = oldSnapShotExecutor.waitingPeriod(); |
| 29 | + uint256 snapShotCancelPeriod = oldSnapShotExecutor.proposalExpirySeconds(); |
| 30 | + uint256 snapShotPendingProposalLimit = oldSnapShotExecutor.pendingProposalLimit(); |
| 31 | + uint256 snapShotOracleTtl = oldSnapShotExecutor.oracleTtl(); |
| 32 | + address oracle = oldSnapShotExecutor.oracle(); |
| 33 | + |
| 34 | + BorgAuth executorAuth = oldSnapShotExecutor.AUTH(); |
| 35 | + BorgAuth implantAuth = eject.AUTH(); |
| 36 | + |
| 37 | + /// @dev For running from `forge script`. Provide the deployer private key through env var. |
| 38 | + function run() public returns(SnapShotExecutor, bytes memory, bytes memory) { |
| 39 | + return run(vm.envUint("DEPLOYER_PRIVATE_KEY")); |
| 40 | + } |
| 41 | + |
| 42 | + /// @dev For running in tests |
| 43 | + function run(uint256 deployerPrivateKey) public returns(SnapShotExecutor, bytes memory, bytes memory) { |
| 44 | + console2.log("Configs:"); |
| 45 | + console2.log(" Safe Multisig:", address(ychadSafe)); |
| 46 | + console2.log(" Eject Implant:", address(eject)); |
| 47 | + console2.log(" Sudo Implant:", address(sudo)); |
| 48 | + console2.log(" Old SnapShotExecutor:", address(oldSnapShotExecutor)); |
| 49 | + |
| 50 | + address deployerAddress = vm.addr(deployerPrivateKey); |
| 51 | + console2.log("Deployer:", deployerAddress); |
| 52 | + |
| 53 | + vm.startBroadcast(deployerPrivateKey); |
| 54 | + |
| 55 | + // Deploy new SnapShotExecutor |
| 56 | + SnapShotExecutor newSnapShotExecutor = new SnapShotExecutor(executorAuth, address(oracle), snapShotWaitingPeriod, snapShotCancelPeriod, snapShotPendingProposalLimit, snapShotOracleTtl); |
| 57 | + |
| 58 | + vm.stopBroadcast(); |
| 59 | + |
| 60 | + console2.log("Deployed addresses:"); |
| 61 | + console2.log(" New SnapShotExecutor: ", address(newSnapShotExecutor)); |
| 62 | + |
| 63 | + // Generate the proposal calldata for old SnapShotExecutor to transfer its implant ownership to the new one. |
| 64 | + // We can't just do it here. The proposal must go through the co-approval process to take effect. |
| 65 | + |
| 66 | + bytes memory grantNewOwnerData = abi.encodeWithSelector( |
| 67 | + implantAuth.updateRole.selector, |
| 68 | + address(newSnapShotExecutor), |
| 69 | + implantAuth.OWNER_ROLE() |
| 70 | + ); |
| 71 | + |
| 72 | + bytes memory revokeOldOwnerData = abi.encodeWithSelector( |
| 73 | + implantAuth.updateRole.selector, |
| 74 | + address(oldSnapShotExecutor), |
| 75 | + 0 |
| 76 | + ); |
| 77 | + |
| 78 | + console2.log("Tx proposal for the old SnapShotExecutor:"); |
| 79 | + console2.log(" to:", address(implantAuth)); |
| 80 | + console2.log(" value: 0"); |
| 81 | + console2.log(" data:"); |
| 82 | + console2.logBytes(grantNewOwnerData); |
| 83 | + console2.log(""); |
| 84 | + |
| 85 | + console2.log("Tx proposal for the new SnapShotExecutor:"); |
| 86 | + console2.log(" to:", address(implantAuth)); |
| 87 | + console2.log(" value: 0"); |
| 88 | + console2.log(" data:"); |
| 89 | + console2.logBytes(revokeOldOwnerData); |
| 90 | + console2.log(""); |
| 91 | + |
| 92 | + return (newSnapShotExecutor, grantNewOwnerData, revokeOldOwnerData); |
| 93 | + } |
| 94 | +} |
0 commit comments