-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from Giveth/f_1354_reward_for_august
reward for august 2022
- Loading branch information
Showing
3 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
deployments/notifyRewardAmount/mainnet/distributor_extended2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* eslint-disable no-use-before-define */ | ||
const hre = require("hardhat"); | ||
const { ethers } = hre; | ||
|
||
// https://github.com/Giveth/giveth-dapps-v2/issues/1353 | ||
|
||
const pools = [ | ||
{ | ||
address: "0xc0dbDcA66a0636236fAbe1B3C16B1bD4C84bB1E1", | ||
amount: " 900000", // 75000 * 6 (rounds) * 2 (weeks) = 900,000, | ||
}, // BAL GIV/ETH | ||
]; | ||
|
||
// Two decimals of precision -> 1666 = 16.66 | ||
const distro = [1666, 1666, 1666, 1666, 1666, 1666]; | ||
|
||
/* START TIME | ||
* GIVeconomy start time + last reward round (17 * 2 weeks) | ||
* 1640361600 + 17 * 2 * 7 * 24 * 3600 = 1660924800 | ||
*/ | ||
const initTime = 1660924800; | ||
|
||
let UnipoolTokenDistributor, currentTime, nonce; | ||
async function main() { | ||
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) { | ||
console.log("notifyReward has been called for", pool.address); | ||
const unipoolTokenDistributor = await UnipoolTokenDistributor.attach( | ||
pool.address, | ||
); | ||
const periodFinish = await unipoolTokenDistributor.periodFinish(); | ||
const duration = await unipoolTokenDistributor.duration(); | ||
// 1 hour of precision | ||
if (periodFinish < currentTime + 3600) { | ||
const pos = Math.floor((currentTime - initTime) / duration); | ||
console.log("pos:", pos); | ||
if (pos < 0) { | ||
console.log("The currentTime is lower than initTime ", { | ||
currentTime, | ||
initTime, | ||
}); | ||
return; | ||
} | ||
if (pos >= distro.length) { | ||
console.log("There is no distro for this pool", { | ||
pos, | ||
poolAddress: pool.address, | ||
}); | ||
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); | ||
} else { | ||
console.log( | ||
"UnipoolTokenDistributor - notifyRewardAmount:", | ||
pool.address, | ||
"already set", | ||
); | ||
} | ||
} | ||
|
||
main(); |
85 changes: 85 additions & 0 deletions
85
deployments/notifyRewardAmount/xDAI/distributor_extended2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* eslint-disable no-use-before-define */ | ||
|
||
// https://github.com/Giveth/giveth-dapps-v2/issues/1353 | ||
|
||
const hre = require("hardhat"); | ||
const { ethers } = hre; | ||
|
||
const pools = [ | ||
{ | ||
address: "0xD93d3bDBa18ebcB3317a57119ea44ed2Cf41C2F2", | ||
amount: "800000", // 100000 * 4 (rounds) * 2 (weeks) = 800,000 | ||
}, // $GIV | ||
]; | ||
|
||
// Two decimals of precision -> 2500 = 25.00 | ||
const distro = [2500, 2500, 2500, 2500]; | ||
|
||
/* START TIME | ||
* GIVeconomy start time + last reward round (17 * 2 weeks) | ||
* 1640361600 + 17 * 2 * 7 * 24 * 3600 = 1656086400 | ||
*/ | ||
const initTime = 1660924800; | ||
|
||
let UnipoolTokenDistributor, currentTime, nonce; | ||
async function main() { | ||
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) { | ||
console.log("notifyReward has been called for", pool.address); | ||
const unipoolTokenDistributor = await UnipoolTokenDistributor.attach( | ||
pool.address, | ||
); | ||
const periodFinish = await unipoolTokenDistributor.periodFinish(); | ||
const duration = await unipoolTokenDistributor.duration(); | ||
|
||
// 1 hour of precision | ||
if (periodFinish < currentTime + 3600) { | ||
const pos = Math.floor((currentTime - initTime) / duration); | ||
console.log("pos:", pos); | ||
if (pos < 0) { | ||
console.log("The currentTime is lower than initTime ", { | ||
currentTime, | ||
initTime, | ||
}); | ||
return; | ||
} | ||
if (pos >= distro.length) { | ||
console.log("There is no distro for this pool", { | ||
pos, | ||
poolAddress: pool.address, | ||
}); | ||
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); | ||
} else { | ||
console.log( | ||
"UnipoolTokenDistributor - notifyRewardAmount:", | ||
pool.address, | ||
"already set", | ||
); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters