Skip to content

Commit fbfa3fe

Browse files
authored
add deployment config for gnosis wsteth and sxdai hyperdrives (#1143)
* add deployment config for gnosis wsteth sxdai * gnosis fork prep * update funding script * add rate incrementing for gnosis wsteth * addressing feedback: update configuration and source addresses from factory
1 parent 548e6a2 commit fbfa3fe

16 files changed

+643
-113
lines changed

hardhat.config.gnosis.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import "@nomicfoundation/hardhat-foundry";
2+
import "@nomicfoundation/hardhat-toolbox-viem";
3+
import "@nomicfoundation/hardhat-viem";
4+
import "dotenv/config";
5+
import "hardhat-deploy";
6+
import { HardhatUserConfig } from "hardhat/config";
7+
import baseConfig from "./hardhat.config";
8+
import "./tasks";
9+
import {
10+
GNOSIS_CHAINLINK_COORDINATOR,
11+
GNOSIS_ERC4626_COORDINATOR,
12+
GNOSIS_FACTORY,
13+
GNOSIS_SXDAI_182DAY,
14+
GNOSIS_WSTETH_182DAY,
15+
} from "./tasks/deploy/config/gnosis";
16+
17+
const { env } = process;
18+
19+
const config: HardhatUserConfig = {
20+
...baseConfig,
21+
networks: {
22+
gnosis: {
23+
live: true,
24+
url: env.HYPERDRIVE_ETHEREUM_URL!,
25+
accounts: [env.DEPLOYER_PRIVATE_KEY!, env.PAUSER_PRIVATE_KEY!],
26+
hyperdriveDeploy: {
27+
factories: [GNOSIS_FACTORY],
28+
coordinators: [
29+
GNOSIS_CHAINLINK_COORDINATOR,
30+
GNOSIS_ERC4626_COORDINATOR,
31+
],
32+
instances: [GNOSIS_WSTETH_182DAY, GNOSIS_SXDAI_182DAY],
33+
checkpointRewarders: [],
34+
checkpointSubrewarders: [],
35+
},
36+
},
37+
},
38+
etherscan: {
39+
apiKey: env.GNOSISSCAN_API_KEY ?? "",
40+
},
41+
};
42+
43+
export default config;

hardhat.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const config: HardhatUserConfig = {
1313
viaIR: false,
1414
optimizer: {
1515
enabled: true,
16-
runs: 10000000,
16+
runs: 13000,
1717
},
1818
evmVersion: "paris",
1919
metadata: {

scripts/deploy-fork.sh

+24-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,34 @@
22

33
set -e
44

5+
# Ensure that the NETWORK variable is defined.
6+
if [[ -z "$NETWORK" ]]; then
7+
echo 'Error: $NETWORK must be set'
8+
exit 1
9+
fi
10+
11+
# Ensure that the ADMIN variable is defined.
12+
if [[ -z "$ADMIN" ]]; then
13+
echo 'Error: $ADMIN must be set'
14+
exit 1
15+
fi
16+
517
# Mint some of each instance's token to the deployer address.
6-
export NETWORK='mainnet_fork'
718
sh scripts/fund-fork-accounts.sh
819

920
# Deploy factory, coordinators, and instances.
10-
npx hardhat deploy:hyperdrive --network mainnet_fork --config hardhat.config.mainnet_fork.ts --show-stack-traces
21+
npx hardhat deploy:hyperdrive --network $NETWORK --config hardhat.config.$NETWORK.ts --show-stack-traces
1122

1223
# Extract the deployed contract addresses to `artifacts/addresses.json`
1324
# for use with the delvtech/infra address server.
14-
cat ./deployments.local.json | jq '.mainnet_fork | {
15-
hyperdriveRegistry: .["DELV Hyperdrive Registry"].address,
16-
}' >./artifacts/addresses.json
17-
cp ./deployments.local.json ./artifacts/
25+
if [ "$NETWORK" == "mainnet_fork" ]; then
26+
cat ./deployments.local.json | jq ".mainnet_fork | {
27+
hyperdriveRegistry: .[\"DELV Hyperdrive Registry\"].address,
28+
}" >./artifacts/addresses.json
29+
cp ./deployments.local.json ./artifacts/
30+
else
31+
cat ./deployments.json | jq ".$NETWORK | {
32+
hyperdriveRegistry: .[\"DELV Hyperdrive Registry\"].address,
33+
}" >./artifacts/addresses.json
34+
cp ./deployments.json ./artifacts/
35+
fi

scripts/deploy.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ set -e
44

55
# Ensure that the network variable is defined
66
if [[ -z "${NETWORK}" ]]; then
7-
echo 'Error: $NETWORK must be set'
8-
exit 1
7+
echo 'Error: $NETWORK must be set'
8+
exit 1
99
fi
1010

1111
# When deploying to "live" networks, ensure that the repository is equivalent
1212
# to the latest remote tag. This avoids accidentally deploying out-of-date or
1313
# ambiguously versioned contracts.
1414
if [[ "${NETWORK}" != "anvil" && "${NETWORK}" != "hardhat" && "${NETWORK}" != "mainnet_fork" ]]; then
15-
git remote update
16-
tag=$(git describe --tags --abbrev=0)
17-
diff=$(git diff ${tag} --raw -- contracts lib)
18-
if [[ ! -z "${diff}" ]]; then
19-
echo "$diff"
20-
echo "Error: repository contents must match tag ${tag}"
21-
exit 1
22-
fi
15+
git remote update
16+
tag=$(git describe --tags --abbrev=0)
17+
diff=$(git diff ${tag} --raw -- contracts lib)
18+
if [[ ! -z "${diff}" ]]; then
19+
echo "$diff"
20+
echo "Error: repository contents must match tag ${tag}"
21+
exit 1
22+
fi
2323
fi
2424

2525
config_filename="hardhat.config.${NETWORK}.ts"
2626
if [[ "${NETWORK}" == "hardhat" ]]; then
27-
config_filename="hardhat.config.ts"
27+
config_filename="hardhat.config.ts"
2828
fi
2929
npx hardhat deploy:hyperdrive --show-stack-traces --network ${NETWORK} --config "$config_filename"
3030
npx hardhat deploy:verify --show-stack-traces --network ${NETWORK} --config "$config_filename"

scripts/fund-fork-accounts.sh

+34-21
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,44 @@ fi
1212
if [[ -z "$ADMIN" ]]; then
1313
addresses=('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC' '0x90F79bf6EB2c4f870365E785982E1f101E93b906' '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65' '0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc' '0x976EA74026E726554dB657fA54763abd0C3a0aa9' '0x14dC79964da2C08b23698B3D3cc7Ca32193d9955' '0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f' '0xa0Ee7A142d267C1f36714E4a8F75612F20a79720')
1414
else
15-
addresses=("${ADMIN}")
15+
addresses=( "$ADMIN" )
1616
fi
1717

1818
# Mint tokens to all of the default anvil accounts.
1919
for address in "${addresses[@]}"
2020
do
2121
echo "funding ${address}..."
22-
echo " - funding eth..."
23-
npx hardhat fork:mint-eth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
24-
echo " - funding dai..."
25-
npx hardhat fork:mint-dai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
26-
echo " - funding eeth..."
27-
npx hardhat fork:mint-eeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
28-
echo " - funding ezeth..."
29-
npx hardhat fork:mint-ezeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
30-
echo " - funding reth..."
31-
npx hardhat fork:mint-reth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
32-
echo " - funding sdai..."
33-
npx hardhat fork:mint-sdai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
34-
echo " - funding steth..."
35-
npx hardhat fork:mint-steth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
36-
echo " - funding usde..."
37-
npx hardhat fork:mint-usde --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
38-
echo " - funding wsteth..."
39-
npx hardhat fork:mint-wsteth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
40-
echo " - funding usdc..."
41-
npx hardhat fork:mint-usdc --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
22+
23+
if [ "$NETWORK" = "mainnet_fork" ]; then
24+
echo " - funding eth..."
25+
npx hardhat fork:mint-eth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
26+
echo " - funding dai..."
27+
npx hardhat fork:mint-dai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
28+
echo " - funding eeth..."
29+
npx hardhat fork:mint-eeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
30+
echo " - funding ezeth..."
31+
npx hardhat fork:mint-ezeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
32+
echo " - funding reth..."
33+
npx hardhat fork:mint-reth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
34+
echo " - funding sdai..."
35+
npx hardhat fork:mint-sdai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
36+
echo " - funding steth..."
37+
npx hardhat fork:mint-steth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
38+
echo " - funding usde..."
39+
npx hardhat fork:mint-usde --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
40+
echo " - funding wsteth..."
41+
npx hardhat fork:mint-wsteth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
42+
echo " - funding usdc..."
43+
npx hardhat fork:mint-usdc --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
44+
fi
45+
46+
if [ "$NETWORK" = "gnosis" ]; then
47+
echo " - funding xdai..."
48+
npx hardhat fork:mint-eth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
49+
echo " - funding wsteth..."
50+
npx hardhat fork:mint-wsteth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
51+
echo " - funding wxdai..."
52+
npx hardhat fork:mint-wxdai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
53+
fi
54+
4255
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { HyperdriveCoordinatorConfig } from "../../lib";
2+
import { GNOSIS_FACTORY_NAME } from "./factory";
3+
4+
export const GNOSIS_CHAINLINK_COORDINATOR_NAME =
5+
"ElementDAO Chainlink Hyperdrive Deployer Coordinator";
6+
export const GNOSIS_CHAINLINK_COORDINATOR: HyperdriveCoordinatorConfig<"Chainlink"> =
7+
{
8+
name: GNOSIS_CHAINLINK_COORDINATOR_NAME,
9+
prefix: "Chainlink",
10+
targetCount: 5,
11+
factoryAddress: async (hre) =>
12+
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
13+
.address,
14+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { HyperdriveCoordinatorConfig } from "../../lib";
2+
import { GNOSIS_FACTORY_NAME } from "./factory";
3+
4+
export const GNOSIS_ERC4626_COORDINATOR_NAME =
5+
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator";
6+
export const GNOSIS_ERC4626_COORDINATOR: HyperdriveCoordinatorConfig<"ERC4626"> =
7+
{
8+
name: GNOSIS_ERC4626_COORDINATOR_NAME,
9+
prefix: "ERC4626",
10+
targetCount: 5,
11+
factoryAddress: async (hre) =>
12+
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
13+
.address,
14+
};

tasks/deploy/config/gnosis/factory.ts

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { Address, parseEther, zeroAddress } from "viem";
2+
import { HyperdriveFactoryConfig, parseDuration } from "../../lib";
3+
4+
// The name of the factory.
5+
export const GNOSIS_FACTORY_NAME = "ElementDAO Hyperdrive Factory";
6+
7+
// The name of the forwarder factory.
8+
export const GNOSIS_FACTORY_FORWARDER_NAME =
9+
"ElementDAO ERC20 Factory Forwarder";
10+
11+
export const GNOSIS_FACTORY: HyperdriveFactoryConfig = {
12+
name: GNOSIS_FACTORY_NAME,
13+
prepare: async (hre, options) => {
14+
await hre.hyperdriveDeploy.ensureDeployed(
15+
GNOSIS_FACTORY_FORWARDER_NAME,
16+
"ERC20ForwarderFactory",
17+
[GNOSIS_FACTORY_FORWARDER_NAME],
18+
options,
19+
);
20+
},
21+
constructorArguments: async (hre) => [
22+
{
23+
governance: (await hre.getNamedAccounts())["deployer"] as Address,
24+
deployerCoordinatorManager: (await hre.getNamedAccounts())[
25+
"deployer"
26+
] as Address,
27+
hyperdriveGovernance: (await hre.getNamedAccounts())[
28+
"deployer"
29+
] as Address,
30+
defaultPausers: [
31+
(await hre.getNamedAccounts())["deployer"] as Address,
32+
(await hre.getNamedAccounts())["pauser"] as Address,
33+
],
34+
feeCollector: zeroAddress,
35+
sweepCollector: zeroAddress,
36+
checkpointRewarder: zeroAddress,
37+
checkpointDurationResolution: parseDuration("1 hours"),
38+
minCheckpointDuration: parseDuration("24 hours"),
39+
maxCheckpointDuration: parseDuration("24 hours"),
40+
minPositionDuration: parseDuration("7 days"),
41+
maxPositionDuration: parseDuration("730 days"),
42+
minFixedAPR: parseEther("0.005"),
43+
maxFixedAPR: parseEther("0.1"),
44+
minTimeStretchAPR: parseEther("0.005"),
45+
maxTimeStretchAPR: parseEther("0.2"),
46+
minCircuitBreakerDelta: parseEther("0.01"),
47+
maxCircuitBreakerDelta: parseEther("0.2"),
48+
minFees: {
49+
curve: parseEther("0.001"),
50+
flat: parseEther("0.0001"),
51+
governanceLP: parseEther("0.15"),
52+
governanceZombie: parseEther("0.03"),
53+
},
54+
maxFees: {
55+
curve: parseEther("0.05"),
56+
flat: parseEther("0.005"),
57+
governanceLP: parseEther("0.15"),
58+
governanceZombie: parseEther("0.03"),
59+
},
60+
linkerFactory: hre.hyperdriveDeploy.deployments.byName(
61+
GNOSIS_FACTORY_FORWARDER_NAME,
62+
).address,
63+
linkerCodeHash: await (
64+
await hre.viem.getContractAt(
65+
"ERC20ForwarderFactory",
66+
hre.hyperdriveDeploy.deployments.byName(
67+
GNOSIS_FACTORY_FORWARDER_NAME,
68+
).address,
69+
)
70+
).read.ERC20LINK_HASH(),
71+
},
72+
GNOSIS_FACTORY_NAME,
73+
],
74+
};

tasks/deploy/config/gnosis/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from "./chainlink-coordinator";
2+
export * from "./erc4626-coordinator";
3+
export * from "./factory";
4+
export * from "./sxdai-182day";
5+
export * from "./wsteth-182day";
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { Address, keccak256, parseEther, toBytes } from "viem";
2+
import {
3+
HyperdriveInstanceConfig,
4+
getLinkerDetails,
5+
normalizeFee,
6+
parseDuration,
7+
toBytes32,
8+
} from "../../lib";
9+
import {
10+
SIX_MONTHS,
11+
SXDAI_ADDRESS_GNOSIS,
12+
WXDAI_ADDRESS_GNOSIS,
13+
} from "../../lib/constants";
14+
import { GNOSIS_ERC4626_COORDINATOR_NAME } from "./erc4626-coordinator";
15+
import { GNOSIS_FACTORY_NAME } from "./factory";
16+
17+
// The name of the pool.
18+
export const GNOSIS_SXDAI_182DAY_NAME = "ElementDAO 182 Day sxDAI Hyperdrive";
19+
20+
// The initial contribution of the pool.
21+
const CONTRIBUTION = parseEther("100");
22+
23+
export const GNOSIS_SXDAI_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
24+
name: GNOSIS_SXDAI_182DAY_NAME,
25+
prefix: "ERC4626",
26+
coordinatorAddress: async (hre) =>
27+
hre.hyperdriveDeploy.deployments.byName(GNOSIS_ERC4626_COORDINATOR_NAME)
28+
.address,
29+
deploymentId: keccak256(toBytes(GNOSIS_SXDAI_182DAY_NAME)),
30+
salt: toBytes32("0x69420"),
31+
extraData: "0x",
32+
contribution: CONTRIBUTION,
33+
fixedAPR: parseEther("0.06"),
34+
timestretchAPR: parseEther("0.05"),
35+
options: async (hre) => ({
36+
extraData: "0x",
37+
asBase: true,
38+
destination: (await hre.getNamedAccounts())["deployer"] as Address,
39+
}),
40+
// Prepare to deploy the contract by setting approvals.
41+
prepare: async (hre) => {
42+
let baseToken = await hre.viem.getContractAt(
43+
"contracts/src/interfaces/IERC20.sol:IERC20",
44+
WXDAI_ADDRESS_GNOSIS,
45+
);
46+
let tx = await baseToken.write.approve([
47+
hre.hyperdriveDeploy.deployments.byName(
48+
GNOSIS_ERC4626_COORDINATOR_NAME,
49+
).address,
50+
CONTRIBUTION,
51+
]);
52+
let pc = await hre.viem.getPublicClient();
53+
await pc.waitForTransactionReceipt({ hash: tx });
54+
},
55+
poolDeployConfig: async (hre) => {
56+
let factoryContract = await hre.viem.getContractAt(
57+
"HyperdriveFactory",
58+
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
59+
.address,
60+
);
61+
return {
62+
baseToken: WXDAI_ADDRESS_GNOSIS,
63+
vaultSharesToken: SXDAI_ADDRESS_GNOSIS,
64+
circuitBreakerDelta: parseEther("0.05"),
65+
minimumShareReserves: parseEther("0.005"),
66+
minimumTransactionAmount: parseEther("0.001"),
67+
positionDuration: parseDuration(SIX_MONTHS),
68+
checkpointDuration: parseDuration("1 day"),
69+
timeStretch: 0n,
70+
governance: await factoryContract.read.governance(),
71+
feeCollector: await factoryContract.read.feeCollector(),
72+
sweepCollector: await factoryContract.read.sweepCollector(),
73+
checkpointRewarder: await factoryContract.read.checkpointRewarder(),
74+
...(await getLinkerDetails(
75+
hre,
76+
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
77+
.address,
78+
)),
79+
fees: {
80+
curve: parseEther("0.01"),
81+
flat: normalizeFee(parseEther("0.0005"), SIX_MONTHS),
82+
governanceLP: parseEther("0.15"),
83+
governanceZombie: parseEther("0.03"),
84+
},
85+
};
86+
},
87+
};

0 commit comments

Comments
 (0)