diff --git a/script/deploy/05_DeployInitialReserveAndSpotOracles.s.sol b/script/deploy/05_DeployInitialReserveAndSpotOracles.s.sol index ae62ac16..5bae94fe 100644 --- a/script/deploy/05_DeployInitialReserveAndSpotOracles.s.sol +++ b/script/deploy/05_DeployInitialReserveAndSpotOracles.s.sol @@ -35,12 +35,16 @@ contract DeployInitialReserveAndSpotOraclesScript is DeployScript { ) ); spotOracle = address( - new WeEthWethSpotOracle{ salt: DEFAULT_SALT }(ltv, address(reserveOracle), maxTimeFromLastUpdate, gracePeriod) + new WeEthWethSpotOracle{ salt: DEFAULT_SALT }( + ltv, address(reserveOracle), maxTimeFromLastUpdate, gracePeriod + ) ); } else { - reserveOracle = - address(new WeEthWethReserveOracle(0, new address[](3), 0, maxChange, maxTimeFromLastUpdate, gracePeriod)); - spotOracle = address(new WeEthWethSpotOracle(ltv, address(reserveOracle), maxTimeFromLastUpdate, gracePeriod)); + reserveOracle = address( + new WeEthWethReserveOracle(0, new address[](3), 0, maxChange, maxTimeFromLastUpdate, gracePeriod) + ); + spotOracle = + address(new WeEthWethSpotOracle(ltv, address(reserveOracle), maxTimeFromLastUpdate, gracePeriod)); } } } diff --git a/script/deploy/08_DeployHandlers.s.sol b/script/deploy/08_DeployHandlers.s.sol index 7c51216e..b915ef70 100644 --- a/script/deploy/08_DeployHandlers.s.sol +++ b/script/deploy/08_DeployHandlers.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.21; -import { BASE_WEETH_WETH_BALANCER_POOL_ID, BASE_WSTETH_WETH_UNISWAP } from "../../src/Constants.sol"; +import { BASE_WETH, BASE_WEETH_WETH_BALANCER_POOL_ID, BASE_WSTETH_WETH_UNISWAP } from "../../src/Constants.sol"; import { DeployScript } from "../Deploy.s.sol"; import { IonPool } from "../../src/IonPool.sol"; import { GemJoin } from "../../src/join/GemJoin.sol"; @@ -29,11 +29,23 @@ contract DeployHandlersScript is DeployScript { if (deployCreate2) { handler = new WeEthWethHandler{ salt: DEFAULT_SALT }( - ILK_INDEX_ZERO, ionPool, gemJoin, whitelist, BASE_WSTETH_WETH_UNISWAP, BASE_WEETH_WETH_BALANCER_POOL_ID + ILK_INDEX_ZERO, + ionPool, + gemJoin, + whitelist, + BASE_WSTETH_WETH_UNISWAP, + BASE_WEETH_WETH_BALANCER_POOL_ID, + BASE_WETH ); } else { handler = new WeEthWethHandler{ salt: DEFAULT_SALT }( - ILK_INDEX_ZERO, ionPool, gemJoin, whitelist, BASE_WSTETH_WETH_UNISWAP, BASE_WEETH_WETH_BALANCER_POOL_ID + ILK_INDEX_ZERO, + ionPool, + gemJoin, + whitelist, + BASE_WSTETH_WETH_UNISWAP, + BASE_WEETH_WETH_BALANCER_POOL_ID, + BASE_WETH ); } } diff --git a/src/Constants.sol b/src/Constants.sol index 444f93bc..bb61368d 100644 --- a/src/Constants.sol +++ b/src/Constants.sol @@ -20,6 +20,7 @@ import { IRenzoOracle, IRestakeManager } from "./interfaces/ProviderInterfaces.sol"; +import { IWETH9 } from "./interfaces/IWETH9.sol"; import { IRedstonePriceFeed } from "./interfaces/IRedstone.sol"; import { IChainlink } from "./interfaces/IChainlink.sol"; import { ICreateX } from "./interfaces/ICreateX.sol"; @@ -108,4 +109,4 @@ bytes32 constant BASE_WEETH_WETH_BALANCER_POOL_ID = 0xab99a3e856deb448ed99713dfc IUniswapV3Pool constant BASE_WSTETH_WETH_UNISWAP = IUniswapV3Pool(0x20E068D76f9E90b90604500B84c7e19dCB923e7e); IChainlink constant BASE_SEQUENCER_UPTIME_FEED = IChainlink(0xBCF85224fc0756B9Fa45aA7892530B47e10b6433); IERC20 constant BASE_WEETH = IERC20(0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A); -IERC20 constant BASE_WETH = IERC20(0x4200000000000000000000000000000000000006); +IWETH9 constant BASE_WETH = IWETH9(0x4200000000000000000000000000000000000006); diff --git a/src/flash/BalancerFlashloanDirectMintHandler.sol b/src/flash/BalancerFlashloanDirectMintHandler.sol index 9278e7f4..db02ed96 100644 --- a/src/flash/BalancerFlashloanDirectMintHandler.sol +++ b/src/flash/BalancerFlashloanDirectMintHandler.sol @@ -14,7 +14,9 @@ IVault constant VAULT = IVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8); /** * @notice This contract allows for easy creation of leverage positions through - * Balancer flashloans and LST mints through the LST provider. + * Balancer flashloans and LST mints through the LST provider. This contract + * should be used when the base asset of the market is `WETH` and when the asset + * required to mint the collateral is also `WETH`. * * @dev There are a couple things to consider here from a security perspective. The * first one is that the flashloan callback must only be callable from the diff --git a/src/flash/IonHandlerBase.sol b/src/flash/IonHandlerBase.sol index f1edfad4..c0c573a1 100644 --- a/src/flash/IonHandlerBase.sol +++ b/src/flash/IonHandlerBase.sol @@ -6,7 +6,6 @@ import { IWETH9 } from "../interfaces/IWETH9.sol"; import { GemJoin } from "../join/GemJoin.sol"; import { WadRayMath, RAY } from "../libraries/math/WadRayMath.sol"; import { Whitelist } from "../Whitelist.sol"; -import { WETH_ADDRESS } from "../Constants.sol"; import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; @@ -70,9 +69,8 @@ abstract contract IonHandlerBase { } IERC20 public immutable BASE; - // Will keep WETH for compatibility with other strategies. But this should - // be removed eventually to remove dependence on WETH as a base asset. IWETH9 public immutable WETH; + uint8 public immutable ILK_INDEX; IonPool public immutable POOL; GemJoin public immutable JOIN; @@ -86,14 +84,14 @@ abstract contract IonHandlerBase { * @param _gemJoin the `GemJoin` associated with the `ilkIndex` of this * contract. * @param _whitelist the `Whitelist` module address. + * @param _weth The WETH address of the chain. */ - constructor(uint8 _ilkIndex, IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist) { + constructor(uint8 _ilkIndex, IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, IWETH9 _weth) { POOL = _ionPool; ILK_INDEX = _ilkIndex; BASE = IERC20(_ionPool.underlying()); - IWETH9 _weth = WETH_ADDRESS; WETH = _weth; address ilkAddress = POOL.getIlkAddress(_ilkIndex); @@ -262,6 +260,6 @@ abstract contract IonHandlerBase { * @dev To allow unwrapping of WETH into ETH. */ receive() external payable { - if (msg.sender != address(WETH_ADDRESS)) revert CannotSendEthToContract(); + if (msg.sender != address(WETH)) revert CannotSendEthToContract(); } } diff --git a/src/flash/PtHandler.sol b/src/flash/PtHandler.sol index 63794d8a..a8bcdb9f 100644 --- a/src/flash/PtHandler.sol +++ b/src/flash/PtHandler.sol @@ -5,6 +5,7 @@ import { IonPool } from "../IonPool.sol"; import { GemJoin } from "../join/GemJoin.sol"; import { Whitelist } from "../Whitelist.sol"; import { IonHandlerBase } from "./IonHandlerBase.sol"; +import { IWETH9 } from "./../interfaces/IWETH9.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -47,9 +48,10 @@ contract PtHandler is IonHandlerBase, IPMarketSwapCallback { IonPool pool, GemJoin join, Whitelist whitelist, - IPMarketV3 _market + IPMarketV3 _market, + IWETH9 _weth ) - IonHandlerBase(0, pool, join, whitelist) + IonHandlerBase(0, pool, join, whitelist, _weth) { if (!pool.hasRole(pool.GEM_JOIN_ROLE(), address(join))) revert InvalidGemJoin(address(join)); diff --git a/src/flash/UniswapFlashloanBalancerSwapHandler.sol b/src/flash/UniswapFlashloanBalancerSwapHandler.sol index e1ddb1a2..8351775d 100644 --- a/src/flash/UniswapFlashloanBalancerSwapHandler.sol +++ b/src/flash/UniswapFlashloanBalancerSwapHandler.sol @@ -22,6 +22,9 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s * rates. DEXes also provide an avenue for atomic deleveraging since the LST -> * ETH exchange can be made. * + * This contract is used when the Balancer has a collateral asset <> base asset + * pool, and the Uniswap has a base asset flashloan. + * * NOTE: Uniswap flashloans do charge a small fee. * * @dev Some tokens only have liquidity on Balancer. Due to the reentrancy lock @@ -60,6 +63,8 @@ abstract contract UniswapFlashloanBalancerSwapHandler is IUniswapV3FlashCallback address token0 = IUniswapV3Pool(_flashloanPool).token0(); address token1 = IUniswapV3Pool(_flashloanPool).token1(); + // The naming convention uses `_weth`, but this terminology refers to + // the `BASE` token of the underlying IonPool. bool _wethIsToken0 = token0 == address(BASE); bool _wethIsToken1 = token1 == address(BASE); diff --git a/src/flash/UniswapFlashswapHandler.sol b/src/flash/UniswapFlashswapHandler.sol index 462568e8..e37dac89 100644 --- a/src/flash/UniswapFlashswapHandler.sol +++ b/src/flash/UniswapFlashswapHandler.sol @@ -22,6 +22,10 @@ import { IUniswapV3SwapCallback } from "@uniswap/v3-core/contracts/interfaces/ca * @dev When using the `UniswapFlashSwapHandler`, the `IUniswapV3Pool pool` fed to the * constructor should be the WETH/[LST] pool. * + * This flow can be used in case when the UniswapV3 Pool has a collateral <> + * base asset pair. However, the current version of this contract always assumes + * that the base asset is `WETH`. + * * Unlike Balancer flashloans, there is no concern here that somebody else could * initiate a flashswap, then direct the callback to be called on this contract. * Uniswap enforces that callback is only called on `msg.sender`. diff --git a/src/flash/lrt/EzEthHandler.sol b/src/flash/lrt/EzEthHandler.sol index 7dc0596a..a9ff3e3f 100644 --- a/src/flash/lrt/EzEthHandler.sol +++ b/src/flash/lrt/EzEthHandler.sol @@ -9,6 +9,8 @@ import { IonHandlerBase } from "../IonHandlerBase.sol"; import { RenzoLibrary } from "./../../libraries/lrt/RenzoLibrary.sol"; import { WETH_ADDRESS } from "../../Constants.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; + import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; /** @@ -30,9 +32,10 @@ contract EzEthHandler is UniswapFlashswapDirectMintHandlerWithDust { IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, - IUniswapV3Pool _wstEthUniswapPool + IUniswapV3Pool _wstEthUniswapPool, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashswapDirectMintHandlerWithDust(_wstEthUniswapPool, WETH_ADDRESS) { } diff --git a/src/flash/lrt/EzEthWethHandler.sol b/src/flash/lrt/EzEthWethHandler.sol index 63138e23..821e8025 100644 --- a/src/flash/lrt/EzEthWethHandler.sol +++ b/src/flash/lrt/EzEthWethHandler.sol @@ -5,14 +5,15 @@ import { IonPool } from "../../IonPool.sol"; import { GemJoin } from "../../join/GemJoin.sol"; import { Whitelist } from "../../Whitelist.sol"; import { IonHandlerBase } from "../IonHandlerBase.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; import { UniswapFlashloanBalancerSwapHandler } from "./../UniswapFlashloanBalancerSwapHandler.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; - /** * @notice Handler for the ezETH collateral in the ezETH/WETH market. * * @custom:security-contact security@molecularlabs.io */ + contract EzEthWethHandler is UniswapFlashloanBalancerSwapHandler { /** * @notice Creates a new `EzEthWethHandler` instance. @@ -29,9 +30,10 @@ contract EzEthWethHandler is UniswapFlashloanBalancerSwapHandler { GemJoin _gemJoin, Whitelist _whitelist, IUniswapV3Pool _wstEthUniswapPool, - bytes32 _balancerPoolId + bytes32 _balancerPoolId, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashloanBalancerSwapHandler(_wstEthUniswapPool, _balancerPoolId) { } } diff --git a/src/flash/lrt/RsEthHandler.sol b/src/flash/lrt/RsEthHandler.sol index 9c556b46..b886d10b 100644 --- a/src/flash/lrt/RsEthHandler.sol +++ b/src/flash/lrt/RsEthHandler.sol @@ -10,6 +10,8 @@ import { IonHandlerBase } from "../IonHandlerBase.sol"; import { RSETH, WETH_ADDRESS } from "../../Constants.sol"; import { KelpDaoLibrary } from "../../libraries/lrt/KelpDaoLibrary.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; + import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; /** @@ -33,9 +35,10 @@ contract RsEthHandler is UniswapFlashswapDirectMintHandler { IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, - IUniswapV3Pool _wstEthUniswapPool + IUniswapV3Pool _wstEthUniswapPool, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashswapDirectMintHandler(_wstEthUniswapPool, WETH_ADDRESS) { } diff --git a/src/flash/lrt/RswEthHandler.sol b/src/flash/lrt/RswEthHandler.sol index 802fe0e0..48f5ac42 100644 --- a/src/flash/lrt/RswEthHandler.sol +++ b/src/flash/lrt/RswEthHandler.sol @@ -9,6 +9,7 @@ import { UniswapFlashswapDirectMintHandler } from "../UniswapFlashswapDirectMint import { IonHandlerBase } from "../IonHandlerBase.sol"; import { RSWETH, WETH_ADDRESS } from "../../Constants.sol"; import { RestakedSwellLibrary } from "../../libraries/lrt/RestakedSwellLibrary.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; @@ -33,9 +34,10 @@ contract RswEthHandler is UniswapFlashswapDirectMintHandler { IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, - IUniswapV3Pool _wstEthUniswapPool + IUniswapV3Pool _wstEthUniswapPool, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashswapDirectMintHandler(_wstEthUniswapPool, WETH_ADDRESS) { } diff --git a/src/flash/lrt/WeEthHandler.sol b/src/flash/lrt/WeEthHandler.sol index 5972c6f4..4fd4314d 100644 --- a/src/flash/lrt/WeEthHandler.sol +++ b/src/flash/lrt/WeEthHandler.sol @@ -9,6 +9,7 @@ import { UniswapFlashswapDirectMintHandler } from "../UniswapFlashswapDirectMint import { IonHandlerBase } from "../IonHandlerBase.sol"; import { EtherFiLibrary } from "../../libraries/lrt/EtherFiLibrary.sol"; import { WEETH_ADDRESS, WETH_ADDRESS, EETH_ADDRESS } from "../../Constants.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; @@ -33,9 +34,10 @@ contract WeEthHandler is UniswapFlashswapDirectMintHandler { IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, - IUniswapV3Pool _wstEthUniswapPool + IUniswapV3Pool _wstEthUniswapPool, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashswapDirectMintHandler(_wstEthUniswapPool, WETH_ADDRESS) { EETH_ADDRESS.approve(address(WEETH_ADDRESS), type(uint256).max); diff --git a/src/flash/lrt/WeEthWethHandler.sol b/src/flash/lrt/WeEthWethHandler.sol index b25a9674..1156e4a1 100644 --- a/src/flash/lrt/WeEthWethHandler.sol +++ b/src/flash/lrt/WeEthWethHandler.sol @@ -7,6 +7,7 @@ import { Whitelist } from "../../Whitelist.sol"; import { IonHandlerBase } from "../IonHandlerBase.sol"; import { UniswapFlashloanBalancerSwapHandler } from "./../UniswapFlashloanBalancerSwapHandler.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; /** * @notice Handler for the weETH collateral in the weETH/WETH market. @@ -29,9 +30,10 @@ contract WeEthWethHandler is UniswapFlashloanBalancerSwapHandler { GemJoin _gemJoin, Whitelist _whitelist, IUniswapV3Pool _wstEthUniswapPool, - bytes32 _balancerPoolId + bytes32 _balancerPoolId, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashloanBalancerSwapHandler(_wstEthUniswapPool, _balancerPoolId) { } } diff --git a/src/flash/lst/EthXHandler.sol b/src/flash/lst/EthXHandler.sol index 8218ae43..0964d553 100644 --- a/src/flash/lst/EthXHandler.sol +++ b/src/flash/lst/EthXHandler.sol @@ -10,6 +10,7 @@ import { IonHandlerBase } from "../IonHandlerBase.sol"; import { UniswapFlashloanBalancerSwapHandler } from "../UniswapFlashloanBalancerSwapHandler.sol"; import { BalancerFlashloanDirectMintHandler } from "../BalancerFlashloanDirectMintHandler.sol"; import { UniswapFlashswapHandler } from "../UniswapFlashswapHandler.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; @@ -47,10 +48,11 @@ contract EthXHandler is Whitelist _whitelist, IUniswapV3Pool _wstEthUniswapPool, IUniswapV3Pool _ethXUniswapPool, - bytes32 _balancerPoolId + bytes32 _balancerPoolId, + IWETH9 _weth ) UniswapFlashloanBalancerSwapHandler(_wstEthUniswapPool, _balancerPoolId) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashswapHandler(_ethXUniswapPool, false) { STADER_DEPOSIT = _staderDeposit; diff --git a/src/flash/lst/SwEthHandler.sol b/src/flash/lst/SwEthHandler.sol index 7fab6a37..dd63e8e5 100644 --- a/src/flash/lst/SwEthHandler.sol +++ b/src/flash/lst/SwEthHandler.sol @@ -10,6 +10,7 @@ import { ISwEth } from "../../interfaces/ProviderInterfaces.sol"; import { SwellLibrary } from "../../libraries/lst/SwellLibrary.sol"; import { WadRayMath } from "../../libraries/math/WadRayMath.sol"; import { Whitelist } from "../../Whitelist.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; @@ -35,9 +36,10 @@ contract SwEthHandler is UniswapFlashswapHandler, BalancerFlashloanDirectMintHan IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, - IUniswapV3Pool _swEthPool + IUniswapV3Pool _swEthPool, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashswapHandler(_swEthPool, true) { } diff --git a/src/flash/lst/WstEthHandler.sol b/src/flash/lst/WstEthHandler.sol index 24e7db7d..1a4155db 100644 --- a/src/flash/lst/WstEthHandler.sol +++ b/src/flash/lst/WstEthHandler.sol @@ -9,6 +9,7 @@ import { BalancerFlashloanDirectMintHandler } from "../BalancerFlashloanDirectMi import { IWstEth } from "../../interfaces/ProviderInterfaces.sol"; import { LidoLibrary } from "../../libraries/lst/LidoLibrary.sol"; import { Whitelist } from "../../Whitelist.sol"; +import { IWETH9 } from "./../../interfaces/IWETH9.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; @@ -36,9 +37,10 @@ contract WstEthHandler is UniswapFlashswapHandler, BalancerFlashloanDirectMintHa IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, - IUniswapV3Pool _wstEthUniswapPool + IUniswapV3Pool _wstEthUniswapPool, + IWETH9 _weth ) - IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist) + IonHandlerBase(_ilkIndex, _ionPool, _gemJoin, _whitelist, _weth) UniswapFlashswapHandler(_wstEthUniswapPool, false) { // NOTE: approves wstETH contract infinite approval to move this contract's stEth diff --git a/src/oracles/reserve/lrt/WeEthWethReserveOracle.sol b/src/oracles/reserve/lrt/WeEthWethReserveOracle.sol index f7a61c34..8d6df5c3 100644 --- a/src/oracles/reserve/lrt/WeEthWethReserveOracle.sol +++ b/src/oracles/reserve/lrt/WeEthWethReserveOracle.sol @@ -65,7 +65,7 @@ contract WeEthWethReserveOracle is ReserveOracle { if (answer == 1) revert SequencerDown(); if (block.timestamp - startedAt <= GRACE_PERIOD) revert GracePeriodNotOver(); - + (, int256 ethPerWeEth,, uint256 ethPerWeEthUpdatedAt,) = BASE_WEETH_ETH_EXCHANGE_RATE_CHAINLINK.latestRoundData(); diff --git a/src/oracles/spot/lrt/WeEthWethSpotOracle.sol b/src/oracles/spot/lrt/WeEthWethSpotOracle.sol index 4a1419c3..1b155772 100644 --- a/src/oracles/spot/lrt/WeEthWethSpotOracle.sol +++ b/src/oracles/spot/lrt/WeEthWethSpotOracle.sol @@ -22,14 +22,14 @@ contract WeEthWethSpotOracle is SpotOracle { /** * @notice The maximum delay for the oracle update in seconds before the - * data is considered stale. + * data is considered stale. */ uint256 public immutable MAX_TIME_FROM_LAST_UPDATE; // seconds /** * @notice Amount of time to wait after the sequencer restarts. */ - uint256 public immutable GRACE_PERIOD; + uint256 public immutable GRACE_PERIOD; /** * @notice Creates a new `WeEthWethSpotOracle` instance. diff --git a/test/fork/concrete/lrt/EzEthHandler.t.sol b/test/fork/concrete/lrt/EzEthHandler.t.sol index d965e26e..8f6ed8df 100644 --- a/test/fork/concrete/lrt/EzEthHandler.t.sol +++ b/test/fork/concrete/lrt/EzEthHandler.t.sol @@ -5,7 +5,7 @@ import { RenzoLibrary } from "./../../../../src/libraries/lrt/RenzoLibrary.sol"; import { LrtHandler_ForkBase } from "../../../helpers/handlers/LrtHandlerForkBase.sol"; import { EzEthHandler } from "./../../../../src/flash/lrt/EzEthHandler.sol"; import { Whitelist } from "../../../../src/Whitelist.sol"; -import { RENZO_RESTAKE_MANAGER, EZETH } from "../../../../src/Constants.sol"; +import { RENZO_RESTAKE_MANAGER, EZETH, WETH_ADDRESS } from "../../../../src/Constants.sol"; import { IIonPool } from "./../../../../src/interfaces/IIonPool.sol"; import { IProviderLibraryExposed } from "../../../helpers/IProviderLibraryExposed.sol"; @@ -31,7 +31,9 @@ abstract contract EzEthHandler_ForkBase is LrtHandler_ForkBase { function setUp() public virtual override { super.setUp(); - ezEthHandler = new EzEthHandler(ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL); + ezEthHandler = new EzEthHandler( + ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL, WETH_ADDRESS + ); EZETH.approve(address(ezEthHandler), type(uint256).max); diff --git a/test/fork/concrete/lrt/EzEthWethHandler.t.sol b/test/fork/concrete/lrt/EzEthWethHandler.t.sol index 95f710c6..19c9ab9d 100644 --- a/test/fork/concrete/lrt/EzEthWethHandler.t.sol +++ b/test/fork/concrete/lrt/EzEthWethHandler.t.sol @@ -24,7 +24,8 @@ contract EzEthWethHandler_ForkTest is UniswapFlashloanBalancerSwapHandler_Test { gemJoins[ILK_INDEX], Whitelist(whitelist), MAINNET_WSTETH_WETH_UNISWAP, - EZETH_WETH_BALANCER_POOL_ID + EZETH_WETH_BALANCER_POOL_ID, + WETH_ADDRESS ); EZETH.approve(address(handler), type(uint256).max); diff --git a/test/fork/concrete/lrt/ReserveOracle.t.sol b/test/fork/concrete/lrt/ReserveOracle.t.sol index 2eb74aa8..f7aa41c3 100644 --- a/test/fork/concrete/lrt/ReserveOracle.t.sol +++ b/test/fork/concrete/lrt/ReserveOracle.t.sol @@ -434,7 +434,9 @@ contract WeEthWethReserveOracle_ForkTest is ReserveOracle_ForkTest { function setUp() public override { super.setUp(); - reserveOracle = new WeEthWethReserveOracle(ILK_INDEX, emptyFeeds, QUORUM, MAX_CHANGE, MAX_TIME_FROM_LAST_UPDATE, GRACE_PERIOD); + reserveOracle = new WeEthWethReserveOracle( + ILK_INDEX, emptyFeeds, QUORUM, MAX_CHANGE, MAX_TIME_FROM_LAST_UPDATE, GRACE_PERIOD + ); } function _getForkRpc() internal override returns (string memory) { diff --git a/test/fork/concrete/lrt/RsEthHandler.t.sol b/test/fork/concrete/lrt/RsEthHandler.t.sol index fb73f2e0..3cf8f862 100644 --- a/test/fork/concrete/lrt/RsEthHandler.t.sol +++ b/test/fork/concrete/lrt/RsEthHandler.t.sol @@ -5,7 +5,7 @@ import { IRsEth } from "../../../../src/interfaces/ProviderInterfaces.sol"; import { KelpDaoLibrary } from "../../../../src/libraries/lrt/KelpDaoLibrary.sol"; import { RsEthHandler } from "../../../../src/flash/lrt/RsEthHandler.sol"; import { Whitelist } from "../../../../src/Whitelist.sol"; -import { RSETH, RSETH_LRT_DEPOSIT_POOL } from "../../../../src/Constants.sol"; +import { RSETH, RSETH_LRT_DEPOSIT_POOL, WETH_ADDRESS } from "../../../../src/Constants.sol"; import { LrtHandler_ForkBase } from "../../../helpers/handlers/LrtHandlerForkBase.sol"; import { IProviderLibraryExposed } from "../../../helpers/IProviderLibraryExposed.sol"; @@ -38,7 +38,9 @@ abstract contract RsEthHandler_ForkBase is LrtHandler_ForkBase { function setUp() public virtual override { super.setUp(); - rsEthHandler = new RsEthHandler(ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL); + rsEthHandler = new RsEthHandler( + ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL, WETH_ADDRESS + ); RSETH.approve(address(rsEthHandler), type(uint256).max); diff --git a/test/fork/concrete/lrt/RswEthHandler.t.sol b/test/fork/concrete/lrt/RswEthHandler.t.sol index 99359c8e..680a3077 100644 --- a/test/fork/concrete/lrt/RswEthHandler.t.sol +++ b/test/fork/concrete/lrt/RswEthHandler.t.sol @@ -5,7 +5,7 @@ import { IRswEth } from "../../../../src/interfaces/ProviderInterfaces.sol"; import { RestakedSwellLibrary } from "../../../../src/libraries/lrt/RestakedSwellLibrary.sol"; import { RswEthHandler } from "../../../../src/flash/lrt/RswEthHandler.sol"; import { Whitelist } from "../../../../src/Whitelist.sol"; -import { RSWETH } from "../../../../src/Constants.sol"; +import { RSWETH, WETH_ADDRESS } from "../../../../src/Constants.sol"; import { LrtHandler_ForkBase } from "../../../helpers/handlers/LrtHandlerForkBase.sol"; import { IIonPool } from "./../../../../src/interfaces/IIonPool.sol"; @@ -39,7 +39,9 @@ abstract contract RswEthHandler_ForkBase is LrtHandler_ForkBase { function setUp() public virtual override { super.setUp(); - rswEthHandler = new RswEthHandler(ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL); + rswEthHandler = new RswEthHandler( + ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL, WETH_ADDRESS + ); RSWETH.approve(address(rswEthHandler), type(uint256).max); diff --git a/test/fork/concrete/lrt/SpotOracle.t.sol b/test/fork/concrete/lrt/SpotOracle.t.sol index f8e19557..c28f96f4 100644 --- a/test/fork/concrete/lrt/SpotOracle.t.sol +++ b/test/fork/concrete/lrt/SpotOracle.t.sol @@ -148,8 +148,9 @@ contract WeEthWethSpotOracle_ForkTest is SpotOracle_ForkTest { function setUp() public override { super.setUp(); - reserveOracle = - new WeEthWethReserveOracle(ILK_INDEX, emptyFeeds, QUORUM, DEFAULT_MAX_CHANGE, MAX_TIME_FROM_LAST_UPDATE, GRACE_PERIOD); + reserveOracle = new WeEthWethReserveOracle( + ILK_INDEX, emptyFeeds, QUORUM, DEFAULT_MAX_CHANGE, MAX_TIME_FROM_LAST_UPDATE, GRACE_PERIOD + ); spotOracle = new WeEthWethSpotOracle(MAX_LTV, address(reserveOracle), MAX_TIME_FROM_LAST_UPDATE, GRACE_PERIOD); } diff --git a/test/fork/concrete/lrt/WeEthHandler.t.sol b/test/fork/concrete/lrt/WeEthHandler.t.sol index 66ffe3bd..6f4b4c0c 100644 --- a/test/fork/concrete/lrt/WeEthHandler.t.sol +++ b/test/fork/concrete/lrt/WeEthHandler.t.sol @@ -6,7 +6,7 @@ import { EtherFiLibrary } from "../../../../src/libraries/lrt/EtherFiLibrary.sol import { LrtHandler_ForkBase } from "../../../helpers/handlers/LrtHandlerForkBase.sol"; import { WeEthHandler } from "../../../../src/flash/lrt/WeEthHandler.sol"; import { Whitelist } from "../../../../src/Whitelist.sol"; -import { WEETH_ADDRESS, EETH_ADDRESS } from "../../../../src/Constants.sol"; +import { WEETH_ADDRESS, EETH_ADDRESS, WETH_ADDRESS } from "../../../../src/Constants.sol"; import { IProviderLibraryExposed } from "../../../helpers/IProviderLibraryExposed.sol"; import { UniswapFlashswapDirectMintHandler_Test } from "../handlers-base/UniswapFlashswapDirectMintHandler.t.sol"; @@ -38,7 +38,9 @@ abstract contract WeEthHandler_ForkBase is LrtHandler_ForkBase { function setUp() public virtual override { super.setUp(); - weEthHandler = new WeEthHandler(ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL); + weEthHandler = new WeEthHandler( + ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL, WETH_ADDRESS + ); WEETH_ADDRESS.approve(address(weEthHandler), type(uint256).max); diff --git a/test/fork/concrete/lrt/WeEthWethHandler.t.sol b/test/fork/concrete/lrt/WeEthWethHandler.t.sol index 8d3c1424..674d4bf3 100644 --- a/test/fork/concrete/lrt/WeEthWethHandler.t.sol +++ b/test/fork/concrete/lrt/WeEthWethHandler.t.sol @@ -5,7 +5,8 @@ import { BASE_WEETH_WETH_BALANCER_POOL_ID, BASE_WETH, BASE_WEETH, - BASE_WEETH_ETH_PRICE_CHAINLINK + BASE_WEETH_ETH_PRICE_CHAINLINK, + WETH_ADDRESS } from "./../../../../src/Constants.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/interfaces/IERC20.sol"; @@ -28,7 +29,8 @@ contract WeEthWethHandler_ForkTest is UniswapFlashloanBalancerSwapHandler_Test { gemJoins[ILK_INDEX], Whitelist(whitelist), BASE_WSTETH_WETH_UNISWAP, - BASE_WEETH_WETH_BALANCER_POOL_ID + BASE_WEETH_WETH_BALANCER_POOL_ID, + WETH_ADDRESS ); BASE_WEETH.approve(address(handler), type(uint256).max); diff --git a/test/fork/concrete/lst/SwEthHandler.t.sol b/test/fork/concrete/lst/SwEthHandler.t.sol index 9f8c778c..b17a6b00 100644 --- a/test/fork/concrete/lst/SwEthHandler.t.sol +++ b/test/fork/concrete/lst/SwEthHandler.t.sol @@ -5,6 +5,7 @@ import { ISwEth } from "../../../../src/interfaces/ProviderInterfaces.sol"; import { SwEthHandler } from "../../../../src/flash//lst/SwEthHandler.sol"; import { SwellLibrary } from "../../../../src/libraries/lst/SwellLibrary.sol"; import { Whitelist } from "../../../../src/Whitelist.sol"; +import { WETH_ADDRESS } from "../../../../src/Constants.sol"; import { LstHandler_ForkBase } from "../../../helpers/handlers/LstHandlerForkBase.sol"; import { IProviderLibraryExposed } from "../../../helpers/IProviderLibraryExposed.sol"; @@ -39,7 +40,8 @@ abstract contract SwEthHandler_ForkBase is LstHandler_ForkBase { function setUp() public virtual override { super.setUp(); - swEthHandler = new SwEthHandler(ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), SWETH_ETH_POOL); + swEthHandler = + new SwEthHandler(ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), SWETH_ETH_POOL, WETH_ADDRESS); IERC20(address(MAINNET_SWELL)).approve(address(swEthHandler), type(uint256).max); diff --git a/test/fork/concrete/lst/WstEthHandler.t.sol b/test/fork/concrete/lst/WstEthHandler.t.sol index b2bde8d3..e349b7f7 100644 --- a/test/fork/concrete/lst/WstEthHandler.t.sol +++ b/test/fork/concrete/lst/WstEthHandler.t.sol @@ -7,6 +7,7 @@ import { WadRayMath, RAY } from "../../../../src/libraries/math/WadRayMath.sol"; import { LidoLibrary } from "../../../../src/libraries/lst/LidoLibrary.sol"; import { Whitelist } from "../../../../src/Whitelist.sol"; import { IonHandlerBase } from "../../../../src/flash/IonHandlerBase.sol"; +import { WETH_ADDRESS } from "../../../../src/Constants.sol"; import { BalancerFlashloanDirectMintHandler_Test } from "../handlers-base/BalancerFlashloanDirectMintHandler.t.sol"; import { UniswapFlashswapHandler_Test } from "../handlers-base/UniswapFlashswapHandler.t.sol"; @@ -43,7 +44,9 @@ abstract contract WstEthHandler_ForkBase is LstHandler_ForkBase { function setUp() public virtual override { super.setUp(); - wstEthHandler = new WstEthHandler(ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL); + wstEthHandler = new WstEthHandler( + ilkIndex, ionPool, gemJoins[ilkIndex], Whitelist(whitelist), WSTETH_WETH_POOL, WETH_ADDRESS + ); IERC20(address(MAINNET_WSTETH)).approve(address(wstEthHandler), type(uint256).max); diff --git a/test/fork/concrete/pendle/PtWeEthHandler.t.sol b/test/fork/concrete/pendle/PtWeEthHandler.t.sol index 8e23bf0f..7e2a444e 100644 --- a/test/fork/concrete/pendle/PtWeEthHandler.t.sol +++ b/test/fork/concrete/pendle/PtWeEthHandler.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.21; -import { WEETH_ADDRESS, PT_WEETH_POOL } from "../../../../src/Constants.sol"; +import { WEETH_ADDRESS, PT_WEETH_POOL, WETH_ADDRESS } from "../../../../src/Constants.sol"; import { PtHandler } from "../../../../src/flash/PtHandler.sol"; import { Whitelist } from "../../../../src/Whitelist.sol"; import { IWeEth } from "../../../../src/interfaces/ProviderInterfaces.sol"; @@ -28,7 +28,8 @@ abstract contract PtWeEthHandler_ForkBase is PtHandler_ForkBase { pool: ionPool, join: gemJoins[ilkIndex], whitelist: Whitelist(whitelist), - _market: PT_WEETH_POOL + _market: PT_WEETH_POOL, + _weth: WETH_ADDRESS }); IERC20 _pt = ptHandler.PT();