init functions for the storage
This commit is contained in:
+46
-8
@@ -17,12 +17,17 @@ export const useRoundsStore = defineStore("rounds", {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async init() {
|
||||
//fill initial round
|
||||
},
|
||||
async updateCurrentRound(sacrificedToken, sacrificedAmount) {
|
||||
const tokenStore = useTokenStore();
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
var data = await memeBurnerStore.getSacrificedRound(this.currentRound)
|
||||
console.log("data123", data);
|
||||
var tokenIndex = this.rounds[this.currentRound].token.findIndex((tokenData) => tokenData.contractAddress === sacrificedToken);
|
||||
this.rounds[this.currentRound].token[tokenIndex].amount = data[tokenIndex][1];
|
||||
|
||||
},
|
||||
async fillRound() {
|
||||
console.log("fillRound");
|
||||
@@ -34,27 +39,60 @@ export const useRoundsStore = defineStore("rounds", {
|
||||
// console.log("activeRound is not completed");
|
||||
// } else
|
||||
if (!this.rounds[this.activeRound]) {
|
||||
console.log("round not filled --> fill round");
|
||||
var data = await memeBurnerStore.getSacrificedRound(this.activeRound)
|
||||
console.log("round not filled --> fill round");
|
||||
console.log("vor error");
|
||||
var data = await memeBurnerStore.getSacrificedRound(this.activeRound)
|
||||
var rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound);
|
||||
var goal = await memeBurnerStore.getGoal(this.activeRound);
|
||||
console.log("data", data);
|
||||
var goal = await memeBurnerStore.getGoal(this.activeRound);
|
||||
console.log("goal", goal);
|
||||
console.log("this.activeRound", this.activeRound);
|
||||
console.log("dataabc", data);
|
||||
console.log("rewardData", rewardData);
|
||||
console.log("pepecoin-rewards", rewardData[0]);
|
||||
|
||||
var tokenArray = []
|
||||
var rewards_clan = BigInt(0);
|
||||
var rewards_sacrifice = BigInt(0);
|
||||
for (let index = 0; index < data.length; index++) {
|
||||
var tokenData = {};
|
||||
const token = tokenStore.token[index];
|
||||
console.log("testabcv", token);
|
||||
console.log("123abc", token.contractAddress);
|
||||
var testcoef = await rewardLockerStore.getSacrificedTokenCoefficient(this.activeRound, token.contractAddress);
|
||||
console.log("testcoef",);
|
||||
console.log(`rewards ${token.name}`, BigInt(rewardData[index]));
|
||||
console.log(`clanwin multiplier ${token.name}`, (testcoef / 10000));
|
||||
const clanwin = BigInt((testcoef / 10000 -1) * rewardData[index]);
|
||||
console.log(`clanwin ${token.name}`, clanwin);
|
||||
const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
|
||||
console.log(`sacrifice rewards`, sacrificeRewards);
|
||||
console.log("token", token);
|
||||
tokenData.name = token.name;
|
||||
tokenData.contractAddress = token.contractAddress;
|
||||
tokenData.vamplogo = token.vamp.logo;
|
||||
tokenData.vampname = token.vamp.name;
|
||||
tokenData.amount = data[index][1];
|
||||
tokenData.rewards = rewardData[index]
|
||||
tokenData.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress);
|
||||
tokenData.rewards_ges = rewardData[index];
|
||||
if (this.currentRound !== this.activeRound) {
|
||||
tokenData.rewards_clan = clanwin;
|
||||
console.log("clanwin", clanwin);
|
||||
tokenData.rewards_sacrifice = sacrificeRewards;
|
||||
rewards_clan = rewards_clan + BigInt(clanwin / BigInt(Math.pow(10, token.decimals)));
|
||||
rewards_sacrifice =
|
||||
rewards_sacrifice + BigInt(sacrificeRewards / BigInt(Math.pow(10, token.decimals)));;
|
||||
}
|
||||
tokenArray.push(tokenData);
|
||||
}
|
||||
this.rounds[this.activeRound] = {
|
||||
goal: goal, token: tokenArray
|
||||
}
|
||||
|
||||
console.log("Math.pow(10, tokenStore.memeToken.decimals)", Math.pow(10, tokenStore.memeToken.decimals));
|
||||
console.log("goal", goal);
|
||||
this.rounds[this.activeRound] = {
|
||||
goal: goal,
|
||||
rewards_clan: rewards_clan,
|
||||
rewards_sacrifice: rewards_sacrifice,
|
||||
token: tokenArray,
|
||||
};
|
||||
} else {
|
||||
console.log("round already filled");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user