|
| 1 | +/* eslint-disable no-use-before-define */ |
| 2 | +const hre = require("hardhat"); |
| 3 | +const { sendReportEmail } = require("../../mailService/mailService"); |
| 4 | +const { ethers } = hre; |
| 5 | + |
| 6 | +const pools = [ |
| 7 | + { |
| 8 | + address: "0x301C739CF6bfb6B47A74878BdEB13f92F13Ae5E7", |
| 9 | + |
| 10 | + // https://github.com/Giveth/giveth-dapps-v2/issues/4434 |
| 11 | + amount: "6374990", |
| 12 | + }, // Garden Unipool |
| 13 | +]; |
| 14 | + |
| 15 | +// Two decimals of precision -> 615 = 6.15 |
| 16 | +const distro = [ |
| 17 | + // https://github.com/Giveth/giveth-dapps-v2/issues/5486 |
| 18 | + 714, 714, 714, 714, 714, 714, 714, 714, 714, 714, 715, 715, 715, 715, |
| 19 | +]; |
| 20 | + |
| 21 | +const initTime = 1767891600; // Timestamp of first round in seconds: Thursday, JAN 08, 2026 17:00:00 GMT |
| 22 | + |
| 23 | +let UnipoolTokenDistributor, currentTime, nonce; |
| 24 | +async function main() { |
| 25 | + console.log("Trying to call notifyRewardAmount...", { |
| 26 | + date: new Date().toString(), |
| 27 | + }); |
| 28 | + currentTime = Math.floor(Date.now() / 1000); |
| 29 | + const [signer, ...addrs] = await ethers.getSigners(); |
| 30 | + nonce = await signer.getTransactionCount(); |
| 31 | + UnipoolTokenDistributor = await ethers.getContractFactory( |
| 32 | + "UnipoolTokenDistributor", |
| 33 | + ); |
| 34 | + await notifyRewardAmount(pools[0]); |
| 35 | +} |
| 36 | + |
| 37 | +async function notifyRewardAmount(pool) { |
| 38 | + const unipoolTokenDistributor = await UnipoolTokenDistributor.attach( |
| 39 | + pool.address, |
| 40 | + ); |
| 41 | + const periodFinish = await unipoolTokenDistributor.periodFinish(); |
| 42 | + const duration = await unipoolTokenDistributor.duration(); |
| 43 | + |
| 44 | + // 10 minutes of precision |
| 45 | + if (periodFinish < currentTime + 60 * 10) { |
| 46 | + const pos = Math.floor((currentTime - initTime) / duration); |
| 47 | + console.log("pos:", pos); |
| 48 | + if (pos < 0) return; |
| 49 | + if (distro[pos] === 0) return; |
| 50 | + const amount = ethers.utils |
| 51 | + .parseEther(pool.amount) |
| 52 | + .mul(distro[pos]) |
| 53 | + .div(10000); |
| 54 | + console.log( |
| 55 | + "UnipoolTokenDistributor - notifyRewardAmount:", |
| 56 | + pool.address, |
| 57 | + "->", |
| 58 | + ethers.utils.formatEther(amount.toString()), |
| 59 | + ); |
| 60 | + const tx = await ( |
| 61 | + await unipoolTokenDistributor.notifyRewardAmount(amount, { nonce }) |
| 62 | + ).wait(); |
| 63 | + nonce += 1; |
| 64 | + console.log("tx:", tx); |
| 65 | + await sendReportEmail({ |
| 66 | + farm: "Giv power", |
| 67 | + network: "Optimisim mainnet", |
| 68 | + pool: pool.address, |
| 69 | + round: pos + 1, |
| 70 | + script: "givpower_distribute_extended_sep_2024.js", |
| 71 | + transactionHash: tx.transactionHash, |
| 72 | + amount, |
| 73 | + }); |
| 74 | + } else { |
| 75 | + console.log( |
| 76 | + "UnipoolTokenDistributor - notifyRewardAmount:", |
| 77 | + pool.address, |
| 78 | + "already set", |
| 79 | + ); |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +main(); |
0 commit comments