new contracts + visual improvements + cyle end
This commit is contained in:
@@ -67,7 +67,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
console.log("token.contractAddress", token.contractAddress);
|
||||
console.log("roundnumber", roundnumber);
|
||||
var test = await this.getSacrificedMeme(roundnumber, token.contractAddress);
|
||||
console.log("test", test);
|
||||
console.log(token.name, test);
|
||||
calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
|
||||
// calls1.push(this.contract.methods.getAmountToReachGoal(token.contractAddress));
|
||||
}
|
||||
@@ -96,6 +96,10 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
async getGoalInBLD(roundNumber) {
|
||||
return await this.contract.methods.getGoalInBLD(roundNumber).call();
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -34,8 +34,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
||||
const calls = [];
|
||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||
const token = tokenStore.token[index];
|
||||
var test = this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress);
|
||||
console.log("test123", test);
|
||||
calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
|
||||
}
|
||||
const multicallStore = useMultiCallStore();
|
||||
|
||||
+30
-33
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
|
||||
import { useMemeburnerStore } from "./memeburner";
|
||||
import { useTokenStore } from "./tokens";
|
||||
import { useRewardLockerStore } from "./rewardlocker";
|
||||
import { useWalletStore } from "./wallet";
|
||||
|
||||
|
||||
export const useRoundsStore = defineStore("rounds", {
|
||||
@@ -33,6 +34,7 @@ export const useRoundsStore = defineStore("rounds", {
|
||||
console.log("fillRound");
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
const tokenStore = useTokenStore();
|
||||
const walletStore = useWalletStore();
|
||||
const rewardLockerStore = useRewardLockerStore();
|
||||
|
||||
// if (this.activeRound === this.currentRound) {
|
||||
@@ -42,13 +44,12 @@ export const useRoundsStore = defineStore("rounds", {
|
||||
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);
|
||||
let rewardData = null;
|
||||
if (await walletStore.isConnected()) {
|
||||
rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -56,43 +57,39 @@ export const useRoundsStore = defineStore("rounds", {
|
||||
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.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)));;
|
||||
}
|
||||
if (this.currentRound !== this.activeRound && await walletStore.isConnected()) {
|
||||
const clanwin = BigInt((testcoef / 10000 - 1) * rewardData[index]);
|
||||
const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
|
||||
tokenData.rewards_ges = rewardData[index];
|
||||
tokenData.rewards_clan = 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);
|
||||
}
|
||||
|
||||
console.log("Math.pow(10, tokenStore.memeToken.decimals)", Math.pow(10, tokenStore.memeToken.decimals));
|
||||
console.log("goal", goal);
|
||||
}
|
||||
|
||||
const goalInBLD = await memeBurnerStore.getGoalInBLD(this.activeRound);
|
||||
this.rounds[this.activeRound] = {
|
||||
goal: goal,
|
||||
rewards_clan: rewards_clan,
|
||||
goal: goal.goal,
|
||||
goalInBLD: goalInBLD /Math.pow(10, tokenStore.memeToken.decimals),
|
||||
expirationTimestamp: goal.expirationTimestamp,
|
||||
rewards_clan: rewards_clan,
|
||||
rewards_sacrifice: rewards_sacrifice,
|
||||
token: tokenArray,
|
||||
};
|
||||
rewards_total: rewards_clan + rewards_sacrifice,
|
||||
token: tokenArray,
|
||||
};
|
||||
} else {
|
||||
console.log("round already filled");
|
||||
}
|
||||
|
||||
+18
-4
@@ -15,10 +15,26 @@ export const useWalletStore = defineStore("wallet", {
|
||||
},
|
||||
actions: {
|
||||
async init() {
|
||||
console.log("wallet init");
|
||||
await this.isConnected();
|
||||
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
||||
if (this.connected) {
|
||||
const web3 = new Web3(window.ethereum);
|
||||
this.web3 = markRaw(web3);
|
||||
this.web3 = markRaw(web3);
|
||||
console.log("hierabc");
|
||||
window.ethereum.on("accountsChanged", async (data) => {
|
||||
console.log("accountsChanged", data);
|
||||
console.log("data", data);
|
||||
if (data.length > 0) {
|
||||
this.address = data[0]
|
||||
this.connected = true;
|
||||
} else {
|
||||
this.address = null;
|
||||
this.connected = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// provider = new ethers.BrowserProvider(window.ethereum);
|
||||
} else {
|
||||
const url = `https://eth-goerli.g.alchemy.com/v2/${goerliKey}`;
|
||||
@@ -31,9 +47,6 @@ export const useWalletStore = defineStore("wallet", {
|
||||
new Web3.providers.WebsocketProvider(`wss://eth-goerli.g.alchemy.com/v2/${goerliKey}`)
|
||||
);
|
||||
},
|
||||
increment() {
|
||||
this.count++;
|
||||
},
|
||||
connectWallet() {
|
||||
const tokenStore = useTokenStore();
|
||||
// if (window.ethereum) {
|
||||
@@ -43,6 +56,7 @@ export const useWalletStore = defineStore("wallet", {
|
||||
console.log("data", data);
|
||||
this.address = data[0];
|
||||
this.connected = true;
|
||||
this.init();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.code === 4001) {
|
||||
|
||||
Reference in New Issue
Block a user