Skip to content

Commit

Permalink
Refactored the verifyDeposit and verifyWithdrawal functions (#1156)
Browse files Browse the repository at this point in the history
* Added a test suite for the stUSD instance

* Added a deployment script

* Updated the deployment configuration of the stUSD market

* Updated the time stretch

* Implemented a base instance test for Morpho Blue

* Refactored the Morpho Blue instance tests

* Added an integration test for the Morpho Blue wstETH/USDA market

* Added a deployment script for Morpho Blue wstETH/USDA

* Addressed FIXMEs

* Updated the time stretch

* Addressed review feedback from @mcclurejt

* Fixed deployments scripts and linter

* Added a deployment script for Morpho Blue wstETH/USDA

* Refactored the `verifyDeposit` and `verifyWithdrawal` logic

* Addressed review feedback from @mcclurejt

* Addressed remaining review feedback from @mcclurejt

* Deployed the new pools
  • Loading branch information
jalextowle authored Sep 4, 2024
1 parent f2acb64 commit 799a60a
Show file tree
Hide file tree
Showing 27 changed files with 1,344 additions and 2,391 deletions.
56 changes: 0 additions & 56 deletions contracts/src/factory/HyperdriveCreate2Factory.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/src/libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.20;
address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

/// @dev The version of the contracts.
string constant VERSION = "v1.0.18";
string constant VERSION = "v1.0.19";

/// @dev The number of targets that must be deployed for a full deployment.
uint256 constant NUM_TARGETS = 5;
Expand Down
125 changes: 95 additions & 30 deletions deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,36 +527,6 @@
"address": "0xdf5d682404b0611f46f2626d9d5a37eb6a6fd27d",
"timestamp": "2024-06-27T04:20:40.013Z"
},
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626HyperdriveCoreDeployer": {
"contract": "ERC4626HyperdriveCoreDeployer",
"address": "0xd9bdabb0f87e46af44063d251eb07edfe260d9f1",
"timestamp": "2024-06-27T04:20:49.416Z"
},
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target0Deployer": {
"contract": "ERC4626Target0Deployer",
"address": "0x2bbf0716fb1ac91169b0dbecff232c7bf1b7e701",
"timestamp": "2024-06-27T04:21:02.853Z"
},
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target1Deployer": {
"contract": "ERC4626Target1Deployer",
"address": "0x068d5258f54b462de4240547dca0f1fce6382426",
"timestamp": "2024-06-27T04:21:16.020Z"
},
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target2Deployer": {
"contract": "ERC4626Target2Deployer",
"address": "0x0fb305a458b1008faee03147b700b3975bea03fd",
"timestamp": "2024-06-27T04:21:29.398Z"
},
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator_ERC4626Target3Deployer": {
"contract": "ERC4626Target3Deployer",
"address": "0xd8ee8f39c42ee9b005582e4dc0d530c7de6f1471",
"timestamp": "2024-06-27T04:21:38.990Z"
},
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator": {
"contract": "ERC4626HyperdriveDeployerCoordinator",
"address": "0xb2f17302ed12fe72d883fcc2b66f1b844fbb7964",
"timestamp": "2024-06-27T04:21:52.756Z"
},
"ElementDAO stETH Hyperdrive Deployer Coordinator_StETHHyperdriveCoreDeployer": {
"contract": "StETHHyperdriveCoreDeployer",
"address": "0xe8dc5073b02d062388db8e50762a8c9a1c823540",
Expand Down Expand Up @@ -866,6 +836,101 @@
"contract": "MorphoBlueHyperdrive",
"address": "0xA29A771683b4857bBd16e1e4f27D5B6bfF53209B",
"timestamp": "2024-08-14T19:30:51.584Z"
},
"ElementDAO 182 Day Morpho Blue wstETH/USDA Hyperdrive_MorphoBlueTarget0": {
"contract": "MorphoBlueTarget0",
"address": "0xdE7F1e3F02018169ef24622400933b7EFF44aE2d",
"timestamp": "2024-09-03T20:36:40.568Z"
},
"ElementDAO 182 Day Morpho Blue wstETH/USDA Hyperdrive_MorphoBlueTarget1": {
"contract": "MorphoBlueTarget1",
"address": "0xdDe9EAc01F5895055c9078c4044689c552f1E12F",
"timestamp": "2024-09-03T20:35:51.225Z"
},
"ElementDAO 182 Day Morpho Blue wstETH/USDA Hyperdrive_MorphoBlueTarget2": {
"contract": "MorphoBlueTarget2",
"address": "0x13C486EC46Eb5cD39e98f9bDD870Fd0257527119",
"timestamp": "2024-09-03T20:36:04.337Z"
},
"ElementDAO 182 Day Morpho Blue wstETH/USDA Hyperdrive_MorphoBlueTarget3": {
"contract": "MorphoBlueTarget3",
"address": "0x5E723b39CA597Ae3b08A6fa6836B3c605f37c3F3",
"timestamp": "2024-09-03T20:36:13.598Z"
},
"ElementDAO 182 Day Morpho Blue wstETH/USDA Hyperdrive_MorphoBlueTarget4": {
"contract": "MorphoBlueTarget4",
"address": "0xE6AA85FaA591650Bb7Ec6b53D68B39b66bC74441",
"timestamp": "2024-09-03T20:36:26.884Z"
},
"ElementDAO 182 Day Morpho Blue wstETH/USDA Hyperdrive": {
"contract": "MorphoBlueHyperdrive",
"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",
"timestamp": "2024-09-03T21:47:17.115Z"
},
"ElementDAO 182 Day stUSD Hyperdrive_ERC4626Target1": {
"contract": "ERC4626Target1",
"address": "0xCD51526c7169652f8380095b338aFC1557BDA155",
"timestamp": "2024-09-03T21:46:28.318Z"
},
"ElementDAO 182 Day stUSD Hyperdrive_ERC4626Target2": {
"contract": "ERC4626Target2",
"address": "0x9a70E96309d62A7c1c16aD9ba1F36bdEe6823C89",
"timestamp": "2024-09-03T21:46:41.719Z"
},
"ElementDAO 182 Day stUSD Hyperdrive_ERC4626Target3": {
"contract": "ERC4626Target3",
"address": "0x94Da7F7fEFDb53Daa5Abe4a430c6e43686807F80",
"timestamp": "2024-09-03T21:46:50.768Z"
},
"ElementDAO 182 Day stUSD Hyperdrive_ERC4626Target4": {
"contract": "ERC4626Target4",
"address": "0xe30bf456cd0697365ea786729EEB082239dad64e",
"timestamp": "2024-09-03T21:47:03.893Z"
},
"ElementDAO 182 Day stUSD Hyperdrive": {
"contract": "ERC4626Hyperdrive",
"address": "0xA4090183878d5B7b6Ad104863743dd7E58985321",
"timestamp": "2024-09-03T21:47:16.998Z"
}
},
"gnosis": {
Expand Down
4 changes: 2 additions & 2 deletions hardhat.config.mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { HardhatUserConfig } from "hardhat/config";
import baseConfig from "./hardhat.config";
import "./tasks";
import {
MAINNET_ERC4626_COORDINATOR,
MAINNET_EZETH_182DAY,
MAINNET_EZETH_COORDINATOR,
MAINNET_FACTORY,
MAINNET_MORPHO_BLUE_COORDINATOR,
MAINNET_MORPHO_BLUE_SUSDE_DAI_182DAY,
MAINNET_MORPHO_BLUE_USDE_DAI_182DAY,
MAINNET_MORPHO_BLUE_WSTETH_USDA_182DAY,
MAINNET_MORPHO_BLUE_WSTETH_USDC_182DAY,
MAINNET_RETH_182DAY,
MAINNET_RETH_COORDINATOR,
MAINNET_STUSD_182DAY,
Expand All @@ -32,6 +32,7 @@ const config: HardhatUserConfig = {
hyperdriveDeploy: {
factories: [MAINNET_FACTORY],
coordinators: [
MAINNET_ERC4626_COORDINATOR,
MAINNET_EZETH_COORDINATOR,
MAINNET_RETH_COORDINATOR,
MAINNET_MORPHO_BLUE_COORDINATOR,
Expand All @@ -41,7 +42,6 @@ const config: HardhatUserConfig = {
MAINNET_RETH_182DAY,
MAINNET_MORPHO_BLUE_SUSDE_DAI_182DAY,
MAINNET_MORPHO_BLUE_USDE_DAI_182DAY,
MAINNET_MORPHO_BLUE_WSTETH_USDC_182DAY,
MAINNET_MORPHO_BLUE_WSTETH_USDA_182DAY,
MAINNET_STUSD_182DAY,
],
Expand Down
1 change: 1 addition & 0 deletions tasks/deploy/config/mainnet/erc4626-coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const MAINNET_ERC4626_COORDINATOR: HyperdriveCoordinatorConfig<"ERC4626">
name: MAINNET_ERC4626_COORDINATOR_NAME,
prefix: "ERC4626",
targetCount: 5,
extraConstructorArgs: [],
factoryAddress: async (hre) =>
hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME)
.address,
Expand Down
19 changes: 12 additions & 7 deletions tasks/deploy/config/mainnet/morpho-blue-wsteth-usda-182day.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
encodeAbiParameters,
keccak256,
parseEther,
toBytes,
zeroAddress,
} from "viem";
import {
Expand All @@ -12,7 +13,7 @@ import {
getLinkerDetails,
normalizeFee,
parseDuration,
toBytes,
toBytes32,
} from "../../lib";
import { MAINNET_FACTORY_NAME } from "./factory";
import { MAINNET_MORPHO_BLUE_COORDINATOR_NAME } from "./morpho-blue-coordinator";
Expand Down Expand Up @@ -100,6 +101,11 @@ export const MAINNET_MORPHO_BLUE_WSTETH_USDA_182DAY: HyperdriveInstanceConfig<"M
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: USDA_ADDRESS_MAINNET,
vaultSharesToken: zeroAddress,
Expand All @@ -109,12 +115,11 @@ export const MAINNET_MORPHO_BLUE_WSTETH_USDA_182DAY: HyperdriveInstanceConfig<"M
positionDuration: parseDuration(SIX_MONTHS),
checkpointDuration: parseDuration("1 day"),
timeStretch: 0n,
governance: (await hre.getNamedAccounts())[
"deployer"
] as Address,
feeCollector: zeroAddress,
sweepCollector: zeroAddress,
checkpointRewarder: zeroAddress,
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(
Expand Down
18 changes: 11 additions & 7 deletions tasks/deploy/config/mainnet/stusd-182day.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, keccak256, parseEther, toBytes, zeroAddress } from "viem";
import { Address, keccak256, parseEther, toBytes } from "viem";
import {
HyperdriveInstanceConfig,
getLinkerDetails,
Expand Down Expand Up @@ -31,7 +31,7 @@ export const MAINNET_STUSD_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
salt: toBytes32("0x69420"),
extraData: "0x",
contribution: CONTRIBUTION,
fixedAPR: parseEther("0.0829"),
fixedAPR: parseEther("0.0666"),
timestretchAPR: parseEther("0.075"),
options: async (hre) => ({
extraData: "0x",
Expand All @@ -54,6 +54,11 @@ export const MAINNET_STUSD_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
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: USDA_ADDRESS_MAINNET,
vaultSharesToken: STUSD_ADDRESS_MAINNET,
Expand All @@ -63,11 +68,10 @@ export const MAINNET_STUSD_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
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,
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)
Expand Down
7 changes: 5 additions & 2 deletions tasks/deploy/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ task(

// form target constructor args
let targetArgs:
| [typeof poolConfig]
| [typeof poolConfig, `0x${string}`]
| [typeof poolConfig, `0x${string}`, `0x${string}`]
| [
typeof poolConfig,
{
Expand All @@ -204,6 +204,7 @@ task(
irm: Address;
lltv: bigint;
},
`0x${string}`,
] = [poolConfig];

// add extra args if present
Expand All @@ -215,7 +216,7 @@ task(
let isMorpho =
(await instanceContract.read.kind()) == "MorphoBlueHyperdrive";
if (extras) {
targetArgs = [poolConfig, ...extras];
targetArgs = [poolConfig, factoryAddress, ...extras];
} else if (isMorpho) {
let morphoInstanceContract = await hre.viem.getContractAt(
"IMorphoBlueHyperdrive",
Expand All @@ -231,6 +232,7 @@ task(
irm: await morphoInstanceContract.read.irm(),
lltv: await morphoInstanceContract.read.lltv(),
},
factoryAddress,
];
}

Expand Down Expand Up @@ -265,6 +267,7 @@ task(
let args = [
i.name,
poolConfig,
factoryAddress,
await ihyperdrive.read.target0(),
await ihyperdrive.read.target1(),
await ihyperdrive.read.target2(),
Expand Down
Loading

0 comments on commit 799a60a

Please sign in to comment.