fill round update + notification update + visual fixes

This commit is contained in:
EmberSpirit
2023-10-08 22:44:14 +02:00
parent 5c7e176457
commit 68cd720c59
12 changed files with 239 additions and 165 deletions
+27 -80
View File
@@ -1,21 +1,20 @@
<template>
<div class="blood-chart-wrapper" v-if="isMobile">
<div class="blood-chart-wrapper">
<div class="blood-arrow left">
<img
class="swiper-arrow"
src="/assets/img/blood-arrow-left.png"
alt="left-arrow"
@click="swiperInstance.slidePrev()"
v-if="token.length > 3"
v-if="token?.length > 3"
/>
</div>
<swiper
v-if="isMobile"
class="blood-chart"
:slidesPerView="3"
:centeredSlides="false"
:initial-slide="0"
:spaceBetween="35"
:spaceBetween="IsMobile ? 35 : 0"
@swiper="onSwiper"
>
<swiper-slide class="blood-chart-element" v-for="coin in token" :key="coin.name">
@@ -25,75 +24,6 @@
</div>
<div class="blood-chart-coin-title low-mid-text">{{ coin.name }}</div>
</div>
<div class="blood-chart-element-body">
<div class="blood-chart-bar-wrapper">
<svg
class="waves"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 24 150 28"
preserveAspectRatio="none"
shape-rendering="auto"
>
<defs>
<path
id="gentle-wave"
d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"
/>
</defs>
<g class="parallax">
<use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(139, 0, 0,0.7)" />
<use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(139, 0, 0,0.5)" />
<use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(139, 0, 0,0.3)" />
<use xlink:href="#gentle-wave" x="48" y="7" fill="#8B0000" />
</g>
</svg>
<div class="blood-chart-bar" :style="`height: ${getPercentage(coin.amount, props.data.goal)}%`">
<div class="wrapper">
<div><span class="dot"></span></div>
<div><span class="dot"></span></div>
<div><span class="dot"></span></div>
<div><span class="dot"></span></div>
<div><span class="dot"></span></div>
<div><span class="dot"></span></div>
</div>
<div class="blood-chart-bar-percentage">
{{ getPercentage(coin.amount, props.data.goal) }}%
</div>
</div>
</div>
</div>
<div class="blood-chart-element-footer">
<div class="blood-chart-amount">
<!-- {{ compactNumber(coin.amount) }} -->
{{ coin.amount.toFixed(2) }}
</div>
<div>$BLOOD</div>
</div>
</swiper-slide>
<!-- <button @click="swiperInstance.slidePrev()">left</button>
<button @click="swiperInstance.slideNext()">left</button> -->
</swiper>
<div class="blood-arrow right">
<img
class="swiper-arrow"
src="/assets/img/blood-arrow-right.png"
alt="left-arrow"
@click="swiperInstance.slideNext()"
v-if="token.length > 3"
/>
</div>
</div>
<div class="blood-chart-wrapper" v-else>
<div class="blood-chart">
<div class="blood-chart-element" v-for="coin in token" :key="coin.name">
<div class="blood-chart-element-header">
<div class="blood-chart-coin">
<img :src="getImageUrl(coin.vamplogo)" alt="logo" />
</div>
<div class="blood-chart-coin-title">{{ coin.name }}</div>
</div>
<div class="blood-chart-element-body">
<div class="blood-chart-bar-wrapper">
<svg
@@ -138,17 +68,29 @@
<div class="blood-chart-element-footer">
<div class="blood-chart-amount">
<!-- {{ compactNumber(coin.amount) }} -->
{{ coin.amount.toFixed(2) }}
</div>
<div class="blood-chart-coin">$BLOOD</div>
{{ coin.amountInBLD.toFixed(2) }}
</div>
<div>$BLOOD</div>
</div>
</swiper-slide>
<!-- <button @click="swiperInstance.slidePrev()">left</button>
<button @click="swiperInstance.slideNext()">left</button> -->
</swiper>
<div class="blood-arrow right">
<img
class="swiper-arrow"
src="/assets/img/blood-arrow-right.png"
alt="left-arrow"
@click="swiperInstance.slideNext()"
v-if="token?.length > 3"
/>
</div>
</div>
</template>
<script setup>
import { computed, ref, inject } from "vue";
import { computed, ref, inject, onMounted } from "vue";
import { getPercentage, compactNumber } from "@/helper/helper.js";
import { useMemeburnerStore } from "@/stores/memeburner";
import { Swiper, SwiperSlide } from "swiper/vue";
@@ -164,9 +106,12 @@ const memeBurnerStore = useMemeburnerStore();
const props = defineProps({
data: Object,
});
const isMobile = inject("isMobile");
console.log(props.data);
onMounted(() => {
console.log("bloodchart-data", props.data);
});
const isMobile = inject("isMobile");
const swiperInstance = ref();
@@ -229,8 +174,9 @@ function getPercentageBloodChart(amount, goal) {
.blood-chart-element
height: 100%
width: 80px
align-items: center
@media (min-width: 992px)
width: 60px
width: 100px
display: flex
flex-direction: column
@@ -257,6 +203,7 @@ function getPercentageBloodChart(amount, goal) {
.blood-chart-element-body
background-color: rgba(233, 233, 233, 0.2)
flex: 0 0 500px
width: 60px
border-radius: 8px 8px 40px 40px
text-align: left
overflow: hidden
+2 -2
View File
@@ -100,6 +100,6 @@ function openUnstake() {
display: flex
text-align: center
gap: 16px
div
flex: 1 1 50%
// div
// flex: 1 1 50%
</style>
+23 -8
View File
@@ -130,22 +130,29 @@ async function stakeAndClaimAllRounds() {
try {
const unclaimedRewards = walletStore.memeToken?.unclaimedRewards;
stateClaim.value = 2;
console.log("tokenNumber.value", tokenNumber.value);
console.log("walletStore.memeToken?.unclaimedRewards", walletStore.memeToken?.unclaimedRewards);
const coefficient = (10000 * tokenNumber.value) / walletStore.memeToken?.unclaimedRewards;
const coefficient = (10000 * tokenNumber.value) / unclaimedRewards;
var hash = await rewardLockerStore.stakeAndClaimAllRounds(coefficient);
stateClaim.value = 3;
const data = await waitForTransaction({
hash: hash,
});
stateClaim.value = 4;
await walletStore.loadWalletData();
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3"
);
});
//
console.log("rewardData", rewardData);
//ClaimedReward (address staker, uint256 reward)
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
unclaimedRewards,
outputClaim.toFixed(5),
"Success!",
"You just claimed and staked",
"Join the next cycle to increase your rewards and win with your clan"
);
await walletStore.loadWalletData();
} catch (error) {
stateClaim.value = 0;
console.error(error);
@@ -161,14 +168,22 @@ async function claimAll() {
const data = await waitForTransaction({
hash: hash,
});
console.log("data", data);
await walletStore.loadWalletData();
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3"
);
});
//
console.log("rewardData", rewardData);
//ClaimedReward (address staker, uint256 reward)
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
walletStore.memeToken?.unclaimedRewards,
outputClaim.toFixed(5),
"Success!",
"You just claimed",
"Join the next cycle to increase your rewards and win with your clan."
);
await walletStore.loadWalletData();
} catch (error) {
state.value = 0;
console.error(error);
+41 -19
View File
@@ -100,24 +100,19 @@
<img src="/assets/img/moon.png" alt="moon" />
</div>
</div>
<div class="sacrifice-fees-info-wrapper">
<div class="sacrifice-fees-img">
<img src="/assets/img/fuel-noozle.png" alt="fuel noozle" />
</div>
<div class="sacrifice-fees-body">
<div class="sacrifice-fees-body-header mid-text">
<div class="sacrifice-fees-body-header-title">Gas Subsidy</div>
<div class="sacrifice-fees-body-header-amount">≤30 Gwei</div>
</div>
<div class="sacrifice-fees-body-subheader">The clan pays your transaction.</div>
</div>
</div>
<div class="sacrifice-buttons-function-wrapper">
<template v-if="walletStore.connected">
<div class="btn btn-immortal sub-header" disabled v-if="stateComputed === 0">Enter Amount</div>
<div
class="btn btn-immortal sub-header"
v-if="
disabled
v-else-if="tokenNumber > activeWalletToken?.balanceOf"
>
Insufficient Balance
</div>
<div
class="btn btn-immortal sub-header"
v-else-if="
activeToken.allowance > 0 &&
activeToken.allowance >= tokenNumber &&
(stateComputed === 1 || stateComputed === 4)
@@ -128,7 +123,7 @@
</div>
<div
class="btn btn-immortal sub-header"
v-if="
v-else-if="
(!activeToken.allowance || activeToken.allowance < tokenNumber) &&
(stateComputed === 1 || stateComputed === 4)
"
@@ -152,6 +147,7 @@
<script setup>
import { ref, defineProps, watch, inject, nextTick, onMounted, onBeforeUnmount, computed, markRaw } from "vue";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { useRoundsStore } from "@/stores/rounds";
import { useTokenStore } from "@/stores/tokens";
import { useMemeburnerStore } from "@/stores/memeburner";
import { useUniswapStore } from "@/stores/uniswap";
@@ -163,6 +159,7 @@ import TokenLogo from "@/components/TokenLogo.vue";
import StakeSuccessToast from "@/components/toasts/StakeSuccessToast.vue";
import { useToast } from "vue-toastification";
const roundStore = useRoundsStore();
const toast = useToast();
import { storeToRefs } from "pinia";
import { waitForTransaction, readContract, watchBlockNumber, multicall } from "@wagmi/core";
@@ -294,12 +291,20 @@ async function sacrificeToken(amount) {
state.value = 3;
const data = await waitForTransaction({
hash: hash,
onReplaced: (transaction) => console.log("check transaction canceled", transaction),
});
console.log("data", data);
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0x5e60ccd3c81486143d815dce24867a494d7fee585a0a44282cf479b19a5186ee"
);
});
const outputSacrifice = Number(rewardData.data) / Math.pow(10, activeToken.value.decimals);
//activeToken is bad here, because it could change during async request
activeToken.value.allowance = await tokenStore.allowance();
state.value = 4;
console.log("state.value = 4");
const outputSacrifice = output.value;
showSuccessToast(
outputSacrifice?.toFixed(5),
"Success!",
@@ -307,6 +312,7 @@ async function sacrificeToken(amount) {
"You can claim once the current cycle is finished and your clan bonus was calculated."
);
await walletStore.loadWalletData();
await roundStore.fillRound(roundStore.currentRound, true);
} catch (error) {
state.value = 0;
console.error(error);
@@ -327,6 +333,8 @@ async function approveToken(amount) {
} catch (error) {
console.error(error);
throw new Error(error);
} finally {
state.value = 0;
}
}
@@ -344,17 +352,27 @@ async function getRewardsFor(value) {
const rewardsForResult = await memeburnerStore.getRewardFor(
BigInt(value * Math.pow(10, activeToken.value.decimals))
);
const rewardsForResultNumber = Number(rewardsForResult[0]) / Math.pow(10, tokenStore.activeToken.decimals);
// const rewardsForResultNumber = Number(rewardsForResult[0]) / Math.pow(10, tokenStore.activeToken.decimals) + Number(rewardsForResult[1]) / Math.pow(10, tokenStore.activeToken.decimals);
const rewardsForResultNumber = rewardsForResult.reduce((x, y) => {
return x + Number(y) / Math.pow(10, tokenStore.activeToken.decimals);
}, 0);
var quoteRewards = await uniswapStore.quoteExactInputSingle(
tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
);
console.log("quoteRewards", quoteRewards);
let variant = "sacrifice";
if (quoteRewards.result) {
console.log("quoteRewards", quoteRewards);
const quoteRewardsNumber = Number(quoteRewards.amount) / Math.pow(10, tokenStore.activeToken.decimals);
if (quoteRewardsNumber * 0.995 > rewardsForResultNumber) {
variant = "buy";
console.log("use Buy-function", { quoteRewardsNumber: quoteRewardsNumber, rewardsForResultNumber });
} else {
console.log("use sacrifice-function", {
quoteRewardsNumber: quoteRewardsNumber,
rewardsForResultNumber,
});
}
} else {
/**
@@ -364,7 +382,7 @@ async function getRewardsFor(value) {
//
newOutput = rewardsForResultNumber;
}
console.log("variant", variant);
const amountDecimal = BigInt(value * Math.pow(10, tokenStore.activeToken.decimals));
console.log("amountDecimal", amountDecimal);
if (!walletStore.connected || (walletStore.connected && activeToken.value.allowance < tokenNumber.value)) {
@@ -402,21 +420,25 @@ async function getRewardsFor(value) {
account: walletStore.address,
});
const amountBuyNumber = Number(amountBuy) / Math.pow(10, tokenStore.activeToken.decimals);
const amountSacrificeNumber = Number(amountSacrifice) / Math.pow(10, tokenStore.activeToken.decimals);
console.log("sacrificeMemeAndBuyBLOOD", amountBuyNumber);
console.log("sacrificeMeme", amountSacrificeNumber);
if (amountBuyNumber * 0.995 > amountSacrificeNumber) {
variant = "buy";
newOutput = amountBuyNumber;
console.log("use buy after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme");
} else {
variant = "sacrifice";
newOutput = amountSacrificeNumber;
console.log("use sacrifice after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme");
}
}
output.value = newOutput;
return { ouput: newOutput, variant: variant };
} catch (error) {
console.log("error", error);
console.error("getRewardsFor", error);
} finally {
loading.value = false;
}
+45 -12
View File
@@ -55,7 +55,7 @@
v-model="tokenNumber"
@close="stakeMenu = false"
:stake="stake"
:amount="walletStore.memeToken.balanceOf"
:amount="walletStore.memeToken?.balanceOf"
v-if="stakeMenu & !unstakeMenu"
>
<template v-slot:body>
@@ -79,7 +79,7 @@
</div>
</template>
<template v-slot:message-end>
<div class="input-balance">Balance: {{ walletStore.memeToken.balanceOf }}</div>
<div class="input-balance">Balance: {{ walletStore.memeToken?.balanceOf }}</div>
</template>
</stake-menu>
<div class="unstake-menu" v-else-if="stakeMenu & unstakeMenu">
@@ -87,10 +87,16 @@
To prevent users from farming rewards you can claim your stake next cycle.
</div>
<div class="unstake-menu-actions">
<div class="btn btn-immortal stake-button" v-if="!loading" @click="orderUnstake">
<div class="btn btn-immortal stake-button" v-if="stateStake <= 1" @click="orderUnstake">
Unstake Next Cycle
</div>
<div class="btn btn--disabled" v-else>Sign Transaction</div>
<div class="btn btn--disabled mid-mid-text text-center" v-else-if="stateStake === 2">
Sign Transaction
</div>
<div class="btn btn--disabled mid-mid-text text-center" v-else-if="stateStake === 3">
<loading-component></loading-component>
</div>
<div
class="btn transparent small-text cancel-button text-center"
@click="stakeMenu = false"
@@ -175,7 +181,7 @@ function openUnstake() {
}
async function orderUnstake() {
loading.value = true;
try {
state.value = 2;
var hash = await rewardLockerStore.orderUnstake();
state.value = 3;
@@ -183,9 +189,26 @@ async function orderUnstake() {
hash: hash,
});
state.value = 4;
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3"
);
});
console.log("rewardData", rewardData);
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
"Success!",
"You just unstaked",
"You can claim your stake next cycle."
);
await walletStore.loadWalletData();
showSuccessToast();
loading.value = false;
} catch (error) {
console.error("orderUnstake", error);
} finally {
state.value = 0;
}
}
async function stakeToken() {
@@ -196,33 +219,43 @@ async function stakeToken() {
const data = await waitForTransaction({
hash: hash,
});
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xf496bf2b14b1d178412b6f7a745900105b49b38b315cfdfbfabad31a6f995c6f"
);
});
//
console.log("rewardData", rewardData);
const outputClaim = Number(rewardData.topics[3]) / Math.pow(10, tokenStore.memeToken.decimals);
console.log("data", data);
state.value = 4;
await walletStore.loadWalletData();
showSuccessToast(
tokenNumber.value,
outputClaim.toFixed(5),
"Success!",
"You just staked",
"Your next sacrifice will get an extra staking bonus as a reward."
);
//reload data
} catch (error) {
state.value = 0;
console.error(error);
throw new Error(error);
} finally {
state.value = 0;
}
}
const stateStake = computed(() => {
let returnState = 0;
if (tokenNumber.value === null || tokenNumber.value === "" || tokenNumber.value === 0) {
returnState = 0;
} else if (state.value === 2) {
if (state.value === 2) {
returnState = 2;
} else if (state.value === 3) {
returnState = 3;
} else if (tokenNumber.value !== null || tokenNumber.value !== "" || tokenNumber.value > 0) {
returnState = 1;
} else if (tokenNumber.value === null || tokenNumber.value === "" || tokenNumber.value === 0) {
returnState = 0;
}
return returnState;
});
+45 -2
View File
@@ -106,6 +106,7 @@ import RewardsWrapper from "@/components/RewardsWrapper.vue";
import { inject, ref, onMounted, computed } from "vue";
import { useRewardLockerStore } from "@/stores/rewardlocker";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { useTokenStore } from "@/stores/tokens";
import { useRoundsStore } from "@/stores/rounds";
import { useRouter } from "vue-router";
import StakeMenu from "@/components/StakeMenu.vue";
@@ -120,6 +121,8 @@ const isMobile = inject("isMobile");
const showPanel = inject("showPanel");
const rewardLockerStore = useRewardLockerStore();
const walletStore = useWalletStoreV2();
const tokenStore = useTokenStore();
const roundStore = useRoundsStore();
const { address } = storeToRefs(walletStore);
const router = useRouter();
@@ -132,10 +135,34 @@ const tokenNumber = ref(null);
const stateClaim = ref(0);
async function stakeAndClaim() {
try {
console.log(tokenNumber.value);
console.log(getCurrentRoundData.value.rewards_total);
const coefficient = (10000 * tokenNumber.value) / getCurrentRoundData.value.rewards_total;
var result = await rewardLockerStore.stakeAndClaimRound(coefficient, roundStore.activeRound);
var hash = await rewardLockerStore.stakeAndClaimRound(coefficient, roundStore.activeRound);
const data = await waitForTransaction({
hash: hash,
});
//ClaimedReward (address staker, uint256 reward)
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xf86340d97020c624010a208b733db95795281fbc45cb6e6a40d161f91fa3e4a0"
);
});
//
console.log("rewardData", rewardData);
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
"Success!",
"You just claimed and staked",
"Join the next cycle to increase your rewards and win with your clan."
);
const walletStore = useWalletStoreV2();
await walletStore.loadWalletData();
} catch (error) {
console.error("stakeAndClaim", error);
}
}
function openStake() {
@@ -157,7 +184,23 @@ async function claimRewards() {
hash: hash,
});
stateClaim.value = 4;
//reload
// ClaimedReward (address staker, uint256 reward)
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3"
);
});
//
console.log("rewardData", rewardData);
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
"Success!",
"You just claimed",
"Join the next cycle to increase your rewards and win with your clan."
);
await roundStore.fillRound(activeRound.value, true);
await walletStore.loadWalletData();
} catch (error) {
-6
View File
@@ -33,7 +33,6 @@ export const useMemeburnerStore = defineStore("memeburner", {
tokenStore.activeToken.contractAddress,
amount,
]);
console.log("tokenStore.activeToken.contractAddress", tokenStore.activeToken.contractAddress);
console.log("amount", amount);
console.log("rewards", rewards);
return rewards;
@@ -57,8 +56,6 @@ export const useMemeburnerStore = defineStore("memeburner", {
const contracts = [];
for (let index = 0; index < tokenStore.sacrificeToken.length; index++) {
const token = tokenStore.sacrificeToken[index];
console.log("token.contractAddress", token.contractAddress);
console.log("roundnumber", roundnumber);
// contracts.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
contracts.push({
...this.contract,
@@ -84,9 +81,6 @@ export const useMemeburnerStore = defineStore("memeburner", {
}
this.loading = true;
const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals));
console.log("this.contract", this.contract);
console.log("amountDecimal", amountDecimal.toString());
console.log("tokenStore.activeToken.contractAddress", tokenStore.activeToken.contractAddress);
var hash = await this.contract.write.sacrificeMeme([
tokenStore.activeToken.contractAddress,
amountDecimal.toString(),
+29 -7
View File
@@ -58,6 +58,29 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
// const multicallStore = useMultiCallStore();
return data;
},
async getTotalSacrificeRewardsForAllToken(roundNumber) {
try {
const tokenStore = useTokenStore();
const contracts = [];
for (let index = 0; index < tokenStore.sacrificeToken.length; index++) {
const token = tokenStore.sacrificeToken[index];
// calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
contracts.push({
...this.contract,
functionName: "getTotalSacrificeRewardsForToken",
args: [roundNumber, token.contractAddress],
});
}
const data = await multicall({
contracts,
});
// const multicallStore = useMultiCallStore();
return data;
} catch (error) {
throw new Error(error)
}
},
async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) {
try {
return await this.contract.read.getSacrificedTokenCoefficient([roundNumber, sacrificedToken]);
@@ -106,7 +129,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return await this.contract.read.getTotalRewardsOf([address, rounds]);
} catch (error) {
console.error("getTotalRewards", error);
throw new Error(error);
}
},
async getStaked(address) {
@@ -114,6 +137,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return await this.contract.read.staked([address]);
} catch (error) {
console.error("getStaked", error);
throw new Error(error);
}
},
async orderUnstake() {
@@ -121,6 +145,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return await this.contract.write.orderUnstake();
} catch (error) {
console.error("orderUnstake", error);
throw new Error(error)
}
},
async unstake(unstakeRound) {
@@ -128,6 +153,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return await this.contract.write.unstake([unstakeRound]);
} catch (error) {
console.error("unstake", error);
throw new Error(error);
}
},
async stakeBloodline(tokenNumber) {
@@ -139,7 +165,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
const spender = this.config.contractAddress;
const deadline = Date.now() + 20 * 60;
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
const value = (tokenNumber * Math.pow(10, decimals)).toString();
const value = BigInt(tokenNumber * Math.pow(10, decimals))
const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
console.log("nonce", nonce);
const { types, message, domain, primaryType } = createPermitObject(
@@ -171,9 +197,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
const data = await waitForTransaction({
hash: hash,
});
const walletStore = useWalletStoreV2();
await walletStore.loadWalletData();
// todo reload roundData and wallet data
return hash;
},
async stakeAndClaimAllRounds(stakeCoefficient) {
console.log("stakeAndClaimAllRounds");
@@ -181,8 +205,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
const roundsStore = useRoundsStore();
const rounds = await roundsStore.getFinshedRoundNumbers();
const addresses = tokenStore.sacrificeToken.map((obj) => obj.contractAddress);
console.log({ stakeCoefficient, rounds, addresses });
console.log("stakeCoefficient", stakeCoefficient);
var stakeCoefficientInt = Math.round(stakeCoefficient);
const hash = await this.contract.write.stakeAndClaim([stakeCoefficientInt, rounds, addresses]);
return hash;
+4 -5
View File
@@ -26,8 +26,6 @@ export const useRoundsStore = defineStore("rounds", {
}
},
getCurrentRoundData() {
console.log("this.rounds", this.rounds);
console.log("this.rounds[this.activeRound]", this.rounds[this.activeRound]);
return this.rounds[this.activeRound];
},
},
@@ -95,13 +93,13 @@ export const useRoundsStore = defineStore("rounds", {
// } else
if (!this.rounds[roundNumber]?.goal || refillRound) {
console.log("round not filled --> fill round");
console.log("vor error");
var data = await memeBurnerStore.getSacrificedRound(roundNumber);
let rewardData = null;
if (walletStore.connected) {
rewardData = await rewardLockerStore.getRewardsForAllToken(roundNumber);
}
const tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(roundNumber);
var goal = await memeBurnerStore.getGoal(roundNumber);
console.log("goal", goal);
var tokenArray = [];
@@ -124,6 +122,7 @@ export const useRoundsStore = defineStore("rounds", {
tokenData.vampname = token.vamp.name;
// tokenData.amount = data[index].result[1];
tokenData.amount = Number(data[index].result[1]) / Math.pow(10, token.decimals);
tokenData.amountInBLD = Number(tokenTotalSacrificed[index].result) / Math.pow(10, token.decimals);
// tokenData.getAmountToReachGoal =
// Number(await memeBurnerStore.getAmountToReachGoal(token.contractAddress)) /
// Math.pow(10, token.decimals);
@@ -133,11 +132,11 @@ export const useRoundsStore = defineStore("rounds", {
const stakeReward = Number(rewardData[index].result[0]);
const sacrificeClanReward = Number(rewardData[index].result[1]);
let clanwin = 0;
if (this.activeRound !== this.currentRound) {
if (roundNumber !== this.currentRound) {
clanwin = (Number(coefficent) / 10000 - 1) * sacrificeClanReward;
console.log("clanwin", clanwin);
}
const sacrificeRewards = Number(sacrificeClanReward) - clanwin;
const sacrificeRewards = Number(sacrificeClanReward);
tokenData.rewards_ges = Number(
rewardData[index].result[1] / BigInt(Math.pow(10, token.decimals)) +
+3 -3
View File
@@ -44,18 +44,18 @@ export const useUniswapStore = defineStore("uniswap", {
const memeBurnerStore = useMemeburnerStore();
var amountEthBase = await memeBurnerStore.getAmountETHBase(amount);
console.log("amountEthBase", amountEthBase);
console.log("123", {
console.log("quoteExactInputSingle-parameter", {
token0: this.poolData.token0,
token1: this.poolData.token1,
fee: this.poolData.fee,
amountEthBase: amountEthBase,
amountEthBase: amountEthBase[1],
pricelimit: 0, //sqrtPriceLimitX96
});
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
this.poolData.token0, //bloodline
this.poolData.token1, //weth
this.poolData.fee,
amountEthBase,
amountEthBase[1],
0, //sqrtPriceLimitX96
]);
return {result: true, amount: quotedAmountOut};
+1 -2
View File
@@ -29,7 +29,6 @@ import { alchemyProvider } from "@wagmi/core/providers/alchemy";
export const useWalletStoreV2 = defineStore("walletV2", {
state: () => ({
count: 0,
alchemy: null,
connected: false,
address: null,
@@ -40,7 +39,7 @@ export const useWalletStoreV2 = defineStore("walletV2", {
config: null,
chain: null,
token: [],
initialized1: false,
stateSacrifice: 0,
}),
getters: {
sacrificeToken: (state) => state.token.filter((obj) => {
+1 -1
View File
@@ -71,7 +71,7 @@
memes.
</p>
<div class="bloodline-container">
<div class="bloodline-border purple">Get up to +100% Clan Bonus <br />on your sacrifice.</div>
<div class="bloodline-border purple">Get up to +25% Clan Bonus <br />on your sacrifice.</div>
</div>
<blood-chart :data="roundsStore.rounds[roundsStore.activeRound]"></blood-chart>
</div>