Skip to content

Commit 294948a

Browse files
committed
gnosis fork prep
1 parent b17aac0 commit 294948a

File tree

5 files changed

+134
-29
lines changed

5 files changed

+134
-29
lines changed

scripts/deploy-fork.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
set -e
44

55
# Mint some of each instance's token to the deployer address.
6-
export NETWORK='mainnet_fork'
76
sh scripts/fund-fork-accounts.sh
87

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

1211
# Extract the deployed contract addresses to `artifacts/addresses.json`
1312
# for use with the delvtech/infra address server.
14-
cat ./deployments.local.json | jq '.mainnet_fork | {
13+
if ["$NETWORK" == "mainnet_fork"]; then
14+
cat ./deployments.local.json | jq ".mainnet_fork | {
1515
hyperdriveRegistry: .["DELV Hyperdrive Registry"].address,
16-
}' >./artifacts/addresses.json
17-
cp ./deployments.local.json ./artifacts/
16+
}" >./artifacts/addresses.json
17+
cp ./deployments.local.json ./artifacts/
18+
else
19+
cat ./deployments.json | jq ".$NETWORK | {
20+
hyperdriveRegistry: .["DELV Hyperdrive Registry"].address,
21+
}" >./artifacts/addresses.json
22+
cp ./deployments.json ./artifacts/
23+
fi

scripts/fund-fork-accounts.sh

+30-18
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,36 @@ fi
1919
for address in "${addresses[@]}"
2020
do
2121
echo "funding ${address}..."
22+
2223
echo " - funding eth..."
2324
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"
25+
26+
if [ "$NETWORK" = "mainnet_fork"]; then
27+
echo " - funding dai..."
28+
npx hardhat fork:mint-dai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
29+
echo " - funding eeth..."
30+
npx hardhat fork:mint-eeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
31+
echo " - funding ezeth..."
32+
npx hardhat fork:mint-ezeth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
33+
echo " - funding reth..."
34+
npx hardhat fork:mint-reth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
35+
echo " - funding sdai..."
36+
npx hardhat fork:mint-sdai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
37+
echo " - funding steth..."
38+
npx hardhat fork:mint-steth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
39+
echo " - funding usde..."
40+
npx hardhat fork:mint-usde --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
41+
echo " - funding wsteth..."
42+
npx hardhat fork:mint-wsteth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
43+
echo " - funding usdc..."
44+
npx hardhat fork:mint-usdc --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
45+
fi
46+
47+
if [ "$NETWORK" = "gnosis" ]; then
48+
echo " - funding wsteth..."
49+
npx hardhat fork:mint-wsteth --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
50+
echo " - funding wxdai..."
51+
npx hardhat fork:mint-wxdai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
52+
fi
53+
4254
done

tasks/fork/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export * from "./mint-steth";
1010
export * from "./mint-usdc";
1111
export * from "./mint-usde";
1212
export * from "./mint-wsteth";
13+
export * from "./mint-wxdai";

tasks/fork/mint-wsteth.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Address, encodeFunctionData, parseEther, zeroAddress } from "viem";
33
import {
44
HyperdriveDeployBaseTask,
55
HyperdriveDeployBaseTaskParams,
6+
WSTETH_ADDRESS_GNOSIS,
67
WSTETH_ADDRESS_MAINNET,
7-
WSTETH_WHALE_MAINNET,
88
} from "../deploy";
99

1010
export type MintWSTETHParams = HyperdriveDeployBaseTaskParams & {
@@ -33,16 +33,24 @@ HyperdriveDeployBaseTask(
3333
.setAction(
3434
async (
3535
{ address, amount }: Required<MintWSTETHParams>,
36-
{ viem, artifacts, getNamedAccounts },
36+
{ viem, artifacts, getNamedAccounts, network },
3737
) => {
3838
if (address === zeroAddress) {
3939
address = (await getNamedAccounts())["deployer"];
4040
}
41+
let wstethAddress =
42+
network.name === "gnosis"
43+
? WSTETH_ADDRESS_GNOSIS
44+
: WSTETH_ADDRESS_MAINNET;
45+
let wstethWhale =
46+
network.name === "gnosis"
47+
? WSTETH_ADDRESS_GNOSIS
48+
: WSTETH_ADDRESS_MAINNET;
4149
let contract = await viem.getContractAt(
4250
"solmate/tokens/ERC20.sol:ERC20",
43-
WSTETH_ADDRESS_MAINNET,
51+
wstethAddress,
4452
);
45-
let balance = await contract.read.balanceOf([WSTETH_WHALE_MAINNET]);
53+
let balance = await contract.read.balanceOf([wstethWhale]);
4654
if (balance < parseEther(amount)) {
4755
console.log(
4856
"ERROR: insufficient funds in WSTETH whale account, skipping...",
@@ -64,12 +72,12 @@ HyperdriveDeployBaseTask(
6472
mode: "anvil",
6573
});
6674
await tc.setBalance({
67-
address: WSTETH_WHALE_MAINNET,
75+
address: wstethWhale,
6876
value: parseEther("1"),
6977
});
7078
let tx = await tc.sendUnsignedTransaction({
71-
from: WSTETH_WHALE_MAINNET,
72-
to: WSTETH_ADDRESS_MAINNET,
79+
from: wstethWhale,
80+
to: wstethAddress,
7381
data: transferData,
7482
});
7583
let pc = await viem.getPublicClient();

tasks/fork/mint-wxdai.ts

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { task, types } from "hardhat/config";
2+
import { Address, encodeFunctionData, parseEther, zeroAddress } from "viem";
3+
import {
4+
HyperdriveDeployBaseTask,
5+
HyperdriveDeployBaseTaskParams,
6+
SXDAI_ADDRESS_GNOSIS,
7+
WXDAI_ADDRESS_GNOSIS,
8+
} from "../deploy";
9+
10+
export type MintWXDAIParams = HyperdriveDeployBaseTaskParams & {
11+
address: string;
12+
amount: string;
13+
};
14+
15+
HyperdriveDeployBaseTask(
16+
task(
17+
"fork:mint-wxdai",
18+
"Mints the specified amount of WXDAI to the input address",
19+
),
20+
)
21+
.addOptionalParam(
22+
"address",
23+
"address to send WXDAI",
24+
zeroAddress,
25+
types.string,
26+
)
27+
.addOptionalParam(
28+
"amount",
29+
"amount (in ether) to mint",
30+
"10000",
31+
types.string,
32+
)
33+
.setAction(
34+
async (
35+
{ address, amount }: Required<MintWXDAIParams>,
36+
{ viem, artifacts, getNamedAccounts },
37+
) => {
38+
if (address === zeroAddress) {
39+
address = (await getNamedAccounts())["deployer"];
40+
}
41+
let contract = await viem.getContractAt(
42+
"solmate/tokens/ERC20.sol:ERC20",
43+
WXDAI_ADDRESS_GNOSIS,
44+
);
45+
let balance = await contract.read.balanceOf([SXDAI_ADDRESS_GNOSIS]);
46+
if (balance < parseEther(amount)) {
47+
console.log(
48+
"ERROR: insufficient funds in WXDAI whale account, skipping...",
49+
);
50+
return;
51+
}
52+
53+
let transferData = encodeFunctionData({
54+
abi: (
55+
await artifacts.readArtifact(
56+
"solmate/tokens/ERC20.sol:ERC20",
57+
)
58+
).abi,
59+
functionName: "transfer",
60+
args: [address as Address, parseEther(amount!)],
61+
});
62+
63+
let tc = await viem.getTestClient({
64+
mode: "anvil",
65+
});
66+
await tc.setBalance({
67+
address: SXDAI_ADDRESS_GNOSIS,
68+
value: parseEther("1"),
69+
});
70+
let tx = await tc.sendUnsignedTransaction({
71+
from: SXDAI_ADDRESS_GNOSIS,
72+
to: WXDAI_ADDRESS_GNOSIS,
73+
data: transferData,
74+
});
75+
let pc = await viem.getPublicClient();
76+
await pc.waitForTransactionReceipt({ hash: tx });
77+
},
78+
);

0 commit comments

Comments
 (0)