Skip to content

Commit

Permalink
Added a Moonwell USDC yield source test and deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed Oct 15, 2024
1 parent 839052e commit 786e0d8
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 8 deletions.
4 changes: 4 additions & 0 deletions hardhat.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
BASE_ERC4626_COORDINATOR,
BASE_FACTORY,
BASE_MOONWELL_ETH_182DAY,
BASE_MOONWELL_EURC_182DAY,
BASE_MOONWELL_USDC_182DAY,
BASE_MORPHO_BLUE_COORDINATOR,
BASE_STK_WELL_182DAY,
BASE_STK_WELL_COORDINATOR,
Expand Down Expand Up @@ -40,6 +42,8 @@ const config: HardhatUserConfig = {
BASE_MORPHO_BLUE_CBETH_USDC_182DAY,
BASE_MOONWELL_ETH_182DAY,
BASE_STK_WELL_182DAY,
BASE_MOONWELL_EURC_182DAY,
BASE_MOONWELL_USDC_182DAY,
],
checkpointRewarders: [],
checkpointSubrewarders: [],
Expand Down
2 changes: 2 additions & 0 deletions tasks/deploy/config/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export * from "./chainlink-coordinator";
export * from "./erc4626-coordinator";
export * from "./factory";
export * from "./moonwell-eth-182day";
export * from "./moonwell-eurc-182day";
export * from "./moonwell-usdc-182day";
export * from "./morpho-blue-coordinator";
export * from "./stk-well-182day";
export * from "./stk-well-coordinator";
18 changes: 10 additions & 8 deletions tasks/deploy/config/base/moonwell-eurc-182day.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@ import { BASE_ERC4626_COORDINATOR_NAME } from "./erc4626-coordinator";
import { BASE_FACTORY_NAME } from "./factory";

// The name of the pool.
export const BASE_MOONWELL_ETH_182DAY_NAME =
"ElementDAO 182 Day Moonwell ETH Hyperdrive";
export const BASE_MOONWELL_EURC_182DAY_NAME =
"ElementDAO 182 Day Moonwell EURC Hyperdrive";

// The initial contribution of the pool.
const CONTRIBUTION = parseEther("0.03");
// EURC only has 6 decimals.
const CONTRIBUTION = 100_000_000n;

export const BASE_MOONWELL_ETH_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
name: BASE_MOONWELL_ETH_182DAY_NAME,
export const BASE_MOONWELL_EURC_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
name: BASE_MOONWELL_EURC_182DAY_NAME,
prefix: "ERC4626",
coordinatorAddress: async (hre) =>
hre.hyperdriveDeploy.deployments.byName(BASE_ERC4626_COORDINATOR_NAME)
.address,
deploymentId: keccak256(toBytes(BASE_MOONWELL_ETH_182DAY_NAME)),
deploymentId: keccak256(toBytes(BASE_MOONWELL_EURC_182DAY_NAME)),
salt: toBytes32("0x69420"),
extraData: "0x",
contribution: CONTRIBUTION,
fixedAPR: parseEther("0.14"),
// The moonwell EURC rate is currently at 19.4%, but we have a cap on our
// fixed rate of 10%. This is the link to the vaults page: https://moonwell.fi/vaults
fixedAPR: parseEther("0.1"),
timestretchAPR: parseEther("0.075"),
options: async (hre) => ({
extraData: "0x",
Expand Down
89 changes: 89 additions & 0 deletions tasks/deploy/config/base/moonwell-usdc-182day.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Address, keccak256, parseEther, toBytes } from "viem";
import {
HyperdriveInstanceConfig,
getLinkerDetails,
normalizeFee,
parseDuration,
toBytes32,
} from "../../lib";
import {
MOONWELL_USDC_ADDRESS_BASE,
SIX_MONTHS,
USDC_ADDRESS_BASE,
} from "../../lib/constants";
import { BASE_ERC4626_COORDINATOR_NAME } from "./erc4626-coordinator";
import { BASE_FACTORY_NAME } from "./factory";

// The name of the pool.
export const BASE_MOONWELL_USDC_182DAY_NAME =
"ElementDAO 182 Day Moonwell USDC Hyperdrive";

// USDC only has 6 decimals.
const CONTRIBUTION = 100_000_000n;

export const BASE_MOONWELL_USDC_182DAY: HyperdriveInstanceConfig<"ERC4626"> = {
name: BASE_MOONWELL_USDC_182DAY_NAME,
prefix: "ERC4626",
coordinatorAddress: async (hre) =>
hre.hyperdriveDeploy.deployments.byName(BASE_ERC4626_COORDINATOR_NAME)
.address,
deploymentId: keccak256(toBytes(BASE_MOONWELL_USDC_182DAY_NAME)),
salt: toBytes32("0x69420"),
extraData: "0x",
contribution: CONTRIBUTION,
// The moonwell EURC rate is currently at 12%, but we have a cap on our
// fixed rate of 10%. This is the link to the vaults page: https://moonwell.fi/vaults
fixedAPR: parseEther("0.12"),
timestretchAPR: parseEther("0.075"),
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",
USDC_ADDRESS_BASE,
);
let tx = await baseToken.write.approve([
hre.hyperdriveDeploy.deployments.byName(
BASE_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(BASE_FACTORY_NAME).address,
);
return {
baseToken: USDC_ADDRESS_BASE,
vaultSharesToken: MOONWELL_USDC_ADDRESS_BASE,
circuitBreakerDelta: parseEther("0.075"),
minimumShareReserves: parseEther("0.001"),
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(BASE_FACTORY_NAME)
.address,
)),
fees: {
curve: parseEther("0.01"),
flat: normalizeFee(parseEther("0.0005"), SIX_MONTHS),
governanceLP: parseEther("0.15"),
governanceZombie: parseEther("0.03"),
},
};
},
};
3 changes: 3 additions & 0 deletions tasks/deploy/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ export const MOONWELL_ETH_ADDRESS_BASE =
export const MOONWELL_EURC_ADDRESS_BASE =
"0xf24608E0CCb972b0b0f4A6446a0BBf58c701a026" as Address;

export const MOONWELL_USDC_ADDRESS_BASE =
"0xc1256Ae5FF1cf2719D4937adb3bbCCab2E00A2Ca" as Address;

export const USDC_ADDRESS_BASE =
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" as Address;

Expand Down

0 comments on commit 786e0d8

Please sign in to comment.