Skip to content

Commit

Permalink
Forknet Setup + Forknet morpho wsteth/usdc deploy + Forknet eeth depl…
Browse files Browse the repository at this point in the history
…oy (#1138)

* add missing token mint hh tasks

* update constants for rate maintenance script

* temp

* updated scripting

* dockerignore fixes

* add wsteth usdc to fork config

* add eeth fork deployment

* add fork instructions and update funded accounts

* add task to remove an instance from the registry

* remove unused mainnet fork deploy config

* fix code block indent

* remove state file (not used)

* addressing feedback: parameter updates to eeth and fix maintain-rate comment
  • Loading branch information
mcclurejt committed Aug 21, 2024
1 parent a76e266 commit 9361300
Show file tree
Hide file tree
Showing 49 changed files with 912 additions and 916 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ node_modules/
out/
target/
*.env
deployments.json
deployments.*.json
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,39 @@ To deploy the smart contracts, run:
NETWORK=<hardhat|anvil|sepolia|mainnet> make deploy
```

To deploy the smart contracts to a mainnet fork environment, run:
To deploy the smart contracts to a mainnet fork environment:

```sh
make deploy-fork
```
1. Add the contract deploy configuration(s) to `tasks/deploy/config/mainnet/`.
Make sure to import the configuration objects in
`tasks/deploy/config/mainnet/index.ts`.

1. Update `hardhat.config.mainnet_fork.ts` to include the new deployment
configurations.

1. In one terminal, start a local anvil fork instance:

```sh
anvil --fork-url <your_mainnet_rpc_url>
```

1. In another terminal, bootstrap the `mainnet_fork` network's deployments in
`deployments.local.json` with the mainnet contract addresses.
```sh
./scripts/bootstrap-fork.sh
```
1. Deploy any new contracts present in `hardhat.config.mainnet_fork.ts` that
have not already been deployed on mainnet.
```sh
NETWORK=mainnet_fork ADMIN=<your_deployer_address> ./scripts/deploy-fork.sh
```
To update the remote fork with these changes, first create a pull request and
obtain the latest version for the `devnet` image. The changes will be reflected
automatically after updating the remote fork's `devnet` image version and
restarting the containers.

### Generate Deploy Configurations

Expand Down
31 changes: 31 additions & 0 deletions deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,37 @@
"contract": "MorphoBlueHyperdrive",
"address": "0xd41225855A5c5Ba1C672CcF4d72D1822a5686d30",
"timestamp": "2024-08-08T15:43:26.033Z"
},
"ElementDAO 182 Day Morpho Blue USDe/DAI Hyperdrive_MorphoBlueTarget0": {
"contract": "MorphoBlueTarget0",
"address": "0x230c708944e0ce1fc470265628d3c64ECf7581F9",
"timestamp": "2024-08-14T19:30:51.687Z"
},
"ElementDAO 182 Day Morpho Blue USDe/DAI Hyperdrive_MorphoBlueTarget1": {
"contract": "MorphoBlueTarget1",
"address": "0x87a9305Ad62e72Ea7504B0B0029Ba832A61D4DF6",
"timestamp": "2024-08-14T19:30:03.423Z"
},
"ElementDAO 182 Day Morpho Blue USDe/DAI Hyperdrive_MorphoBlueTarget2": {
"contract": "MorphoBlueTarget2",
"address": "0xbb170C562d46ce71dAc431c4849cbE9d6cebf326",
"timestamp": "2024-08-14T19:30:16.496Z"
},
"ElementDAO 182 Day Morpho Blue USDe/DAI Hyperdrive_MorphoBlueTarget3": {
"contract": "MorphoBlueTarget3",
"address": "0x67a48DaF2F6E183a992647D685298A3a144af8CE",
"timestamp": "2024-08-14T19:30:29.489Z"
},
"ElementDAO 182 Day Morpho Blue USDe/DAI Hyperdrive_MorphoBlueTarget4": {
"contract": "MorphoBlueTarget4",
"address": "0xAA7fE6c0ec2f339ab829622926A8B61eA635662D",
"timestamp": "2024-08-14T19:30:38.431Z"
},
"ElementDAO 182 Day Morpho Blue USDe/DAI Hyperdrive": {
"contract": "MorphoBlueHyperdrive",
"address": "0xA29A771683b4857bBd16e1e4f27D5B6bfF53209B",
"timestamp": "2024-08-14T19:30:51.584Z"
}

}
}
50 changes: 25 additions & 25 deletions hardhat.config.mainnet_fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ import { HardhatUserConfig } from "hardhat/config";
import baseConfig from "./hardhat.config";
import "./tasks";
import {
MAINNET_FORK_CHECKPOINT_REWARDER,
MAINNET_FORK_CHECKPOINT_SUBREWARDER,
MAINNET_FORK_DAI_14DAY,
MAINNET_FORK_DAI_30DAY,
MAINNET_FORK_ERC4626_COORDINATOR,
MAINNET_FORK_FACTORY,
MAINNET_FORK_RETH_14DAY,
MAINNET_FORK_RETH_30DAY,
MAINNET_FORK_RETH_COORDINATOR,
MAINNET_FORK_STETH_14DAY,
MAINNET_FORK_STETH_30DAY,
MAINNET_FORK_STETH_COORDINATOR,
} from "./tasks/deploy/config/mainnet-fork";
MAINNET_EETH_182DAY,
MAINNET_EETH_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_USDC_182DAY,
MAINNET_RETH_182DAY,
MAINNET_RETH_COORDINATOR,
} from "./tasks/deploy/config/mainnet";

const { env } = process;
let DEFAULT_PK =
Expand All @@ -33,22 +32,23 @@ const config: HardhatUserConfig = {
url: env.HYPERDRIVE_ETHEREUM_URL ?? "http://anvil:8545",
accounts: [env.DEPLOYER_PRIVATE_KEY ?? DEFAULT_PK],
hyperdriveDeploy: {
checkpointRewarders: [MAINNET_FORK_CHECKPOINT_REWARDER],
checkpointSubrewarders: [MAINNET_FORK_CHECKPOINT_SUBREWARDER],
factories: [MAINNET_FORK_FACTORY],
factories: [MAINNET_FACTORY],
coordinators: [
MAINNET_FORK_ERC4626_COORDINATOR,
MAINNET_FORK_STETH_COORDINATOR,
MAINNET_FORK_RETH_COORDINATOR,
MAINNET_EZETH_COORDINATOR,
MAINNET_RETH_COORDINATOR,
MAINNET_MORPHO_BLUE_COORDINATOR,
MAINNET_EETH_COORDINATOR,
],
instances: [
MAINNET_FORK_DAI_14DAY,
MAINNET_FORK_DAI_30DAY,
MAINNET_FORK_STETH_14DAY,
MAINNET_FORK_STETH_30DAY,
MAINNET_FORK_RETH_14DAY,
MAINNET_FORK_RETH_30DAY,
MAINNET_EZETH_182DAY,
MAINNET_RETH_182DAY,
MAINNET_MORPHO_BLUE_SUSDE_DAI_182DAY,
MAINNET_MORPHO_BLUE_USDE_DAI_182DAY,
MAINNET_MORPHO_BLUE_WSTETH_USDC_182DAY,
MAINNET_EETH_182DAY,
],
checkpointRewarders: [],
checkpointSubrewarders: [],
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions scripts/bootstrap-fork.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -e

# Bootstrap the "mainnet_fork" addresses in `deployments.local.json`.
jq '.mainnet | { mainnet_fork: . }' <deployments.json >deployments.local.json
34 changes: 5 additions & 29 deletions scripts/deploy-fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,16 @@

set -e

# Ensure that the `ADMIN` variable is defined.
if [[ -z "${ADMIN}" ]]; then
echo 'Error: $ADMIN must be set'
exit 1
fi

# Mint some of each instance's token to the admin address.
npx hardhat fork:mint-eth --address ${ADMIN} --amount 1000 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat fork:mint-steth --address ${ADMIN} --amount 1000 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat fork:mint-reth --address ${ADMIN} --amount 1000 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat fork:mint-dai --address ${ADMIN} --amount 20000 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat fork:mint-sdai --address ${ADMIN} --amount 20000 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
# Mint some of each instance's token to the deployer address.
export NETWORK='mainnet_fork'
sh scripts/fund-fork-accounts.sh

# Deploy factory, coordinators, and instances.
npx hardhat deploy:hyperdrive --network mainnet_fork --config hardhat.config.mainnet_fork.ts --show-stack-traces

# Add all deployed instances to the registry.
npx hardhat registry:add --name DAI_14_DAY --value 1 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat registry:add --name DAI_30_DAY --value 1 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat registry:add --name STETH_14_DAY --value 1 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat registry:add --name STETH_30_DAY --value 1 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat registry:add --name RETH_14_DAY --value 1 --network mainnet_fork --config hardhat.config.mainnet_fork.ts
npx hardhat registry:add --name RETH_30_DAY --value 1 --network mainnet_fork --config hardhat.config.mainnet_fork.ts

# Extract the deployed contract addresses to `artifacts/addresses.json`
# for use with the delvtech/infra address server.
cat ./deployments.local.json | jq '.mainnet_fork | {
dai14Day: .DAI_14_DAY.address,
dai30Day: .DAI_30_DAY.address,
steth14Day: .STETH_14_DAY.address,
steth30Day: .STETH_30_DAY.address,
reth14Day: .RETH_14_DAY.address,
reth30Day: .RETH_30_DAY.address,
factory: .FACTORY.address,
hyperdriveRegistry: .["DELV Hyperdrive Registry"].address,
}' >./artifacts/addresses.json
hyperdriveRegistry: .["DELV Hyperdrive Registry"].address,
}' >./artifacts/addresses.json
cp ./deployments.local.json ./artifacts/
38 changes: 27 additions & 11 deletions scripts/fund-fork-accounts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,35 @@ if [[ -z "${NETWORK}" ]]; then
exit 1
fi

# Fund default anvil accounts if $ADMIN is not set.
if [[ -z "$ADMIN" ]]; then
addresses=('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC' '0x90F79bf6EB2c4f870365E785982E1f101E93b906' '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65' '0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc' '0x976EA74026E726554dB657fA54763abd0C3a0aa9' '0x14dC79964da2C08b23698B3D3cc7Ca32193d9955' '0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f' '0xa0Ee7A142d267C1f36714E4a8F75612F20a79720')
else
addresses=("${ADMIN}")
fi

# Mint tokens to all of the default anvil accounts.
addresses=('0x042CAb2Ea353fC48C9491bDbF10a12Cfe9072B6C' '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC' '0x90F79bf6EB2c4f870365E785982E1f101E93b906' '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65' '0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc' '0x976EA74026E726554dB657fA54763abd0C3a0aa9' '0x14dC79964da2C08b23698B3D3cc7Ca32193d9955' '0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f' '0xa0Ee7A142d267C1f36714E4a8F75612F20a79720' '0x004dfC2dBA6573fa4dFb1E86e3723e1070C0CfdE' '0x005182C62DA59Ff202D53d6E42Cef6585eBF9617' '0x005BB73FddB8CE049eE366b50d2f48763E9Dc0De' '0x0065291E64E40FF740aE833BE2F68F536A742b70' '0x0076b154e60BF0E9088FcebAAbd4A778deC5ce2c' '0x00860d89A40a5B4835a3d498fC1052De04996de6' '0x00905A77Dc202e618d15d1a04Bc340820F99d7C4' '0x009ef846DcbaA903464635B0dF2574CBEE66caDd' '0x00D5E029aFCE62738fa01EdCA21c9A4bAeabd434' '0x020A6F562884395A7dA2be0b607Bf824546699e2' '0x020a898437E9c9DCdF3c2ffdDB94E759C0DAdFB6' '0x020b42c1E3665d14275E2823bCef737015c7f787' '0x02147558D39cE51e19de3A2E1e5b7c8ff2778829' '0x021f1Bbd2Ec870FB150bBCAdaaA1F85DFd72407C' '0x02237E07b7Ac07A17E1bdEc720722cb568f22840' '0x022ca016Dc7af612e9A8c5c0e344585De53E9667' '0x0235037B42b4c0575c2575D50D700dD558098b78')
for address in "${addresses[@]}"
do
echo "funding ${address}..."
echo " - funding ${address} eth..."
npx hardhat fork:mint-eth --address ${address} --amount 1000 --network ${NETWORK} --config hardhat.config.${NETWORK}.ts
echo " - funding ${address} steth..."
npx hardhat fork:mint-steth --address ${address} --amount 1000 --network ${NETWORK} --config hardhat.config.${NETWORK}.ts
echo " - funding ${address} reth..."
npx hardhat fork:mint-reth --address ${address} --amount 1000 --network ${NETWORK} --config hardhat.config.${NETWORK}.ts
echo " - funding ${address} dai..."
npx hardhat fork:mint-dai --address ${address} --amount 20000 --network ${NETWORK} --config hardhat.config.${NETWORK}.ts
echo " - funding ${address} sdai..."
npx hardhat fork:mint-sdai --address ${address} --amount 20000 --network ${NETWORK} --config hardhat.config.${NETWORK}.ts
echo " - funding eth..."
npx hardhat fork:mint-eth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding dai..."
npx hardhat fork:mint-dai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding eeth..."
npx hardhat fork:mint-eeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding ezeth..."
npx hardhat fork:mint-ezeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding reth..."
npx hardhat fork:mint-reth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding sdai..."
npx hardhat fork:mint-sdai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding steth..."
npx hardhat fork:mint-steth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding usde..."
npx hardhat fork:mint-usde --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding wsteth..."
npx hardhat fork:mint-wsteth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
echo " - funding usdc..."
npx hardhat fork:mint-usdc --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
done
12 changes: 0 additions & 12 deletions tasks/deploy/config/mainnet-fork/checkpoint-rewarder.ts

This file was deleted.

64 changes: 0 additions & 64 deletions tasks/deploy/config/mainnet-fork/checkpoint-subrewarder.ts

This file was deleted.

Loading

0 comments on commit 9361300

Please sign in to comment.