diff --git a/script/deploy/DeployManager.sol b/script/deploy/DeployManager.sol index 7aa9052a..c0f02f45 100644 --- a/script/deploy/DeployManager.sol +++ b/script/deploy/DeployManager.sol @@ -24,6 +24,7 @@ import {UpgradeLidoARMSetBufferScript} from "./mainnet/009_UpgradeLidoARMSetBuff import {UpgradeOriginARMSetBufferScript} from "./sonic/005_UpgradeOriginARMSetBufferScript.sol"; import {UpgradeLidoARMAssetScript} from "./mainnet/010_UpgradeLidoARMAssetScript.sol"; import {DeployEtherFiARMScript} from "./mainnet/011_DeployEtherFiARMScript.sol"; +import {UpgradeEtherFiARMScript} from "./mainnet/012_UpgradeEtherFiARMScript.sol"; contract DeployManager is Script { using stdJson for string; @@ -84,6 +85,7 @@ contract DeployManager is Script { _runDeployFile(new DeployPendleAdaptor()); _runDeployFile(new UpgradeLidoARMAssetScript()); _runDeployFile(new DeployEtherFiARMScript()); + _runDeployFile(new UpgradeEtherFiARMScript()); } else if (block.chainid == 17000) { // Holesky _runDeployFile(new DeployCoreHoleskyScript()); diff --git a/script/deploy/mainnet/012_UpgradeEtherFiARMScript.sol b/script/deploy/mainnet/012_UpgradeEtherFiARMScript.sol new file mode 100644 index 00000000..c2574fa9 --- /dev/null +++ b/script/deploy/mainnet/012_UpgradeEtherFiARMScript.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.23; + +// Foundry imports +import {console} from "forge-std/console.sol"; + +// Contract imports +import {Proxy} from "contracts/Proxy.sol"; +import {EtherFiARM} from "contracts/EtherFiARM.sol"; +import {Mainnet} from "contracts/utils/Addresses.sol"; +import {MorphoMarket} from "contracts/markets/MorphoMarket.sol"; + +// Deployment imports +import {GovProposal, GovSixHelper} from "contracts/utils/GovSixHelper.sol"; +import {AbstractDeployScript} from "../AbstractDeployScript.sol"; + +contract UpgradeEtherFiARMScript is AbstractDeployScript { + using GovSixHelper for GovProposal; + + GovProposal public govProposal; + + string public constant override DEPLOY_NAME = "012_UpgradeEtherFiARMScript"; + bool public constant override proposalExecuted = false; + + Proxy morphoMarketProxy; + EtherFiARM etherFiARMImpl; + MorphoMarket morphoMarket; + + function _execute() internal override { + console.log("Deploy:", DEPLOY_NAME); + console.log("------------"); + + // 1. Deploy new EtherFiARM implementation + uint256 claimDelay = tenderlyTestnet ? 1 minutes : 10 minutes; + etherFiARMImpl = new EtherFiARM( + Mainnet.EETH, + Mainnet.WETH, + Mainnet.ETHERFI_WITHDRAWAL, + claimDelay, + 1e7, // minSharesToRedeem + 1e18, // allocateThreshold + Mainnet.ETHERFI_WITHDRAWAL_NFT, + Mainnet.ETHERFI_REDEMPTION_MANAGER + ); + _recordDeploy("ETHERFI_ARM_IMPL", address(etherFiARMImpl)); + + console.log("Finished deploying", DEPLOY_NAME); + } + + function _fork() internal override { + vm.startPrank(Proxy(payable(deployedContracts["ETHER_FI_ARM"])).owner()); + Proxy(payable(deployedContracts["ETHER_FI_ARM"])).upgradeTo(address(etherFiARMImpl)); + vm.stopPrank(); + } +} diff --git a/src/contracts/AbstractARM.sol b/src/contracts/AbstractARM.sol index 62727bec..6fb52cca 100644 --- a/src/contracts/AbstractARM.sol +++ b/src/contracts/AbstractARM.sol @@ -240,6 +240,7 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { * @param amountIn The amount of input tokens to send. * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert. * @param to Recipient of the output tokens. + * @return amounts The input and output token amounts. */ function swapExactTokensForTokens( IERC20 inToken, @@ -247,9 +248,13 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { uint256 amountIn, uint256 amountOutMin, address to - ) external virtual { + ) external virtual returns (uint256[] memory amounts) { uint256 amountOut = _swapExactTokensForTokens(inToken, outToken, amountIn, to); require(amountOut >= amountOutMin, "ARM: Insufficient output amount"); + + amounts = new uint256[](2); + amounts[0] = amountIn; + amounts[1] = amountOut; } /** @@ -297,6 +302,7 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { * @param amountOut The amount of output tokens to receive. * @param amountInMax The maximum amount of input tokens that can be required before the transaction reverts. * @param to Recipient of the output tokens. + * @return amounts The input and output token amounts. */ function swapTokensForExactTokens( IERC20 inToken, @@ -304,10 +310,14 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { uint256 amountOut, uint256 amountInMax, address to - ) external virtual { + ) external virtual returns (uint256[] memory amounts) { uint256 amountIn = _swapTokensForExactTokens(inToken, outToken, amountOut, to); require(amountIn <= amountInMax, "ARM: Excess input amount"); + + amounts = new uint256[](2); + amounts[0] = amountIn; + amounts[1] = amountOut; } /** diff --git a/src/contracts/Interfaces.sol b/src/contracts/Interfaces.sol index 3f36b906..04d3d997 100644 --- a/src/contracts/Interfaces.sol +++ b/src/contracts/Interfaces.sol @@ -28,6 +28,7 @@ interface IOethARM { * @param amountIn The amount of input tokens to send. * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert. * @param to Recipient of the output tokens. + * @return amounts The input and output token amounts. */ function swapExactTokensForTokens( IERC20 inToken, @@ -35,7 +36,7 @@ interface IOethARM { uint256 amountIn, uint256 amountOutMin, address to - ) external; + ) external returns (uint256[] memory amounts); /** * @notice Uniswap V2 Router compatible interface. Swaps an exact amount of @@ -68,6 +69,7 @@ interface IOethARM { * @param amountOut The amount of output tokens to receive. * @param amountInMax The maximum amount of input tokens that can be required before the transaction reverts. * @param to Recipient of the output tokens. + * @return amounts The input and output token amounts. */ function swapTokensForExactTokens( IERC20 inToken, @@ -75,7 +77,7 @@ interface IOethARM { uint256 amountOut, uint256 amountInMax, address to - ) external; + ) external returns (uint256[] memory amounts); /** * @notice Uniswap V2 Router compatible interface. Receive an exact amount of