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

Commit

Permalink
Update script
Browse files Browse the repository at this point in the history
  • Loading branch information
antisaa committed Aug 19, 2024
1 parent a1f5e2f commit c2920d3
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 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_v2")).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 All @@ -91,7 +91,6 @@ task("market:base:add-rewards-to-existing-flywheel", "Adds rewards to existing f
await publicClient.waitForTransactionReceipt({ hash: addTx });
console.log(`Added strategy (${market}) to flywheel (${flywheel.address})`);
} else console.log(`Strategy (${market}) was already added to flywheel (${flywheel.address})`);
*/
});

task("market:base:deploy-flywheel-and-add-rewards", "Sets caps on a market")
Expand Down Expand Up @@ -175,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}_v2`);
let _flywheel = await deployments.getOrNull(`${contractName}_${name}_v3`);
if (!_flywheel) {
_flywheel = await deployments.deploy(`${contractName}_${name}_v2`, {
_flywheel = await deployments.deploy(`${contractName}_${name}_v3`, {
contract: contractName,
from: deployer,
log: true,
Expand All @@ -202,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}_v2`)).address as Address
(await deployments.get(`${contractName}_${name}_v3`)).address as Address
);

let flywheelRewards = await deployments.getOrNull(`IonicFlywheelDynamicRewards_${name}_v2`);
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}_v2`, {
flywheelRewards = await deployments.deploy(`IonicFlywheelDynamicRewards_${name}_v3`, {
contract: "IonicFlywheelDynamicRewards",
from: deployer,
log: true,
Expand All @@ -229,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 @@ -250,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 Down

0 comments on commit c2920d3

Please sign in to comment.