no bigint rounddata + cycle improvements

This commit is contained in:
EmberSpirit
2023-09-14 22:07:51 +02:00
parent 0ff38abfb4
commit ca243064f7
5 changed files with 69 additions and 37 deletions
+41 -21
View File
@@ -27,7 +27,8 @@ export const useRoundsStore = defineStore("rounds", {
}
},
getCurrentRoundData() {
console.log("this.rounds", this.rounds);
console.log("this.rounds", this.rounds);
console.log("this.rounds[this.activeRound]", this.rounds[this.activeRound]);
return this.rounds[this.activeRound];
},
},
@@ -99,42 +100,61 @@ export const useRoundsStore = defineStore("rounds", {
console.log("goal", goal);
var tokenArray = [];
var rewards_clan = 0;
var rewards_sacrifice = 0;
var rewards_sacrifice = 0;
var rewards_staking = 0;
console.log("data", data);
for (let index = 0; index < data.length; index++) {
var tokenData = {};
const token = tokenStore.token[index];
var testcoef = await rewardLockerStore.getSacrificedTokenCoefficient(
roundNumber,
token.contractAddress
);
);
console.log("testcoef", testcoef);
tokenData.name = token.name;
tokenData.contractAddress = token.contractAddress;
tokenData.vamplogo = token.vamp.logo;
tokenData.vampname = token.vamp.name;
tokenData.amount = data[index].result[1];
tokenData.getAmountToReachGoal = await memeBurnerStore.getAmountToReachGoal(token.contractAddress);
if (this.currentRound !== roundNumber && walletStore.connected) {
const clanwin = (Number(testcoef) / 10000 - 1) * Number(rewardData[index].result);
const sacrificeRewards = Number(rewardData[index].result) - clanwin;
// tokenData.amount = data[index].result[1];
tokenData.amount = Number(data[index].result[1]) / Math.pow(10, token.decimals);
tokenData.getAmountToReachGoal =
Number(await memeBurnerStore.getAmountToReachGoal(token.contractAddress)) /
Math.pow(10, token.decimals);
if (this.currentRound !== roundNumber && walletStore.connected) {
console.log("index", index);
console.log("rewardData[index]", rewardData[index]);
const stakeReward = Number(rewardData[index].result[0]);
const sacrificeClanReward = Number(rewardData[index].result[1]);
console.log("stakeReward", stakeReward);
console.log("sacrificeClanReward", sacrificeClanReward);
const clanwin = (Number(testcoef) / 10000 - 1) * sacrificeClanReward;
console.log("clanwin", clanwin);
const sacrificeRewards = Number(sacrificeClanReward) - clanwin;
console.log("sacrificeRewards", sacrificeRewards);
tokenData.rewards_ges =
Number(rewardData[index].result[1] / BigInt(Math.pow(10, token.decimals)) +
rewardData[index].result[0] / BigInt(Math.pow(10, token.decimals)));
tokenData.rewards_clan = clanwin / Math.pow(10, token.decimals);;
tokenData.rewards_staking = Number(rewardData[index].result[0] / BigInt(Math.pow(10, token.decimals)));
tokenData.rewards_sacrifice = sacrificeRewards / Math.pow(10, token.decimals);
tokenData.rewards_ges = BigInt(rewardData[index].result);
tokenData.rewards_clan = BigInt(clanwin);
tokenData.rewards_sacrifice = BigInt(sacrificeRewards);
rewards_clan = rewards_clan + clanwin / Math.pow(10, token.decimals);
rewards_sacrifice = rewards_sacrifice + sacrificeRewards / Math.pow(10, token.decimals);
rewards_clan = rewards_clan + tokenData.rewards_clan;
rewards_sacrifice = rewards_sacrifice + tokenData.rewards_sacrifice;
rewards_staking = rewards_staking + tokenData.rewards_staking;
}
tokenArray.push(tokenData);
}
}
console.log("clanwin123", rewards_clan);
const goalInBLD = await memeBurnerStore.getGoalInBLD(roundNumber);
this.rounds[roundNumber] = {
goal: goal[0],
goalInBLD: goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals)),
expirationTimestamp: goal[1],
rewards_clan: BigInt(rewards_clan),
rewards_sacrifice: BigInt(rewards_sacrifice),
rewards_total: BigInt(rewards_clan + rewards_sacrifice),
goal: Number(goal[0]) / Math.pow(10, tokenStore.memeToken.decimals),
goalInBLD: Number(goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals))),
expirationTimestamp: Number(goal[1]),
rewards_clan: Number(rewards_clan),
rewards_staking: Number(rewards_staking),
rewards_sacrifice: Number(rewards_sacrifice),
rewards_total: Number(rewards_clan + rewards_sacrifice),
token: tokenArray,
};
console.log("this.rounds[roundNumber]", this.rounds[roundNumber]);