Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deployment config for gnosis wsteth and sxdai hyperdrives #1143

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions hardhat.config.gnosis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 {
GNOSIS_CHAINLINK_COORDINATOR,
GNOSIS_ERC4626_COORDINATOR,
GNOSIS_FACTORY,
GNOSIS_SXDAI_182DAY,
GNOSIS_WSTETH_182DAY,
} from "./tasks/deploy/config/gnosis";

const { env } = process;

const config: HardhatUserConfig = {
...baseConfig,
networks: {
gnosis: {
live: true,
url: env.HYPERDRIVE_ETHEREUM_URL!,
accounts: [env.DEPLOYER_PRIVATE_KEY!, env.PAUSER_PRIVATE_KEY!],
hyperdriveDeploy: {
factories: [GNOSIS_FACTORY],
coordinators: [
GNOSIS_CHAINLINK_COORDINATOR,
GNOSIS_ERC4626_COORDINATOR,
],
instances: [GNOSIS_WSTETH_182DAY, GNOSIS_SXDAI_182DAY],
checkpointRewarders: [],
checkpointSubrewarders: [],
},
},
},
etherscan: {
apiKey: env.GNOSISSCAN_API_KEY ?? "",
},
};

export default config;
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config: HardhatUserConfig = {
viaIR: false,
optimizer: {
enabled: true,
runs: 10000000,
runs: 13000,
},
evmVersion: "paris",
metadata: {
Expand Down
30 changes: 24 additions & 6 deletions scripts/deploy-fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@

set -e

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

# 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 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
npx hardhat deploy:hyperdrive --network $NETWORK --config hardhat.config.$NETWORK.ts --show-stack-traces

# Extract the deployed contract addresses to `artifacts/addresses.json`
# for use with the delvtech/infra address server.
cat ./deployments.local.json | jq '.mainnet_fork | {
hyperdriveRegistry: .["DELV Hyperdrive Registry"].address,
}' >./artifacts/addresses.json
cp ./deployments.local.json ./artifacts/
if [ "$NETWORK" == "mainnet_fork" ]; then
cat ./deployments.local.json | jq ".mainnet_fork | {
hyperdriveRegistry: .[\"DELV Hyperdrive Registry\"].address,
}" >./artifacts/addresses.json
cp ./deployments.local.json ./artifacts/
else
cat ./deployments.json | jq ".$NETWORK | {
hyperdriveRegistry: .[\"DELV Hyperdrive Registry\"].address,
}" >./artifacts/addresses.json
cp ./deployments.json ./artifacts/
fi
22 changes: 11 additions & 11 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ set -e

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

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

config_filename="hardhat.config.${NETWORK}.ts"
if [[ "${NETWORK}" == "hardhat" ]]; then
config_filename="hardhat.config.ts"
config_filename="hardhat.config.ts"
fi
npx hardhat deploy:hyperdrive --show-stack-traces --network ${NETWORK} --config "$config_filename"
npx hardhat deploy:verify --show-stack-traces --network ${NETWORK} --config "$config_filename"
55 changes: 34 additions & 21 deletions scripts/fund-fork-accounts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,44 @@ fi
if [[ -z "$ADMIN" ]]; then
addresses=('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC' '0x90F79bf6EB2c4f870365E785982E1f101E93b906' '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65' '0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc' '0x976EA74026E726554dB657fA54763abd0C3a0aa9' '0x14dC79964da2C08b23698B3D3cc7Ca32193d9955' '0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f' '0xa0Ee7A142d267C1f36714E4a8F75612F20a79720')
else
addresses=("${ADMIN}")
addresses=( "$ADMIN" )
fi

# Mint tokens to all of the default anvil accounts.
for address in "${addresses[@]}"
do
echo "funding ${address}..."
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"

if [ "$NETWORK" = "mainnet_fork" ]; then
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"
fi

if [ "$NETWORK" = "gnosis" ]; then
echo " - funding xdai..."
npx hardhat fork:mint-eth --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 wxdai..."
npx hardhat fork:mint-wxdai --address "${address}" --network "${NETWORK}" --config "hardhat.config.${NETWORK}.ts"
fi

done
14 changes: 14 additions & 0 deletions tasks/deploy/config/gnosis/chainlink-coordinator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { HyperdriveCoordinatorConfig } from "../../lib";
import { GNOSIS_FACTORY_NAME } from "./factory";

export const GNOSIS_CHAINLINK_COORDINATOR_NAME =
"ElementDAO Chainlink Hyperdrive Deployer Coordinator";
export const GNOSIS_CHAINLINK_COORDINATOR: HyperdriveCoordinatorConfig<"Chainlink"> =
{
name: GNOSIS_CHAINLINK_COORDINATOR_NAME,
prefix: "Chainlink",
targetCount: 5,
factoryAddress: async (hre) =>
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
.address,
};
14 changes: 14 additions & 0 deletions tasks/deploy/config/gnosis/erc4626-coordinator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { HyperdriveCoordinatorConfig } from "../../lib";
import { GNOSIS_FACTORY_NAME } from "./factory";

export const GNOSIS_ERC4626_COORDINATOR_NAME =
"ElementDAO ERC4626 Hyperdrive Deployer Coordinator";
export const GNOSIS_ERC4626_COORDINATOR: HyperdriveCoordinatorConfig<"ERC4626"> =
{
name: GNOSIS_ERC4626_COORDINATOR_NAME,
prefix: "ERC4626",
targetCount: 5,
factoryAddress: async (hre) =>
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
.address,
};
74 changes: 74 additions & 0 deletions tasks/deploy/config/gnosis/factory.ts
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 GNOSIS_FACTORY_NAME = "ElementDAO Hyperdrive Factory";

// The name of the forwarder factory.
export const GNOSIS_FACTORY_FORWARDER_NAME =
"ElementDAO ERC20 Factory Forwarder";

export const GNOSIS_FACTORY: HyperdriveFactoryConfig = {
name: GNOSIS_FACTORY_NAME,
prepare: async (hre, options) => {
await hre.hyperdriveDeploy.ensureDeployed(
GNOSIS_FACTORY_FORWARDER_NAME,
"ERC20ForwarderFactory",
[GNOSIS_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.2"),
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(
GNOSIS_FACTORY_FORWARDER_NAME,
).address,
linkerCodeHash: await (
await hre.viem.getContractAt(
"ERC20ForwarderFactory",
hre.hyperdriveDeploy.deployments.byName(
GNOSIS_FACTORY_FORWARDER_NAME,
).address,
)
).read.ERC20LINK_HASH(),
},
GNOSIS_FACTORY_NAME,
],
};
5 changes: 5 additions & 0 deletions tasks/deploy/config/gnosis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./chainlink-coordinator";
export * from "./erc4626-coordinator";
export * from "./factory";
export * from "./sxdai-182day";
export * from "./wsteth-182day";
87 changes: 87 additions & 0 deletions tasks/deploy/config/gnosis/sxdai-182day.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Address, keccak256, parseEther, toBytes } from "viem";
import {
HyperdriveInstanceConfig,
getLinkerDetails,
normalizeFee,
parseDuration,
toBytes32,
} from "../../lib";
import {
SIX_MONTHS,
SXDAI_ADDRESS_GNOSIS,
WXDAI_ADDRESS_GNOSIS,
} from "../../lib/constants";
import { GNOSIS_ERC4626_COORDINATOR_NAME } from "./erc4626-coordinator";
import { GNOSIS_FACTORY_NAME } from "./factory";

// The name of the pool.
export const GNOSIS_SXDAI_182DAY_NAME = "ElementDAO 182 Day sxDAI Hyperdrive";

// The initial contribution of the pool.
const CONTRIBUTION = parseEther("100");

export const GNOSIS_SXDAI_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
name: GNOSIS_SXDAI_182DAY_NAME,
prefix: "ERC4626",
coordinatorAddress: async (hre) =>
hre.hyperdriveDeploy.deployments.byName(GNOSIS_ERC4626_COORDINATOR_NAME)
.address,
deploymentId: keccak256(toBytes(GNOSIS_SXDAI_182DAY_NAME)),
salt: toBytes32("0x69420"),
extraData: "0x",
contribution: CONTRIBUTION,
fixedAPR: parseEther("0.06"),
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",
WXDAI_ADDRESS_GNOSIS,
);
let tx = await baseToken.write.approve([
hre.hyperdriveDeploy.deployments.byName(
GNOSIS_ERC4626_COORDINATOR_NAME,
).address,
CONTRIBUTION,
]);
let pc = await hre.viem.getPublicClient();
await pc.waitForTransactionReceipt({ hash: tx });
},
poolDeployConfig: async (hre) => {
let factoryContract = await hre.viem.getContractAt(
"HyperdriveFactory",
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
.address,
);
return {
baseToken: WXDAI_ADDRESS_GNOSIS,
vaultSharesToken: SXDAI_ADDRESS_GNOSIS,
circuitBreakerDelta: parseEther("0.05"),
minimumShareReserves: parseEther("0.005"),
minimumTransactionAmount: parseEther("0.001"),
positionDuration: parseDuration(SIX_MONTHS),
checkpointDuration: parseDuration("1 day"),
timeStretch: 0n,
governance: await factoryContract.read.governance(),
feeCollector: await factoryContract.read.feeCollector(),
sweepCollector: await factoryContract.read.sweepCollector(),
checkpointRewarder: await factoryContract.read.checkpointRewarder(),
...(await getLinkerDetails(
hre,
hre.hyperdriveDeploy.deployments.byName(GNOSIS_FACTORY_NAME)
.address,
)),
fees: {
curve: parseEther("0.01"),
flat: normalizeFee(parseEther("0.0005"), SIX_MONTHS),
governanceLP: parseEther("0.15"),
governanceZombie: parseEther("0.03"),
},
};
},
};
Loading
Loading