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

Commit a933e35

Browse files
committed
Merge branch 'development' into feat/adrastia-prudentia-caps
2 parents 21619f8 + 23f492e commit a933e35

File tree

495 files changed

+326678
-11478
lines changed

Some content is hidden

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

495 files changed

+326678
-11478
lines changed

.github/workflows/pull-request-build-and-test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
node-version: 20
2929

3030
- name: Install Npm dependencies
31-
run: npm install
31+
run: npm install --force
3232

3333
- name: Lint
3434
run: npm run lint
@@ -48,7 +48,7 @@ jobs:
4848
submodules: recursive
4949

5050
- name: Install Npm dependencies
51-
run: npm install
51+
run: npm install --force
5252

5353
- name: Install Foundry
5454
uses: foundry-rs/foundry-toolchain@v1
@@ -88,7 +88,7 @@ jobs:
8888
submodules: recursive
8989

9090
- name: Install Npm dependencies
91-
run: npm install
91+
run: npm install --force
9292

9393
- name: Install Foundry
9494
uses: foundry-rs/foundry-toolchain@v1

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ deployments/kovan/
1313
contracts.iml
1414
node_modules/
1515
ionic-contracts.iml
16+
cache_hardhat
17+
transactions.json

.vscode/extensions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"arcanis.vscode-zipfs",
4+
"esbenp.prettier-vscode"
5+
]
6+
}

.vscode/settings.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
"editor.defaultFormatter": "esbenp.prettier-vscode",
33
"editor.formatOnSave": true,
44
"editor.tabSize": 2,
5-
"typescript.tsdk": "node_modules/typescript/lib",
5+
"typescript.tsdk": ".yarn/sdks/typescript/lib",
66
"[typescript]": {
77
"editor.defaultFormatter": "esbenp.prettier-vscode"
88
},
99
"solidity.packageDefaultDependenciesContractsDirectory": "contracts",
10-
"solidity.packageDefaultDependenciesDirectory": "lib"
10+
"solidity.packageDefaultDependenciesDirectory": "lib",
11+
"search.exclude": {
12+
"**/.yarn": true,
13+
"**/.pnp.*": true
14+
},
15+
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
16+
"typescript.enablePromptUseWorkspaceTsdk": true
1117
}
+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 { deployPythPriceOracle } from "./oracles/pyth";

chainDeploy/helpers/irms.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Hash, 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 as Hash });
25+
console.log("JumpRateModel: ", jrm.address);
26+
};

0 commit comments

Comments
 (0)