diff --git a/deployments.json b/deployments.json index a9a63bfed..4d374becb 100644 --- a/deployments.json +++ b/deployments.json @@ -867,41 +867,6 @@ "address": "0x7548c4F665402BAb3a4298B88527824B7b18Fe27", "timestamp": "2024-09-03T20:36:40.438Z" }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626HyperdriveCoreDeployer": { - "contract": "ERC4626HyperdriveCoreDeployer", - "address": "0x1dcac79c73ca892d5872e5d8cb3ff43db0c81289", - "timestamp": "2024-09-03T21:44:28.498Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target0Deployer": { - "contract": "ERC4626Target0Deployer", - "address": "0x9e8af51810042156f4cdae3109523345cc768541", - "timestamp": "2024-09-03T21:44:41.585Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target1Deployer": { - "contract": "ERC4626Target1Deployer", - "address": "0xf19359677a2a0d5e3e43b7cc2bc73bac892d4c04", - "timestamp": "2024-09-03T21:44:50.642Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target2Deployer": { - "contract": "ERC4626Target2Deployer", - "address": "0x218077b6c774abe7f262f9f1fc0b995352a0b6f3", - "timestamp": "2024-09-03T21:45:03.729Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target3Deployer": { - "contract": "ERC4626Target3Deployer", - "address": "0xe275a81e0223688eb7da761169eb121b4ef7c3ef", - "timestamp": "2024-09-03T21:45:16.862Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target4Deployer": { - "contract": "ERC4626Target4Deployer", - "address": "0x0fb70c3de906eddab929b5d288b638adb5238ccb", - "timestamp": "2024-09-03T21:45:29.967Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator": { - "contract": "ERC4626HyperdriveDeployerCoordinator", - "address": "0x50ea16a4050e65748eeb82d94e0c84ac233225df", - "timestamp": "2024-09-03T21:45:39.060Z" - }, "ElementDAO 182 Day stUSD Hyperdrive_ERC4626Target0": { "contract": "ERC4626Target0", "address": "0x686ffbDd397De6B2fff855b1bed53947da673F4f", @@ -991,6 +956,71 @@ "contract": "ERC4626Hyperdrive", "address": "0x05b65FA90AD702e6Fd0C3Bd7c4c9C47BAB2BEa6b", "timestamp": "2024-10-10T00:32:40.530Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626HyperdriveCoreDeployer": { + "contract": "ERC4626HyperdriveCoreDeployer", + "address": "0xa7f4fa98e61cca63130b66699620bd80ccdbe5b7", + "timestamp": "2024-11-03T23:31:16.861Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target0Deployer": { + "contract": "ERC4626Target0Deployer", + "address": "0x56568eb63e1b0dde1adccf60fa370d051bfdf89f", + "timestamp": "2024-11-03T23:31:26.412Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target1Deployer": { + "contract": "ERC4626Target1Deployer", + "address": "0x83cfd1fb412d0b4ab5c4852f3faf990d63cc760a", + "timestamp": "2024-11-03T23:31:40.184Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target2Deployer": { + "contract": "ERC4626Target2Deployer", + "address": "0x3837024d7b9d4a60514bb9f7cb9d9493e29656fd", + "timestamp": "2024-11-03T23:31:53.431Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target3Deployer": { + "contract": "ERC4626Target3Deployer", + "address": "0x01f06f23d684d2beacb4dc9dcb4bd27a3fe624b1", + "timestamp": "2024-11-03T23:32:02.705Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target4Deployer": { + "contract": "ERC4626Target4Deployer", + "address": "0x7b5ce2411fcf3d06e9e60bde66cc8ee869ff13b9", + "timestamp": "2024-11-03T23:32:16.194Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator": { + "contract": "ERC4626HyperdriveDeployerCoordinator", + "address": "0x0ebbb7e85337cf4ed496dd81a300c6c31ba633c9", + "timestamp": "2024-11-03T23:32:25.459Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target0": { + "contract": "ERC4626Target0", + "address": "0x12A860db0b8928da0C0b64b5ce51A524c3a40e13", + "timestamp": "2024-11-03T23:34:03.923Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target1": { + "contract": "ERC4626Target1", + "address": "0x05890fac1b957B48a4f74d6fE74cf76C92389B17", + "timestamp": "2024-11-03T23:33:14.380Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target2": { + "contract": "ERC4626Target2", + "address": "0x72f88Ba5DD6cF894A7367010C54Eddb5E208Ce45", + "timestamp": "2024-11-03T23:33:27.773Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target3": { + "contract": "ERC4626Target3", + "address": "0x9aA89A768E642a9d4Ce0c8d0ebFc2DC051F55289", + "timestamp": "2024-11-03T23:33:41.239Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target4": { + "contract": "ERC4626Target4", + "address": "0xe549BAc862A408294df78c6CA7B89D75e8582147", + "timestamp": "2024-11-03T23:33:50.414Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive": { + "contract": "ERC4626Hyperdrive", + "address": "0xf1232Dc21eADAf503D82f1e1361CfF2BBf40394D", + "timestamp": "2024-11-03T23:34:03.748Z" } }, "gnosis": { @@ -1049,41 +1079,6 @@ "address": "0x0fb305a458b1008faee03147b700b3975bea03fd", "timestamp": "2024-08-29T18:28:07.186Z" }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626HyperdriveCoreDeployer": { - "contract": "ERC4626HyperdriveCoreDeployer", - "address": "0xb2f17302ed12fe72d883fcc2b66f1b844fbb7964", - "timestamp": "2024-08-29T18:28:26.929Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target0Deployer": { - "contract": "ERC4626Target0Deployer", - "address": "0xe441e793f7d6f7b0d633a770554d8924103a30b4", - "timestamp": "2024-08-29T18:28:32.385Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target1Deployer": { - "contract": "ERC4626Target1Deployer", - "address": "0xe8dc5073b02d062388db8e50762a8c9a1c823540", - "timestamp": "2024-08-29T18:28:37.783Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target2Deployer": { - "contract": "ERC4626Target2Deployer", - "address": "0xe0da47a1a6ceb80bb945652cb96a821fa5d91327", - "timestamp": "2024-08-29T18:28:47.370Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target3Deployer": { - "contract": "ERC4626Target3Deployer", - "address": "0x279c0504575639131be082923c21289d553d7c08", - "timestamp": "2024-08-29T18:28:57.080Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target4Deployer": { - "contract": "ERC4626Target4Deployer", - "address": "0xca76fd3033fa9f754c05844773d79c193ad784b5", - "timestamp": "2024-08-29T18:29:02.504Z" - }, - "ElementDAO ERC4626 Hyperdrive Deployer Coordinator": { - "contract": "ERC4626HyperdriveDeployerCoordinator", - "address": "0xb274f4fcc2b391e0dfabfbe7b7c130447018f6ea", - "timestamp": "2024-08-29T18:29:12.102Z" - }, "ElementDAO 182 Day wstETH Hyperdrive_ChainlinkTarget0": { "contract": "ChainlinkTarget0", "address": "0x87f566edE278C328e9A3af3b6958e0F95fE80476", @@ -1143,6 +1138,71 @@ "contract": "ERC4626Hyperdrive", "address": "0xEe9BFf933aDD313C4289E98dA80fEfbF9d5Cd9Ba", "timestamp": "2024-08-29T18:31:32.479Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626HyperdriveCoreDeployer": { + "contract": "ERC4626HyperdriveCoreDeployer", + "address": "0xd917235d89a58af93302e9a998d62735740c8117", + "timestamp": "2024-11-04T15:57:06.432Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target0Deployer": { + "contract": "ERC4626Target0Deployer", + "address": "0x77644b188a5d1d58246a233761273c74b0f9d88d", + "timestamp": "2024-11-04T15:57:15.554Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target1Deployer": { + "contract": "ERC4626Target1Deployer", + "address": "0xbaa863b62c69993143b013fe7b8af278fd52f76b", + "timestamp": "2024-11-04T15:57:24.581Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target2Deployer": { + "contract": "ERC4626Target2Deployer", + "address": "0x68ba944d89d7481f3a9d73dcb75b7e6c7db5562b", + "timestamp": "2024-11-04T15:57:43.579Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target3Deployer": { + "contract": "ERC4626Target3Deployer", + "address": "0xb7c320cef81f0f9abb726590ef5105f551816d76", + "timestamp": "2024-11-04T15:57:52.727Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target4Deployer": { + "contract": "ERC4626Target4Deployer", + "address": "0x8d6d5d48f881bcccd6c09256724692b3a971b87b", + "timestamp": "2024-11-04T15:58:01.648Z" + }, + "ElementDAO ERC4626 Hyperdrive Deployer Coordinator": { + "contract": "ERC4626HyperdriveDeployerCoordinator", + "address": "0xe670f140dedcdf142e15ce198e1a99fecd67d21c", + "timestamp": "2024-11-04T15:58:06.455Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target0": { + "contract": "ERC4626Target0", + "address": "0xd35e6bFF0d1c3FE78F9d45b184BdbC9Fc7d5e455", + "timestamp": "2024-11-04T15:58:56.172Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target1": { + "contract": "ERC4626Target1", + "address": "0xAbC4622d505891648Ffa2bB649994F59f4B10f98", + "timestamp": "2024-11-04T15:58:36.874Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target2": { + "contract": "ERC4626Target2", + "address": "0x0da0ab9296f45CbD694875A6fDf8E14C16b79ce1", + "timestamp": "2024-11-04T15:58:41.717Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target3": { + "contract": "ERC4626Target3", + "address": "0x11505124Bd6b77Bee2bBcce19f2999055F953c87", + "timestamp": "2024-11-04T15:58:46.522Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive_ERC4626Target4": { + "contract": "ERC4626Target4", + "address": "0x70DfeF2aA019486a9E938888B67bf78E41F3B16b", + "timestamp": "2024-11-04T15:58:51.274Z" + }, + "ElementDAO 182 Day sGYD Hyperdrive": { + "contract": "ERC4626Hyperdrive", + "address": "0x9248f874AaA2c53AD9324d7A2D033ea133443874", + "timestamp": "2024-11-04T15:58:56.075Z" } }, "linea": { diff --git a/foundry.toml b/foundry.toml index 8e7e5bc65..4ef2b18da 100644 --- a/foundry.toml +++ b/foundry.toml @@ -28,6 +28,8 @@ remappings = [ gas_limit = "18446744073709551615" # allows the ffi to be used ffi = true +# the evm version +evm_version = "cancun" # See more config options https://github.com/foundry-rs/foundry/tree/master/config [profile.production] diff --git a/hardhat.config.gnosis.ts b/hardhat.config.gnosis.ts index 87684fe9b..7d98cbd5f 100644 --- a/hardhat.config.gnosis.ts +++ b/hardhat.config.gnosis.ts @@ -10,6 +10,7 @@ import { GNOSIS_CHAINLINK_COORDINATOR, GNOSIS_ERC4626_COORDINATOR, GNOSIS_FACTORY, + GNOSIS_SGYD_182DAY, GNOSIS_SXDAI_182DAY, GNOSIS_WSTETH_182DAY, } from "./tasks/deploy/config/gnosis"; @@ -30,7 +31,11 @@ const config: HardhatUserConfig = { GNOSIS_CHAINLINK_COORDINATOR, GNOSIS_ERC4626_COORDINATOR, ], - instances: [GNOSIS_WSTETH_182DAY, GNOSIS_SXDAI_182DAY], + instances: [ + GNOSIS_WSTETH_182DAY, + GNOSIS_SXDAI_182DAY, + GNOSIS_SGYD_182DAY, + ], checkpointRewarders: [], checkpointSubrewarders: [], }, diff --git a/hardhat.config.mainnet.ts b/hardhat.config.mainnet.ts index 1d0cf4df3..6317d4d61 100644 --- a/hardhat.config.mainnet.ts +++ b/hardhat.config.mainnet.ts @@ -19,6 +19,7 @@ import { MAINNET_MORPHO_BLUE_WSTETH_USDA_182DAY, MAINNET_RETH_182DAY, MAINNET_RETH_COORDINATOR, + MAINNET_SGYD_182DAY, MAINNET_STUSD_182DAY, MAINNET_SUSDE_182DAY, } from "./tasks/deploy/config/mainnet"; @@ -50,6 +51,7 @@ const config: HardhatUserConfig = { MAINNET_MORPHO_BLUE_CBBTC_USDC_182DAY, MAINNET_STUSD_182DAY, MAINNET_SUSDE_182DAY, + MAINNET_SGYD_182DAY, ], checkpointRewarders: [], checkpointSubrewarders: [], diff --git a/tasks/deploy/config/gnosis/index.ts b/tasks/deploy/config/gnosis/index.ts index 0edc2d351..5923ca763 100644 --- a/tasks/deploy/config/gnosis/index.ts +++ b/tasks/deploy/config/gnosis/index.ts @@ -1,5 +1,6 @@ export * from "./chainlink-coordinator"; export * from "./erc4626-coordinator"; export * from "./factory"; +export * from "./sgyd-182day"; export * from "./sxdai-182day"; export * from "./wsteth-182day"; diff --git a/tasks/deploy/config/gnosis/sgyd-182day.ts b/tasks/deploy/config/gnosis/sgyd-182day.ts new file mode 100644 index 000000000..f97a3b149 --- /dev/null +++ b/tasks/deploy/config/gnosis/sgyd-182day.ts @@ -0,0 +1,89 @@ +import { Address, keccak256, parseEther, toBytes } from "viem"; +import { + HyperdriveInstanceConfig, + getLinkerDetails, + normalizeFee, + parseDuration, + toBytes32, +} from "../../lib"; +import { + GYD_ADDRESS_GNOSIS, + SGYD_ADDRESS_GNOSIS, + SIX_MONTHS, +} from "../../lib/constants"; +import { GNOSIS_ERC4626_COORDINATOR_NAME } from "./erc4626-coordinator"; +import { GNOSIS_FACTORY_NAME } from "./factory"; + +// The name of the pool. +export const GNOSIS_SGYD_182DAY_NAME = "ElementDAO 182 Day sGYD Hyperdrive"; + +// The initial contribution of the pool. +const CONTRIBUTION = parseEther("100"); + +export const GNOSIS_SGYD_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { + name: GNOSIS_SGYD_182DAY_NAME, + prefix: "ERC4626", + coordinatorAddress: async (hre) => + hre.hyperdriveDeploy.deployments.byName(GNOSIS_ERC4626_COORDINATOR_NAME) + .address, + deploymentId: keccak256(toBytes(GNOSIS_SGYD_182DAY_NAME)), + salt: toBytes32("0x69420"), + extraData: "0x", + contribution: CONTRIBUTION, + // The current fixed rate on sGYD is 11.85%, but our maximum is 10%: + // https://app.gyro.finance/sgyd/ethereum/ + fixedAPR: parseEther("0.1"), + timestretchAPR: parseEther("0.075"), + 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", + GYD_ADDRESS_GNOSIS, + ); + let tx = await baseToken.write.approve([ + hre.hyperdriveDeploy.deployments.byName( + GNOSIS_ERC4626_COORDINATOR_NAME, + ).address, + CONTRIBUTION, + ]); + let pc = await hre.viem.getPublicClient(); + await pc.waitForTransactionReceipt({ hash: tx }); + }, + poolDeployConfig: async (hre) => { + let factoryContract = await hre.viem.getContractAt( + "HyperdriveFactory", + hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME) + .address, + ); + return { + baseToken: GYD_ADDRESS_GNOSIS, + vaultSharesToken: SGYD_ADDRESS_GNOSIS, + circuitBreakerDelta: parseEther("0.075"), + minimumShareReserves: parseEther("0.001"), + minimumTransactionAmount: parseEther("0.001"), + positionDuration: parseDuration(SIX_MONTHS), + checkpointDuration: parseDuration("1 day"), + timeStretch: 0n, + governance: await factoryContract.read.hyperdriveGovernance(), + feeCollector: await factoryContract.read.feeCollector(), + sweepCollector: await factoryContract.read.sweepCollector(), + checkpointRewarder: await factoryContract.read.checkpointRewarder(), + ...(await getLinkerDetails( + hre, + hre.hyperdriveDeploy.deployments.byName(GNOSIS_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/config/mainnet/index.ts b/tasks/deploy/config/mainnet/index.ts index e519d6488..607bddc8f 100644 --- a/tasks/deploy/config/mainnet/index.ts +++ b/tasks/deploy/config/mainnet/index.ts @@ -17,6 +17,7 @@ export * from "./morpho-blue-wsteth-usda-182day"; export * from "./morpho-blue-wsteth-usdc-182day"; export * from "./reth-182day"; export * from "./reth-coordinator"; +export * from "./sgyd-182day"; export * from "./staking-usds-coordinator"; export * from "./staking-usds-sky-182day"; export * from "./steth-182day"; diff --git a/tasks/deploy/config/mainnet/sgyd-182day.ts b/tasks/deploy/config/mainnet/sgyd-182day.ts new file mode 100644 index 000000000..330f563dd --- /dev/null +++ b/tasks/deploy/config/mainnet/sgyd-182day.ts @@ -0,0 +1,90 @@ +import { Address, keccak256, parseEther, toBytes } from "viem"; +import { + HyperdriveInstanceConfig, + getLinkerDetails, + normalizeFee, + parseDuration, + toBytes32, +} from "../../lib"; +import { + GYD_ADDRESS_MAINNET, + SGYD_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_SGYD_182DAY_NAME = "ElementDAO 182 Day sGYD Hyperdrive"; + +// The initial contribution of the pool. +const CONTRIBUTION = parseEther("100"); + +export const MAINNET_SGYD_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { + name: MAINNET_SGYD_182DAY_NAME, + prefix: "ERC4626", + coordinatorAddress: async (hre) => + hre.hyperdriveDeploy.deployments.byName( + MAINNET_ERC4626_COORDINATOR_NAME, + ).address, + deploymentId: keccak256(toBytes(MAINNET_SGYD_182DAY_NAME + "1")), + salt: toBytes32("0x69421"), + extraData: "0x", + contribution: CONTRIBUTION, + // The current fixed rate on sGYD is 11.85%, but our maximum is 10%: + // https://app.gyro.finance/sgyd/ethereum/ + fixedAPR: parseEther("0.1"), + timestretchAPR: parseEther("0.075"), + 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", + GYD_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) => { + let factoryContract = await hre.viem.getContractAt( + "HyperdriveFactory", + hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME) + .address, + ); + return { + baseToken: GYD_ADDRESS_MAINNET, + vaultSharesToken: SGYD_ADDRESS_MAINNET, + circuitBreakerDelta: parseEther("0.075"), + minimumShareReserves: parseEther("0.001"), + minimumTransactionAmount: parseEther("0.001"), + positionDuration: parseDuration(SIX_MONTHS), + checkpointDuration: parseDuration("1 day"), + timeStretch: 0n, + governance: await factoryContract.read.hyperdriveGovernance(), + feeCollector: await factoryContract.read.feeCollector(), + sweepCollector: await factoryContract.read.sweepCollector(), + checkpointRewarder: await factoryContract.read.checkpointRewarder(), + ...(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 a2538d385..442f2e9fc 100644 --- a/tasks/deploy/lib/constants.ts +++ b/tasks/deploy/lib/constants.ts @@ -64,6 +64,9 @@ export const EETH_MEMBERSHIP_MANAGER_ADDRESS_MAINNET = export const EZETH_ADDRESS_MAINNET = "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110" as Address; +export const GYD_ADDRESS_MAINNET = + "0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A" as Address; + export const LBTC_ADDRESS_MAINNET = "0x8236a87084f8B84306f72007F36F2618A5634494" as Address; @@ -73,6 +76,9 @@ export const RETH_ADDRESS_MAINNET = export const SDAI_ADDRESS_MAINNET = "0x83F20F44975D03b1b09e64809B757c47f942BEeA" as Address; +export const SGYD_ADDRESS_MAINNET = + "0xeA50f402653c41cAdbaFD1f788341dB7B7F37816" as Address; + export const STETH_ADDRESS_MAINNET = "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84" as Address; @@ -216,6 +222,12 @@ export const CHAINLINK_AGGREGATOR_ADDRESS_GNOSIS = export const CHAINLINK_AGGREGATOR_WSTETH_ETH_PROXY_GNOSIS = "0x0064AC007fF665CF8D0D3Af5E0AD1c26a3f853eA" as Address; +export const GYD_ADDRESS_GNOSIS = + "0xCA5d8F8a8d49439357d3CF46Ca2e720702F132b8" as Address; + +export const SGYD_ADDRESS_GNOSIS = + "0xeA50f402653c41cAdbaFD1f788341dB7B7F37816" as Address; + export const SXDAI_ADDRESS_GNOSIS = "0xaf204776c7245bF4147c2612BF6e5972Ee483701" as Address; diff --git a/test/instances/aave/AaveHyperdrive.t.sol b/test/instances/aave/AaveHyperdrive.t.sol index 88b97ecf8..f768a3602 100644 --- a/test/instances/aave/AaveHyperdrive.t.sol +++ b/test/instances/aave/AaveHyperdrive.t.sol @@ -73,6 +73,8 @@ contract AaveHyperdriveTest is InstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/aave/AaveL2Hyperdrive.t.sol b/test/instances/aave/AaveL2Hyperdrive.t.sol index e6b45aa4f..12dcd93dc 100644 --- a/test/instances/aave/AaveL2Hyperdrive.t.sol +++ b/test/instances/aave/AaveL2Hyperdrive.t.sol @@ -83,6 +83,8 @@ contract AaveL2HyperdriveTest is InstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/aerodrome/AerodromeLp_AERO_USDC_Hyperdrive.t.sol b/test/instances/aerodrome/AerodromeLp_AERO_USDC_Hyperdrive.t.sol index cb41a67f9..101ec2f73 100644 --- a/test/instances/aerodrome/AerodromeLp_AERO_USDC_Hyperdrive.t.sol +++ b/test/instances/aerodrome/AerodromeLp_AERO_USDC_Hyperdrive.t.sol @@ -57,6 +57,8 @@ contract AerodromeLp_AERO_USDC_Hyperdrive is AerodromeLpHyperdriveInstanceTest { shouldAccrueInterest: false, // The base test tolerances. closeLongWithBaseTolerance: 0, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 10, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, diff --git a/test/instances/chainlink/CbETHBase.t.sol b/test/instances/chainlink/CbETHBase.t.sol index 3541ca2fe..882a1d576 100644 --- a/test/instances/chainlink/CbETHBase.t.sol +++ b/test/instances/chainlink/CbETHBase.t.sol @@ -56,6 +56,8 @@ contract CbETHBaseTest is ChainlinkHyperdriveInstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/chainlink/WstETHGnosisChain.t.sol b/test/instances/chainlink/WstETHGnosisChain.t.sol index f14bf37dc..bcb89041f 100644 --- a/test/instances/chainlink/WstETHGnosisChain.t.sol +++ b/test/instances/chainlink/WstETHGnosisChain.t.sol @@ -57,6 +57,8 @@ contract WstETHGnosisChainTest is ChainlinkHyperdriveInstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/corn/Corn_LBTC_Hyperdrive.sol b/test/instances/corn/Corn_LBTC_Hyperdrive.sol index 6ac1413a3..69f10a480 100644 --- a/test/instances/corn/Corn_LBTC_Hyperdrive.sol +++ b/test/instances/corn/Corn_LBTC_Hyperdrive.sol @@ -55,6 +55,8 @@ contract Corn_LBTC_Hyperdrive is CornHyperdriveInstanceTest { shouldAccrueInterest: false, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, diff --git a/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol b/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol index e534b1eab..4e578794c 100644 --- a/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol +++ b/test/instances/corn/Corn_sDAI_Hyperdrive.t.sol @@ -55,6 +55,8 @@ contract Corn_sDAI_Hyperdrive is CornHyperdriveInstanceTest { shouldAccrueInterest: false, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e7, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/eeth/EETHHyperdrive.t.sol b/test/instances/eeth/EETHHyperdrive.t.sol index e3737f318..5c5a80f42 100644 --- a/test/instances/eeth/EETHHyperdrive.t.sol +++ b/test/instances/eeth/EETHHyperdrive.t.sol @@ -77,6 +77,8 @@ contract EETHHyperdriveTest is InstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/erc4626/MoonwellETH.t.sol b/test/instances/erc4626/MoonwellETH.t.sol index 95aece3ac..0af2247f1 100644 --- a/test/instances/erc4626/MoonwellETH.t.sol +++ b/test/instances/erc4626/MoonwellETH.t.sol @@ -53,6 +53,8 @@ contract MoonwellETHHyperdriveTest is MetaMorphoHyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e6, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/MoonwellEURC.t.sol b/test/instances/erc4626/MoonwellEURC.t.sol index 4bd8a4c6c..716b9a897 100644 --- a/test/instances/erc4626/MoonwellEURC.t.sol +++ b/test/instances/erc4626/MoonwellEURC.t.sol @@ -60,6 +60,8 @@ contract MoonwellEURCHyperdriveTest is MetaMorphoHyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e6, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/MoonwellUSDC.t.sol b/test/instances/erc4626/MoonwellUSDC.t.sol index 9c1eaa477..d877b0ec2 100644 --- a/test/instances/erc4626/MoonwellUSDC.t.sol +++ b/test/instances/erc4626/MoonwellUSDC.t.sol @@ -60,6 +60,8 @@ contract MoonwellUSDCHyperdriveTest is MetaMorphoHyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e6, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/SUSDe.t.sol b/test/instances/erc4626/SUSDe.t.sol index d63a6904c..8426bf0f8 100644 --- a/test/instances/erc4626/SUSDe.t.sol +++ b/test/instances/erc4626/SUSDe.t.sol @@ -83,6 +83,8 @@ contract SUSDeHyperdriveTest is ERC4626HyperdriveInstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/erc4626/ScrvUSD.t.sol b/test/instances/erc4626/ScrvUSD.t.sol index 606047d95..0907d5dd3 100644 --- a/test/instances/erc4626/ScrvUSD.t.sol +++ b/test/instances/erc4626/ScrvUSD.t.sol @@ -67,6 +67,8 @@ contract scrvUSDHyperdriveTest is ERC4626HyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e6, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/SnARS.t.sol b/test/instances/erc4626/SnARS.t.sol index 84de12425..7a4258394 100644 --- a/test/instances/erc4626/SnARS.t.sol +++ b/test/instances/erc4626/SnARS.t.sol @@ -78,6 +78,8 @@ contract SnARSHyperdriveTest is ERC4626HyperdriveInstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 0, + closeShortWithBaseUpperBoundTolerance: 0, + closeShortWithBaseTolerance: 0, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/erc4626/StUSD.t.sol b/test/instances/erc4626/StUSD.t.sol index cdfdad9d6..1dfdf26d1 100644 --- a/test/instances/erc4626/StUSD.t.sol +++ b/test/instances/erc4626/StUSD.t.sol @@ -70,6 +70,8 @@ contract stUSDHyperdriveTest is ERC4626HyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e6, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/sGYD.t.sol b/test/instances/erc4626/sGYD.t.sol new file mode 100644 index 000000000..d52e708eb --- /dev/null +++ b/test/instances/erc4626/sGYD.t.sol @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.20; + +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 { InstanceTest } from "../../utils/InstanceTest.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"; + +contract sGYDHyperdriveTest is ERC4626HyperdriveInstanceTest { + using HyperdriveUtils for uint256; + using HyperdriveUtils for IHyperdrive; + using Lib for *; + using stdStorage for StdStorage; + + /// @dev The GYD contract. + IERC20 internal constant GYD = + IERC20(0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A); + + /// @dev The sGYD contract. + IERC4626 internal constant SGYD = + IERC4626(0xeA50f402653c41cAdbaFD1f788341dB7B7F37816); + + /// @dev Whale accounts. + address internal GYD_TOKEN_WHALE = + address(0xa1886c8d748DeB3774225593a70c79454B1DA8a6); + address[] internal baseTokenWhaleAccounts = [GYD_TOKEN_WHALE]; + address internal SGYD_TOKEN_WHALE = + address(0x7a12F90D69E3D779049632634ADE17ad082447e5); + address[] internal vaultSharesTokenWhaleAccounts = [SGYD_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: GYD, + vaultSharesToken: IERC20(SGYD), + 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. + closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, + roundTripLpInstantaneousWithBaseTolerance: 1e5, + roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, + roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, + roundTripLongInstantaneousWithBaseTolerance: 1e5, + roundTripLongMaturityWithBaseUpperBoundTolerance: 1e3, + roundTripLongMaturityWithBaseTolerance: 1e5, + roundTripShortInstantaneousWithBaseUpperBoundTolerance: 1e3, + roundTripShortInstantaneousWithBaseTolerance: 1e5, + roundTripShortMaturityWithBaseTolerance: 1e5, + // The share test tolerances. + closeLongWithSharesTolerance: 20, + closeShortWithSharesTolerance: 100, + roundTripLpInstantaneousWithSharesTolerance: 1e7, + roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, + roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, + roundTripLongInstantaneousWithSharesTolerance: 1e5, + roundTripLongMaturityWithSharesUpperBoundTolerance: 1e3, + roundTripLongMaturityWithSharesTolerance: 1e5, + roundTripShortInstantaneousWithSharesUpperBoundTolerance: 1e3, + roundTripShortInstantaneousWithSharesTolerance: 1e5, + roundTripShortMaturityWithSharesTolerance: 1e5, + // The verification tolerances. + verifyDepositTolerance: 2, + verifyWithdrawalTolerance: 2 + }) + ) + {} + + /// @notice Forge function that is invoked to setup the testing environment. + function setUp() public override __mainnet_fork(21_088_994) { + // Invoke the Instance testing suite setup. + super.setUp(); + + // sGYD receives payments from "streams" that are configured to pay GYD + // to the sGYD contract over time. To simplify the interest accrual + // logic, we advance enough time to ensure that all of these streams + // have concluded their payouts. + uint256 maximumDuration = 1 days * 365 * 5; // 5 years + vm.warp(block.timestamp + maximumDuration); + } + + /// 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 { + // Advance the time. + vm.warp(block.timestamp + timeDelta); + + // Accrue interest in the sGYD market. This amounts to manually + // updating the total supply assets by minting more GYD to the contract. + uint256 totalAssets = SGYD.totalAssets(); + (totalAssets, ) = totalAssets.calculateInterest( + variableRate, + timeDelta + ); + bytes32 balanceLocation = keccak256(abi.encode(address(SGYD), 52)); + vm.store(address(GYD), balanceLocation, bytes32(totalAssets)); + } +} diff --git a/test/instances/erc4626/sGYD_gnosis.t.sol b/test/instances/erc4626/sGYD_gnosis.t.sol new file mode 100644 index 000000000..59138fee3 --- /dev/null +++ b/test/instances/erc4626/sGYD_gnosis.t.sol @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.20; + +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 { InstanceTest } from "../../utils/InstanceTest.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"; + +contract sGYD_gnosis_HyperdriveTest is ERC4626HyperdriveInstanceTest { + using HyperdriveUtils for uint256; + using HyperdriveUtils for IHyperdrive; + using Lib for *; + using stdStorage for StdStorage; + + /// @dev The storage location of ERC20 data in L2 GYD and sGYD. + bytes32 ERC20_STORAGE_LOCATION = + 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; + + /// @dev The GYD contract. + IERC20 internal constant GYD = + IERC20(0xCA5d8F8a8d49439357d3CF46Ca2e720702F132b8); + + /// @dev The sGYD contract. + IERC4626 internal constant SGYD = + IERC4626(0xeA50f402653c41cAdbaFD1f788341dB7B7F37816); + + /// @dev Whale accounts. + address internal GYD_TOKEN_WHALE = + address(0xa1886c8d748DeB3774225593a70c79454B1DA8a6); + address[] internal baseTokenWhaleAccounts = [GYD_TOKEN_WHALE]; + address internal SGYD_TOKEN_WHALE = + address(0x7a12F90D69E3D779049632634ADE17ad082447e5); + address[] internal vaultSharesTokenWhaleAccounts = [SGYD_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: GYD, + vaultSharesToken: IERC20(SGYD), + 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. + closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 1e4, + closeShortWithBaseTolerance: 1e4, + roundTripLpInstantaneousWithBaseTolerance: 1e5, + roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, + roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, + roundTripLongInstantaneousWithBaseTolerance: 1e5, + roundTripLongMaturityWithBaseUpperBoundTolerance: 1e3, + roundTripLongMaturityWithBaseTolerance: 1e5, + roundTripShortInstantaneousWithBaseUpperBoundTolerance: 1e3, + roundTripShortInstantaneousWithBaseTolerance: 1e5, + roundTripShortMaturityWithBaseTolerance: 1e5, + // The share test tolerances. + closeLongWithSharesTolerance: 20, + closeShortWithSharesTolerance: 100, + roundTripLpInstantaneousWithSharesTolerance: 1e7, + roundTripLpWithdrawalSharesWithSharesTolerance: 1e7, + roundTripLongInstantaneousWithSharesUpperBoundTolerance: 1e3, + roundTripLongInstantaneousWithSharesTolerance: 1e5, + roundTripLongMaturityWithSharesUpperBoundTolerance: 1e3, + roundTripLongMaturityWithSharesTolerance: 1e5, + roundTripShortInstantaneousWithSharesUpperBoundTolerance: 1e3, + roundTripShortInstantaneousWithSharesTolerance: 1e5, + roundTripShortMaturityWithSharesTolerance: 1e5, + // The verification tolerances. + verifyDepositTolerance: 2, + verifyWithdrawalTolerance: 2 + }) + ) + {} + + /// @notice Forge function that is invoked to setup the testing environment. + function setUp() public override __gnosis_chain_fork(36_808_076) { + // NOTE: We need to mint GYD since the current supply is very low. + // + // Mint GYD to the GYD whale. + setBalanceGYD(GYD_TOKEN_WHALE, 1_000_000e18); + + // NOTE: We need to mint sGYD since the current supply is zero. + // + // Mint GYD to the sGYD whale and mint sGYD. + setBalanceGYD(SGYD_TOKEN_WHALE, 1_000_000e18); + vm.stopPrank(); + vm.startPrank(SGYD_TOKEN_WHALE); + GYD.approve(address(SGYD), 1_000_000e18); + SGYD.deposit(1_000_000e18, SGYD_TOKEN_WHALE); + + // 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 { + // Advance the time. + vm.warp(block.timestamp + timeDelta); + + // Accrue interest in the sGYD market. This amounts to manually + // updating the total supply assets by minting more GYD to the contract. + uint256 totalAssets = SGYD.totalAssets(); + (totalAssets, ) = totalAssets.calculateInterest( + variableRate, + timeDelta + ); + setBalanceGYD(address(SGYD), totalAssets); + } + + /// @dev Sets the GYD balance of an account. + /// @param _account The account to be updated. + /// @param _amount The amount of tokens to set. + function setBalanceGYD(address _account, uint256 _amount) internal { + bytes32 balanceLocation = keccak256( + abi.encode(address(_account), ERC20_STORAGE_LOCATION) + ); + vm.store(address(GYD), balanceLocation, bytes32(_amount)); + } + + /// @dev Sets the sGYD balance of an account. + /// @param _account The account to be updated. + /// @param _amount The amount of tokens to set. + function setBalanceSGYD(address _account, uint256 _amount) internal { + bytes32 balanceLocation = keccak256( + abi.encode(address(_account), ERC20_STORAGE_LOCATION) + ); + vm.store(address(SGYD), balanceLocation, bytes32(_amount)); + } +} diff --git a/test/instances/erc4626/sUSDS.t.sol b/test/instances/erc4626/sUSDS.t.sol index 164e376dc..50c1d2c21 100644 --- a/test/instances/erc4626/sUSDS.t.sol +++ b/test/instances/erc4626/sUSDS.t.sol @@ -75,6 +75,8 @@ contract sUSDSHyperdriveTest is ERC4626HyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 1e3, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e8, roundTripLpWithdrawalSharesWithBaseTolerance: 1e8, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/erc4626/sxDai.t.sol b/test/instances/erc4626/sxDai.t.sol index 84be14207..789fbf0de 100644 --- a/test/instances/erc4626/sxDai.t.sol +++ b/test/instances/erc4626/sxDai.t.sol @@ -2,18 +2,9 @@ pragma solidity ^0.8.20; import { stdStorage, StdStorage } from "forge-std/Test.sol"; -import { ERC4626HyperdriveCoreDeployer } from "../../../contracts/src/deployers/erc4626/ERC4626HyperdriveCoreDeployer.sol"; -import { ERC4626HyperdriveDeployerCoordinator } from "../../../contracts/src/deployers/erc4626/ERC4626HyperdriveDeployerCoordinator.sol"; -import { ERC4626Target0Deployer } from "../../../contracts/src/deployers/erc4626/ERC4626Target0Deployer.sol"; -import { ERC4626Target1Deployer } from "../../../contracts/src/deployers/erc4626/ERC4626Target1Deployer.sol"; -import { ERC4626Target2Deployer } from "../../../contracts/src/deployers/erc4626/ERC4626Target2Deployer.sol"; -import { ERC4626Target3Deployer } from "../../../contracts/src/deployers/erc4626/ERC4626Target3Deployer.sol"; -import { ERC4626Target4Deployer } from "../../../contracts/src/deployers/erc4626/ERC4626Target4Deployer.sol"; -import { ERC4626Conversions } from "../../../contracts/src/instances/erc4626/ERC4626Conversions.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 { FixedPointMath } from "../../../contracts/src/libraries/FixedPointMath.sol"; import { InstanceTest } from "../../utils/InstanceTest.sol"; import { HyperdriveUtils } from "../../utils/HyperdriveUtils.sol"; import { InstanceTest } from "../../utils/InstanceTest.sol"; @@ -72,6 +63,8 @@ contract sxDaiHyperdriveTest is ERC4626HyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e5, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/ezETH/EzETHHyperdrive.t.sol b/test/instances/ezETH/EzETHHyperdrive.t.sol index 89defb25d..57e7ca2eb 100644 --- a/test/instances/ezETH/EzETHHyperdrive.t.sol +++ b/test/instances/ezETH/EzETHHyperdrive.t.sol @@ -87,6 +87,8 @@ contract EzETHHyperdriveTest is InstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/ezeth-linea/EzETHLineaTest.t.sol b/test/instances/ezeth-linea/EzETHLineaTest.t.sol index 6dbb46410..20f161667 100644 --- a/test/instances/ezeth-linea/EzETHLineaTest.t.sol +++ b/test/instances/ezeth-linea/EzETHLineaTest.t.sol @@ -73,6 +73,8 @@ contract EzETHLineaHyperdriveTest is InstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/lseth/LsETHHyperdrive.t.sol b/test/instances/lseth/LsETHHyperdrive.t.sol index aefc4b371..9bc2d64ee 100644 --- a/test/instances/lseth/LsETHHyperdrive.t.sol +++ b/test/instances/lseth/LsETHHyperdrive.t.sol @@ -75,6 +75,8 @@ contract LsETHHyperdriveTest is InstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, 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 0de16e46f..d026c22a5 100644 --- a/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_USDe_DAI_Hyperdrive.t.sol @@ -62,6 +62,8 @@ contract MorphoBlue_USDe_DAI_HyperdriveTest is shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e13, roundTripLpWithdrawalSharesWithBaseTolerance: 1e13, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/morpho-blue/MorphoBlue_WBTC_USDC_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_WBTC_USDC_Hyperdrive.t.sol index 8eff4fa54..d44f903dc 100644 --- a/test/instances/morpho-blue/MorphoBlue_WBTC_USDC_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_WBTC_USDC_Hyperdrive.t.sol @@ -61,6 +61,8 @@ contract MorphoBlue_WBTC_USDC_Hyperdrive is MorphoBlueHyperdriveInstanceTest { shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, 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 02fdb9f1f..52289c5bd 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 @@ -63,6 +63,8 @@ contract MorphoBlue_cbETH_USDC_Base_HyperdriveTest is shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, diff --git a/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Mainnet_Hyperdrive.t.sol b/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Mainnet_Hyperdrive.t.sol index ecaa3b199..52c0a2b91 100644 --- a/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Mainnet_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_cbETH_USDC_Mainnet_Hyperdrive.t.sol @@ -63,6 +63,8 @@ contract MorphoBlue_cbBTC_USDC_Mainnet_HyperdriveTest is shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, 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 d02c399b7..9c9c317bb 100644 --- a/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_sUSDe_DAI_Hyperdrive.t.sol @@ -62,6 +62,8 @@ contract MorphoBlue_sUSDe_DAI_HyperdriveTest is shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e13, roundTripLpWithdrawalSharesWithBaseTolerance: 1e13, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, 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 da2cd030a..476f2f657 100644 --- a/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_wstETH_USDA_Hyperdrive.t.sol @@ -62,6 +62,8 @@ contract MorphoBlue_wstETH_USDA_HyperdriveTest is shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e13, roundTripLpWithdrawalSharesWithBaseTolerance: 1e13, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, 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 2b2b015f1..86db09c8a 100644 --- a/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol +++ b/test/instances/morpho-blue/MorphoBlue_wstETH_USDC_Hyperdrive.t.sol @@ -63,6 +63,8 @@ contract MorphoBlue_wstETH_USDC_HyperdriveTest is shouldAccrueInterest: true, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e5, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 100, diff --git a/test/instances/reth/RETHHyperdrive.t.sol b/test/instances/reth/RETHHyperdrive.t.sol index ef1273f65..12149f988 100644 --- a/test/instances/reth/RETHHyperdrive.t.sol +++ b/test/instances/reth/RETHHyperdrive.t.sol @@ -75,6 +75,8 @@ contract RETHHyperdriveTest is InstanceTest { }), // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e3, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol b/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol index 2dffe3c33..323cfd0c6 100644 --- a/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol +++ b/test/instances/rseth-linea/RsETHLineaHyperdrive.t.sol @@ -74,6 +74,8 @@ contract RsETHLineaHyperdriveTest is InstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/staking-usds/StakingUSDS_Chronicle_Hyperdrive.t.sol b/test/instances/staking-usds/StakingUSDS_Chronicle_Hyperdrive.t.sol index fe266a729..b5cb0549d 100644 --- a/test/instances/staking-usds/StakingUSDS_Chronicle_Hyperdrive.t.sol +++ b/test/instances/staking-usds/StakingUSDS_Chronicle_Hyperdrive.t.sol @@ -55,6 +55,8 @@ contract StakingUSDS_Chronicle_Hyperdrive is StakingUSDSHyperdriveInstanceTest { shouldAccrueInterest: false, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e7, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/staking-usds/StakingUSDS_Sky_Hyperdrive.t.sol b/test/instances/staking-usds/StakingUSDS_Sky_Hyperdrive.t.sol index d8f701c87..476fe85b3 100644 --- a/test/instances/staking-usds/StakingUSDS_Sky_Hyperdrive.t.sol +++ b/test/instances/staking-usds/StakingUSDS_Sky_Hyperdrive.t.sol @@ -55,6 +55,8 @@ contract StakingUSDS_Sky_Hyperdrive is StakingUSDSHyperdriveInstanceTest { shouldAccrueInterest: false, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e7, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/instances/steth/StETHHyperdrive.t.sol b/test/instances/steth/StETHHyperdrive.t.sol index 051dd50ed..7dd3c4f94 100644 --- a/test/instances/steth/StETHHyperdrive.t.sol +++ b/test/instances/steth/StETHHyperdrive.t.sol @@ -71,6 +71,8 @@ contract StETHHyperdriveTest is InstanceTest { // // The base test tolerances. closeLongWithBaseTolerance: 20, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 0, roundTripLpWithdrawalSharesWithBaseTolerance: 0, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 0, diff --git a/test/instances/stk-well/StkWellHyperdrive.t.sol b/test/instances/stk-well/StkWellHyperdrive.t.sol index 3e3864cd2..b96352701 100644 --- a/test/instances/stk-well/StkWellHyperdrive.t.sol +++ b/test/instances/stk-well/StkWellHyperdrive.t.sol @@ -76,6 +76,8 @@ contract StkWellHyperdriveInstanceTest is InstanceTest { shouldAccrueInterest: false, // The base test tolerances. closeLongWithBaseTolerance: 2, + closeShortWithBaseUpperBoundTolerance: 10, + closeShortWithBaseTolerance: 100, roundTripLpInstantaneousWithBaseTolerance: 1e3, roundTripLpWithdrawalSharesWithBaseTolerance: 1e7, roundTripLongInstantaneousWithBaseUpperBoundTolerance: 1e3, diff --git a/test/utils/InstanceTest.sol b/test/utils/InstanceTest.sol index d0b298098..649ad011c 100644 --- a/test/utils/InstanceTest.sol +++ b/test/utils/InstanceTest.sol @@ -85,6 +85,12 @@ abstract contract InstanceTest is HyperdriveTest { /// @dev The equality tolerance in wei for the close long with base /// test. uint256 closeLongWithBaseTolerance; + /// @dev The upper bound tolerance in wei for the close short with base + /// test. + uint256 closeShortWithBaseUpperBoundTolerance; + /// @dev The equality tolerance in wei for the close short with base + /// test. + uint256 closeShortWithBaseTolerance; /// @dev The equality tolerance in wei for the close short with shares /// test. uint256 closeShortWithSharesTolerance; @@ -2560,8 +2566,15 @@ abstract contract InstanceTest is HyperdriveTest { // Convert proceeds to the base token and ensure the proper about of // interest was credited to Bob. - assertLe(baseProceeds, expectedBaseProceeds + 10); - assertApproxEqAbs(baseProceeds, expectedBaseProceeds, 100); + assertLe( + baseProceeds, + expectedBaseProceeds + config.closeShortWithBaseUpperBoundTolerance + ); + assertApproxEqAbs( + baseProceeds, + expectedBaseProceeds, + config.closeShortWithBaseTolerance + ); // Ensure the withdrawal accounting is correct. verifyWithdrawal(