From 8ba7c39eb64dab96965d0662e2534601580f5695 Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Thu, 26 Sep 2024 17:50:31 -0500 Subject: [PATCH 1/9] add tests for staked usds --- test/instances/aave/AaveHyperdrive.t.sol | 1 + test/instances/chainlink/CbETHBase.t.sol | 1 + .../chainlink/WstETHGnosisChain.t.sol | 1 + test/instances/corn/CornHyperdrive.t.sol | 1 + test/instances/corn/Corn_LBTC_Hyperdrive.sol | 1 + .../instances/corn/Corn_sDAI_Hyperdrive.t.sol | 1 + test/instances/eeth/EETHHyperdrive.t.sol | 1 + test/instances/erc4626/SUSDe.t.sol | 1 + test/instances/erc4626/StUSD.t.sol | 1 + test/instances/erc4626/sUSDS.t.sol | 145 ++++++++++++++++++ test/instances/erc4626/sxDai.t.sol | 1 + test/instances/ezETH/EzETHHyperdrive.t.sol | 1 + .../ezeth-linea/EzETHLineaTest.t.sol | 1 + test/instances/lseth/LsETHHyperdrive.t.sol | 1 + .../MorphoBlue_USDe_DAI_Hyperdrive.t.sol | 1 + ...orphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol | 1 + .../MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol | 1 + .../MorphoBlue_wstETH_USDA_Hyperdrive.t.sol | 1 + .../MorphoBlue_wstETH_USDC_Hyperdrive.t.sol | 1 + test/instances/reth/RETHHyperdrive.t.sol | 1 + .../rseth-linea/RsETHLineaHyperdrive.t.sol | 1 + test/instances/steth/StETHHyperdrive.t.sol | 1 + test/utils/InstanceTest.sol | 15 +- 23 files changed, 175 insertions(+), 6 deletions(-) create mode 100644 test/instances/erc4626/sUSDS.t.sol diff --git a/test/instances/aave/AaveHyperdrive.t.sol b/test/instances/aave/AaveHyperdrive.t.sol index 793ebe855..fff57af70 100644 --- a/test/instances/aave/AaveHyperdrive.t.sol +++ b/test/instances/aave/AaveHyperdrive.t.sol @@ -84,6 +84,7 @@ contract AaveHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e5, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/chainlink/CbETHBase.t.sol b/test/instances/chainlink/CbETHBase.t.sol index d35f36e15..6f961414d 100644 --- a/test/instances/chainlink/CbETHBase.t.sol +++ b/test/instances/chainlink/CbETHBase.t.sol @@ -67,6 +67,7 @@ contract CbETHBaseTest is ChainlinkHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e3, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e4, diff --git a/test/instances/chainlink/WstETHGnosisChain.t.sol b/test/instances/chainlink/WstETHGnosisChain.t.sol index 4352f002c..f25f16452 100644 --- a/test/instances/chainlink/WstETHGnosisChain.t.sol +++ b/test/instances/chainlink/WstETHGnosisChain.t.sol @@ -68,6 +68,7 @@ contract WstETHGnosisChainTest is ChainlinkHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e3, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/corn/CornHyperdrive.t.sol b/test/instances/corn/CornHyperdrive.t.sol index 1b4249279..e64b9de31 100644 --- a/test/instances/corn/CornHyperdrive.t.sol +++ b/test/instances/corn/CornHyperdrive.t.sol @@ -87,6 +87,7 @@ contract CornHyperdriveInstanceTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/corn/Corn_LBTC_Hyperdrive.sol b/test/instances/corn/Corn_LBTC_Hyperdrive.sol index f0cc951bd..8b74ce846 100644 --- a/test/instances/corn/Corn_LBTC_Hyperdrive.sol +++ b/test/instances/corn/Corn_LBTC_Hyperdrive.sol @@ -71,6 +71,7 @@ contract Corn_LBTC_Hyperdrive is CornHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol b/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol index 890f90269..6bac696a1 100644 --- a/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol +++ b/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol @@ -71,6 +71,7 @@ contract Corn_sDAI_Hyperdrive is CornHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/eeth/EETHHyperdrive.t.sol b/test/instances/eeth/EETHHyperdrive.t.sol index 972a0deec..e4d8aaee7 100644 --- a/test/instances/eeth/EETHHyperdrive.t.sol +++ b/test/instances/eeth/EETHHyperdrive.t.sol @@ -93,6 +93,7 @@ contract EETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e5, roundTripLpWithdrawalSharesWithSharesTolerance: 1e5, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/SUSDe.t.sol b/test/instances/erc4626/SUSDe.t.sol index b0a5afd88..84b90f75a 100644 --- a/test/instances/erc4626/SUSDe.t.sol +++ b/test/instances/erc4626/SUSDe.t.sol @@ -84,6 +84,7 @@ contract SUSDeHyperdriveTest is ERC4626HyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e8, roundTripLpWithdrawalSharesWithSharesTolerance: 1e8, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/StUSD.t.sol b/test/instances/erc4626/StUSD.t.sol index 22320b74b..c26e43db8 100644 --- a/test/instances/erc4626/StUSD.t.sol +++ b/test/instances/erc4626/StUSD.t.sol @@ -81,6 +81,7 @@ contract stUSDHyperdriveTest is ERC4626HyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e7, roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/sUSDS.t.sol b/test/instances/erc4626/sUSDS.t.sol new file mode 100644 index 000000000..d6f282038 --- /dev/null +++ b/test/instances/erc4626/sUSDS.t.sol @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity 0.8.22; + +import { stdStorage, StdStorage } from "forge-std/Test.sol"; +import { IERC20 } from "../../../contracts/src/interfaces/IERC20.sol"; +import { IERC4626 } from "../../../contracts/src/interfaces/IERC4626.sol"; +import { IHyperdrive } from "../../../contracts/src/interfaces/IHyperdrive.sol"; +import { HyperdriveUtils } from "../../utils/HyperdriveUtils.sol"; +import { InstanceTest } from "../../utils/InstanceTest.sol"; +import { Lib } from "../../utils/Lib.sol"; +import { ERC4626HyperdriveInstanceTest } from "./ERC4626HyperdriveInstanceTest.t.sol"; + +import "forge-std/console2.sol"; + +interface ISUSDS { + function chi() external view returns (uint256); + function rho() external view returns (uint256); + function drip() external returns (uint256); +} + +contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { + using HyperdriveUtils for uint256; + using HyperdriveUtils for IHyperdrive; + using Lib for *; + using stdStorage for StdStorage; + + /// @dev The USDS contract. + IERC20 internal constant USDS = + IERC20(0xdC035D45d973E3EC169d2276DDab16f1e407384F); + + /// @dev The sUSDS contract. + IERC4626 internal constant SUSDS = + IERC4626(0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD); + + /// @dev Whale accounts. + address internal USDS_TOKEN_WHALE = + address(0x0650CAF159C5A49f711e8169D4336ECB9b950275); + address[] internal baseTokenWhaleAccounts = [USDS_TOKEN_WHALE]; + address internal SUSDS_TOKEN_WHALE = + address(0x2674341D40b445c21287b81c4Bc95EC8E358f7E8); + address[] internal vaultSharesTokenWhaleAccounts = [SUSDS_TOKEN_WHALE]; + + /// @notice Instantiates the instance testing suite with the configuration. + constructor() + InstanceTest( + InstanceTestConfig({ + name: "Hyperdrive", + kind: "ERC4626Hyperdrive", + decimals: 18, + baseTokenWhaleAccounts: baseTokenWhaleAccounts, + vaultSharesTokenWhaleAccounts: vaultSharesTokenWhaleAccounts, + baseToken: USDS, + vaultSharesToken: SUSDS, + shareTolerance: 1e3, + minimumShareReserves: 1e15, + minimumTransactionAmount: 1e15, + positionDuration: POSITION_DURATION, + fees: IHyperdrive.Fees({ + curve: 0, + flat: 0, + governanceLP: 0, + governanceZombie: 0 + }), + enableBaseDeposits: true, + enableShareDeposits: true, + enableBaseWithdraws: true, + enableShareWithdraws: true, + baseWithdrawError: new bytes(0), + isRebasing: false, + shouldAccrueInterest: true, + // The base test tolerances. + roundTripLpInstantaneousWithBaseTolerance: 1e8, + roundTripLpWithdrawalSharesWithBaseTolerance: 1e8, + roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, + roundTripLongInstantaneousWithBaseTolerance: 1e8, + roundTripLongMaturityWithBaseUpperBoundTolerance: 1e3, + roundTripLongMaturityWithBaseTolerance: 1e5, + roundTripShortInstantaneousWithBaseUpperBoundTolerance: 1e3, + roundTripShortInstantaneousWithBaseTolerance: 1e5, + roundTripShortMaturityWithBaseTolerance: 1e5, + // The share test tolerances. + closeLongWithSharesTolerance: 1e3, + closeLongWithBaseTolerance: 1e3, + closeShortWithSharesTolerance: 100, + roundTripLpInstantaneousWithSharesTolerance: 1e7, + roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, + roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, + roundTripLongInstantaneousWithSharesTolerance: 1e5, + roundTripLongMaturityWithSharesUpperBoundTolerance: 1e3, + roundTripLongMaturityWithSharesTolerance: 1e17, + roundTripShortInstantaneousWithSharesUpperBoundTolerance: 1e3, + roundTripShortInstantaneousWithSharesTolerance: 1e5, + roundTripShortMaturityWithSharesTolerance: 1e17, + // The verification tolerances. + verifyDepositTolerance: 5, + verifyWithdrawalTolerance: 2 + }) + ) + {} + + /// @notice Forge function that is invoked to setup the testing environment. + function setUp() public override __mainnet_fork(20_836_852) { + // Invoke the Instance testing suite setup. + super.setUp(); + } + + /// Helpers /// + + /// @dev Advance time and accrue interest. + /// @param timeDelta The time to advance. + /// @param variableRate The variable rate. + function advanceTime( + uint256 timeDelta, + int256 variableRate + ) internal override { + uint256 chi = ISUSDS(address(SUSDS)).chi(); + // Accrue interest in the sUSDS market. This amounts to manually + // updating the total supply assets. + (chi, ) = chi.calculateInterest( + variableRate, + timeDelta + ); + // Advance the time. + vm.warp(block.timestamp + timeDelta); + console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); + console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); + vm.store(address(SUSDS), bytes32(uint256(5)), bytes32((uint256(block.timestamp)<<192)|chi)); + console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); + console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); + + console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); + console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); + + // vm.warp(block.timestamp + timeDelta); + + // Interest accumulates in the dsr based on time passed. + // This may caused insolvency if too much interest accrues as no real dai is being + // accrued. + // console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); + // console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); + // ISUSDS(address(SUSDS)).drip(); + // console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); + // console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); + } +} diff --git a/test/instances/erc4626/sxDai.t.sol b/test/instances/erc4626/sxDai.t.sol index 33a025eba..e2fbd1595 100644 --- a/test/instances/erc4626/sxDai.t.sol +++ b/test/instances/erc4626/sxDai.t.sol @@ -73,6 +73,7 @@ contract sxDaiHyperdriveTest is ERC4626HyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e7, roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/ezETH/EzETHHyperdrive.t.sol b/test/instances/ezETH/EzETHHyperdrive.t.sol index ddec13e54..0fc62bc9c 100644 --- a/test/instances/ezETH/EzETHHyperdrive.t.sol +++ b/test/instances/ezETH/EzETHHyperdrive.t.sol @@ -103,6 +103,7 @@ contract EzETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 1e6, closeShortWithSharesTolerance: 1e6, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e7, roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/ezeth-linea/EzETHLineaTest.t.sol b/test/instances/ezeth-linea/EzETHLineaTest.t.sol index 665f3294f..32c134597 100644 --- a/test/instances/ezeth-linea/EzETHLineaTest.t.sol +++ b/test/instances/ezeth-linea/EzETHLineaTest.t.sol @@ -90,6 +90,7 @@ contract EzETHLineaHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 100, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/lseth/LsETHHyperdrive.t.sol b/test/instances/lseth/LsETHHyperdrive.t.sol index 63b46eedb..089b1a844 100644 --- a/test/instances/lseth/LsETHHyperdrive.t.sol +++ b/test/instances/lseth/LsETHHyperdrive.t.sol @@ -91,6 +91,7 @@ contract LsETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e3, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol index 09dd5fe80..ab216c5b0 100644 --- a/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol @@ -76,6 +76,7 @@ contract MorphoBlue_USDe_DAI_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol index cfae4c3ad..0e025bca0 100644 --- a/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol @@ -79,6 +79,7 @@ contract MorphoBlue_cbETH_USDC_Base_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol index 097035d98..8effef3b4 100644 --- a/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol @@ -76,6 +76,7 @@ contract MorphoBlue_sUSDe_DAI_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol index 733c46c39..c943a9492 100644 --- a/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol @@ -76,6 +76,7 @@ contract MorphoBlue_wstETH_USDA_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol index 93c3a3d36..b4db16403 100644 --- a/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol @@ -79,6 +79,7 @@ contract MorphoBlue_wstETH_USDC_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, + closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/reth/RETHHyperdrive.t.sol b/test/instances/reth/RETHHyperdrive.t.sol index 0588597f9..6a51ac406 100644 --- a/test/instances/reth/RETHHyperdrive.t.sol +++ b/test/instances/reth/RETHHyperdrive.t.sol @@ -86,6 +86,7 @@ contract RETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 2e3, roundTripLpWithdrawalSharesWithSharesTolerance: 2e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol b/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol index 31bd22b80..be244471d 100644 --- a/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol +++ b/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol @@ -85,6 +85,7 @@ contract RsETHLineaHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 100, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 100, roundTripLpWithdrawalSharesWithSharesTolerance: 1e4, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/steth/StETHHyperdrive.t.sol b/test/instances/steth/StETHHyperdrive.t.sol index 3045d0159..7517a0202 100644 --- a/test/instances/steth/StETHHyperdrive.t.sol +++ b/test/instances/steth/StETHHyperdrive.t.sol @@ -87,6 +87,7 @@ contract StETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e5, roundTripLpWithdrawalSharesWithSharesTolerance: 1e5, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/utils/InstanceTest.sol b/test/utils/InstanceTest.sol index fd5765c67..a6e9ff3d0 100644 --- a/test/utils/InstanceTest.sol +++ b/test/utils/InstanceTest.sol @@ -82,6 +82,9 @@ abstract contract InstanceTest is HyperdriveTest { /// @dev The equality tolerance in wei for the close long with shares /// test. uint256 closeLongWithSharesTolerance; + /// @dev The equality tolerance in wei for the close long with base + /// test. + uint256 closeLongWithBaseTolerance; /// @dev The equality tolerance in wei for the close short with shares /// test. uint256 closeShortWithSharesTolerance; @@ -555,7 +558,7 @@ abstract contract InstanceTest is HyperdriveTest { // Ensure that the total supply increased by the base paid. (uint256 totalBase, uint256 totalShares) = getSupply(); - assertApproxEqAbs(totalBase, totalBaseBefore + amountPaid, 1); + assertApproxEqAbs(totalBase, totalBaseBefore + amountPaid, config.verifyDepositTolerance); assertApproxEqAbs( totalShares, totalSharesBefore + hyperdrive.convertToShares(amountPaid), @@ -621,7 +624,7 @@ abstract contract InstanceTest is HyperdriveTest { // Ensure that the total supply and scaled total supply stay the same. (uint256 totalBase, uint256 totalShares) = getSupply(); assertEq(totalBase, totalBaseBefore); - assertApproxEqAbs(totalShares, totalSharesBefore, 1); + assertApproxEqAbs(totalShares, totalSharesBefore, config.verifyDepositTolerance); // Ensure that the ETH balances didn't change. assertEq( @@ -740,7 +743,7 @@ abstract contract InstanceTest is HyperdriveTest { assertApproxEqAbs( traderSharesAfter, traderBalancesBefore.sharesBalance, - 1 + config.verifyWithdrawalTolerance ); } else { // If vault share withdrawals aren't supported, we revert since this @@ -773,12 +776,12 @@ abstract contract InstanceTest is HyperdriveTest { assertApproxEqAbs( hyperdriveBaseAfter, hyperdriveBalancesBefore.baseBalance, - 1 + config.verifyWithdrawalTolerance ); assertApproxEqAbs( traderBaseAfter, traderBalancesBefore.baseBalance, - 1 + config.verifyWithdrawalTolerance ); // Ensure that the shares balances were updated correctly. @@ -1822,7 +1825,7 @@ abstract contract InstanceTest is HyperdriveTest { assertApproxEqAbs( baseProceeds, longAmount.mulDown(ONE - hyperdrive.getPoolConfig().fees.flat), - 10 + config.closeLongWithBaseTolerance ); // Ensure the withdrawal accounting is correct. From 384c0fd2f031bb532085de09dbc675c59f60f95b Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Thu, 26 Sep 2024 17:57:45 -0500 Subject: [PATCH 2/9] remove console logs --- test/instances/erc4626/sUSDS.t.sol | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/test/instances/erc4626/sUSDS.t.sol b/test/instances/erc4626/sUSDS.t.sol index d6f282038..041cdfd72 100644 --- a/test/instances/erc4626/sUSDS.t.sol +++ b/test/instances/erc4626/sUSDS.t.sol @@ -10,8 +10,6 @@ import { InstanceTest } from "../../utils/InstanceTest.sol"; import { Lib } from "../../utils/Lib.sol"; import { ERC4626HyperdriveInstanceTest } from "./ERC4626HyperdriveInstanceTest.t.sol"; -import "forge-std/console2.sol"; - interface ISUSDS { function chi() external view returns (uint256); function rho() external view returns (uint256); @@ -122,24 +120,8 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { ); // Advance the time. vm.warp(block.timestamp + timeDelta); - console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); - console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); + + // Update the sUSDS market state. vm.store(address(SUSDS), bytes32(uint256(5)), bytes32((uint256(block.timestamp)<<192)|chi)); - console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); - console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); - - console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); - console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); - - // vm.warp(block.timestamp + timeDelta); - - // Interest accumulates in the dsr based on time passed. - // This may caused insolvency if too much interest accrues as no real dai is being - // accrued. - // console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); - // console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); - // ISUSDS(address(SUSDS)).drip(); - // console2.log("rho", ISUSDS(address(SUSDS)).rho().toString(18)); - // console2.log("chi", ISUSDS(address(SUSDS)).chi().toString(18)); } } From 6a6c5cd6c943942d936467af3f1af63f5ef8fcb1 Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Thu, 26 Sep 2024 17:59:14 -0500 Subject: [PATCH 3/9] appease nitler --- test/instances/erc4626/sUSDS.t.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/instances/erc4626/sUSDS.t.sol b/test/instances/erc4626/sUSDS.t.sol index 041cdfd72..faf896e8e 100644 --- a/test/instances/erc4626/sUSDS.t.sol +++ b/test/instances/erc4626/sUSDS.t.sol @@ -112,15 +112,17 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { int256 variableRate ) internal override { uint256 chi = ISUSDS(address(SUSDS)).chi(); + // Accrue interest in the sUSDS market. This amounts to manually // updating the total supply assets. (chi, ) = chi.calculateInterest( variableRate, timeDelta ); + // Advance the time. vm.warp(block.timestamp + timeDelta); - + // Update the sUSDS market state. vm.store(address(SUSDS), bytes32(uint256(5)), bytes32((uint256(block.timestamp)<<192)|chi)); } From abb871e5490e18dd3a51d27899b74888f19ea191 Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Thu, 26 Sep 2024 18:00:40 -0500 Subject: [PATCH 4/9] prettier --- test/instances/erc4626/sUSDS.t.sol | 13 +++++++------ test/utils/InstanceTest.sol | 12 ++++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/instances/erc4626/sUSDS.t.sol b/test/instances/erc4626/sUSDS.t.sol index faf896e8e..49787d4b8 100644 --- a/test/instances/erc4626/sUSDS.t.sol +++ b/test/instances/erc4626/sUSDS.t.sol @@ -115,15 +115,16 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { // Accrue interest in the sUSDS market. This amounts to manually // updating the total supply assets. - (chi, ) = chi.calculateInterest( - variableRate, - timeDelta - ); - + (chi, ) = chi.calculateInterest(variableRate, timeDelta); + // Advance the time. vm.warp(block.timestamp + timeDelta); // Update the sUSDS market state. - vm.store(address(SUSDS), bytes32(uint256(5)), bytes32((uint256(block.timestamp)<<192)|chi)); + vm.store( + address(SUSDS), + bytes32(uint256(5)), + bytes32((uint256(block.timestamp) << 192) | chi) + ); } } diff --git a/test/utils/InstanceTest.sol b/test/utils/InstanceTest.sol index a6e9ff3d0..3aff91b93 100644 --- a/test/utils/InstanceTest.sol +++ b/test/utils/InstanceTest.sol @@ -558,7 +558,11 @@ abstract contract InstanceTest is HyperdriveTest { // Ensure that the total supply increased by the base paid. (uint256 totalBase, uint256 totalShares) = getSupply(); - assertApproxEqAbs(totalBase, totalBaseBefore + amountPaid, config.verifyDepositTolerance); + assertApproxEqAbs( + totalBase, + totalBaseBefore + amountPaid, + config.verifyDepositTolerance + ); assertApproxEqAbs( totalShares, totalSharesBefore + hyperdrive.convertToShares(amountPaid), @@ -624,7 +628,11 @@ abstract contract InstanceTest is HyperdriveTest { // Ensure that the total supply and scaled total supply stay the same. (uint256 totalBase, uint256 totalShares) = getSupply(); assertEq(totalBase, totalBaseBefore); - assertApproxEqAbs(totalShares, totalSharesBefore, config.verifyDepositTolerance); + assertApproxEqAbs( + totalShares, + totalSharesBefore, + config.verifyDepositTolerance + ); // Ensure that the ETH balances didn't change. assertEq( From b4e8c914b4d4faf97853b097e29cfa190d9b5b7c Mon Sep 17 00:00:00 2001 From: Alex Towle Date: Thu, 26 Sep 2024 18:43:09 -0500 Subject: [PATCH 5/9] Fixed a small discrepancy between `advanceTime` and the actual variable rate --- test/instances/erc4626/sUSDS.t.sol | 69 +++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/test/instances/erc4626/sUSDS.t.sol b/test/instances/erc4626/sUSDS.t.sol index 49787d4b8..5f51828fd 100644 --- a/test/instances/erc4626/sUSDS.t.sol +++ b/test/instances/erc4626/sUSDS.t.sol @@ -12,7 +12,11 @@ import { ERC4626HyperdriveInstanceTest } from "./ERC4626HyperdriveInstanceTest.t interface ISUSDS { function chi() external view returns (uint256); + function rho() external view returns (uint256); + + function ssr() external view returns (uint256); + function drip() external returns (uint256); } @@ -22,6 +26,9 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { using Lib for *; using stdStorage for StdStorage; + /// @dev The RAY constant from sUSDS. + uint256 internal constant RAY = 1e27; + /// @dev The USDS contract. IERC20 internal constant USDS = IERC20(0xdC035D45d973E3EC169d2276DDab16f1e407384F); @@ -85,10 +92,10 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, roundTripLongInstantaneousWithSharesTolerance: 1e5, roundTripLongMaturityWithSharesUpperBoundTolerance: 1e3, - roundTripLongMaturityWithSharesTolerance: 1e17, + roundTripLongMaturityWithSharesTolerance: 1e5, roundTripShortInstantaneousWithSharesUpperBoundTolerance: 1e3, roundTripShortInstantaneousWithSharesTolerance: 1e5, - roundTripShortMaturityWithSharesTolerance: 1e17, + roundTripShortMaturityWithSharesTolerance: 1e5, // The verification tolerances. verifyDepositTolerance: 5, verifyWithdrawalTolerance: 2 @@ -112,6 +119,9 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { int256 variableRate ) internal override { uint256 chi = ISUSDS(address(SUSDS)).chi(); + uint256 rho = ISUSDS(address(SUSDS)).rho(); + uint256 ssr = ISUSDS(address(SUSDS)).ssr(); + chi = (_rpow(ssr, block.timestamp - rho) * chi) / RAY; // Accrue interest in the sUSDS market. This amounts to manually // updating the total supply assets. @@ -127,4 +137,59 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { bytes32((uint256(block.timestamp) << 192) | chi) ); } + + /// @dev The ray pow method from sUSDS. + /// @param x The base of the exponentiation. + /// @param n The exponent of the exponentiation. + /// @param z The result of the exponentiation. + function _rpow(uint256 x, uint256 n) internal pure returns (uint256 z) { + assembly { + switch x + case 0 { + switch n + case 0 { + z := RAY + } + default { + z := 0 + } + } + default { + switch mod(n, 2) + case 0 { + z := RAY + } + default { + z := x + } + let half := div(RAY, 2) // for rounding. + for { + n := div(n, 2) + } n { + n := div(n, 2) + } { + let xx := mul(x, x) + if iszero(eq(div(xx, x), x)) { + revert(0, 0) + } + let xxRound := add(xx, half) + if lt(xxRound, xx) { + revert(0, 0) + } + x := div(xxRound, RAY) + if mod(n, 2) { + let zx := mul(z, x) + if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { + revert(0, 0) + } + let zxRound := add(zx, half) + if lt(zxRound, zx) { + revert(0, 0) + } + z := div(zxRound, RAY) + } + } + } + } + } } From 41746eb37076ef080dd54873482670e40ecf787c Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Fri, 27 Sep 2024 09:24:17 -0500 Subject: [PATCH 6/9] fix CI error --- test/instances/aave/AaveHyperdrive.t.sol | 2 +- test/instances/chainlink/CbETHBase.t.sol | 2 +- test/instances/chainlink/WstETHGnosisChain.t.sol | 2 +- test/instances/corn/Corn_LBTC_Hyperdrive.sol | 2 +- test/instances/corn/Corn_sDAI_Hyperdrive.t.sol | 2 +- test/instances/eeth/EETHHyperdrive.t.sol | 2 +- test/instances/erc4626/SUSDe.t.sol | 2 +- test/instances/erc4626/StUSD.t.sol | 2 +- test/instances/erc4626/sUSDS.t.sol | 2 +- test/instances/erc4626/sxDai.t.sol | 2 +- test/instances/ezETH/EzETHHyperdrive.t.sol | 2 +- test/instances/ezeth-linea/EzETHLineaTest.t.sol | 2 +- test/instances/lseth/LsETHHyperdrive.t.sol | 2 +- test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol | 2 +- .../morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol | 2 +- .../instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol | 2 +- .../morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol | 2 +- .../morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol | 2 +- test/instances/reth/RETHHyperdrive.t.sol | 2 +- test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol | 2 +- test/instances/steth/StETHHyperdrive.t.sol | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/instances/aave/AaveHyperdrive.t.sol b/test/instances/aave/AaveHyperdrive.t.sol index fff57af70..eceb8f36a 100644 --- a/test/instances/aave/AaveHyperdrive.t.sol +++ b/test/instances/aave/AaveHyperdrive.t.sol @@ -72,6 +72,7 @@ contract AaveHyperdriveTest is InstanceTest { isRebasing: true, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -84,7 +85,6 @@ contract AaveHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e5, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/chainlink/CbETHBase.t.sol b/test/instances/chainlink/CbETHBase.t.sol index 6f961414d..05ea1af06 100644 --- a/test/instances/chainlink/CbETHBase.t.sol +++ b/test/instances/chainlink/CbETHBase.t.sol @@ -55,6 +55,7 @@ contract CbETHBaseTest is ChainlinkHyperdriveInstanceTest { // tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -67,7 +68,6 @@ contract CbETHBaseTest is ChainlinkHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e3, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e4, diff --git a/test/instances/chainlink/WstETHGnosisChain.t.sol b/test/instances/chainlink/WstETHGnosisChain.t.sol index f25f16452..1fec834d7 100644 --- a/test/instances/chainlink/WstETHGnosisChain.t.sol +++ b/test/instances/chainlink/WstETHGnosisChain.t.sol @@ -56,6 +56,7 @@ contract WstETHGnosisChainTest is ChainlinkHyperdriveInstanceTest { // tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -68,7 +69,6 @@ contract WstETHGnosisChainTest is ChainlinkHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e3, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/corn/Corn_LBTC_Hyperdrive.sol b/test/instances/corn/Corn_LBTC_Hyperdrive.sol index 8b74ce846..7b4903d5e 100644 --- a/test/instances/corn/Corn_LBTC_Hyperdrive.sol +++ b/test/instances/corn/Corn_LBTC_Hyperdrive.sol @@ -54,6 +54,7 @@ contract Corn_LBTC_Hyperdrive is CornHyperdriveInstanceTest { isRebasing: false, shouldAccrueInterest: false, // The base test tolerances. + closeLongWithBaseTolerance: 2, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, @@ -71,7 +72,6 @@ contract Corn_LBTC_Hyperdrive is CornHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, - closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol b/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol index 6bac696a1..d9109a3a2 100644 --- a/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol +++ b/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol @@ -54,6 +54,7 @@ contract Corn_sDAI_Hyperdrive is CornHyperdriveInstanceTest { isRebasing: false, shouldAccrueInterest: false, // The base test tolerances. + closeLongWithBaseTolerance: 2, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e7, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -71,7 +72,6 @@ contract Corn_sDAI_Hyperdrive is CornHyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, - closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/eeth/EETHHyperdrive.t.sol b/test/instances/eeth/EETHHyperdrive.t.sol index e4d8aaee7..c962825c4 100644 --- a/test/instances/eeth/EETHHyperdrive.t.sol +++ b/test/instances/eeth/EETHHyperdrive.t.sol @@ -81,6 +81,7 @@ contract EETHHyperdriveTest is InstanceTest { // NOTE: Base withdrawals are disabled, so the tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -93,7 +94,6 @@ contract EETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e5, roundTripLpWithdrawalSharesWithSharesTolerance: 1e5, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/SUSDe.t.sol b/test/instances/erc4626/SUSDe.t.sol index 84b90f75a..023def884 100644 --- a/test/instances/erc4626/SUSDe.t.sol +++ b/test/instances/erc4626/SUSDe.t.sol @@ -72,6 +72,7 @@ contract SUSDeHyperdriveTest is ERC4626HyperdriveInstanceTest { // NOTE: Base withdrawals are disabled, so the tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -84,7 +85,6 @@ contract SUSDeHyperdriveTest is ERC4626HyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e8, roundTripLpWithdrawalSharesWithSharesTolerance: 1e8, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/StUSD.t.sol b/test/instances/erc4626/StUSD.t.sol index c26e43db8..da3dc89a0 100644 --- a/test/instances/erc4626/StUSD.t.sol +++ b/test/instances/erc4626/StUSD.t.sol @@ -69,6 +69,7 @@ contract stUSDHyperdriveTest is ERC4626HyperdriveInstanceTest { isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e6, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -81,7 +82,6 @@ contract stUSDHyperdriveTest is ERC4626HyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e7, roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/sUSDS.t.sol b/test/instances/erc4626/sUSDS.t.sol index 5f51828fd..27158be6e 100644 --- a/test/instances/erc4626/sUSDS.t.sol +++ b/test/instances/erc4626/sUSDS.t.sol @@ -74,6 +74,7 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 1e3, roundTripLpInstantaneousWithBaseTolerance: 1e8, roundTripLpWithdrawalSharesWithBaseTolerance: 1e8, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -85,7 +86,6 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { roundTripShortMaturityWithBaseTolerance: 1e5, // The share test tolerances. closeLongWithSharesTolerance: 1e3, - closeLongWithBaseTolerance: 1e3, closeShortWithSharesTolerance: 100, roundTripLpInstantaneousWithSharesTolerance: 1e7, roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, diff --git a/test/instances/erc4626/sxDai.t.sol b/test/instances/erc4626/sxDai.t.sol index e2fbd1595..1ce019ead 100644 --- a/test/instances/erc4626/sxDai.t.sol +++ b/test/instances/erc4626/sxDai.t.sol @@ -61,6 +61,7 @@ contract sxDaiHyperdriveTest is ERC4626HyperdriveInstanceTest { isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -73,7 +74,6 @@ contract sxDaiHyperdriveTest is ERC4626HyperdriveInstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e7, roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/ezETH/EzETHHyperdrive.t.sol b/test/instances/ezETH/EzETHHyperdrive.t.sol index 0fc62bc9c..f4ab64124 100644 --- a/test/instances/ezETH/EzETHHyperdrive.t.sol +++ b/test/instances/ezETH/EzETHHyperdrive.t.sol @@ -91,6 +91,7 @@ contract EzETHHyperdriveTest is InstanceTest { // NOTE: Base withdrawals are disabled, so the tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -103,7 +104,6 @@ contract EzETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 1e6, closeShortWithSharesTolerance: 1e6, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e7, roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/ezeth-linea/EzETHLineaTest.t.sol b/test/instances/ezeth-linea/EzETHLineaTest.t.sol index 32c134597..cb5b51b58 100644 --- a/test/instances/ezeth-linea/EzETHLineaTest.t.sol +++ b/test/instances/ezeth-linea/EzETHLineaTest.t.sol @@ -78,6 +78,7 @@ contract EzETHLineaHyperdriveTest is InstanceTest { // NOTE: Base withdrawals are disabled, so the tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -90,7 +91,6 @@ contract EzETHLineaHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 100, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/lseth/LsETHHyperdrive.t.sol b/test/instances/lseth/LsETHHyperdrive.t.sol index 089b1a844..df8ab49db 100644 --- a/test/instances/lseth/LsETHHyperdrive.t.sol +++ b/test/instances/lseth/LsETHHyperdrive.t.sol @@ -79,6 +79,7 @@ contract LsETHHyperdriveTest is InstanceTest { // NOTE: Base withdrawals are disabled, so the tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -91,7 +92,6 @@ contract LsETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e3, roundTripLpWithdrawalSharesWithSharesTolerance: 1e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol index ab216c5b0..525b7cdd9 100644 --- a/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol @@ -61,6 +61,7 @@ contract MorphoBlue_USDe_DAI_HyperdriveTest is isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 2, roundTripLpInstantaneousWithBaseTolerance: 1e13, roundTripLpWithdrawalSharesWithBaseTolerance: 1e13, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -76,7 +77,6 @@ contract MorphoBlue_USDe_DAI_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, - closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol index 0e025bca0..f13add5c7 100644 --- a/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Base_Hyperdrive.t.sol @@ -62,6 +62,7 @@ contract MorphoBlue_cbETH_USDC_Base_HyperdriveTest is isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 2, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, @@ -79,7 +80,6 @@ contract MorphoBlue_cbETH_USDC_Base_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, - closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol index 8effef3b4..d83598c92 100644 --- a/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol @@ -61,6 +61,7 @@ contract MorphoBlue_sUSDe_DAI_HyperdriveTest is isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 2, roundTripLpInstantaneousWithBaseTolerance: 1e13, roundTripLpWithdrawalSharesWithBaseTolerance: 1e13, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -76,7 +77,6 @@ contract MorphoBlue_sUSDe_DAI_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, - closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol index c943a9492..907401e1d 100644 --- a/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol @@ -61,6 +61,7 @@ contract MorphoBlue_wstETH_USDA_HyperdriveTest is isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 2, roundTripLpInstantaneousWithBaseTolerance: 1e13, roundTripLpWithdrawalSharesWithBaseTolerance: 1e13, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -76,7 +77,6 @@ contract MorphoBlue_wstETH_USDA_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, - closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol index b4db16403..2aae2a926 100644 --- a/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol @@ -62,6 +62,7 @@ contract MorphoBlue_wstETH_USDC_HyperdriveTest is isRebasing: false, shouldAccrueInterest: true, // The base test tolerances. + closeLongWithBaseTolerance: 2, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, @@ -79,7 +80,6 @@ contract MorphoBlue_wstETH_USDC_HyperdriveTest is // The share test tolerances. closeLongWithSharesTolerance: 0, closeShortWithSharesTolerance: 0, - closeLongWithBaseTolerance: 0, roundTripLpInstantaneousWithSharesTolerance: 0, roundTripLpWithdrawalSharesWithSharesTolerance: 0, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 0, diff --git a/test/instances/reth/RETHHyperdrive.t.sol b/test/instances/reth/RETHHyperdrive.t.sol index 6a51ac406..d6d00603a 100644 --- a/test/instances/reth/RETHHyperdrive.t.sol +++ b/test/instances/reth/RETHHyperdrive.t.sol @@ -74,6 +74,7 @@ contract RETHHyperdriveTest is InstanceTest { governanceZombie: 0 }), // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e3, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, @@ -86,7 +87,6 @@ contract RETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 2e3, roundTripLpWithdrawalSharesWithSharesTolerance: 2e3, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol b/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol index be244471d..d63456afa 100644 --- a/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol +++ b/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol @@ -73,6 +73,7 @@ contract RsETHLineaHyperdriveTest is InstanceTest { // NOTE: Base withdrawals are disabled, so the tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -85,7 +86,6 @@ contract RsETHLineaHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 100, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 100, roundTripLpWithdrawalSharesWithSharesTolerance: 1e4, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, diff --git a/test/instances/steth/StETHHyperdrive.t.sol b/test/instances/steth/StETHHyperdrive.t.sol index 7517a0202..a05fd38bd 100644 --- a/test/instances/steth/StETHHyperdrive.t.sol +++ b/test/instances/steth/StETHHyperdrive.t.sol @@ -75,6 +75,7 @@ contract StETHHyperdriveTest is InstanceTest { // NOTE: Base withdrawals are disabled, so the tolerances are zero. // // The base test tolerances. + closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, @@ -87,7 +88,6 @@ contract StETHHyperdriveTest is InstanceTest { // The share test tolerances. closeLongWithSharesTolerance: 20, closeShortWithSharesTolerance: 100, - closeLongWithBaseTolerance: 20, roundTripLpInstantaneousWithSharesTolerance: 1e5, roundTripLpWithdrawalSharesWithSharesTolerance: 1e5, roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, From 0d8cd1cb6f46e4c203b466bef48bebdbc4d46d30 Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Fri, 27 Sep 2024 10:16:38 -0500 Subject: [PATCH 7/9] add deployment script --- tasks/deploy/config/mainnet/susds-182day.ts | 84 +++++++++++++++++++++ tasks/deploy/lib/constants.ts | 12 +++ 2 files changed, 96 insertions(+) create mode 100644 tasks/deploy/config/mainnet/susds-182day.ts diff --git a/tasks/deploy/config/mainnet/susds-182day.ts b/tasks/deploy/config/mainnet/susds-182day.ts new file mode 100644 index 000000000..ccabf09f4 --- /dev/null +++ b/tasks/deploy/config/mainnet/susds-182day.ts @@ -0,0 +1,84 @@ +import { Address, keccak256, parseEther, toBytes, zeroAddress } from "viem"; +import { + HyperdriveInstanceConfig, + getLinkerDetails, + normalizeFee, + parseDuration, + toBytes32, +} from "../../lib"; +import { + USDS_ADDRESS_MAINNET, + SUSDS_ADDRESS_MAINNET, + SIX_MONTHS, +} from "../../lib/constants"; +import { MAINNET_ERC4626_COORDINATOR_NAME } from "./erc4626-coordinator"; +import { MAINNET_FACTORY_NAME } from "./factory"; + +// The name of the pool. +export const MAINNET_SUSDS_182DAY_NAME = "ElementDAO 182 Day sUSDS Hyperdrive"; + +// The initial contribution of the pool. +const CONTRIBUTION = parseEther("100"); + +export const MAINNET_DAI_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { + name: MAINNET_SUSDS_182DAY_NAME, + prefix: "ERC4626", + coordinatorAddress: async (hre) => + hre.hyperdriveDeploy.deployments.byName( + MAINNET_ERC4626_COORDINATOR_NAME, + ).address, + deploymentId: keccak256(toBytes(MAINNET_SUSDS_182DAY_NAME)), + salt: toBytes32("0x69420"), + extraData: "0x", + contribution: CONTRIBUTION, + fixedAPR: parseEther("0.0625"), + timestretchAPR: parseEther("0.05"), + options: async (hre) => ({ + extraData: "0x", + asBase: true, + destination: (await hre.getNamedAccounts())["deployer"] as Address, + }), + // Prepare to deploy the contract by setting approvals. + prepare: async (hre) => { + let baseToken = await hre.viem.getContractAt( + "contracts/src/interfaces/IERC20.sol:IERC20", + DAI_ADDRESS_MAINNET, + ); + let tx = await baseToken.write.approve([ + hre.hyperdriveDeploy.deployments.byName( + MAINNET_ERC4626_COORDINATOR_NAME, + ).address, + CONTRIBUTION, + ]); + let pc = await hre.viem.getPublicClient(); + await pc.waitForTransactionReceipt({ hash: tx }); + }, + poolDeployConfig: async (hre) => { + return { + baseToken: DAI_ADDRESS_MAINNET, + vaultSharesToken: SDAI_ADDRESS_MAINNET, + circuitBreakerDelta: parseEther("0.05"), + minimumShareReserves: parseEther("10"), + minimumTransactionAmount: parseEther("0.001"), + positionDuration: parseDuration(SIX_MONTHS), + checkpointDuration: parseDuration("1 day"), + timeStretch: 0n, + // TODO: Read from the factory. + governance: (await hre.getNamedAccounts())["deployer"] as Address, + feeCollector: zeroAddress, + sweepCollector: zeroAddress, + checkpointRewarder: zeroAddress, + ...(await getLinkerDetails( + hre, + hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME) + .address, + )), + fees: { + curve: parseEther("0.01"), + flat: normalizeFee(parseEther("0.0005"), SIX_MONTHS), + governanceLP: parseEther("0.15"), + governanceZombie: parseEther("0.03"), + }, + }; + }, +}; diff --git a/tasks/deploy/lib/constants.ts b/tasks/deploy/lib/constants.ts index ea20a49fd..3860d4aa9 100644 --- a/tasks/deploy/lib/constants.ts +++ b/tasks/deploy/lib/constants.ts @@ -77,6 +77,9 @@ export const STETH_ADDRESS_MAINNET = export const STUSD_ADDRESS_MAINNET = "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776" as Address; +export const SUSDS_ADDRESS_MAINNET = + "0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD" as Address; + export const RENZO_RESTAKE_MANAGER_ADDRESS_MAINNET = "0x74a09653A083691711cF8215a6ab074BB4e99ef5" as Address; @@ -89,6 +92,9 @@ export const USDC_ADDRESS_MAINNET = export const USDE_ADDRESS_MAINNET = "0x4c9EDD5852cd905f086C759E8383e09bff1E68B3" as Address; +export const USDS_ADDRESS_MAINNET = + "0xdC035D45d973E3EC169d2276DDab16f1e407384F" as Address; + export const WSTETH_ADDRESS_MAINNET = "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0" as Address; @@ -114,6 +120,9 @@ export const SDAI_WHALE_MAINNET = export const STETH_WHALE_MAINNET = "0xd15a672319cf0352560ee76d9e89eab0889046d3" as Address; +export const SUSDS_WHALE_MAINNET = + "0x2674341D40b445c21287b81c4Bc95EC8E358f7E8" as Address; + export const USDA_WHALE_MAINNET = "0xEc0B13b2271E212E1a74D55D51932BD52A002961" as Address; @@ -123,6 +132,9 @@ export const USDC_WHALE_MAINNET = export const USDE_WHALE_MAINNET = "0xf89d7b9c864f589bbf53a82105107622b35eaa40" as Address; +export const USDS_WHALE_MAINNET = + "0x0650CAF159C5A49f711e8169D4336ECB9b950275" as Address; + export const WSTETH_WHALE_MAINNET = "0xc329400492c6ff2438472d4651ad17389fcb843a" as Address; From 99285c8c0896c5007fbdf6fcef6a0b8d2da17528 Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Fri, 27 Sep 2024 11:13:19 -0500 Subject: [PATCH 8/9] changed variable names from DAI --- tasks/deploy/config/mainnet/susds-182day.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/deploy/config/mainnet/susds-182day.ts b/tasks/deploy/config/mainnet/susds-182day.ts index ccabf09f4..c391057f0 100644 --- a/tasks/deploy/config/mainnet/susds-182day.ts +++ b/tasks/deploy/config/mainnet/susds-182day.ts @@ -20,7 +20,7 @@ export const MAINNET_SUSDS_182DAY_NAME = "ElementDAO 182 Day sUSDS Hyperdrive"; // The initial contribution of the pool. const CONTRIBUTION = parseEther("100"); -export const MAINNET_DAI_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { +export const MAINNET_SUSDS_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { name: MAINNET_SUSDS_182DAY_NAME, prefix: "ERC4626", coordinatorAddress: async (hre) => @@ -42,7 +42,7 @@ export const MAINNET_DAI_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { prepare: async (hre) => { let baseToken = await hre.viem.getContractAt( "contracts/src/interfaces/IERC20.sol:IERC20", - DAI_ADDRESS_MAINNET, + USDS_ADDRESS_MAINNET, ); let tx = await baseToken.write.approve([ hre.hyperdriveDeploy.deployments.byName( @@ -55,8 +55,8 @@ export const MAINNET_DAI_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { }, poolDeployConfig: async (hre) => { return { - baseToken: DAI_ADDRESS_MAINNET, - vaultSharesToken: SDAI_ADDRESS_MAINNET, + baseToken: USDS_ADDRESS_MAINNET, + vaultSharesToken: SUSDS_ADDRESS_MAINNET, circuitBreakerDelta: parseEther("0.05"), minimumShareReserves: parseEther("10"), minimumTransactionAmount: parseEther("0.001"), From 8fddcf5ba6aa1c4d6cabfae40666619e9d031040 Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Fri, 27 Sep 2024 11:26:21 -0500 Subject: [PATCH 9/9] prettier --- tasks/deploy/config/mainnet/susds-182day.ts | 4 ++-- tasks/deploy/lib/constants.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/deploy/config/mainnet/susds-182day.ts b/tasks/deploy/config/mainnet/susds-182day.ts index c391057f0..6d8d75a28 100644 --- a/tasks/deploy/config/mainnet/susds-182day.ts +++ b/tasks/deploy/config/mainnet/susds-182day.ts @@ -7,9 +7,9 @@ import { toBytes32, } from "../../lib"; import { - USDS_ADDRESS_MAINNET, - SUSDS_ADDRESS_MAINNET, SIX_MONTHS, + SUSDS_ADDRESS_MAINNET, + USDS_ADDRESS_MAINNET, } from "../../lib/constants"; import { MAINNET_ERC4626_COORDINATOR_NAME } from "./erc4626-coordinator"; import { MAINNET_FACTORY_NAME } from "./factory"; diff --git a/tasks/deploy/lib/constants.ts b/tasks/deploy/lib/constants.ts index 3860d4aa9..cca8f6dcb 100644 --- a/tasks/deploy/lib/constants.ts +++ b/tasks/deploy/lib/constants.ts @@ -121,7 +121,7 @@ export const STETH_WHALE_MAINNET = "0xd15a672319cf0352560ee76d9e89eab0889046d3" as Address; export const SUSDS_WHALE_MAINNET = - "0x2674341D40b445c21287b81c4Bc95EC8E358f7E8" as Address; + "0x2674341D40b445c21287b81c4Bc95EC8E358f7E8" as Address; export const USDA_WHALE_MAINNET = "0xEc0B13b2271E212E1a74D55D51932BD52A002961" as Address; @@ -133,7 +133,7 @@ export const USDE_WHALE_MAINNET = "0xf89d7b9c864f589bbf53a82105107622b35eaa40" as Address; export const USDS_WHALE_MAINNET = - "0x0650CAF159C5A49f711e8169D4336ECB9b950275" as Address; + "0x0650CAF159C5A49f711e8169D4336ECB9b950275" as Address; export const WSTETH_WHALE_MAINNET = "0xc329400492c6ff2438472d4651ad17389fcb843a" as Address;