From b530f988726e2fac23184c582c04da69912f0011 Mon Sep 17 00:00:00 2001 From: antisaa Date: Mon, 12 Aug 2024 15:17:28 +0200 Subject: [PATCH] Update RSR flywheel script --- tasks/chain-specific/base/single.ts | 38 ++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/tasks/chain-specific/base/single.ts b/tasks/chain-specific/base/single.ts index c7bb6a60..4fb1e11f 100644 --- a/tasks/chain-specific/base/single.ts +++ b/tasks/chain-specific/base/single.ts @@ -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); @@ -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, @@ -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")]); @@ -93,18 +96,29 @@ 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})`); + } + + //const tx = await flywheel.write.updateFeeSettings([0n, deployer as Address]); + //await publicClient.waitForTransactionReceipt({ hash: tx }); /* await run("flywheel:deploy-borrow-booster", { name: "ION" });