|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity 0.8.23; |
| 3 | + |
| 4 | +// Contracts |
| 5 | +import {Proxy} from "contracts/Proxy.sol"; |
| 6 | +import {Mainnet} from "contracts/utils/Addresses.sol"; |
| 7 | +import {MultiAssetARM} from "contracts/MultiAssetARM.sol"; |
| 8 | +import {MorphoMarket} from "contracts/markets/MorphoMarket.sol"; |
| 9 | +import {Abstract4626MarketWrapper} from "contracts/markets/Abstract4626MarketWrapper.sol"; |
| 10 | + |
| 11 | +// Deployment |
| 12 | +import {AbstractDeployScript} from "script/deploy/helpers/AbstractDeployScript.s.sol"; |
| 13 | + |
| 14 | +/// @title Deploy the WETH ARM Morpho market |
| 15 | +/// @notice Deploys a MorphoMarket wrapper for the WETH ARM using the same Morpho vault as the |
| 16 | +/// LidoARM and EtherFiARM wrappers. The mainnet 2/8 multisig owns the wrapper and acts as |
| 17 | +/// its harvester. It also adds and activates the wrapper on the WETH ARM. |
| 18 | +/// @dev The multisig actions are simulated in _fork(); on mainnet they are executed separately by |
| 19 | +/// the multisig after the proxy and implementation have been deployed. |
| 20 | +contract $042_DeployWETHMorphoMarketScript is AbstractDeployScript("042_DeployWETHMorphoMarketScript") { |
| 21 | + function _execute() internal override { |
| 22 | + address wethARM = resolver.resolve("WETH_ARM"); |
| 23 | + |
| 24 | + // 1. Deploy the MorphoMarket proxy. |
| 25 | + Proxy morphoMarketProxy = new Proxy(); |
| 26 | + _recordDeployment("MORPHO_MARKET_WETH_ARM", address(morphoMarketProxy)); |
| 27 | + |
| 28 | + // 2. Deploy the implementation for the WETH ARM and the shared Morpho vault. |
| 29 | + MorphoMarket morphoMarketImpl = new MorphoMarket(wethARM, Mainnet.MORPHO_WETH_VAULT); |
| 30 | + _recordDeployment("MORPHO_MARKET_WETH_ARM_IMPL", address(morphoMarketImpl)); |
| 31 | + |
| 32 | + // 3. Initialize the wrapper and hand ownership to the WETH ARM's 2/8 multisig. |
| 33 | + bytes memory data = abi.encodeWithSelector( |
| 34 | + Abstract4626MarketWrapper.initialize.selector, Mainnet.MULTISIG_2_OF_8, Mainnet.MERKLE_DISTRIBUTOR |
| 35 | + ); |
| 36 | + morphoMarketProxy.initialize(address(morphoMarketImpl), Mainnet.MULTISIG_2_OF_8, data); |
| 37 | + } |
| 38 | + |
| 39 | + function _fork() internal override { |
| 40 | + MultiAssetARM wethARM = MultiAssetARM(payable(resolver.resolve("WETH_ARM"))); |
| 41 | + address morphoMarket = resolver.resolve("MORPHO_MARKET_WETH_ARM"); |
| 42 | + |
| 43 | + // Idempotent: the deployment runner can replay pending multisig actions on forks. |
| 44 | + if (!wethARM.supportedMarkets(morphoMarket)) { |
| 45 | + address[] memory markets = new address[](1); |
| 46 | + markets[0] = morphoMarket; |
| 47 | + |
| 48 | + vm.prank(Mainnet.MULTISIG_2_OF_8); |
| 49 | + wethARM.addMarkets(markets); |
| 50 | + } |
| 51 | + |
| 52 | + if (wethARM.activeMarket() != morphoMarket) { |
| 53 | + vm.prank(Mainnet.MULTISIG_2_OF_8); |
| 54 | + wethARM.setActiveMarket(morphoMarket); |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments