|
| 1 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | +pragma solidity 0.8.19; |
| 3 | + |
| 4 | +import "@forge-std/Test.sol"; |
| 5 | + |
| 6 | +import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; |
| 7 | + |
| 8 | +import {MTokenInterface} from "@protocol/MTokenInterfaces.sol"; |
| 9 | +import {MWethOwnerWrapper} from "@protocol/MWethOwnerWrapper.sol"; |
| 10 | + |
| 11 | +import {HybridProposal, ActionType} from "@proposals/proposalTypes/HybridProposal.sol"; |
| 12 | +import {AllChainAddresses as Addresses} from "@proposals/Addresses.sol"; |
| 13 | +import {BASE_FORK_ID} from "@utils/ChainIds.sol"; |
| 14 | +import {ProposalActions} from "@proposals/utils/ProposalActions.sol"; |
| 15 | + |
| 16 | +import {DeployMWethOwnerWrapper} from "@script/DeployMWethOwnerWrapper.s.sol"; |
| 17 | + |
| 18 | +/// @title MIP-B53: WETH Market Ownership Wrapper |
| 19 | +/// @notice Proposal to deploy and migrate WETH market admin to a wrapper contract |
| 20 | +/// that can reliably receive native ETH, enabling reserve reductions. |
| 21 | +/// @dev This proposal: |
| 22 | +/// 1. Deploys MWethOwnerWrapper implementation and proxy |
| 23 | +/// 2. Transfers WETH market admin from TEMPORAL_GOVERNOR to the wrapper |
| 24 | +/// 3. Wrapper is owned by TEMPORAL_GOVERNOR, maintaining governance control |
| 25 | +/// 4. Enables future WETH reserve reductions via the wrapper |
| 26 | +contract mipb53 is HybridProposal { |
| 27 | + using ProposalActions for *; |
| 28 | + |
| 29 | + string public constant override name = "MIP-B53"; |
| 30 | + |
| 31 | + constructor() { |
| 32 | + bytes memory proposalDescription = abi.encodePacked( |
| 33 | + vm.readFile("./proposals/mips/mip-b53/b53.md") |
| 34 | + ); |
| 35 | + _setProposalDescription(proposalDescription); |
| 36 | + } |
| 37 | + |
| 38 | + function primaryForkId() public pure override returns (uint256) { |
| 39 | + return BASE_FORK_ID; |
| 40 | + } |
| 41 | + |
| 42 | + function deploy(Addresses addresses, address) public override { |
| 43 | + vm.selectFork(BASE_FORK_ID); |
| 44 | + |
| 45 | + // Deploy the MWethOwnerWrapper implementation and proxy |
| 46 | + DeployMWethOwnerWrapper deployer = new DeployMWethOwnerWrapper(); |
| 47 | + (TransparentUpgradeableProxy proxy, ) = deployer.deploy(addresses); |
| 48 | + |
| 49 | + console.log("MWethOwnerWrapper deployed at:", address(proxy)); |
| 50 | + } |
| 51 | + |
| 52 | + function build(Addresses addresses) public override { |
| 53 | + vm.selectFork(BASE_FORK_ID); |
| 54 | + |
| 55 | + address wrapperProxy = addresses.getAddress("MWETH_OWNER_WRAPPER"); |
| 56 | + address moonwellWeth = addresses.getAddress("MOONWELL_WETH"); |
| 57 | + |
| 58 | + // Step 1: Set the wrapper as pending admin of the WETH market |
| 59 | + _pushAction( |
| 60 | + moonwellWeth, |
| 61 | + abi.encodeWithSignature( |
| 62 | + "_setPendingAdmin(address)", |
| 63 | + payable(wrapperProxy) |
| 64 | + ), |
| 65 | + "Set MWethOwnerWrapper as pending admin of MOONWELL_WETH", |
| 66 | + ActionType.Base |
| 67 | + ); |
| 68 | + |
| 69 | + // Step 2: Accept admin role from the wrapper |
| 70 | + _pushAction( |
| 71 | + wrapperProxy, |
| 72 | + abi.encodeWithSignature("_acceptAdmin()"), |
| 73 | + "MWethOwnerWrapper accepts admin role for MOONWELL_WETH", |
| 74 | + ActionType.Base |
| 75 | + ); |
| 76 | + } |
| 77 | + |
| 78 | + function validate(Addresses addresses, address) public override { |
| 79 | + vm.selectFork(BASE_FORK_ID); |
| 80 | + |
| 81 | + address wrapperProxy = addresses.getAddress("MWETH_OWNER_WRAPPER"); |
| 82 | + address moonwellWeth = addresses.getAddress("MOONWELL_WETH"); |
| 83 | + address temporalGovernor = addresses.getAddress("TEMPORAL_GOVERNOR"); |
| 84 | + address weth = addresses.getAddress("WETH"); |
| 85 | + |
| 86 | + // Validate wrapper configuration |
| 87 | + MWethOwnerWrapper wrapper = MWethOwnerWrapper(payable(wrapperProxy)); |
| 88 | + |
| 89 | + assertEq( |
| 90 | + wrapper.owner(), |
| 91 | + temporalGovernor, |
| 92 | + "Wrapper owner should be TEMPORAL_GOVERNOR" |
| 93 | + ); |
| 94 | + |
| 95 | + assertEq( |
| 96 | + address(wrapper.mToken()), |
| 97 | + moonwellWeth, |
| 98 | + "Wrapper mToken should be MOONWELL_WETH" |
| 99 | + ); |
| 100 | + |
| 101 | + assertEq( |
| 102 | + address(wrapper.weth()), |
| 103 | + weth, |
| 104 | + "Wrapper WETH address should be correct" |
| 105 | + ); |
| 106 | + |
| 107 | + // Validate admin transfer |
| 108 | + MTokenInterface mToken = MTokenInterface(moonwellWeth); |
| 109 | + |
| 110 | + assertEq( |
| 111 | + mToken.admin(), |
| 112 | + wrapperProxy, |
| 113 | + "MOONWELL_WETH admin should be the wrapper" |
| 114 | + ); |
| 115 | + |
| 116 | + assertEq( |
| 117 | + mToken.pendingAdmin(), |
| 118 | + address(0), |
| 119 | + "MOONWELL_WETH pendingAdmin should be zero after accepting" |
| 120 | + ); |
| 121 | + |
| 122 | + console.log("✓ MWethOwnerWrapper successfully deployed and configured"); |
| 123 | + console.log("✓ MOONWELL_WETH admin transferred to wrapper"); |
| 124 | + console.log("✓ Wrapper owned by TEMPORAL_GOVERNOR"); |
| 125 | + console.log("✓ Future WETH reserve reductions now enabled"); |
| 126 | + } |
| 127 | +} |
0 commit comments