You Cycle Rewards
+
-
-
-
+ />
+
Total Reward
@@ -35,7 +46,7 @@
$BLOOD
0
-
todo
+
{{ getCurrentRoundData?.rewards_total }}
diff --git a/src/stores/rewardlocker.js b/src/stores/rewardlocker.js
index 1014b0a..b7cc883 100644
--- a/src/stores/rewardlocker.js
+++ b/src/stores/rewardlocker.js
@@ -43,7 +43,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
// calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
contracts.push({
...this.contract,
- functionName: "rewards",
+ functionName: "getRewards",
args: [walletStore.address, roundNumber, token.contractAddress],
});
}
diff --git a/src/stores/rounds.js b/src/stores/rounds.js
index cdded35..5a628bc 100644
--- a/src/stores/rounds.js
+++ b/src/stores/rounds.js
@@ -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]);
diff --git a/src/views/CycleView.vue b/src/views/CycleView.vue
index ca2c09a..0ee2731 100644
--- a/src/views/CycleView.vue
+++ b/src/views/CycleView.vue
@@ -138,10 +138,13 @@ onMounted(async () => {
roundsStore.activeRound = roundsStore.currentRound;
}
await roundsStore.fillRound(roundsStore.activeRound);
- const expirationTimestamp = roundsStore.getCurrentRoundData.expirationTimestamp;
- timer.value = setInterval(function () {
- timeBetweenDates(expirationTimestamp);
- }, 1000);
+ console.log("roundsStore.getCurrentRoundData", roundsStore.getCurrentRoundData);
+ if (roundsStore.currentRound === roundsStore.activeRound) {
+ const expirationTimestamp = roundsStore.getCurrentRoundData.expirationTimestamp;
+ timer.value = setInterval(function () {
+ timeBetweenDates(expirationTimestamp);
+ }, 1000);
+ }
});
onBeforeUnmount(() => {
@@ -164,11 +167,10 @@ async function nextSlide() {
}
function timeBetweenDates(expirationTimestamp) {
- const dateEntered = new Date(Number(expirationTimestamp) * 1000);
+ const dateEntered = new Date(expirationTimestamp * 1000);
if (dateEntered) {
var now = new Date();
difference.value = dateEntered.getTime() - now.getTime();
- console.log("difference.value", difference.value);
if (difference.value <= 0) {
clearInterval(timer.value);
days.value = "0d";
@@ -180,8 +182,6 @@ function timeBetweenDates(expirationTimestamp) {
var _hours = Math.floor(_minutes / 60);
var _days = Math.floor(_hours / 24);
- console.log("_days", _days);
-
days.value = _days;
hours.value = _hours % 24;
minutes.value = _minutes % 60;