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

Commit 748987f

Browse files
authored
Merge pull request #88 from ionicprotocol/create-separate-scripts-for-flywheel
Update script with new version of ION flywheel
2 parents 25fd4cf + e4e7eae commit 748987f

12 files changed

+6575
-17
lines changed

deployments/base/IonicFlywheelDynamicRewards_ION_v3.json

Lines changed: 289 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/IonicFlywheel_ION_v2.json

Lines changed: 1016 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/IonicFlywheel_ION_v2_Implementation.json

Lines changed: 1126 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/IonicFlywheel_ION_v2_Proxy.json

Lines changed: 289 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/IonicFlywheel_ION_v3.json

Lines changed: 1016 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/IonicFlywheel_ION_v3_Implementation.json

Lines changed: 1126 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/IonicFlywheel_ION_v3_Proxy.json

Lines changed: 289 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/solcInputs/3358b0e3b9146a940b243313bb7c29a1.json

Lines changed: 1364 additions & 0 deletions
Large diffs are not rendered by default.

deploymentsBrief/base.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
"IonicFlywheelDynamicRewards_ION": {
102102
"address": "0x6660174886cb3B26B38E5D4c1324E0BfB361F7CA"
103103
},
104+
"IonicFlywheelDynamicRewards_ION_v3": {
105+
"address": "0x57913CfF75Acd553923E58D3EAFbCDDCCf7816d7"
106+
},
104107
"IonicFlywheelDynamicRewards_RSR": {
105108
"address": "0xCdfF6BA3613f37E719234A26775fF72BD937f22B"
106109
},
@@ -116,6 +119,24 @@
116119
"IonicFlywheel_ION_Proxy": {
117120
"address": "0x6e93f617AB6CEfFec7c276B4fD4c136B7A7aDD54"
118121
},
122+
"IonicFlywheel_ION_v2": {
123+
"address": "0x8D3879dAd76CaFF4b79F45Ca56bb90713182058a"
124+
},
125+
"IonicFlywheel_ION_v2_Implementation": {
126+
"address": "0xeA19016fA9f4A2cce97d8aFA7D0D8e1b74a7887f"
127+
},
128+
"IonicFlywheel_ION_v2_Proxy": {
129+
"address": "0x8D3879dAd76CaFF4b79F45Ca56bb90713182058a"
130+
},
131+
"IonicFlywheel_ION_v3": {
132+
"address": "0x5Dc1fd5cFA5F1efdaCBC790b41A2BfB41bf4F122"
133+
},
134+
"IonicFlywheel_ION_v3_Implementation": {
135+
"address": "0xa7BC89F9Bcd2E6565c250182767f20e2aC89bc7B"
136+
},
137+
"IonicFlywheel_ION_v3_Proxy": {
138+
"address": "0x5Dc1fd5cFA5F1efdaCBC790b41A2BfB41bf4F122"
139+
},
119140
"IonicFlywheel_RSR": {
120141
"address": "0xE4E74A0c98b8dEa4bcbB870C9391Bb73a230ced4"
121142
},
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { task } from "hardhat/config";
2+
import { Address, formatEther, parseEther } from "viem";
3+
import { COMPTROLLER } from ".";
4+
5+
task("market:base:disable-flywheel", "Deploys flywheel and adds rewards").setAction(
6+
async (_, { viem, run, deployments, getNamedAccounts }) => {
7+
const { deployer } = await getNamedAccounts();
8+
const publicClient = await viem.getPublicClient();
9+
10+
const flywheel = await viem.getContractAt(
11+
"IonicFlywheel",
12+
(await deployments.get("IonicFlywheel_ION_v2")).address as Address
13+
);
14+
15+
const comptroller = await viem.getContractAt("IonicComptroller", COMPTROLLER);
16+
const addTx = await comptroller.write.addNonAccruingFlywheel([flywheel.address]);
17+
await publicClient.waitForTransactionReceipt({ hash: addTx });
18+
console.log({ addTx });
19+
console.log("Remove IonicFlywheel_ION_v2 from comptroller");
20+
}
21+
);

tasks/chain-specific/base/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import "./markets";
22
import "./single";
33
import "./rewards";
44
import "./tokens";
5+
import "./disableFlywheel";
56

67
export const COMPTROLLER = "0x05c9C6417F246600f8f5f49fcA9Ee991bfF73D13";

tasks/chain-specific/base/rewards.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ task("market:base:add-rewards-to-existing-flywheel", "Adds rewards to existing f
6161
`Implementation successfully set to ${implementationAddress}: ${setImplementationTx}`
6262
);
6363
*/
64-
64+
/*
6565
// Sending tokens
6666
const ionToken = await viem.getContractAt("EIP20Interface", reward);
6767
const balance = await ionToken.read.balanceOf([market]);
6868
if (balance < parseEther(rewardAmount)) {
6969
await ionToken.write.transfer([market, parseEther(rewardAmount)]);
7070
}
71-
71+
*/
7272
// Approving token sepening for fwRewards contract
7373
const flywheel = await viem.getContractAt(
7474
"IonicFlywheel",
75-
(await deployments.get("IonicFlywheel_ION")).address as Address
75+
(await deployments.get("IonicFlywheel_ION_v3")).address as Address
7676
);
7777

7878
const _market = await viem.getContractAt("CErc20RewardsDelegate", market);
@@ -82,7 +82,7 @@ task("market:base:add-rewards-to-existing-flywheel", "Adds rewards to existing f
8282
console.log(`mining tx ${tx}`);
8383
await publicClient.waitForTransactionReceipt({ hash: tx });
8484
console.log(`approved flywheel ${flywheel.address} to pull reward tokens from market ${market}`);
85-
85+
8686
// Adding strategies to flywheel
8787
const allFlywheelStrategies = (await flywheel.read.getAllStrategies()) as Address[];
8888
if (!allFlywheelStrategies.map((s) => s.toLowerCase()).includes(market.toLowerCase())) {
@@ -156,14 +156,14 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
156156
`Implementation successfully set to ${implementationAddress}: ${setImplementationTx}`
157157
);
158158
*/
159-
159+
/*
160160
// Sending tokens
161161
const ionToken = await viem.getContractAt("EIP20Interface", reward);
162162
const balance = await ionToken.read.balanceOf([market]);
163163
if (balance < parseEther(rewardAmount)) {
164164
await ionToken.write.transfer([market, parseEther(rewardAmount)]);
165165
}
166-
166+
*/
167167
// Deploying flywheel
168168
let booster = "";
169169
let flywheelBoosterAddress;
@@ -174,14 +174,14 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
174174
} else {
175175
contractName = "IonicFlywheel";
176176
}
177-
177+
178178
if (booster != "") {
179179
flywheelBoosterAddress = (await deployments.get(booster)).address as Address;
180180
} else flywheelBoosterAddress = zeroAddress;
181181

182-
let _flywheel = await deployments.getOrNull(`${contractName}_${name}`);
182+
let _flywheel = await deployments.getOrNull(`${contractName}_${name}_v3`);
183183
if (!_flywheel) {
184-
_flywheel = await deployments.deploy(`${contractName}_${name}`, {
184+
_flywheel = await deployments.deploy(`${contractName}_${name}_v3`, {
185185
contract: contractName,
186186
from: deployer,
187187
log: true,
@@ -201,18 +201,18 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
201201
} else {
202202
console.log(`Flywheel ${name} already deployed at ${_flywheel.address}`);
203203
}
204-
204+
205205
// Deploying flywheel rewards
206206
const flywheel = await viem.getContractAt(
207207
`${contractName}`,
208-
(await deployments.get(`${contractName}_${name}`)).address as Address
208+
(await deployments.get(`${contractName}_${name}_v3`)).address as Address
209209
);
210210

211-
let flywheelRewards = await deployments.getOrNull(`IonicFlywheelDynamicRewards_${name}`);
211+
let flywheelRewards = await deployments.getOrNull(`IonicFlywheelDynamicRewards_${name}_v3`);
212212
if (flywheelRewards) {
213213
console.log(`Flywheel rewards ${name} already deployed at ${flywheelRewards.address}`);
214214
} else {
215-
flywheelRewards = await deployments.deploy(`IonicFlywheelDynamicRewards_${name}`, {
215+
flywheelRewards = await deployments.deploy(`IonicFlywheelDynamicRewards_${name}_v3`, {
216216
contract: "IonicFlywheelDynamicRewards",
217217
from: deployer,
218218
log: true,
@@ -228,7 +228,7 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
228228
const txFlywheel = await flywheel.write.setFlywheelRewards([flywheelRewards.address as Address]);
229229
await publicClient.waitForTransactionReceipt({ hash: txFlywheel });
230230
console.log(`Set rewards (${flywheelRewards.address}) to flywheel (${flywheel.address})`);
231-
231+
232232
// Adding strategies to flywheel
233233
const allFlywheelStrategies = (await flywheel.read.getAllStrategies()) as Address[];
234234
if (!allFlywheelStrategies.map((s) => s.toLowerCase()).includes(market.toLowerCase())) {
@@ -249,7 +249,7 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
249249
console.log(`Flywheel ${flywheel.address} already added to pool ${COMPTROLLER}`);
250250
}
251251
console.log(`Added flywheel (${flywheel.address}) to pool (${COMPTROLLER})`);
252-
252+
253253
// Approving token sepening for fwRewards contract
254254
const _market = await viem.getContractAt("CErc20RewardsDelegate", market);
255255
const fwRewards = await flywheel.read.flywheelRewards();
@@ -264,7 +264,7 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
264264
task("market:base:add-flywheel-ION-rewards-to-ionbsdETH", "Adds rewards to existing flywheel").setAction(
265265
async (_, { viem, run, deployments, getNamedAccounts }) => {
266266
const market = "0x3d9669de9e3e98db41a1cbf6dc23446109945e3c"; // ionbsdETH
267-
const rewardAmount = "1666"; // epoch will start 2 days so 25000 / 30 * 2
267+
const rewardAmount = "23334"; // epoch will start 2 days so 25000 / 30 * 2
268268
const ion = "0x3eE5e23eEE121094f1cFc0Ccc79d6C809Ebd22e5";
269269
await run("market:base:add-rewards-to-existing-flywheel", {
270270
market,
@@ -277,7 +277,7 @@ task("market:base:add-flywheel-ION-rewards-to-ionbsdETH", "Adds rewards to exist
277277
task("market:base:deploy-flywheel-and-add-ION-rewards-to-ionhyUSD", "Deploys flywheel and adds rewards").setAction(
278278
async (_, { viem, run, deployments, getNamedAccounts }) => {
279279
const market = "0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe"; // ionhyUSD
280-
const rewardAmount = "1000"; // epoch will start 2 days so 15000 / 30 * 2
280+
const rewardAmount = "14000"; // epoch will start 2 days so 15000 / 30 * 2
281281
const ion = "0x3eE5e23eEE121094f1cFc0Ccc79d6C809Ebd22e5";
282282
const name = "ION"; // For borrow flywheel use Borrow_ION for supply flywheel just ION
283283
// NOTE: Make sure that epoch duration for supply and borrow are not the same

0 commit comments

Comments
 (0)