Skip to content

Commit ab4da7e

Browse files
authored
Morpho mainnet WBTC/USDC deployment script (#1208)
* add tests. all tests passing * linting fix * tweak deployment config * linting fix * linting fix * undo change on hardhat mainnet fork config * finalize deployment params and add link to morpho market * fix comment about underlying market
1 parent c641e1b commit ab4da7e

File tree

5 files changed

+148
-0
lines changed

5 files changed

+148
-0
lines changed

hardhat.config.mainnet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
MAINNET_MORPHO_BLUE_COORDINATOR,
1616
MAINNET_MORPHO_BLUE_SUSDE_DAI_182DAY,
1717
MAINNET_MORPHO_BLUE_USDE_DAI_182DAY,
18+
MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY,
1819
MAINNET_MORPHO_BLUE_WSTETH_USDA_182DAY,
1920
MAINNET_RETH_182DAY,
2021
MAINNET_RETH_COORDINATOR,
@@ -45,6 +46,7 @@ const config: HardhatUserConfig = {
4546
MAINNET_MORPHO_BLUE_SUSDE_DAI_182DAY,
4647
MAINNET_MORPHO_BLUE_USDE_DAI_182DAY,
4748
MAINNET_MORPHO_BLUE_WSTETH_USDA_182DAY,
49+
MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY,
4850
MAINNET_MORPHO_BLUE_CBBTC_USDC_182DAY,
4951
MAINNET_STUSD_182DAY,
5052
MAINNET_SUSDE_182DAY,

hardhat.config.mainnet_fork.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
MAINNET_MORPHO_BLUE_COORDINATOR,
1616
MAINNET_MORPHO_BLUE_SUSDE_DAI_182DAY,
1717
MAINNET_MORPHO_BLUE_USDE_DAI_182DAY,
18+
MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY,
1819
MAINNET_MORPHO_BLUE_WSTETH_USDC_182DAY,
1920
MAINNET_RETH_182DAY,
2021
MAINNET_RETH_COORDINATOR,
@@ -45,6 +46,7 @@ const config: HardhatUserConfig = {
4546
MAINNET_MORPHO_BLUE_SUSDE_DAI_182DAY,
4647
MAINNET_MORPHO_BLUE_USDE_DAI_182DAY,
4748
MAINNET_MORPHO_BLUE_WSTETH_USDC_182DAY,
49+
MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY,
4850
MAINNET_EETH_182DAY,
4951
],
5052
checkpointRewarders: [],

tasks/deploy/config/mainnet/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from "./morpho-blue-cbbtc-usdc-182day";
1212
export * from "./morpho-blue-coordinator";
1313
export * from "./morpho-blue-susde-dai-182day";
1414
export * from "./morpho-blue-usde-dai-182day";
15+
export * from "./morpho-blue-wbtc-usdc-182day";
1516
export * from "./morpho-blue-wsteth-usda-182day";
1617
export * from "./morpho-blue-wsteth-usdc-182day";
1718
export * from "./reth-182day";
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import {
2+
Address,
3+
encodeAbiParameters,
4+
keccak256,
5+
parseEther,
6+
toBytes,
7+
zeroAddress,
8+
} from "viem";
9+
import {
10+
HyperdriveInstanceConfig,
11+
SIX_MONTHS,
12+
USDC_ADDRESS_MAINNET,
13+
WBTC_ADDRESS_MAINNET,
14+
getLinkerDetails,
15+
normalizeFee,
16+
parseDuration,
17+
toBytes32,
18+
} from "../../lib";
19+
import { MAINNET_FACTORY_NAME } from "./factory";
20+
import { MAINNET_MORPHO_BLUE_COORDINATOR_NAME } from "./morpho-blue-coordinator";
21+
22+
export const MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY_NAME =
23+
"ElementDAO 182 Day Morpho Blue WBTC/USDC Hyperdrive";
24+
25+
// USDC only has 6 decimals.
26+
const CONTRIBUTION = 100_000_000n;
27+
28+
const morphoBlueParameters = encodeAbiParameters(
29+
[
30+
{
31+
components: [
32+
{
33+
name: "morpho",
34+
type: "address",
35+
},
36+
{
37+
name: "collateralToken",
38+
type: "address",
39+
},
40+
{
41+
name: "oracle",
42+
type: "address",
43+
},
44+
{
45+
name: "irm",
46+
type: "address",
47+
},
48+
{
49+
name: "lltv",
50+
type: "uint256",
51+
},
52+
],
53+
name: "MorphoBlueParams",
54+
type: "tuple",
55+
},
56+
],
57+
[
58+
{
59+
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb" as `0x${string}`,
60+
collateralToken: WBTC_ADDRESS_MAINNET,
61+
oracle: "0xDddd770BADd886dF3864029e4B377B5F6a2B6b83" as `0x${string}`,
62+
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" as `0x${string}`,
63+
lltv: BigInt("860000000000000000"),
64+
},
65+
],
66+
);
67+
68+
export const MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY: HyperdriveInstanceConfig<"MorphoBlue"> =
69+
{
70+
name: MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY_NAME,
71+
prefix: "MorphoBlue",
72+
coordinatorAddress: async (hre) =>
73+
hre.hyperdriveDeploy.deployments.byName(
74+
MAINNET_MORPHO_BLUE_COORDINATOR_NAME,
75+
).address,
76+
deploymentId: keccak256(
77+
toBytes(MAINNET_MORPHO_BLUE_WBTC_USDC_182DAY_NAME),
78+
),
79+
salt: toBytes32("0x42080085"),
80+
extraData: morphoBlueParameters,
81+
contribution: CONTRIBUTION,
82+
// NOTE: Link to the underlying market on Morpho:
83+
// https://app.morpho.org/market?id=0x3a85e619751152991742810df6ec69ce473daef99e28a64ab2340d7b7ccfee49&network=mainnet&morphoPrice=0.75
84+
fixedAPR: parseEther("0.0575"),
85+
timestretchAPR: parseEther("0.075"),
86+
options: async (hre) => ({
87+
extraData: "0x",
88+
asBase: true,
89+
destination: (await hre.getNamedAccounts())["deployer"] as Address,
90+
}),
91+
// Prepare to deploy the contract by setting approvals.
92+
prepare: async (hre, options) => {
93+
let pc = await hre.viem.getPublicClient();
94+
let baseToken = await hre.viem.getContractAt(
95+
"contracts/src/interfaces/IERC20.sol:IERC20",
96+
USDC_ADDRESS_MAINNET,
97+
);
98+
let tx = await baseToken.write.approve([
99+
hre.hyperdriveDeploy.deployments.byName(
100+
MAINNET_MORPHO_BLUE_COORDINATOR_NAME,
101+
).address,
102+
CONTRIBUTION,
103+
]);
104+
await pc.waitForTransactionReceipt({ hash: tx });
105+
},
106+
poolDeployConfig: async (hre) => {
107+
let factoryContract = await hre.viem.getContractAt(
108+
"HyperdriveFactory",
109+
hre.hyperdriveDeploy.deployments.byName(MAINNET_FACTORY_NAME)
110+
.address,
111+
);
112+
return {
113+
baseToken: USDC_ADDRESS_MAINNET,
114+
vaultSharesToken: zeroAddress,
115+
circuitBreakerDelta: parseEther("0.075"),
116+
minimumShareReserves: 1_000_000n,
117+
minimumTransactionAmount: 1_000_000n,
118+
positionDuration: parseDuration(SIX_MONTHS),
119+
checkpointDuration: parseDuration("1 day"),
120+
timeStretch: 0n,
121+
governance: await factoryContract.read.hyperdriveGovernance(),
122+
feeCollector: await factoryContract.read.feeCollector(),
123+
sweepCollector: await factoryContract.read.sweepCollector(),
124+
checkpointRewarder:
125+
await factoryContract.read.checkpointRewarder(),
126+
...(await getLinkerDetails(
127+
hre,
128+
hre.hyperdriveDeploy.deployments.byName(
129+
MAINNET_FACTORY_NAME,
130+
).address,
131+
)),
132+
fees: {
133+
curve: parseEther("0.01"),
134+
flat: normalizeFee(parseEther("0.0005"), SIX_MONTHS),
135+
governanceLP: parseEther("0.15"),
136+
governanceZombie: parseEther("0.03"),
137+
},
138+
};
139+
},
140+
};

tasks/deploy/lib/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ export const USDS_ADDRESS_MAINNET =
103103
export const WSTETH_ADDRESS_MAINNET =
104104
"0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0" as Address;
105105

106+
export const WBTC_ADDRESS_MAINNET =
107+
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" as Address;
108+
106109
// ╭─────────────────────────────────────────────────────────╮
107110
// │ Mainnet Whales │
108111
// ╰─────────────────────────────────────────────────────────╯

0 commit comments

Comments
 (0)