comments: cycle.js

This commit is contained in:
butterscotch
2023-10-18 21:34:04 +03:00
parent 32ababbb39
commit 0b9e14c628
+8 -1
View File
@@ -91,7 +91,10 @@ export const useCycleStore = defineStore("cycles", {
async updateCurrentCycle(sacrificedToken) {
console.log("updateCurrentCycle");
const memeBurnerStore = useMemeburnerStore();
const rewardLockerStore = useRewardLockerStore();
// TODO: Could be combined in one multicall and could be simplified to request data only for sacrificedToken
var data = await memeBurnerStore.getSacrificedCycle(this.currentCycle);
var tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(this.currentCycle);
console.log("this.currentCycle", this.currentCycle);
console.log("this.cycles", this.cycles);
if (this.cycles[this.currentCycle]) {
@@ -99,6 +102,8 @@ export const useCycleStore = defineStore("cycles", {
(tokenData) => tokenData.contractAddress === sacrificedToken
);
this.cycles[this.currentCycle].token[tokenIndex].amount = data[tokenIndex].result[1];
// was missed update totalSacrificeRewards for sacrificedToken
this.cycles[this.currentCycle].token[tokenIndex].amountInBLD = tokenTotalSacrificed[tokenIndex].result;
}
},
/**
@@ -158,7 +163,8 @@ export const useCycleStore = defineStore("cycles", {
const sacrificeClanReward = rewardData[index].result[1];
let clanwin = 0n;
if (cycleNumber !== this.currentCycle) {
clanwin = (coefficent / 10000n - 1n) * sacrificeClanReward;
// previous version would not work due to missing remainder
clanwin = (sacrificeClanReward * coefficent / 10000n) - sacrificeClanReward;
console.log("clanwin", clanwin);
}
const sacrificeRewards = sacrificeClanReward;
@@ -208,6 +214,7 @@ export const useCycleStore = defineStore("cycles", {
const array = [];
const rewardLockerStore = useRewardLockerStore();
const lastCompletedCycle = await rewardLockerStore.lastCompletedCycle();
// Question: cycle 0 doesn't exist, does it make sense to start from index 1?
for (let index = 0; index <= Number(lastCompletedCycle); index++) {
array.push(index);
}