Skip to content

Commit

Permalink
use existing create2 deployer so that we don't have to worry about de…
Browse files Browse the repository at this point in the history
…ployer nonces (#1150)

* use existing create2 deployer so that we don't have to worry about deployer nonces

* add bytecode hash script and update registry deploy script to use hex salt

* deploy wstETH & sxDAI pools to gnosis

* fix remappings

* prettier

* fix devnet image

* another devnet fix

* fix

* fix

* f
  • Loading branch information
mcclurejt authored Aug 30, 2024
1 parent bcffe9c commit 6bb72b2
Show file tree
Hide file tree
Showing 15 changed files with 274 additions and 43 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_hyperdrivetypes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- "v*"

jobs:

build-wheel:
name: build hyperdrivetypes wheel
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/devnet_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
build-args: |
ADMIN=${{ vars.DEVNET_ADMIN }}
DEPLOYER_PRIVATE_KEY=${{ vars.DEVNET_ADMIN_PRIVATE_KEY }}
REGISTRY_SALT=${{ vars.REGISTRY_SALT }}
FACTORY_MIN_CURVE_FEE=0 # 0%
FACTORY_MIN_FLAT_FEE=0 # 0%
FACTORY_MIN_GOVERNANCE_LP_FEE=0 # 0%
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_hyperdrivetypes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
- name: generate hyperdrivetypes files
run: make build

- name: install hyperdrivetypes
run: python -m pip install python/hyperdrivetypes[all]

- name: run type checker
run: python -m pyright python/

- name: run tests
run: make test-python
run: make test-python
1 change: 1 addition & 0 deletions .github/workflows/testnet_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ADMIN=${{ vars.TESTNET_ADMIN }}
REGISTRY_SALT=${{ vars.REGISTRY_SALT }}
DEPLOYER_PRIVATE_KEY=${{ vars.TESTNET_ADMIN_PRIVATE_KEY }}
IS_COMPETITION_MODE=true
BASE_TOKEN_NAME=Multi Collateral DAI
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
[submodule "lib/morpho-blue"]
path = lib/morpho-blue
url = https://github.com/morpho-org/morpho-blue
[submodule "lib/createx"]
path = lib/createx
url = https://github.com/pcaversaccio/createx
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ ARG NETWORK=anvil
ARG HYPERDRIVE_ETHEREUM_URL=http://127.0.0.1:8545
ARG ADMIN=0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
ARG DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
ARG REGISTRY_SALT
ENV REGISTRY_SALT=${REGISTRY_SALT}
ARG IS_COMPETITION_MODE=false
ARG BASE_TOKEN_NAME=Base
ARG BASE_TOKEN_SYMBOL=BASE
Expand Down Expand Up @@ -80,7 +82,7 @@ ARG STETH_HYPERDRIVE_GOVERNANCE_LP_FEE=0.15
ARG STETH_HYPERDRIVE_GOVERNANCE_ZOMBIE_FEE=0.03
RUN anvil --dump-state ./data & ANVIL="$!" && \
sleep 2 && \
npx hardhat fork:mint-eth --address ${ADMIN} --amount 10 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
npx hardhat fork:mint-eth --address ${ADMIN} --amount 50 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
make deploy && \
npx hardhat registry:add --name ERC4626_HYPERDRIVE --value 1 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
npx hardhat registry:add --name STETH_HYPERDRIVE --value 1 --network ${NETWORK} --config "hardhat.config.${NETWORK}.ts" && \
Expand Down
7 changes: 7 additions & 0 deletions contracts/src/interfaces/IDeterministicDeployer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

import { ICreateX } from "createx/ICreateX.sol";

/// @notice This is included so that it appears in artifacts for tooling.
interface IDeterministicDeployer is ICreateX {}
152 changes: 152 additions & 0 deletions deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -867,5 +867,157 @@
"address": "0xA29A771683b4857bBd16e1e4f27D5B6bfF53209B",
"timestamp": "2024-08-14T19:30:51.584Z"
}
},
"gnosis": {
"DELV Hyperdrive Registry": {
"contract": "HyperdriveRegistry",
"address": "0x666fa9ef9bca174a042c4c306b23ba8ee0c59666",
"timestamp": "2024-08-29T18:26:34.726Z"
},
"ElementDAO ERC20 Factory Forwarder": {
"contract": "ERC20ForwarderFactory",
"address": "0xe61fb0f6a265f614ca6bf2ee83bbc463cb34da38",
"timestamp": "2024-08-29T18:26:44.380Z"
},
"ElementDAO Hyperdrive Factory": {
"contract": "HyperdriveFactory",
"address": "0xd9400ab142b4ad18c181538b76522334e0cd8d37",
"timestamp": "2024-08-29T18:26:54.281Z"
},
"ElementDAO Chainlink Hyperdrive Deployer Coordinator_ChainlinkHyperdriveCoreDeployer": {
"contract": "ChainlinkHyperdriveCoreDeployer",
"address": "0xbe082293b646cb619a638d29e8eff7cf2f46aa3a",
"timestamp": "2024-08-29T18:27:03.986Z"
},
"LPMath": {
"contract": "LPMath",
"address": "0x08b40647714ac1e5742633fc2d83c20d61a199d2",
"timestamp": "2024-08-29T18:27:13.666Z"
},
"ElementDAO Chainlink Hyperdrive Deployer Coordinator_ChainlinkTarget0Deployer": {
"contract": "ChainlinkTarget0Deployer",
"address": "0xf95b98256edb861be389b9807f6656e8be2dc488",
"timestamp": "2024-08-29T18:27:23.216Z"
},
"ElementDAO Chainlink Hyperdrive Deployer Coordinator_ChainlinkTarget1Deployer": {
"contract": "ChainlinkTarget1Deployer",
"address": "0xdf5d682404b0611f46f2626d9d5a37eb6a6fd27d",
"timestamp": "2024-08-29T18:27:32.880Z"
},
"ElementDAO Chainlink Hyperdrive Deployer Coordinator_ChainlinkTarget2Deployer": {
"contract": "ChainlinkTarget2Deployer",
"address": "0xd9bdabb0f87e46af44063d251eb07edfe260d9f1",
"timestamp": "2024-08-29T18:27:42.562Z"
},
"ElementDAO Chainlink Hyperdrive Deployer Coordinator_ChainlinkTarget3Deployer": {
"contract": "ChainlinkTarget3Deployer",
"address": "0x2bbf0716fb1ac91169b0dbecff232c7bf1b7e701",
"timestamp": "2024-08-29T18:27:52.145Z"
},
"ElementDAO Chainlink Hyperdrive Deployer Coordinator_ChainlinkTarget4Deployer": {
"contract": "ChainlinkTarget4Deployer",
"address": "0x068d5258f54b462de4240547dca0f1fce6382426",
"timestamp": "2024-08-29T18:27:57.586Z"
},
"ElementDAO Chainlink Hyperdrive Deployer Coordinator": {
"contract": "ChainlinkHyperdriveDeployerCoordinator",
"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",
"timestamp": "2024-08-29T18:30:27.435Z"
},
"ElementDAO 182 Day wstETH Hyperdrive_ChainlinkTarget1": {
"contract": "ChainlinkTarget1",
"address": "0xEb9f3848aCD0c0766FD4c117B4C440A5acAC7a9A",
"timestamp": "2024-08-29T18:29:48.460Z"
},
"ElementDAO 182 Day wstETH Hyperdrive_ChainlinkTarget2": {
"contract": "ChainlinkTarget2",
"address": "0x2E54EBA93F35817CE75090AE6F026e138b4549CD",
"timestamp": "2024-08-29T18:29:58.122Z"
},
"ElementDAO 182 Day wstETH Hyperdrive_ChainlinkTarget3": {
"contract": "ChainlinkTarget3",
"address": "0x174D04D254F9B7D85Da3e80B09ad24034E47151a",
"timestamp": "2024-08-29T18:30:07.871Z"
},
"ElementDAO 182 Day wstETH Hyperdrive_ChainlinkTarget4": {
"contract": "ChainlinkTarget4",
"address": "0x121439b3a97dC7CCbdEDd352096Aaef740f42C54",
"timestamp": "2024-08-29T18:30:17.501Z"
},
"ElementDAO 182 Day wstETH Hyperdrive": {
"contract": "ChainlinkHyperdrive",
"address": "0x2f840f1575EE77adAa43415Ac5953F7Db9F8C6ba",
"timestamp": "2024-08-29T18:30:27.213Z"
},
"ElementDAO 182 Day sxDAI Hyperdrive_ERC4626Target0": {
"contract": "ERC4626Target0",
"address": "0xDC7AdBc302785C3c95ffa288f7287237E434b706",
"timestamp": "2024-08-29T18:31:32.656Z"
},
"ElementDAO 182 Day sxDAI Hyperdrive_ERC4626Target1": {
"contract": "ERC4626Target1",
"address": "0x92eA2678aFCd2f7c76DDfC4488ad7Af68215253c",
"timestamp": "2024-08-29T18:30:53.720Z"
},
"ElementDAO 182 Day sxDAI Hyperdrive_ERC4626Target2": {
"contract": "ERC4626Target2",
"address": "0xD304b96d64B5CB13060B5677CdF41E3850E3fCD6",
"timestamp": "2024-08-29T18:31:03.353Z"
},
"ElementDAO 182 Day sxDAI Hyperdrive_ERC4626Target3": {
"contract": "ERC4626Target3",
"address": "0xde92e963a7e8945B09495576cEcAaEc72506501C",
"timestamp": "2024-08-29T18:31:13.002Z"
},
"ElementDAO 182 Day sxDAI Hyperdrive_ERC4626Target4": {
"contract": "ERC4626Target4",
"address": "0x859b393d89F57649c8bfaA32F6E342f30f3F7eA0",
"timestamp": "2024-08-29T18:31:22.719Z"
},
"ElementDAO 182 Day sxDAI Hyperdrive": {
"contract": "ERC4626Hyperdrive",
"address": "0xEe9BFf933aDD313C4289E98dA80fEfbF9d5Cd9Ba",
"timestamp": "2024-08-29T18:31:32.479Z"
}
}
}
15 changes: 8 additions & 7 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ cache = true
cache_path = 'forge-cache'
# Import statement remappings
remappings = [
'aave=lib/aave-v3-core/contracts',
'forge-std=lib/forge-std/src',
'morpho-blue=lib/morpho-blue',
'nomad=lib/ExcessivelySafeCall/src',
'openzeppelin=lib/openzeppelin-contracts/contracts',
'solmate=lib/solmate/src',
'etherfi=lib/smart-contracts',
'aave/=lib/aave-v3-core/contracts',
'forge-std/=lib/forge-std/src',
'morpho-blue/=lib/morpho-blue',
'nomad/=lib/ExcessivelySafeCall/src',
'openzeppelin/=lib/openzeppelin-contracts/contracts',
'solmate/=lib/solmate/src',
'etherfi/=lib/smart-contracts',
'createx/=lib/createx/src',
]
# gas limit - max u64
gas_limit = "18446744073709551615"
Expand Down
15 changes: 14 additions & 1 deletion hardhat.config.gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const config: HardhatUserConfig = {
networks: {
gnosis: {
live: true,
chainId: 100,
url: env.HYPERDRIVE_ETHEREUM_URL!,
accounts: [env.DEPLOYER_PRIVATE_KEY!, env.PAUSER_PRIVATE_KEY!],
hyperdriveDeploy: {
Expand All @@ -36,7 +37,19 @@ const config: HardhatUserConfig = {
},
},
etherscan: {
apiKey: env.GNOSISSCAN_API_KEY ?? "",
customChains: [
{
network: "gnosis",
chainId: 100,
urls: {
apiURL: "https://api.gnosisscan.io/api",
browserURL: "https://gnosisscan.io/",
},
},
],
apiKey: {
gnosis: env.GNOSISSCAN_API_KEY ?? "",
},
},
};

Expand Down
1 change: 1 addition & 0 deletions lib/createx
Submodule createx added at cbac80
1 change: 1 addition & 0 deletions tasks/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export * from "./hyperdrive";
export * from "./instance";
export * from "./lib";
export * from "./registry";
export * from "./registry-create2-info";
export * from "./verify";
16 changes: 16 additions & 0 deletions tasks/deploy/lib/constants.ts

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions tasks/deploy/registry-create2-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { task } from "hardhat/config";
import { encodeAbiParameters, encodePacked, keccak256 } from "viem";
import {
HyperdriveDeployNamedTask,
HyperdriveDeployNamedTaskParams,
} from "./lib";

export type RegistryCreate2InfoParams = HyperdriveDeployNamedTaskParams;

HyperdriveDeployNamedTask(
task(
"registry-create2-info",
"prints the bytecode hash of a HyperdriveRegistry with the provided name",
),
).setAction(async ({ name }: RegistryCreate2InfoParams, { artifacts }) => {
// Assemble the creation code by packing the registry contract's
// bytecode with its constructor arguments.
let artifact = artifacts.readArtifactSync("HyperdriveRegistry");
let creationCode = encodePacked(
["bytes", "bytes"],
[
artifact.bytecode,
encodeAbiParameters([{ name: "_name", type: "string" }], [name]),
],
);
let hash = keccak256(creationCode);
console.log(`HASH: ${hash}`);
});
Loading

0 comments on commit 6bb72b2

Please sign in to comment.