From e6c7cb22b95bde681be74018b9f6c718d8e0efbf Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Mon, 2 Dec 2024 07:35:15 +0330 Subject: [PATCH 1/2] Add DEC 2024 rewards related to https://github.com/Giveth/giveth-dapps-v2/issues/4869 --- .../givpower_distribute_extended_dec_2024.js | 83 ++++++++++++++++++ .../givpower_distribute_extended_dec_2024.js | 87 +++++++++++++++++++ .../givpower_distribute_extended_dec_2024.js | 83 ++++++++++++++++++ package.json | 3 + 4 files changed, 256 insertions(+) create mode 100644 deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js create mode 100644 deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js create mode 100644 deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js diff --git a/deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js b/deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js new file mode 100644 index 0000000..1830b3e --- /dev/null +++ b/deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js @@ -0,0 +1,83 @@ +/* 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/4434 + amount: "3825000", + }, // Garden Unipool +]; + +// Two decimals of precision -> 615 = 6.15 +const distro = [ + // https://github.com/Giveth/giveth-dapps-v2/issues/4869 + 685, 700, 713, 727, 742, 756, 770, 783, 797, 811, 825, 839, 852, +]; + +const initTime = 1733842800; // Timestamp of first round in seconds: Tuesday, DEC 10, 2024 15: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_sep_2024.js", + transactionHash: tx.transactionHash, + amount, + }); + } else { + console.log( + "UnipoolTokenDistributor - notifyRewardAmount:", + pool.address, + "already set", + ); + } +} + +main(); diff --git a/deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js b/deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js new file mode 100644 index 0000000..b1f07f0 --- /dev/null +++ b/deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js @@ -0,0 +1,87 @@ +/* eslint-disable no-use-before-define */ +const hre = require("hardhat"); +const { sendReportEmail } = require("../../mailService/mailService"); +const { ethers } = hre; + +const pools = [ + { + address: "0xD93d3bDBa18ebcB3317a57119ea44ed2Cf41C2F2", + + // https://github.com/Giveth/giveth-dapps-v2/issues/4434 + amount: "2550000", + }, // Garden Unipool +]; + +// Two decimals of precision -> 615 = 6.15 +const distro = [ + // https://github.com/Giveth/giveth-dapps-v2/issues/4869 + 685, 700, 713, 727, 742, 756, 770, 783, 797, 811, 825, 839, 852, +]; + +const initTime = 1733842800; // Timestamp of first round in seconds: Tuesday, DEC 10, 2024 15:00:00 GMT + +let UnipoolTokenDistributor, currentTime, nonce; +async function main() { + try { + 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]); + } catch (e) { + console.log("error when calling notifyRewardAmount:", e); + throw e; + } +} + +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; + 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: "Gnosis", + pool: pool.address, + round: pos + 1, + script: "givpower_distribute_extended_sep_2024.js", + transactionHash: tx.transactionHash, + amount, + }); + } else { + console.log( + "UnipoolTokenDistributor - notifyRewardAmount:", + pool.address, + "already set", + ); + } +} + +main(); diff --git a/deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js b/deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js new file mode 100644 index 0000000..28e83fd --- /dev/null +++ b/deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js @@ -0,0 +1,83 @@ +/* eslint-disable no-use-before-define */ +const hre = require("hardhat"); +const { sendReportEmail } = require("../../mailService/mailService"); +const { ethers } = hre; + +const pools = [ + { + address: "0xc790f82bf6f8709aa4a56dc11afad7af7c2a9867", + + // https://github.com/Giveth/giveth-dapps-v2/issues/4434 + amount: "2125000", + }, // Garden Unipool +]; + +// Two decimals of precision -> 615 = 6.15 +const distro = [ + // https://github.com/Giveth/giveth-dapps-v2/issues/4869 + 685, 700, 713, 727, 742, 756, 770, 783, 797, 811, 825, 839, 852, +]; + +const initTime = 1733842800; // Timestamp of first round in seconds: Tuesday, DEC 10, 2024 15: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: "ZKEVM mainnet", + pool: pool.address, + round: pos + 1, + script: "givpower_distribute_extended_sep_2024.js", + transactionHash: tx.transactionHash, + amount, + }); + } else { + console.log( + "UnipoolTokenDistributor - notifyRewardAmount:", + pool.address, + "already set", + ); + } +} + +main(); diff --git a/package.json b/package.json index fc0c8c9..02c8384 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,15 @@ "distributor:xDAI:givPower:extended:oct2023": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_oct_2023.js", "distributor:xDAI:givPower:extended:may2024": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_may_2024.js", "distributor:xDAI:givPower:extended:sep2024": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_sep_2024.js", + "distributor:xDAI:givPower:extended:dec2024": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js", "distributor:xDAI:givPower:extended:sep2024Temp": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_sep_2024Temp.js", "distributor:optimismMainnet:givPower:extended": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended.js", "distributor:optimismMainnet:givPower:extended:oct2023": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_oct_2023.js", "distributor:optimismMainnet:givPower:extended:sep2024": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_sep_2024.js", + "distributor:optimismMainnet:givPower:extended:dec2024": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js", "distributor:optimismMainnet:givPower:extended:sep2024Temp": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_sep_2024Temp.js", "distributor:zkevm:givPower:extended:sep2024": "HARDHAT_NETWORK=zkEVM ts-node deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_sep_2024.js", + "distributor:zkevm:givPower:extended:dec2024": "HARDHAT_NETWORK=zkEVM ts-node deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js", "distributor:zkevm:givPower:extended:sep2024Temp": "HARDHAT_NETWORK=zkEVM ts-node deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_sep_2024.js", "distributor:mainnet:extended": "HARDHAT_NETWORK=mainnet ts-node deployments/notifyRewardAmount/mainnet/distributor_extended.js", "distributor:mainnet:extended2": "HARDHAT_NETWORK=mainnet ts-node deployments/notifyRewardAmount/mainnet/distributor_extended2.js", From 52b6945f265c67a48538fb3b063cb70f4fc45eb9 Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Thu, 5 Dec 2024 10:39:48 +0330 Subject: [PATCH 2/2] Modify amounts of DEC 2024 rewards related to https://github.com/Giveth/giv-token-contracts/pull/107 --- .../optimism/givpower_distribute_extended_dec_2024.js | 2 +- .../xDAI/givpower_distribute_extended_dec_2024.js | 2 +- .../zkevm/givpower_distribute_extended_dec_2024.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js b/deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js index 1830b3e..b1f7518 100644 --- a/deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js +++ b/deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js @@ -8,7 +8,7 @@ const pools = [ address: "0x301C739CF6bfb6B47A74878BdEB13f92F13Ae5E7", // https://github.com/Giveth/giveth-dapps-v2/issues/4434 - amount: "3825000", + amount: "3584250", }, // Garden Unipool ]; diff --git a/deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js b/deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js index b1f07f0..79f5313 100644 --- a/deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js +++ b/deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js @@ -8,7 +8,7 @@ const pools = [ address: "0xD93d3bDBa18ebcB3317a57119ea44ed2Cf41C2F2", // https://github.com/Giveth/giveth-dapps-v2/issues/4434 - amount: "2550000", + amount: "2389500", }, // Garden Unipool ]; diff --git a/deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js b/deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js index 28e83fd..c4e5e69 100644 --- a/deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js +++ b/deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js @@ -8,7 +8,7 @@ const pools = [ address: "0xc790f82bf6f8709aa4a56dc11afad7af7c2a9867", // https://github.com/Giveth/giveth-dapps-v2/issues/4434 - amount: "2125000", + amount: "1991250", }, // Garden Unipool ];