2023-06-03 20:53:36 +03:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from "path";
|
|
|
|
import BigNumber from "bignumber.js";
|
|
|
|
|
|
|
|
import { getStakersWithRewardsBeforeHack } from '../utils/stakers';
|
|
|
|
|
2023-06-12 16:22:32 +03:00
|
|
|
// Format options for BigNumber printing
|
|
|
|
const fmt = {
|
|
|
|
prefix: '',
|
|
|
|
decimalSeparator: '.',
|
|
|
|
groupSeparator: '_',
|
|
|
|
groupSize: 3,
|
|
|
|
secondaryGroupSize: 0,
|
|
|
|
fractionGroupSeparator: ' ',
|
|
|
|
fractionGroupSize: 0,
|
|
|
|
suffix: ''
|
|
|
|
}
|
|
|
|
BigNumber.config({ FORMAT: fmt });
|
|
|
|
|
2023-06-03 20:53:36 +03:00
|
|
|
async function main() {
|
|
|
|
const stakersWithRewardsBeforeHack = await getStakersWithRewardsBeforeHack();
|
|
|
|
|
|
|
|
const rewardsSum = stakersWithRewardsBeforeHack.reduce((acc, staker) => acc.plus(staker.rewardBalance), BigNumber(0));
|
|
|
|
console.log("Sum of rewards before hack:", rewardsSum.div(1e18).toFixed(2), "TORN");
|
|
|
|
|
|
|
|
const stakersDisplayedInfo = stakersWithRewardsBeforeHack.map(staker => {
|
|
|
|
return `${staker.address} = ${staker.rewardBalance.toString(10)} (~ ${staker.rewardBalance.div(1e18).toFixed(2)} TORN)`;
|
|
|
|
})
|
2023-06-12 16:22:32 +03:00
|
|
|
fs.writeFileSync(path.join("data", "rewardsBeforeHack.txt"), stakersDisplayedInfo.join('\n'));
|
|
|
|
|
|
|
|
const commandsToAccrueRewards = stakersWithRewardsBeforeHack.map(staker => {
|
|
|
|
return `staking.setReward(${staker.address}, staking.checkReward(${staker.address}) + ${staker.rewardBalance.toFormat()});`;
|
|
|
|
})
|
|
|
|
const commandToReplenishStaking = `IERC20(tornAddress).transfer(stakingProxyAddress, ${rewardsSum.toFormat()});`;
|
|
|
|
const codePadding = " ".repeat(8);
|
|
|
|
const codeToAccrueRewards = codePadding + commandsToAccrueRewards.join(`\n${codePadding}`) + '\n' + codePadding + commandToReplenishStaking;
|
|
|
|
fs.writeFileSync(path.join("data", "codeToAccrueRewards.txt"), codeToAccrueRewards);
|
2023-06-03 20:53:36 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|