Skip to content

Commit

Permalink
extend givpower optimism 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenluz authored Apr 24, 2024
1 parent be1c1b5 commit 4257869
Showing 1 changed file with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* eslint-disable no-use-before-define */
const hre = require("hardhat");
const { sendReportEmail } = require("../../mailService/mailService");
const { ethers } = hre;

const pools = [
{
address: "0x301C739CF6bfb6B47A74878BdEB13f92F13Ae5E7",

// https://github.com/Giveth/giveth-dapps-v2/issues/4057
amount: "4250000",
}, // Garden Unipool
];

// Two decimals of precision -> 615 = 6.15
const distro = [
665, 673, 680, 688, 695, 702, 711, 718, 726, 733, 741, 748, 756, 764
];

const initTime = 1714500000; // Timestamp of first round in seconds: Tuesday, APR 30, 2024 18:00:00 GMT

let UnipoolTokenDistributor, currentTime, nonce;
async function main() {
console.log("Trying to call notifyRewardAmount...", {
date: new Date().toString(),
});
currentTime = Math.floor(Date.now() / 1000);
const [signer, ...addrs] = await ethers.getSigners();
nonce = await signer.getTransactionCount();
UnipoolTokenDistributor = await ethers.getContractFactory(
"UnipoolTokenDistributor",
);
await notifyRewardAmount(pools[0]);
}

async function notifyRewardAmount(pool) {
const unipoolTokenDistributor = await UnipoolTokenDistributor.attach(
pool.address,
);
const periodFinish = await unipoolTokenDistributor.periodFinish();
const duration = await unipoolTokenDistributor.duration();

// 10 minutes of precision
if (periodFinish < currentTime + 60 * 10) {
const pos = Math.floor((currentTime - initTime) / duration);
console.log("pos:", pos);
if (pos < 0) return;
if (distro[pos] === 0) return;
const amount = ethers.utils
.parseEther(pool.amount)
.mul(distro[pos])
.div(10000);
console.log(
"UnipoolTokenDistributor - notifyRewardAmount:",
pool.address,
"->",
ethers.utils.formatEther(amount.toString()),
);
const tx = await (
await unipoolTokenDistributor.notifyRewardAmount(amount, { nonce })
).wait();
nonce += 1;
console.log("tx:", tx);
await sendReportEmail({
farm: "Giv power",
network: "Optimisim mainnet",
pool: pool.address,
round: pos + 1,
script: "givpower_distribute_extended.js",
transactionHash: tx.transactionHash,
amount,
});
} else {
console.log(
"UnipoolTokenDistributor - notifyRewardAmount:",
pool.address,
"already set",
);
}
}

main();

0 comments on commit 4257869

Please sign in to comment.