-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented the mainnet deployment scripts (#1072)
* Started writing the mainnet configuration * Added the mainnet deployment scripts * Update the version * Changed the name of the registry * Fixed the deployment flow * Updated the scripts * Fixed the registry script
- Loading branch information
1 parent
7d0c8d9
commit fd37a51
Showing
16 changed files
with
328 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import "@nomicfoundation/hardhat-foundry"; | ||
import "@nomicfoundation/hardhat-toolbox-viem"; | ||
import "@nomicfoundation/hardhat-viem"; | ||
import "dotenv/config"; | ||
import "hardhat-deploy"; | ||
import { HardhatUserConfig } from "hardhat/config"; | ||
import baseConfig from "./hardhat.config"; | ||
import "./tasks"; | ||
import { | ||
MAINNET_DAI_182DAY, | ||
MAINNET_ERC4626_COORDINATOR, | ||
MAINNET_FACTORY, | ||
MAINNET_STETH_182DAY, | ||
MAINNET_STETH_COORDINATOR, | ||
} from "./tasks/deploy/config/mainnet"; | ||
|
||
const { env } = process; | ||
|
||
const config: HardhatUserConfig = { | ||
...baseConfig, | ||
networks: { | ||
mainnet: { | ||
live: true, | ||
url: env.HYPERDRIVE_ETHEREUM_URL!, | ||
accounts: [env.DEPLOYER_PRIVATE_KEY!, env.PAUSER_PRIVATE_KEY!], | ||
hyperdriveDeploy: { | ||
factories: [MAINNET_FACTORY], | ||
coordinators: [ | ||
MAINNET_ERC4626_COORDINATOR, | ||
MAINNET_STETH_COORDINATOR, | ||
], | ||
instances: [MAINNET_DAI_182DAY, MAINNET_STETH_182DAY], | ||
checkpointRewarders: [], | ||
checkpointSubrewarders: [], | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Address, keccak256, parseEther, toBytes, zeroAddress } from "viem"; | ||
import { | ||
HyperdriveInstanceConfig, | ||
getLinkerDetails, | ||
normalizeFee, | ||
parseDuration, | ||
toBytes32, | ||
} from "../../lib"; | ||
import { | ||
MAINNET_DAI_ADDRESS, | ||
MAINNET_SDAI_ADDRESS, | ||
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_DAI_182DAY_NAME = "ElementDAO 182 Day sDAI Hyperdrive"; | ||
|
||
// The initial contribution of the pool. | ||
const CONTRIBUTION = parseEther("100"); | ||
|
||
export const MAINNET_DAI_182DAY: HyperdriveInstanceConfig<"ERC4626"> = { | ||
name: MAINNET_DAI_182DAY_NAME, | ||
prefix: "ERC4626", | ||
coordinatorAddress: async (hre) => | ||
hre.hyperdriveDeploy.deployments.byName( | ||
MAINNET_ERC4626_COORDINATOR_NAME, | ||
).address, | ||
deploymentId: keccak256(toBytes(MAINNET_DAI_182DAY_NAME)), | ||
salt: toBytes32("0x69420"), | ||
extraData: "0x", | ||
contribution: CONTRIBUTION, | ||
fixedAPR: parseEther("0.08"), | ||
timestretchAPR: parseEther("0.05"), | ||
options: async (hre) => ({ | ||
extraData: "0x", | ||
asBase: true, | ||
destination: (await hre.getNamedAccounts())["deployer"] as Address, | ||
}), | ||
// Prepare to deploy the contract by setting approvals. | ||
prepare: async (hre) => { | ||
let baseToken = await hre.viem.getContractAt( | ||
"contracts/src/interfaces/IERC20.sol:IERC20", | ||
MAINNET_DAI_ADDRESS, | ||
); | ||
let tx = await baseToken.write.approve([ | ||
hre.hyperdriveDeploy.deployments.byName( | ||
MAINNET_ERC4626_COORDINATOR_NAME, | ||
).address, | ||
CONTRIBUTION, | ||
]); | ||
let pc = await hre.viem.getPublicClient(); | ||
await pc.waitForTransactionReceipt({ hash: tx }); | ||
}, | ||
poolDeployConfig: async (hre) => { | ||
return { | ||
baseToken: MAINNET_DAI_ADDRESS, | ||
vaultSharesToken: MAINNET_SDAI_ADDRESS, | ||
circuitBreakerDelta: parseEther("0.05"), | ||
minimumShareReserves: parseEther("10"), | ||
minimumTransactionAmount: parseEther("0.001"), | ||
positionDuration: parseDuration(SIX_MONTHS), | ||
checkpointDuration: parseDuration("1 day"), | ||
timeStretch: 0n, | ||
// TODO: Read from the factory. | ||
governance: (await hre.getNamedAccounts())["deployer"] as Address, | ||
feeCollector: zeroAddress, | ||
sweepCollector: zeroAddress, | ||
checkpointRewarder: zeroAddress, | ||
...(await getLinkerDetails( | ||
hre, | ||
hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME) | ||
.address, | ||
)), | ||
fees: { | ||
curve: parseEther("0.01"), | ||
flat: normalizeFee(parseEther("0.0005"), SIX_MONTHS), | ||
governanceLP: parseEther("0.15"), | ||
governanceZombie: parseEther("0.03"), | ||
}, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { HyperdriveCoordinatorConfig } from "../../lib"; | ||
import { MAINNET_FACTORY_NAME } from "./factory"; | ||
|
||
export const MAINNET_ERC4626_COORDINATOR_NAME = | ||
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator"; | ||
export const MAINNET_ERC4626_COORDINATOR: HyperdriveCoordinatorConfig<"ERC4626"> = | ||
{ | ||
name: MAINNET_ERC4626_COORDINATOR_NAME, | ||
prefix: "ERC4626", | ||
targetCount: 4, | ||
factoryAddress: async (hre) => | ||
hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME) | ||
.address, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Address, parseEther, zeroAddress } from "viem"; | ||
import { HyperdriveFactoryConfig, parseDuration } from "../../lib"; | ||
|
||
// The name of the factory. | ||
export const MAINNET_FACTORY_NAME = "ElementDAO Hyperdrive Factory"; | ||
|
||
// The name of the forwarder factory. | ||
export const MAINNET_FACTORY_FORWARDER_NAME = | ||
"ElementDAO ERC20 Factory Forwarder"; | ||
|
||
export const MAINNET_FACTORY: HyperdriveFactoryConfig = { | ||
name: MAINNET_FACTORY_NAME, | ||
prepare: async (hre, options) => { | ||
await hre.hyperdriveDeploy.ensureDeployed( | ||
MAINNET_FACTORY_FORWARDER_NAME, | ||
"ERC20ForwarderFactory", | ||
[MAINNET_FACTORY_FORWARDER_NAME], | ||
options, | ||
); | ||
}, | ||
constructorArguments: async (hre) => [ | ||
{ | ||
governance: (await hre.getNamedAccounts())["deployer"] as Address, | ||
deployerCoordinatorManager: (await hre.getNamedAccounts())[ | ||
"deployer" | ||
] as Address, | ||
hyperdriveGovernance: (await hre.getNamedAccounts())[ | ||
"deployer" | ||
] as Address, | ||
defaultPausers: [ | ||
(await hre.getNamedAccounts())["deployer"] as Address, | ||
(await hre.getNamedAccounts())["pauser"] as Address, | ||
], | ||
feeCollector: zeroAddress, | ||
sweepCollector: zeroAddress, | ||
checkpointRewarder: zeroAddress, | ||
checkpointDurationResolution: parseDuration("1 hours"), | ||
minCheckpointDuration: parseDuration("24 hours"), | ||
maxCheckpointDuration: parseDuration("24 hours"), | ||
minPositionDuration: parseDuration("7 days"), | ||
maxPositionDuration: parseDuration("730 days"), | ||
minFixedAPR: parseEther("0.005"), | ||
maxFixedAPR: parseEther("0.1"), | ||
minTimeStretchAPR: parseEther("0.005"), | ||
maxTimeStretchAPR: parseEther("0.1"), | ||
minCircuitBreakerDelta: parseEther("0.01"), | ||
maxCircuitBreakerDelta: parseEther("0.2"), | ||
minFees: { | ||
curve: parseEther("0.001"), | ||
flat: parseEther("0.0001"), | ||
governanceLP: parseEther("0.15"), | ||
governanceZombie: parseEther("0.03"), | ||
}, | ||
maxFees: { | ||
curve: parseEther("0.05"), | ||
flat: parseEther("0.005"), | ||
governanceLP: parseEther("0.15"), | ||
governanceZombie: parseEther("0.03"), | ||
}, | ||
linkerFactory: hre.hyperdriveDeploy.deployments.byName( | ||
MAINNET_FACTORY_FORWARDER_NAME, | ||
).address, | ||
linkerCodeHash: await ( | ||
await hre.viem.getContractAt( | ||
"ERC20ForwarderFactory", | ||
hre.hyperdriveDeploy.deployments.byName( | ||
MAINNET_FACTORY_FORWARDER_NAME, | ||
).address, | ||
) | ||
).read.ERC20LINK_HASH(), | ||
}, | ||
MAINNET_FACTORY_NAME, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from "./dai-182day"; | ||
export * from "./erc4626-coordinator"; | ||
export * from "./factory"; | ||
export * from "./steth-182day"; | ||
export * from "./steth-coordinator"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Address, keccak256, parseEther, toBytes, zeroAddress } from "viem"; | ||
import { | ||
ETH_ADDRESS, | ||
HyperdriveInstanceConfig, | ||
MAINNET_STETH_ADDRESS, | ||
SIX_MONTHS, | ||
getLinkerDetails, | ||
normalizeFee, | ||
parseDuration, | ||
toBytes32, | ||
} from "../../lib"; | ||
import { MAINNET_FACTORY_NAME } from "./factory"; | ||
import { MAINNET_STETH_COORDINATOR_NAME } from "./steth-coordinator"; | ||
|
||
// The name of the pool. | ||
export const MAINNET_STETH_182DAY_NAME = "ElementDAO 182 Day stETH Hyperdrive"; | ||
|
||
// The initial contribution of the pool. | ||
const CONTRIBUTION = parseEther("0.01"); | ||
|
||
export const MAINNET_STETH_182DAY: HyperdriveInstanceConfig<"StETH"> = { | ||
name: MAINNET_STETH_182DAY_NAME, | ||
prefix: "StETH", | ||
coordinatorAddress: async (hre) => | ||
hre.hyperdriveDeploy.deployments.byName(MAINNET_STETH_COORDINATOR_NAME) | ||
.address, | ||
deploymentId: keccak256(toBytes(MAINNET_STETH_182DAY_NAME)), | ||
salt: toBytes32("0xababe"), | ||
extraData: "0x", | ||
contribution: CONTRIBUTION, | ||
fixedAPR: parseEther("0.0314"), | ||
timestretchAPR: parseEther("0.035"), | ||
options: async (hre) => ({ | ||
asBase: false, | ||
extraData: "0x", | ||
destination: (await hre.getNamedAccounts())["deployer"] as Address, | ||
}), | ||
prepare: async (hre) => { | ||
// approve the coordinator | ||
let vaultSharesToken = await hre.viem.getContractAt( | ||
"ILido", | ||
MAINNET_STETH_ADDRESS, | ||
); | ||
let pc = await hre.viem.getPublicClient(); | ||
let tx = await vaultSharesToken.write.approve([ | ||
hre.hyperdriveDeploy.deployments.byName( | ||
MAINNET_STETH_COORDINATOR_NAME, | ||
).address, | ||
await vaultSharesToken.read.getPooledEthByShares([CONTRIBUTION]), | ||
]); | ||
await pc.waitForTransactionReceipt({ hash: tx }); | ||
}, | ||
poolDeployConfig: async (hre) => { | ||
return { | ||
baseToken: ETH_ADDRESS, | ||
vaultSharesToken: MAINNET_STETH_ADDRESS, | ||
circuitBreakerDelta: parseEther("0.035"), | ||
minimumShareReserves: parseEther("0.001"), | ||
minimumTransactionAmount: parseEther("0.001"), | ||
positionDuration: parseDuration(SIX_MONTHS), | ||
checkpointDuration: parseDuration("1 day"), | ||
timeStretch: 0n, | ||
governance: (await hre.getNamedAccounts())["deployer"] as Address, | ||
feeCollector: zeroAddress, | ||
sweepCollector: zeroAddress, | ||
checkpointRewarder: zeroAddress, | ||
...(await getLinkerDetails( | ||
hre, | ||
hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME) | ||
.address, | ||
)), | ||
fees: { | ||
curve: parseEther("0.01"), | ||
flat: normalizeFee(parseEther("0.0005"), SIX_MONTHS), | ||
governanceLP: parseEther("0.15"), | ||
governanceZombie: parseEther("0.03"), | ||
}, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { HyperdriveCoordinatorConfig, MAINNET_STETH_ADDRESS } from "../../lib"; | ||
import { MAINNET_FACTORY_NAME } from "./factory"; | ||
|
||
export const MAINNET_STETH_COORDINATOR_NAME = | ||
"ElementDAO stETH Hyperdrive Deployer Coordinator"; | ||
export const MAINNET_STETH_COORDINATOR: HyperdriveCoordinatorConfig<"StETH"> = { | ||
name: MAINNET_STETH_COORDINATOR_NAME, | ||
prefix: "StETH", | ||
factoryAddress: async (hre) => | ||
hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME).address, | ||
targetCount: 4, | ||
token: MAINNET_STETH_ADDRESS, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.