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

Commit caf1aa0

Browse files
authored
Merge pull request #83 from ionicprotocol/update-rsr-flywheel-script
Update RSR flywheel script
2 parents c807c3f + b530f98 commit caf1aa0

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

tasks/chain-specific/base/single.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ task("market:base:rsr-ion-rewards", "Sets caps on a market").setAction(
3434
const bsdETH = "0xCb327b99fF831bF8223cCEd12B1338FF3aA322Ff";
3535
const ioneUSD = "0x9c2a4f9c5471fd36be3bbd8437a33935107215a1";
3636
const eUSD = "0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4";
37+
const hyUSD = "0xCc7FF230365bD730eE4B352cC2492CEdAC49383e"
38+
const ionhyUSD = "0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe"
3739
const IONIC = "0x3eE5e23eEE121094f1cFc0Ccc79d6C809Ebd22e5";
3840
const RSR = "0xab36452dbac151be02b16ca17d8919826072f64a";
3941
const pool = "0x05c9C6417F246600f8f5f49fcA9Ee991bfF73D13";
4042
const comptroller = "0x05c9C6417F246600f8f5f49fcA9Ee991bfF73D13";
41-
const markets = `${ionbsdETH},${ioneUSD}`;
43+
const markets = `${ionhyUSD}`;
4244

4345
/*
4446
const comptrollerContract = await viem.getContractAt("IonicComptroller", comptroller as Address);
@@ -56,15 +58,15 @@ task("market:base:rsr-ion-rewards", "Sets caps on a market").setAction(
5658
// await publicClient.waitForTransactionReceipt({ hash: tx });
5759

5860
// STEP 1: upgrade markets to the new implementation
59-
/*
60-
console.log(`Upgrading market: ${ionbsdETH} to CErc20RewardsDelegate`);
61+
62+
console.log(`Upgrading market: ${ionhyUSD} to CErc20RewardsDelegate`);
6163
await run("market:upgrade", {
6264
comptroller,
63-
underlying: bsdETH,
65+
underlying: hyUSD,
6466
implementationAddress: (await deployments.get("CErc20RewardsDelegate")).address,
6567
signer: deployer
6668
});
67-
69+
/*
6870
console.log(`Upgrading market: ${ioneUSD} to CErc20RewardsDelegate`);
6971
await run("market:upgrade", {
7072
comptroller,
@@ -76,10 +78,11 @@ task("market:base:rsr-ion-rewards", "Sets caps on a market").setAction(
7678
*/
7779
// STEP 2: send reward tokens to strategies
7880
const rsrToken = await viem.getContractAt("EIP20Interface", RSR);
79-
const balance = await rsrToken.read.balanceOf([ionbsdETH]);
80-
if (balance < parseEther("127863.019791")) {
81-
await rsrToken.write.transfer([ionbsdETH, parseEther("127863.019791")]);
81+
const balance = await rsrToken.read.balanceOf([ionhyUSD]);
82+
if (balance < parseEther("45000")) {
83+
await rsrToken.write.transfer([ionhyUSD, parseEther("45000")]);
8284
}
85+
/*
8386
const balanceUSD = await rsrToken.read.balanceOf([ioneUSD]);
8487
if (balanceUSD < parseEther("138981.543251")) {
8588
await rsrToken.write.transfer([ioneUSD, parseEther("138981.543251")]);
@@ -93,18 +96,29 @@ task("market:base:rsr-ion-rewards", "Sets caps on a market").setAction(
9396
strategies: markets,
9497
pool
9598
});
96-
99+
*/
97100
const flywheel = await viem.getContractAt(
98101
"IonicFlywheelBorrow",
99-
(await deployments.get("IonicFlywheelBorrow_Borrow_RSR")).address as Address
102+
(await deployments.get("IonicFlywheel_RSR")).address as Address
100103
);
101104
await run("approve-market-flywheel", {
102105
fwAddress: flywheel.address,
103106
markets: markets
104107
});
105108

106-
const tx = await flywheel.write.updateFeeSettings([0n, deployer as Address]);
107-
await publicClient.waitForTransactionReceipt({ hash: tx });
109+
const strategyAddresses = markets.split(",");
110+
const allFlywheelStrategies = (await flywheel.read.getAllStrategies()) as Address[];
111+
for (const strategy of strategyAddresses) {
112+
if (!allFlywheelStrategies.map((s) => s.toLowerCase()).includes(strategy.toLowerCase())) {
113+
console.log(`Adding strategy ${strategy} to flywheel ${flywheel.address}`);
114+
const addTx = await flywheel.write.addStrategyForRewards([strategy]);
115+
await publicClient.waitForTransactionReceipt({ hash: addTx });
116+
console.log(`Added strategy (${strategy}) to flywheel (${flywheel.address})`);
117+
} else console.log(`Strategy (${strategy}) was already added to flywheel (${flywheel.address})`);
118+
}
119+
120+
//const tx = await flywheel.write.updateFeeSettings([0n, deployer as Address]);
121+
//await publicClient.waitForTransactionReceipt({ hash: tx });
108122

109123
/*
110124
await run("flywheel:deploy-borrow-booster", { name: "ION" });

0 commit comments

Comments
 (0)