Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2b4a591

Browse files
authoredDec 10, 2024··
Merge pull request #107 from Giveth/4869_adjust_notify_reward_dec_2024
Add DEC 2024 rewards
2 parents b891b15 + 52b6945 commit 2b4a591

File tree

4 files changed

+256
-0
lines changed

4 files changed

+256
-0
lines changed
 
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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: "3584250",
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/4869
18+
685, 700, 713, 727, 742, 756, 770, 783, 797, 811, 825, 839, 852,
19+
];
20+
21+
const initTime = 1733842800; // Timestamp of first round in seconds: Tuesday, DEC 10, 2024 15: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();
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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: "0xD93d3bDBa18ebcB3317a57119ea44ed2Cf41C2F2",
9+
10+
// https://github.com/Giveth/giveth-dapps-v2/issues/4434
11+
amount: "2389500",
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/4869
18+
685, 700, 713, 727, 742, 756, 770, 783, 797, 811, 825, 839, 852,
19+
];
20+
21+
const initTime = 1733842800; // Timestamp of first round in seconds: Tuesday, DEC 10, 2024 15:00:00 GMT
22+
23+
let UnipoolTokenDistributor, currentTime, nonce;
24+
async function main() {
25+
try {
26+
console.log("Trying to call notifyRewardAmount...", {
27+
date: new Date().toString(),
28+
});
29+
currentTime = Math.floor(Date.now() / 1000);
30+
const [signer, ...addrs] = await ethers.getSigners();
31+
nonce = await signer.getTransactionCount();
32+
UnipoolTokenDistributor = await ethers.getContractFactory(
33+
"UnipoolTokenDistributor",
34+
);
35+
await notifyRewardAmount(pools[0]);
36+
} catch (e) {
37+
console.log("error when calling notifyRewardAmount:", e);
38+
throw e;
39+
}
40+
}
41+
42+
async function notifyRewardAmount(pool) {
43+
const unipoolTokenDistributor = await UnipoolTokenDistributor.attach(
44+
pool.address,
45+
);
46+
const periodFinish = await unipoolTokenDistributor.periodFinish();
47+
const duration = await unipoolTokenDistributor.duration();
48+
49+
// 10 minutes of precision
50+
if (periodFinish < currentTime + 60 * 10) {
51+
const pos = Math.floor((currentTime - initTime) / duration);
52+
console.log("pos:", pos);
53+
if (pos < 0) return;
54+
const amount = ethers.utils
55+
.parseEther(pool.amount)
56+
.mul(distro[pos])
57+
.div(10000);
58+
console.log(
59+
"UnipoolTokenDistributor - notifyRewardAmount:",
60+
pool.address,
61+
"->",
62+
ethers.utils.formatEther(amount.toString()),
63+
);
64+
const tx = await (
65+
await unipoolTokenDistributor.notifyRewardAmount(amount, { nonce })
66+
).wait();
67+
nonce += 1;
68+
console.log("tx:", tx);
69+
await sendReportEmail({
70+
farm: "Giv power",
71+
network: "Gnosis",
72+
pool: pool.address,
73+
round: pos + 1,
74+
script: "givpower_distribute_extended_sep_2024.js",
75+
transactionHash: tx.transactionHash,
76+
amount,
77+
});
78+
} else {
79+
console.log(
80+
"UnipoolTokenDistributor - notifyRewardAmount:",
81+
pool.address,
82+
"already set",
83+
);
84+
}
85+
}
86+
87+
main();
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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: "0xc790f82bf6f8709aa4a56dc11afad7af7c2a9867",
9+
10+
// https://github.com/Giveth/giveth-dapps-v2/issues/4434
11+
amount: "1991250",
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/4869
18+
685, 700, 713, 727, 742, 756, 770, 783, 797, 811, 825, 839, 852,
19+
];
20+
21+
const initTime = 1733842800; // Timestamp of first round in seconds: Tuesday, DEC 10, 2024 15: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: "ZKEVM 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();

‎package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@
2828
"distributor:xDAI:givPower:extended:oct2023": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_oct_2023.js",
2929
"distributor:xDAI:givPower:extended:may2024": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_may_2024.js",
3030
"distributor:xDAI:givPower:extended:sep2024": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_sep_2024.js",
31+
"distributor:xDAI:givPower:extended:dec2024": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_dec_2024.js",
3132
"distributor:xDAI:givPower:extended:sep2024Temp": "HARDHAT_NETWORK=xDAI ts-node deployments/notifyRewardAmount/xDAI/givpower_distribute_extended_sep_2024Temp.js",
3233
"distributor:optimismMainnet:givPower:extended": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended.js",
3334
"distributor:optimismMainnet:givPower:extended:oct2023": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_oct_2023.js",
3435
"distributor:optimismMainnet:givPower:extended:sep2024": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_sep_2024.js",
36+
"distributor:optimismMainnet:givPower:extended:dec2024": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_dec_2024.js",
3537
"distributor:optimismMainnet:givPower:extended:sep2024Temp": "HARDHAT_NETWORK=optimismMainnet ts-node deployments/notifyRewardAmount/optimism/givpower_distribute_extended_sep_2024Temp.js",
3638
"distributor:zkevm:givPower:extended:sep2024": "HARDHAT_NETWORK=zkEVM ts-node deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_sep_2024.js",
39+
"distributor:zkevm:givPower:extended:dec2024": "HARDHAT_NETWORK=zkEVM ts-node deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_dec_2024.js",
3740
"distributor:zkevm:givPower:extended:sep2024Temp": "HARDHAT_NETWORK=zkEVM ts-node deployments/notifyRewardAmount/zkevm/givpower_distribute_extended_sep_2024.js",
3841
"distributor:mainnet:extended": "HARDHAT_NETWORK=mainnet ts-node deployments/notifyRewardAmount/mainnet/distributor_extended.js",
3942
"distributor:mainnet:extended2": "HARDHAT_NETWORK=mainnet ts-node deployments/notifyRewardAmount/mainnet/distributor_extended2.js",

0 commit comments

Comments
 (0)
Please sign in to comment.