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) { async updateCurrentCycle(sacrificedToken) {
console.log("updateCurrentCycle"); console.log("updateCurrentCycle");
const memeBurnerStore = useMemeburnerStore(); 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 data = await memeBurnerStore.getSacrificedCycle(this.currentCycle);
var tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(this.currentCycle);
console.log("this.currentCycle", this.currentCycle); console.log("this.currentCycle", this.currentCycle);
console.log("this.cycles", this.cycles); console.log("this.cycles", this.cycles);
if (this.cycles[this.currentCycle]) { if (this.cycles[this.currentCycle]) {
@@ -99,6 +102,8 @@ export const useCycleStore = defineStore("cycles", {
(tokenData) => tokenData.contractAddress === sacrificedToken (tokenData) => tokenData.contractAddress === sacrificedToken
); );
this.cycles[this.currentCycle].token[tokenIndex].amount = data[tokenIndex].result[1]; 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]; const sacrificeClanReward = rewardData[index].result[1];
let clanwin = 0n; let clanwin = 0n;
if (cycleNumber !== this.currentCycle) { 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); console.log("clanwin", clanwin);
} }
const sacrificeRewards = sacrificeClanReward; const sacrificeRewards = sacrificeClanReward;
@@ -208,6 +214,7 @@ export const useCycleStore = defineStore("cycles", {
const array = []; const array = [];
const rewardLockerStore = useRewardLockerStore(); const rewardLockerStore = useRewardLockerStore();
const lastCompletedCycle = await rewardLockerStore.lastCompletedCycle(); 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++) { for (let index = 0; index <= Number(lastCompletedCycle); index++) {
array.push(index); array.push(index);
} }