diff --git a/build/deployments.json b/build/deployments.json index 69b6c958..bb5ad370 100644 --- a/build/deployments.json +++ b/build/deployments.json @@ -18,5 +18,13 @@ "XOGN_GOV": "0x1D3Fbd4d129Ddd2372EA85c5Fa00b2682081c9EC", "XOGN_IMPL": "0x97711c7a5D64A064a95d10e37f786d2bD8b1F3c8" } + }, + "8453": { + "executions": { + "001_Timelock": 1725274861 + }, + "contracts": { + "TIMELOCK": "0xf817cb3092179083c48c014688D98B72fB61464f" + } } } \ No newline at end of file diff --git a/contracts/Timelock.sol b/contracts/Timelock.sol index 6bffcb9a..3e9eb097 100644 --- a/contracts/Timelock.sol +++ b/contracts/Timelock.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.10; import "OpenZeppelin/openzeppelin-contracts@4.6.0/contracts/governance/TimelockController.sol"; contract Timelock is TimelockController { - constructor(address[] memory proposers, address[] memory executors) - TimelockController(86400 * 2, proposers, executors) + constructor(uint256 minDelay, address[] memory proposers, address[] memory executors) + TimelockController(minDelay, proposers, executors) {} } diff --git a/contracts/utils/Addresses.sol b/contracts/utils/Addresses.sol index 2513a9c1..79bf23a4 100644 --- a/contracts/utils/Addresses.sol +++ b/contracts/utils/Addresses.sol @@ -20,3 +20,8 @@ library Addresses { address public constant OUSD_BUYBACK_IMPL = 0x386d8fEC5b6d5B5E36a48A376644e36239dB65d6; address public constant OETH_BUYBACK_IMPL = 0x4F11d31f781B57051764a3823b24d520626b4833; } + +library AddressesBase { + // 5/8 multisig + address public constant GOVERNOR = 0x92A19381444A001d62cE67BaFF066fA1111d7202; +} diff --git a/script/deploy/mainnet/BaseMainnetScript.sol b/script/deploy/AbstractScript.sol similarity index 94% rename from script/deploy/mainnet/BaseMainnetScript.sol rename to script/deploy/AbstractScript.sol index e5d8319a..93163feb 100644 --- a/script/deploy/mainnet/BaseMainnetScript.sol +++ b/script/deploy/AbstractScript.sol @@ -10,7 +10,7 @@ import {Vm, VmSafe} from "forge-std/Vm.sol"; import {Addresses} from "contracts/utils/Addresses.sol"; import {GovProposal, GovProposalHelper} from "contracts/utils/GovProposalHelper.sol"; -abstract contract BaseMainnetScript is Script { +abstract contract AbstractScript is Script { using GovProposalHelper for GovProposal; uint256 public deployBlockNum = type(uint256).max; @@ -47,7 +47,7 @@ abstract contract BaseMainnetScript is Script { function setUp() external {} function run() external { - if (block.chainid != 1) { + if (block.chainid != AbstractScript(address(this)).CHAIN_ID()) { revert("Not Mainnet"); } // Will not execute script if after this block number @@ -80,6 +80,8 @@ abstract contract BaseMainnetScript is Script { function DEPLOY_NAME() external view virtual returns (string memory); + function CHAIN_ID() external view virtual returns (uint256); + function proposalExecuted() external view virtual returns (bool); function skip() external view virtual returns (bool) { diff --git a/script/deploy/DeployManager.sol b/script/deploy/DeployManager.sol index 710ed0f2..10862dba 100644 --- a/script/deploy/DeployManager.sol +++ b/script/deploy/DeployManager.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.10; import "forge-std/Script.sol"; import "OpenZeppelin/openzeppelin-contracts@4.6.0/contracts/utils/Strings.sol"; -import {BaseMainnetScript} from "./mainnet/BaseMainnetScript.sol"; +import {AbstractScript} from "./AbstractScript.sol"; import {XOGNSetupScript} from "./mainnet/010_xOGNSetupScript.sol"; import {OgnOgvMigrationScript} from "./mainnet/011_OgnOgvMigrationScript.sol"; @@ -12,6 +12,8 @@ import {MigrationZapperScript} from "./mainnet/012_MigrationZapperScript.sol"; import {UpgradeMigratorScript} from "./mainnet/013_UpgradeMigratorScript.sol"; import {XOGNGovernanceScript} from "./mainnet/014_xOGNGovernanceScript.sol"; +import {DeployTimelockScript} from "./base/001_Timelock.sol"; + import {VmSafe} from "forge-std/Vm.sol"; contract DeployManager is Script { @@ -69,14 +71,18 @@ contract DeployManager is Script { function run() external { // TODO: Use vm.readDir to recursively build this? - _runDeployFile(new XOGNSetupScript()); - _runDeployFile(new OgnOgvMigrationScript()); - _runDeployFile(new MigrationZapperScript()); - _runDeployFile(new UpgradeMigratorScript()); - _runDeployFile(new XOGNGovernanceScript()); + if (block.chainid == 1) { + _runDeployFile(new XOGNSetupScript()); + _runDeployFile(new OgnOgvMigrationScript()); + _runDeployFile(new MigrationZapperScript()); + _runDeployFile(new UpgradeMigratorScript()); + _runDeployFile(new XOGNGovernanceScript()); + } else if (block.chainid == 8453) { + _runDeployFile(new DeployTimelockScript()); + } } - function _runDeployFile(BaseMainnetScript deployScript) internal { + function _runDeployFile(AbstractScript deployScript) internal { if (deployScript.proposalExecuted()) { // No action to do return; @@ -137,7 +143,7 @@ contract DeployManager is Script { /** * Post-deployment */ - BaseMainnetScript.DeployRecord[] memory records = deployScript.getAllDeployRecords(); + AbstractScript.DeployRecord[] memory records = deployScript.getAllDeployRecords(); for (uint256 i = 0; i < records.length; ++i) { string memory name = records[i].name; diff --git a/script/deploy/base/001_Timelock.sol b/script/deploy/base/001_Timelock.sol new file mode 100644 index 00000000..f4e53ccd --- /dev/null +++ b/script/deploy/base/001_Timelock.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.10; + +import "../AbstractScript.sol"; +import {Vm} from "forge-std/Vm.sol"; + +import {AddressesBase} from "contracts/utils/Addresses.sol"; + +import {Timelock} from "contracts/Timelock.sol"; + +contract DeployTimelockScript is AbstractScript { + string public constant override DEPLOY_NAME = "001_Timelock"; + uint256 public constant override CHAIN_ID = 8453; + bool public constant override proposalExecuted = false; + + constructor() {} + + function _execute() internal override { + console.log("Deploy:"); + console.log("------------"); + + address[] memory proposers = new address[](1); + address[] memory executors = new address[](1); + + proposers[0] = AddressesBase.GOVERNOR; + executors[0] = AddressesBase.GOVERNOR; + + // 1. Deploy Timelock + Timelock timelock = new Timelock( + 60, // 60s + proposers, + executors + ); + _recordDeploy("TIMELOCK", address(timelock)); + } + + function _fork() internal override {} +} diff --git a/script/deploy/mainnet/010_xOGNSetupScript.sol b/script/deploy/mainnet/010_xOGNSetupScript.sol index 23b8e4a9..75c62a8f 100644 --- a/script/deploy/mainnet/010_xOGNSetupScript.sol +++ b/script/deploy/mainnet/010_xOGNSetupScript.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.10; -import "./BaseMainnetScript.sol"; +import "../AbstractScript.sol"; import {Vm} from "forge-std/Vm.sol"; import {Addresses} from "contracts/utils/Addresses.sol"; @@ -19,8 +19,9 @@ import {Timelock} from "contracts/Timelock.sol"; import {IMintableERC20} from "contracts/interfaces/IMintableERC20.sol"; -contract XOGNSetupScript is BaseMainnetScript { +contract XOGNSetupScript is AbstractScript { string public constant override DEPLOY_NAME = "010_xOGNSetup"; + uint256 public constant override CHAIN_ID = 1; bool public constant override proposalExecuted = true; constructor() {} diff --git a/script/deploy/mainnet/011_OgnOgvMigrationScript.sol b/script/deploy/mainnet/011_OgnOgvMigrationScript.sol index 5b6c71ec..39cbfb5e 100644 --- a/script/deploy/mainnet/011_OgnOgvMigrationScript.sol +++ b/script/deploy/mainnet/011_OgnOgvMigrationScript.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.10; -import "./BaseMainnetScript.sol"; +import "../AbstractScript.sol"; import {Vm} from "forge-std/Vm.sol"; import {Addresses} from "contracts/utils/Addresses.sol"; @@ -16,10 +16,11 @@ import {IMintableERC20} from "contracts/interfaces/IMintableERC20.sol"; import {GovProposal, GovProposalHelper} from "contracts/utils/GovProposalHelper.sol"; -contract OgnOgvMigrationScript is BaseMainnetScript { +contract OgnOgvMigrationScript is AbstractScript { using GovProposalHelper for GovProposal; string public constant override DEPLOY_NAME = "011_OgnOgvMigration"; + uint256 public constant override CHAIN_ID = 1; bool public constant override proposalExecuted = true; GovProposal public govProposal; diff --git a/script/deploy/mainnet/012_MigrationZapperScript.sol b/script/deploy/mainnet/012_MigrationZapperScript.sol index c3891552..a5ccb281 100644 --- a/script/deploy/mainnet/012_MigrationZapperScript.sol +++ b/script/deploy/mainnet/012_MigrationZapperScript.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.10; -import "./BaseMainnetScript.sol"; +import "../AbstractScript.sol"; import {Vm} from "forge-std/Vm.sol"; import {Addresses} from "contracts/utils/Addresses.sol"; @@ -17,12 +17,13 @@ import {MigrationZapper} from "contracts/MigrationZapper.sol"; import "OpenZeppelin/openzeppelin-contracts@4.6.0/contracts/token/ERC20/extensions/ERC20Votes.sol"; import "OpenZeppelin/openzeppelin-contracts@4.6.0/contracts/governance/TimelockController.sol"; -contract MigrationZapperScript is BaseMainnetScript { +contract MigrationZapperScript is AbstractScript { using GovFive for GovFive.GovFiveProposal; GovFive.GovFiveProposal public govProposal; string public constant override DEPLOY_NAME = "012_MigrationZapper"; + uint256 public constant override CHAIN_ID = 1; bool public constant override proposalExecuted = true; constructor() {} diff --git a/script/deploy/mainnet/013_UpgradeMigratorScript.sol b/script/deploy/mainnet/013_UpgradeMigratorScript.sol index e9a64c92..5f8b947c 100644 --- a/script/deploy/mainnet/013_UpgradeMigratorScript.sol +++ b/script/deploy/mainnet/013_UpgradeMigratorScript.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.10; -import "./BaseMainnetScript.sol"; +import "../AbstractScript.sol"; import {Addresses} from "contracts/utils/Addresses.sol"; @@ -11,12 +11,13 @@ import {GovFive} from "contracts/utils/GovFive.sol"; import {Migrator} from "contracts/Migrator.sol"; import {OgvStaking} from "contracts/OgvStaking.sol"; -contract UpgradeMigratorScript is BaseMainnetScript { +contract UpgradeMigratorScript is AbstractScript { using GovFive for GovFive.GovFiveProposal; GovFive.GovFiveProposal public govProposal; string public constant override DEPLOY_NAME = "013_UpgradeMigrator"; + uint256 public constant override CHAIN_ID = 1; bool public constant override proposalExecuted = true; constructor() {} diff --git a/script/deploy/mainnet/014_xOGNGovernanceScript.sol b/script/deploy/mainnet/014_xOGNGovernanceScript.sol index f4967b04..3c106a0c 100644 --- a/script/deploy/mainnet/014_xOGNGovernanceScript.sol +++ b/script/deploy/mainnet/014_xOGNGovernanceScript.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.10; -import "./BaseMainnetScript.sol"; +import "../AbstractScript.sol"; import {Addresses} from "contracts/utils/Addresses.sol"; @@ -14,12 +14,13 @@ import {GovFive} from "contracts/utils/GovFive.sol"; import {ERC20Votes} from "OpenZeppelin/openzeppelin-contracts@4.6.0/contracts/token/ERC20/extensions/ERC20Votes.sol"; import {TimelockController} from "OpenZeppelin/openzeppelin-contracts@4.6.0/contracts/governance/TimelockController.sol"; -contract XOGNGovernanceScript is BaseMainnetScript { +contract XOGNGovernanceScript is AbstractScript { using GovFive for GovFive.GovFiveProposal; GovFive.GovFiveProposal public govProposal; string public constant override DEPLOY_NAME = "014_xOGNGovernance"; + uint256 public constant override CHAIN_ID = 1; bool public constant override proposalExecuted = false; uint256 public constant OGN_EPOCH = 1717041600; // May 30, 2024 GMT diff --git a/script/deploy/mainnet/015_RevokeMultisigGovernance.sol b/script/deploy/mainnet/015_RevokeMultisigGovernance.sol index 10371aa8..e6d11cfe 100644 --- a/script/deploy/mainnet/015_RevokeMultisigGovernance.sol +++ b/script/deploy/mainnet/015_RevokeMultisigGovernance.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.10; -import "./BaseMainnetScript.sol"; +import "../AbstractScript.sol"; import {Addresses} from "contracts/utils/Addresses.sol"; @@ -11,12 +11,13 @@ import {Governance} from "contracts/Governance.sol"; import {GovFive} from "contracts/utils/GovFive.sol"; -contract RevokeMultisigGovernanceScript is BaseMainnetScript { +contract RevokeMultisigGovernanceScript is AbstractScript { using GovFive for GovFive.GovFiveProposal; GovFive.GovFiveProposal public govProposal; string public constant override DEPLOY_NAME = "015_RevokeMultisigGovernance"; + uint256 public constant override CHAIN_ID = 1; bool public constant override proposalExecuted = false; constructor() {}