bigint umpdate
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
</div>
|
||||
<div class="blood-chart-element-footer">
|
||||
<div class="blood-chart-amount">
|
||||
{{ formatNumber(coin.amountInBLD) }}
|
||||
{{ formatNumber(coin.amountInBLD / 10n ** tokenStore.memeToken.decimals) }}
|
||||
</div>
|
||||
<div>$BLOOD</div>
|
||||
</div>
|
||||
@@ -99,6 +99,8 @@ import { getPercentage, compactNumber, formatNumber } from "@/helper/helper.js";
|
||||
import { useCycleStore } from "@/stores/cycles";
|
||||
|
||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||
import { useTokenStore } from "@/stores/tokens";
|
||||
|
||||
import { Swiper, SwiperSlide } from "swiper/vue";
|
||||
|
||||
// Import Swiper styles
|
||||
@@ -107,6 +109,7 @@ import "swiper/css/navigation";
|
||||
import "swiper/css/pagination";
|
||||
|
||||
const cycleStore = useCycleStore();
|
||||
const tokenStore = useTokenStore();
|
||||
|
||||
const props = defineProps({
|
||||
data: Object,
|
||||
|
||||
@@ -244,24 +244,24 @@ function Blood3() {
|
||||
|
||||
<style lang="sass">
|
||||
.blood-svg
|
||||
width: 40vmax
|
||||
position: absolute
|
||||
top: 50%
|
||||
left: 50%
|
||||
transform: translate(-50%,-50%)
|
||||
pointer-events: none
|
||||
|
||||
position: fixed
|
||||
top: 50%
|
||||
left: 50%
|
||||
transform: translate(-50%,-50%)
|
||||
pointer-events: none
|
||||
width: 100%
|
||||
|
||||
.blood-svg
|
||||
opacity: 0
|
||||
|
||||
|
||||
.blood-splash-2
|
||||
width: 70vmax
|
||||
width: 100%
|
||||
|
||||
|
||||
|
||||
.blood-splash-3
|
||||
width: 60vmax
|
||||
width: 100%
|
||||
|
||||
|
||||
p
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<template v-slot:body>
|
||||
<token-name-price
|
||||
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
|
||||
:price="walletStore.memeToken?.unclaimedRewards"
|
||||
:price="walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals"
|
||||
></token-name-price>
|
||||
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline logo'"></token-logo>
|
||||
</template>
|
||||
@@ -28,7 +28,7 @@
|
||||
@close="stakeMenu = false"
|
||||
:amount="walletStore.memeToken?.unclaimedRewards"
|
||||
:stake="stake"
|
||||
v-if="stakeMenu"
|
||||
v-if="stakeMenu && walletStore.memeToken?.unclaimedRewards"
|
||||
>
|
||||
<template v-slot:body>
|
||||
<div class="btn btn-immortal stake-button" disabled v-if="stateClaimComp === 0">
|
||||
@@ -55,8 +55,13 @@
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:message-end>
|
||||
<div class="input-balance">
|
||||
Balance: {{ formatNumber(walletStore.memeToken?.unclaimedRewards) }}
|
||||
<div class="input-balance" v-if="walletStore.memeToken?.unclaimedRewards">
|
||||
Balance:
|
||||
{{
|
||||
formatNumber(
|
||||
walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
</stake-menu>
|
||||
@@ -127,9 +132,10 @@ function openStake() {
|
||||
|
||||
async function stakeAndClaimAllCycles() {
|
||||
try {
|
||||
const unclaimedRewards = walletStore.memeToken?.unclaimedRewards;
|
||||
const unclaimedRewards = walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals;
|
||||
stateClaim.value = 2;
|
||||
const coefficient = (10000 * tokenNumber.value) / unclaimedRewards;
|
||||
console.log("unclaimedRewards", unclaimedRewards);
|
||||
const coefficient = BigInt(10000 * tokenNumber.value) / unclaimedRewards;
|
||||
var hash = await rewardLockerStore.stakeAndClaimAllCycles(coefficient);
|
||||
stateClaim.value = 3;
|
||||
const data = await waitForTransaction({
|
||||
@@ -144,7 +150,7 @@ async function stakeAndClaimAllCycles() {
|
||||
//
|
||||
console.log("rewardData", rewardData);
|
||||
//ClaimedReward (address staker, uint256 reward)
|
||||
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
|
||||
const outputClaim = BigInt(rewardData.topics[2]) / 10n ** tokenStore.memeToken.decimals;
|
||||
showSuccessToast(
|
||||
formatNumber(outputClaim),
|
||||
"Success!",
|
||||
@@ -175,7 +181,7 @@ async function claimAll() {
|
||||
//
|
||||
console.log("rewardData", rewardData);
|
||||
//ClaimedReward (address staker, uint256 reward)
|
||||
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
|
||||
const outputClaim = rewardData.topics[2] / 10n ** tokenStore.memeToken.decimals;
|
||||
showSuccessToast(
|
||||
formatNumber(outputClaim),
|
||||
"Success!",
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<div class="connected-token" v-for="token in walletStore.token">
|
||||
<token-name-price
|
||||
:name="tokenStore.getToken(token.contractAddress).name"
|
||||
:price="token.balanceOf"
|
||||
:price="token.balanceOf / 10n ** tokenStore.getToken(token.contractAddress).decimals"
|
||||
></token-name-price>
|
||||
<div class="connected-token-button">
|
||||
<div class="bloodline-badge grey" @click="badgeClick(token)">
|
||||
@@ -117,7 +117,6 @@ function isMetaMaskInstalled(connector) {
|
||||
//we could also show buy, if there is no pepe
|
||||
function badgeClick(token) {
|
||||
var tokenData = tokenStore.getToken(token.contractAddress);
|
||||
tokenStore.activeToken = tokenData;
|
||||
if (tokenStore.memeToken.contractAddress === token.contractAddress) {
|
||||
//buy
|
||||
window.open(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div class="sacrifice-wrapper card card--glow">
|
||||
<div class="sacrifice-headline">Select Sacrifice</div>
|
||||
<button @click="splashBlood++">splash</button>
|
||||
<div class="sacrifice-headline">Select Sacrifice {{ splashBlood }}</div>
|
||||
<div class="sacrifice-select-tokens">
|
||||
<div class="sacrifice-tokens">
|
||||
<div
|
||||
@@ -26,20 +25,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="sacrifice-from-to-wrapper" v-if="activeToken.contractAddress">
|
||||
<div
|
||||
:class="{
|
||||
'sacrifice-from-wrapper': true,
|
||||
'bloodline-border': true,
|
||||
'bloodline-border--variant1': true,
|
||||
purple: true,
|
||||
}"
|
||||
>
|
||||
<div class="sacrifice-from-wrapper bloodline-border bloodline-border--variant1 purple">
|
||||
<token-input
|
||||
:modelValue="sacrificeStore.sacrificeNumber"
|
||||
:modelValue="sacrificeStore.sacrificeNumber / 10n ** activeToken.decimals"
|
||||
@input="
|
||||
($event) => {
|
||||
sacrificeStore.sacrificeNumber = $event.target.value;
|
||||
processChange($event.target.value);
|
||||
const value = BigInt($event.target.value) * 10n ** 18n;
|
||||
sacrificeStore.sacrificeNumber = value;
|
||||
processChange(value);
|
||||
}
|
||||
"
|
||||
:max="activeWalletToken?.balanceOf"
|
||||
@@ -66,7 +59,7 @@
|
||||
<template v-slot:message-end v-if="activeWalletToken?.balanceOf">
|
||||
<div class="input-balance tiny-text">
|
||||
Balance:
|
||||
{{ activeWalletToken?.balanceOf }}
|
||||
{{ BigInt(activeWalletToken?.balanceOf) / 10n ** activeToken.decimals }}
|
||||
</div>
|
||||
<div class="input-max tiny-text" @click="addMaxTokens">Max</div>
|
||||
</template>
|
||||
@@ -232,7 +225,7 @@ const stateComputed = computed(() => {
|
||||
if (
|
||||
sacrificeStore.sacrificeNumber === null ||
|
||||
sacrificeStore.sacrificeNumber === "" ||
|
||||
sacrificeStore.sacrificeNumber === 0
|
||||
sacrificeStore.sacrificeNumber === 0n
|
||||
) {
|
||||
returnState = 0;
|
||||
} else if (sacrificeStore.sacrificeState === 2) {
|
||||
@@ -275,6 +268,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
async function approveToken(amount) {
|
||||
try {
|
||||
console.log("amount", amount);
|
||||
sacrificeStore.sacrificeState = 2;
|
||||
const hash = await tokenStore.approveToken(amount);
|
||||
sacrificeStore.sacrificeState = 3;
|
||||
@@ -295,11 +289,11 @@ async function approveToken(amount) {
|
||||
|
||||
async function addTokens(value) {
|
||||
if (!walletStore.connected || sacrificeStore.sacrificeNumber < activeWalletToken.value?.balanceOf) {
|
||||
sacrificeStore.sacrificeNumber = Number(sacrificeStore.sacrificeNumber) + Number(value);
|
||||
sacrificeStore.sacrificeNumber = BigInt(sacrificeStore.sacrificeNumber) + value;
|
||||
} else {
|
||||
sacrificeStore.sacrificeNumber = Number(sacrificeStore.sacrificeNumber) - Number(value);
|
||||
if (sacrificeStore.sacrificeNumber < 0) {
|
||||
sacrificeStore.sacrificeNumber = 0;
|
||||
sacrificeStore.sacrificeNumber = sacrificeStore.sacrificeNumber - value;
|
||||
if (sacrificeStore.sacrificeNumber < 0n) {
|
||||
sacrificeStore.sacrificeNumber = 0n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +324,9 @@ function showApprovedToast(value, header, subheader, info) {
|
||||
},
|
||||
// Listen and react to events using callbacks. In this case we listen for
|
||||
// the "click" event emitted when clicking the toast button
|
||||
listeners: {},
|
||||
listeners: {
|
||||
sacrificed: showSplash,
|
||||
},
|
||||
};
|
||||
|
||||
// Render the toast and its contents
|
||||
@@ -345,9 +341,16 @@ function showApprovedToast(value, header, subheader, info) {
|
||||
});
|
||||
}
|
||||
|
||||
function showSplash() {
|
||||
splashBlood.value++;
|
||||
}
|
||||
|
||||
//call function in the store and remove icon,
|
||||
async function sacrificeToken() {
|
||||
await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, activeToken.value);
|
||||
var result = await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, activeToken.value);
|
||||
if (result) {
|
||||
showSplash();
|
||||
}
|
||||
toast.dismiss(approveToast.value);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,9 @@
|
||||
<div class="connected-stake-body">
|
||||
<slot name="body">
|
||||
<token-name-price
|
||||
v-if="walletStore.memeToken?.staked"
|
||||
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
|
||||
:price="formatNumber(walletStore.memeToken?.staked)"
|
||||
:price="formatNumber(walletStore.memeToken?.staked / 10n ** tokenStore.memeToken.decimals)"
|
||||
></token-name-price>
|
||||
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline-token'"></token-logo>
|
||||
<token-name-price class="stake-reward" name="Extra Reward" price="+25%"></token-name-price>
|
||||
@@ -103,7 +104,9 @@
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:message-end>
|
||||
<div class="input-balance">Balance: {{ walletStore.memeToken?.balanceOf }}</div>
|
||||
<div class="input-balance">
|
||||
Balance: {{ walletStore.memeToken?.balanceOf / 10n ** tokenStore.memeToken.decimals }}
|
||||
</div>
|
||||
</template>
|
||||
</stake-menu>
|
||||
<div class="unstake-menu" v-else-if="stakeMenu & unstakeMenu">
|
||||
@@ -222,7 +225,7 @@ async function orderUnstake() {
|
||||
});
|
||||
console.log("rewardData", rewardData);
|
||||
|
||||
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
|
||||
const outputClaim = Number(rewardData.topics[2]) / 10n ** tokenStore.memeToken.decimals;
|
||||
showSuccessToast(
|
||||
formatNumber(outputClaim),
|
||||
"Success!",
|
||||
@@ -239,6 +242,7 @@ async function orderUnstake() {
|
||||
|
||||
async function stakeToken() {
|
||||
try {
|
||||
console.log("stakeToken");
|
||||
state.value = 2;
|
||||
const hash = await rewardLockerStore.stakeBloodline(tokenNumber.value);
|
||||
state.value = 3;
|
||||
@@ -253,9 +257,9 @@ async function stakeToken() {
|
||||
//
|
||||
console.log("rewardData", rewardData);
|
||||
|
||||
const outputClaim = Number(rewardData.topics[3]) / Math.pow(10, tokenStore.memeToken.decimals);
|
||||
const outputClaim = BigInt(rewardData.topics[3]) / 10n ** tokenStore.memeToken.decimals;
|
||||
console.log("data", data);
|
||||
state.value = 4;
|
||||
state.value = 0;
|
||||
await walletStore.loadWalletData();
|
||||
showSuccessToast(
|
||||
formatNumber(outputClaim),
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<div class="stake-menu">
|
||||
<token-input :modelValue="props.modelValue" @input="emit('update:modelValue', Number($event.target.value))">
|
||||
<template v-slot:message>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(25)">25%</div>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(50)">50%</div>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(75)">75%</div>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(100)">100%</div>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(25n)">25%</div>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(50n)">50%</div>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(75n)">75%</div>
|
||||
<div class="stake-adder-step bloodline-badge grey" @click="addTokensPercent(100n)">100%</div>
|
||||
</template>
|
||||
<template v-slot:message-end>
|
||||
<slot name="message-end"> </slot>
|
||||
@@ -47,15 +47,18 @@ const emit = defineEmits(["close", "update:modelValue"]);
|
||||
|
||||
async function addTokensPercent(value) {
|
||||
console.log("value", value);
|
||||
console.log(walletStore.memeToken.balanceOf);
|
||||
console.log("props.amount", props.amount);
|
||||
console.log(walletStore.memeToken.balanceOf / 10n ** tokenStore.memeToken.decimals);
|
||||
let amount;
|
||||
if (props.amount !== undefined || props.amount !== null) {
|
||||
amount = (props.amount * value) / 100;
|
||||
console.log("props.amount", props.amount);
|
||||
amount = ((props.amount / 10n ** tokenStore.memeToken.decimals) * value) / 100n;
|
||||
} else if (props.stake) {
|
||||
amount = (walletStore.memeToken.balanceOf * value) / 100;
|
||||
amount = ((walletStore.memeToken.balanceOf / 10n ** tokenStore.memeToken.decimals) * value) / 100n;
|
||||
} else {
|
||||
amount = (walletStore.memeToken.staked * value) / 100;
|
||||
amount = ((walletStore.memeToken.staked / 10n ** tokenStore.memeToken.decimals) * value) / 100n;
|
||||
}
|
||||
console.log("amount", amount);
|
||||
emit("update:modelValue", Number(amount));
|
||||
}
|
||||
|
||||
@@ -78,11 +81,12 @@ async function unstakeBloodline() {
|
||||
|
||||
async function stakeBloodline() {
|
||||
try {
|
||||
console.log("stakeBloodline");
|
||||
const fromAddress = walletStore.address;
|
||||
const spender = rewardLockerStore.config.contractAddress;
|
||||
const deadline = Date.now() + 20 * 60;
|
||||
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
|
||||
const value = (tokenNumber.value * Math.pow(10, decimals)).toString();
|
||||
const value = BigInt(tokenNumber.value) * 10n ** decimals;
|
||||
const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
|
||||
const { types, message, domain, primaryType } = createPermitObject(
|
||||
fromAddress,
|
||||
|
||||
@@ -21,22 +21,25 @@
|
||||
</div> -->
|
||||
<div class="rewards-list">
|
||||
<rewards-wrapper
|
||||
v-if="getCurrentCycleData?.rewards_sacrifice !== undefined"
|
||||
title="Sacrafice Reward"
|
||||
coin="$BLOOD"
|
||||
:amount="formatNumber(getCurrentCycleData?.rewards_sacrifice)"
|
||||
:amount="formatNumber(getCurrentCycleData?.rewards_sacrifice / 10n ** tokenStore.memeToken.decimals)"
|
||||
image="/assets/img/vampir.png"
|
||||
/>
|
||||
<rewards-wrapper
|
||||
v-if="getCurrentCycleData?.rewards_staking !== undefined"
|
||||
title="Staking Bonus"
|
||||
coin="$BLOOD"
|
||||
:amount="formatNumber(getCurrentCycleData?.rewards_staking)"
|
||||
:amount="formatNumber(getCurrentCycleData?.rewards_staking / 10n ** tokenStore.memeToken.decimals)"
|
||||
info="max: 312m"
|
||||
image="/assets/img/vampir.png"
|
||||
/>
|
||||
<rewards-wrapper
|
||||
v-if="getCurrentCycleData?.rewards_clan !== undefined"
|
||||
title="Clan Bonus"
|
||||
coin="$BLOOD"
|
||||
:amount="formatNumber(getCurrentCycleData?.rewards_clan)"
|
||||
:amount="formatNumber(getCurrentCycleData?.rewards_clan / 10n ** tokenStore.memeToken.decimals)"
|
||||
image="/assets/img/vampir.png"
|
||||
/>
|
||||
</div>
|
||||
@@ -44,8 +47,9 @@
|
||||
<div class="rewards-total-headline sub-header">Total Reward</div>
|
||||
<div class="rewards-total-inner bloodline-border bloodline-border--variant1">
|
||||
<token-name-price
|
||||
v-if="getCurrentCycleData?.rewards_total !== undefined"
|
||||
name="$BLOOD"
|
||||
:price="formatNumber(getCurrentCycleData?.rewards_total)"
|
||||
:price="formatNumber(getCurrentCycleData?.rewards_total / 10n ** tokenStore.memeToken.decimals)"
|
||||
></token-name-price>
|
||||
<token-logo img="/assets/img/vampir.png" :alt="'vampire'"></token-logo>
|
||||
</div>
|
||||
@@ -171,8 +175,9 @@ async function stakeAndClaim() {
|
||||
});
|
||||
//
|
||||
console.log("rewardData", rewardData);
|
||||
const outputClaim = Number(rewardData?.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
|
||||
const outputStaked = Number(stakeData?.topics[3]) / Math.pow(10, tokenStore.memeToken.decimals);
|
||||
console.log("stakeData", stakeData);
|
||||
const outputClaim = Number(rewardData?.topics[2]) / 10 ** tokenStore.memeToken.decimals;
|
||||
const outputStaked = Number(stakeData?.topics[3]) / 10 ** tokenStore.memeToken.decimals;
|
||||
showSuccessToast(
|
||||
formatNumber(outputClaim + outputStaked),
|
||||
"Success!",
|
||||
@@ -220,7 +225,7 @@ async function claimRewards() {
|
||||
//
|
||||
console.log("rewardData", rewardData);
|
||||
|
||||
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
|
||||
const outputClaim = BigInt(rewardData.topics[2]) / 10n ** tokenStore.memeToken.decimals;
|
||||
showSuccessToast(
|
||||
formatNumber(outputClaim),
|
||||
"Success!",
|
||||
|
||||
@@ -62,10 +62,12 @@ const emit = defineEmits(["update:modelValue"]);
|
||||
.stake-adder-step
|
||||
padding: 4px 16px
|
||||
color: var(--black)
|
||||
font-size: 14px
|
||||
font-size: 12px
|
||||
border-width: 1px
|
||||
border-color: transparent
|
||||
border-style: solid
|
||||
@media (min-width: 992px)
|
||||
font-size: 14px
|
||||
&:hover,&:active, &:focus
|
||||
background-color: var(--grey-light)
|
||||
cursor: pointer
|
||||
|
||||
@@ -17,13 +17,15 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import LoadingComponent from "@/components/LoadingComponent.vue";
|
||||
import { getCurrentInstance, computed, watch } from "vue";
|
||||
import { getCurrentInstance, computed, watch, inject } from "vue";
|
||||
import { useTokenStore } from "@/stores/tokens";
|
||||
import { useSacrificeStore } from "@/stores/sacrifice";
|
||||
|
||||
import CardComponent from "@/components/CardComponent.vue";
|
||||
import { useToast } from "vue-toastification";
|
||||
|
||||
const emit = defineEmits(["sacrificed"]);
|
||||
|
||||
const props = defineProps({
|
||||
value: String,
|
||||
header: String,
|
||||
@@ -37,6 +39,8 @@ const sacrificeStore = useSacrificeStore();
|
||||
|
||||
const instance = getCurrentInstance();
|
||||
const id = instance.attrs["toast-id"];
|
||||
const splashBlood = inject("splashBlood");
|
||||
|
||||
function closeToast() {
|
||||
toast.dismiss(id);
|
||||
}
|
||||
@@ -64,8 +68,16 @@ const stateComputed = computed(() => {
|
||||
});
|
||||
|
||||
async function sacrificeClick() {
|
||||
await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, tokenStore.activeToken);
|
||||
closeToast();
|
||||
try {
|
||||
var result = await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, tokenStore.activeToken);
|
||||
if (result) {
|
||||
emit("sacrificed");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("error", error);
|
||||
} finally {
|
||||
closeToast();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="sass">
|
||||
|
||||
Reference in New Issue
Block a user