Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit eddb623

Browse files
committed
feat: init commit
1 parent c2275f5 commit eddb623

File tree

144 files changed

+73200
-11301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+73200
-11301
lines changed
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { zeroAddress, Hash, Address } from "viem";
2+
3+
import { FuseFlywheelDeployFnParams } from "..";
4+
5+
export const deployFlywheelWithDynamicRewards = async ({
6+
viem,
7+
getNamedAccounts,
8+
deployments,
9+
deployConfig
10+
}: FuseFlywheelDeployFnParams): Promise<Array<string>> => {
11+
const { deployer } = await getNamedAccounts();
12+
const publicClient = await viem.getPublicClient();
13+
14+
const dynamicFlywheels = [];
15+
16+
for (const config of deployConfig.dynamicFlywheels!) {
17+
if (config) {
18+
console.log(`Deploying IonicFlywheel & ReplacingFlywheelDynamicRewards for ${config.rewardToken} reward token`);
19+
const flywheelBooster = await viem.getContractAt(
20+
"LooplessFlywheelBooster",
21+
(await deployments.get("LooplessFlywheelBooster")).address as Address
22+
);
23+
const flywheelToReplace = config.flywheelToReplace ? config.flywheelToReplace : zeroAddress;
24+
25+
//// IonicFlywheelCore with Dynamic Rewards
26+
const fwc = await deployments.deploy(`IonicFlywheel_${config.name}`, {
27+
contract: "IonicFlywheel",
28+
from: deployer,
29+
log: true,
30+
proxy: {
31+
execute: {
32+
init: {
33+
methodName: "initialize",
34+
args: [config.rewardToken, zeroAddress, flywheelBooster.address, deployer]
35+
}
36+
},
37+
proxyContract: "OpenZeppelinTransparentProxy",
38+
owner: deployer
39+
},
40+
waitConfirmations: 1
41+
});
42+
if (fwc.transactionHash) {
43+
await publicClient.waitForTransactionReceipt({ hash: fwc.transactionHash as Hash });
44+
}
45+
console.log("IonicFlywheel: ", fwc.address);
46+
47+
const fdr = await deployments.deploy(`ReplacingFlywheelDynamicRewards_${config.name}`, {
48+
contract: "ReplacingFlywheelDynamicRewards",
49+
from: deployer,
50+
args: [flywheelToReplace, fwc.address, config.cycleLength],
51+
log: true,
52+
waitConfirmations: 1
53+
});
54+
if (fdr.transactionHash) {
55+
await publicClient.waitForTransactionReceipt({ hash: fdr.transactionHash as Hash });
56+
}
57+
console.log("ReplacingFlywheelDynamicRewards: ", fdr.address);
58+
59+
const flywheelCore = await viem.getContractAt(
60+
`IonicFlywheel_${config.name}`,
61+
(await deployments.get(`IonicFlywheel_${config.name}`)).address as Address
62+
);
63+
const currentRewards = await flywheelCore.read.flywheelRewards();
64+
if (currentRewards != fdr.address) {
65+
const hash = await flywheelCore.write.setFlywheelRewards([fdr.address]);
66+
await publicClient.waitForTransactionReceipt({ hash });
67+
console.log("setFlywheelRewards: ", hash);
68+
} else {
69+
console.log(`rewards contract already set`);
70+
}
71+
72+
dynamicFlywheels.push(fwc.address);
73+
}
74+
}
75+
return dynamicFlywheels;
76+
};

chainDeploy/helpers/getCgPrice.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import axios from "axios";
2+
3+
export const getCgPrice = async (coingeckoId: string) => {
4+
let usdPrice = NaN;
5+
6+
try {
7+
const { data } = await axios.get(
8+
`https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids=${coingeckoId}`
9+
);
10+
11+
if (data[coingeckoId] && data[coingeckoId].usd) {
12+
usdPrice = data[coingeckoId].usd;
13+
}
14+
} catch (e) {
15+
const { data } = await axios.get(`https://coins.llama.fi/prices/current/coingecko:${coingeckoId}`);
16+
17+
if (data.coins[`coingecko:${coingeckoId}`] && data.coins[`coingecko:${coingeckoId}`].price) {
18+
usdPrice = data.coins[`coingecko:${coingeckoId}`].price;
19+
}
20+
}
21+
22+
if (usdPrice) {
23+
return usdPrice;
24+
} else {
25+
return 1;
26+
}
27+
};

chainDeploy/helpers/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { ChainDeployConfig, ChainlinkFeedBaseCurrency } from "../../chains/types";
2+
export { deployIRMs } from "./irms";
3+
export { deployChainlinkOracle } from "./oracles/chainlink";
4+
export { deployFlywheelWithDynamicRewards } from "./dynamicFlywheels";
5+
export { deployErc4626PriceOracle } from "./oracles/erc4626";
6+
export { configureBalancerSwap } from "./liquidators/ionicLiquidator";

chainDeploy/helpers/irms.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { parseEther } from "viem";
2+
import { IrmDeployFnParams } from "../../chains/types";
3+
4+
export const deployIRMs = async ({
5+
viem,
6+
getNamedAccounts,
7+
deployments,
8+
deployConfig
9+
}: IrmDeployFnParams): Promise<void> => {
10+
const publicClient = await viem.getPublicClient();
11+
const { deployer } = await getNamedAccounts();
12+
//// IRM MODELS|
13+
const jrm = await deployments.deploy("JumpRateModel", {
14+
from: deployer,
15+
args: [
16+
deployConfig.blocksPerYear,
17+
parseEther("0").toString(), // baseRatePerYear 0
18+
parseEther("0.18").toString(), // multiplierPerYear 0.18
19+
parseEther("4").toString(), //jumpMultiplierPerYear 4
20+
parseEther("0.8").toString() // kink 0.8
21+
],
22+
log: true
23+
});
24+
if (jrm.transactionHash) await publicClient.waitForTransactionReceipt({ hash: jrm.transactionHash });
25+
console.log("JumpRateModel: ", jrm.address);
26+
};

0 commit comments

Comments
 (0)