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

Commit

Permalink
Merge pull request #88 from ionicprotocol/create-separate-scripts-for…
Browse files Browse the repository at this point in the history
…-flywheel

Update script with new version of ION flywheel
  • Loading branch information
rhlsthrm authored Aug 19, 2024
2 parents 25fd4cf + e4e7eae commit 748987f
Show file tree
Hide file tree
Showing 12 changed files with 6,575 additions and 17 deletions.
289 changes: 289 additions & 0 deletions deployments/base/IonicFlywheelDynamicRewards_ION_v3.json

Large diffs are not rendered by default.

1,016 changes: 1,016 additions & 0 deletions deployments/base/IonicFlywheel_ION_v2.json

Large diffs are not rendered by default.

1,126 changes: 1,126 additions & 0 deletions deployments/base/IonicFlywheel_ION_v2_Implementation.json

Large diffs are not rendered by default.

289 changes: 289 additions & 0 deletions deployments/base/IonicFlywheel_ION_v2_Proxy.json

Large diffs are not rendered by default.

1,016 changes: 1,016 additions & 0 deletions deployments/base/IonicFlywheel_ION_v3.json

Large diffs are not rendered by default.

1,126 changes: 1,126 additions & 0 deletions deployments/base/IonicFlywheel_ION_v3_Implementation.json

Large diffs are not rendered by default.

289 changes: 289 additions & 0 deletions deployments/base/IonicFlywheel_ION_v3_Proxy.json

Large diffs are not rendered by default.

1,364 changes: 1,364 additions & 0 deletions deployments/base/solcInputs/3358b0e3b9146a940b243313bb7c29a1.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions deploymentsBrief/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
"IonicFlywheelDynamicRewards_ION": {
"address": "0x6660174886cb3B26B38E5D4c1324E0BfB361F7CA"
},
"IonicFlywheelDynamicRewards_ION_v3": {
"address": "0x57913CfF75Acd553923E58D3EAFbCDDCCf7816d7"
},
"IonicFlywheelDynamicRewards_RSR": {
"address": "0xCdfF6BA3613f37E719234A26775fF72BD937f22B"
},
Expand All @@ -116,6 +119,24 @@
"IonicFlywheel_ION_Proxy": {
"address": "0x6e93f617AB6CEfFec7c276B4fD4c136B7A7aDD54"
},
"IonicFlywheel_ION_v2": {
"address": "0x8D3879dAd76CaFF4b79F45Ca56bb90713182058a"
},
"IonicFlywheel_ION_v2_Implementation": {
"address": "0xeA19016fA9f4A2cce97d8aFA7D0D8e1b74a7887f"
},
"IonicFlywheel_ION_v2_Proxy": {
"address": "0x8D3879dAd76CaFF4b79F45Ca56bb90713182058a"
},
"IonicFlywheel_ION_v3": {
"address": "0x5Dc1fd5cFA5F1efdaCBC790b41A2BfB41bf4F122"
},
"IonicFlywheel_ION_v3_Implementation": {
"address": "0xa7BC89F9Bcd2E6565c250182767f20e2aC89bc7B"
},
"IonicFlywheel_ION_v3_Proxy": {
"address": "0x5Dc1fd5cFA5F1efdaCBC790b41A2BfB41bf4F122"
},
"IonicFlywheel_RSR": {
"address": "0xE4E74A0c98b8dEa4bcbB870C9391Bb73a230ced4"
},
Expand Down
21 changes: 21 additions & 0 deletions tasks/chain-specific/base/disableFlywheel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { task } from "hardhat/config";
import { Address, formatEther, parseEther } from "viem";
import { COMPTROLLER } from ".";

task("market:base:disable-flywheel", "Deploys flywheel and adds rewards").setAction(
async (_, { viem, run, deployments, getNamedAccounts }) => {
const { deployer } = await getNamedAccounts();
const publicClient = await viem.getPublicClient();

const flywheel = await viem.getContractAt(
"IonicFlywheel",
(await deployments.get("IonicFlywheel_ION_v2")).address as Address
);

const comptroller = await viem.getContractAt("IonicComptroller", COMPTROLLER);
const addTx = await comptroller.write.addNonAccruingFlywheel([flywheel.address]);
await publicClient.waitForTransactionReceipt({ hash: addTx });
console.log({ addTx });
console.log("Remove IonicFlywheel_ION_v2 from comptroller");
}
);
1 change: 1 addition & 0 deletions tasks/chain-specific/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import "./markets";
import "./single";
import "./rewards";
import "./tokens";
import "./disableFlywheel";

export const COMPTROLLER = "0x05c9C6417F246600f8f5f49fcA9Ee991bfF73D13";
34 changes: 17 additions & 17 deletions tasks/chain-specific/base/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ task("market:base:add-rewards-to-existing-flywheel", "Adds rewards to existing f
`Implementation successfully set to ${implementationAddress}: ${setImplementationTx}`
);
*/

/*
// Sending tokens
const ionToken = await viem.getContractAt("EIP20Interface", reward);
const balance = await ionToken.read.balanceOf([market]);
if (balance < parseEther(rewardAmount)) {
await ionToken.write.transfer([market, parseEther(rewardAmount)]);
}

*/
// Approving token sepening for fwRewards contract
const flywheel = await viem.getContractAt(
"IonicFlywheel",
(await deployments.get("IonicFlywheel_ION")).address as Address
(await deployments.get("IonicFlywheel_ION_v3")).address as Address
);

const _market = await viem.getContractAt("CErc20RewardsDelegate", market);
Expand All @@ -82,7 +82,7 @@ task("market:base:add-rewards-to-existing-flywheel", "Adds rewards to existing f
console.log(`mining tx ${tx}`);
await publicClient.waitForTransactionReceipt({ hash: tx });
console.log(`approved flywheel ${flywheel.address} to pull reward tokens from market ${market}`);

// Adding strategies to flywheel
const allFlywheelStrategies = (await flywheel.read.getAllStrategies()) as Address[];
if (!allFlywheelStrategies.map((s) => s.toLowerCase()).includes(market.toLowerCase())) {
Expand Down Expand Up @@ -156,14 +156,14 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
`Implementation successfully set to ${implementationAddress}: ${setImplementationTx}`
);
*/

/*
// Sending tokens
const ionToken = await viem.getContractAt("EIP20Interface", reward);
const balance = await ionToken.read.balanceOf([market]);
if (balance < parseEther(rewardAmount)) {
await ionToken.write.transfer([market, parseEther(rewardAmount)]);
}

*/
// Deploying flywheel
let booster = "";
let flywheelBoosterAddress;
Expand All @@ -174,14 +174,14 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
} else {
contractName = "IonicFlywheel";
}

if (booster != "") {
flywheelBoosterAddress = (await deployments.get(booster)).address as Address;
} else flywheelBoosterAddress = zeroAddress;

let _flywheel = await deployments.getOrNull(`${contractName}_${name}`);
let _flywheel = await deployments.getOrNull(`${contractName}_${name}_v3`);
if (!_flywheel) {
_flywheel = await deployments.deploy(`${contractName}_${name}`, {
_flywheel = await deployments.deploy(`${contractName}_${name}_v3`, {
contract: contractName,
from: deployer,
log: true,
Expand All @@ -201,18 +201,18 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
} else {
console.log(`Flywheel ${name} already deployed at ${_flywheel.address}`);
}

// Deploying flywheel rewards
const flywheel = await viem.getContractAt(
`${contractName}`,
(await deployments.get(`${contractName}_${name}`)).address as Address
(await deployments.get(`${contractName}_${name}_v3`)).address as Address
);

let flywheelRewards = await deployments.getOrNull(`IonicFlywheelDynamicRewards_${name}`);
let flywheelRewards = await deployments.getOrNull(`IonicFlywheelDynamicRewards_${name}_v3`);
if (flywheelRewards) {
console.log(`Flywheel rewards ${name} already deployed at ${flywheelRewards.address}`);
} else {
flywheelRewards = await deployments.deploy(`IonicFlywheelDynamicRewards_${name}`, {
flywheelRewards = await deployments.deploy(`IonicFlywheelDynamicRewards_${name}_v3`, {
contract: "IonicFlywheelDynamicRewards",
from: deployer,
log: true,
Expand All @@ -228,7 +228,7 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
const txFlywheel = await flywheel.write.setFlywheelRewards([flywheelRewards.address as Address]);
await publicClient.waitForTransactionReceipt({ hash: txFlywheel });
console.log(`Set rewards (${flywheelRewards.address}) to flywheel (${flywheel.address})`);

// Adding strategies to flywheel
const allFlywheelStrategies = (await flywheel.read.getAllStrategies()) as Address[];
if (!allFlywheelStrategies.map((s) => s.toLowerCase()).includes(market.toLowerCase())) {
Expand All @@ -249,7 +249,7 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
console.log(`Flywheel ${flywheel.address} already added to pool ${COMPTROLLER}`);
}
console.log(`Added flywheel (${flywheel.address}) to pool (${COMPTROLLER})`);

// Approving token sepening for fwRewards contract
const _market = await viem.getContractAt("CErc20RewardsDelegate", market);
const fwRewards = await flywheel.read.flywheelRewards();
Expand All @@ -264,7 +264,7 @@ task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
task("market:base:add-flywheel-ION-rewards-to-ionbsdETH", "Adds rewards to existing flywheel").setAction(
async (_, { viem, run, deployments, getNamedAccounts }) => {
const market = "0x3d9669de9e3e98db41a1cbf6dc23446109945e3c"; // ionbsdETH
const rewardAmount = "1666"; // epoch will start 2 days so 25000 / 30 * 2
const rewardAmount = "23334"; // epoch will start 2 days so 25000 / 30 * 2
const ion = "0x3eE5e23eEE121094f1cFc0Ccc79d6C809Ebd22e5";
await run("market:base:add-rewards-to-existing-flywheel", {
market,
Expand All @@ -277,7 +277,7 @@ task("market:base:add-flywheel-ION-rewards-to-ionbsdETH", "Adds rewards to exist
task("market:base:deploy-flywheel-and-add-ION-rewards-to-ionhyUSD", "Deploys flywheel and adds rewards").setAction(
async (_, { viem, run, deployments, getNamedAccounts }) => {
const market = "0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe"; // ionhyUSD
const rewardAmount = "1000"; // epoch will start 2 days so 15000 / 30 * 2
const rewardAmount = "14000"; // epoch will start 2 days so 15000 / 30 * 2
const ion = "0x3eE5e23eEE121094f1cFc0Ccc79d6C809Ebd22e5";
const name = "ION"; // For borrow flywheel use Borrow_ION for supply flywheel just ION
// NOTE: Make sure that epoch duration for supply and borrow are not the same
Expand Down

0 comments on commit 748987f

Please sign in to comment.