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

Commit

Permalink
Update RSR flywheel script
Browse files Browse the repository at this point in the history
  • Loading branch information
antisaa committed Aug 12, 2024
1 parent c807c3f commit 9260036
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions tasks/chain-specific/base/single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ task("market:base:rsr-ion-rewards", "Sets caps on a market").setAction(
const bsdETH = "0xCb327b99fF831bF8223cCEd12B1338FF3aA322Ff";
const ioneUSD = "0x9c2a4f9c5471fd36be3bbd8437a33935107215a1";
const eUSD = "0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4";
const hyUSD = "0xCc7FF230365bD730eE4B352cC2492CEdAC49383e"
const ionhyUSD = "0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe"
const IONIC = "0x3eE5e23eEE121094f1cFc0Ccc79d6C809Ebd22e5";
const RSR = "0xab36452dbac151be02b16ca17d8919826072f64a";
const pool = "0x05c9C6417F246600f8f5f49fcA9Ee991bfF73D13";
const comptroller = "0x05c9C6417F246600f8f5f49fcA9Ee991bfF73D13";
const markets = `${ionbsdETH},${ioneUSD}`;
const markets = `${ionhyUSD}`;

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

// STEP 1: upgrade markets to the new implementation
/*
console.log(`Upgrading market: ${ionbsdETH} to CErc20RewardsDelegate`);

console.log(`Upgrading market: ${ionhyUSD} to CErc20RewardsDelegate`);
await run("market:upgrade", {
comptroller,
underlying: bsdETH,
underlying: hyUSD,
implementationAddress: (await deployments.get("CErc20RewardsDelegate")).address,
signer: deployer
});
/*
console.log(`Upgrading market: ${ioneUSD} to CErc20RewardsDelegate`);
await run("market:upgrade", {
comptroller,
Expand All @@ -76,10 +78,11 @@ task("market:base:rsr-ion-rewards", "Sets caps on a market").setAction(
*/
// STEP 2: send reward tokens to strategies
const rsrToken = await viem.getContractAt("EIP20Interface", RSR);
const balance = await rsrToken.read.balanceOf([ionbsdETH]);
if (balance < parseEther("127863.019791")) {
await rsrToken.write.transfer([ionbsdETH, parseEther("127863.019791")]);
const balance = await rsrToken.read.balanceOf([ionhyUSD]);
if (balance < parseEther("45000")) {
await rsrToken.write.transfer([ionhyUSD, parseEther("45000")]);
}
/*
const balanceUSD = await rsrToken.read.balanceOf([ioneUSD]);
if (balanceUSD < parseEther("138981.543251")) {
await rsrToken.write.transfer([ioneUSD, parseEther("138981.543251")]);
Expand All @@ -93,18 +96,34 @@ task("market:base:rsr-ion-rewards", "Sets caps on a market").setAction(
strategies: markets,
pool
});

*/
const flywheel = await viem.getContractAt(
"IonicFlywheelBorrow",
(await deployments.get("IonicFlywheelBorrow_Borrow_RSR")).address as Address
(await deployments.get("IonicFlywheel_RSR")).address as Address
);
await run("approve-market-flywheel", {
fwAddress: flywheel.address,
markets: markets
});

const tx = await flywheel.write.updateFeeSettings([0n, deployer as Address]);
await publicClient.waitForTransactionReceipt({ hash: tx });
const strategyAddresses = markets.split(",");
const allFlywheelStrategies = (await flywheel.read.getAllStrategies()) as Address[];
for (const strategy of strategyAddresses) {
if (!allFlywheelStrategies.map((s) => s.toLowerCase()).includes(strategy.toLowerCase())) {
console.log(`Adding strategy ${strategy} to flywheel ${flywheel.address}`);
const addTx = await flywheel.write.addStrategyForRewards([strategy]);
await publicClient.waitForTransactionReceipt({ hash: addTx });
console.log(`Added strategy (${strategy}) to flywheel (${flywheel.address})`);
} else console.log(`Strategy (${strategy}) was already added to flywheel (${flywheel.address})`);
}

await run("flywheel:add-to-pool", {
flywheel: flywheel.address,
pool: pool
});

//const tx = await flywheel.write.updateFeeSettings([0n, deployer as Address]);
//await publicClient.waitForTransactionReceipt({ hash: tx });

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

0 comments on commit 9260036

Please sign in to comment.