bigint umpdate
This commit is contained in:
@@ -33,8 +33,14 @@ watch(showPanel, (newValue, oldValue) => {
|
|||||||
console.log("document.body", document.body);
|
console.log("document.body", document.body);
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
document.body.classList.add("sideoutpanel-open");
|
document.body.classList.add("sideoutpanel-open");
|
||||||
|
if (isMobile) {
|
||||||
|
document.body.classList.add("mobile");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.remove("sideoutpanel-open");
|
document.body.classList.remove("sideoutpanel-open");
|
||||||
|
if (isMobile) {
|
||||||
|
document.body.classList.remove("mobile");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -78,6 +84,7 @@ onMounted(async () => {
|
|||||||
cycleStore.activeCycle = cycleStore.currentCycle;
|
cycleStore.activeCycle = cycleStore.currentCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("cycleStore.activeCycle", cycleStore.activeCycle);
|
||||||
await cycleStore.fillCycle(cycleStore.activeCycle);
|
await cycleStore.fillCycle(cycleStore.activeCycle);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -95,6 +102,7 @@ onMounted(async () => {
|
|||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="footer-inner">
|
<div class="footer-inner">
|
||||||
<div class="footer-headline">Join Bloodline</div>
|
<div class="footer-headline">Join Bloodline</div>
|
||||||
|
|
||||||
<div class="footer-social-links">
|
<div class="footer-social-links">
|
||||||
<div class="social-bloodline-badge">
|
<div class="social-bloodline-badge">
|
||||||
<div class="social-bloodline-badge-icon">
|
<div class="social-bloodline-badge-icon">
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="blood-chart-element-footer">
|
<div class="blood-chart-element-footer">
|
||||||
<div class="blood-chart-amount">
|
<div class="blood-chart-amount">
|
||||||
{{ formatNumber(coin.amountInBLD) }}
|
{{ formatNumber(coin.amountInBLD / 10n ** tokenStore.memeToken.decimals) }}
|
||||||
</div>
|
</div>
|
||||||
<div>$BLOOD</div>
|
<div>$BLOOD</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -99,6 +99,8 @@ import { getPercentage, compactNumber, formatNumber } from "@/helper/helper.js";
|
|||||||
import { useCycleStore } from "@/stores/cycles";
|
import { useCycleStore } from "@/stores/cycles";
|
||||||
|
|
||||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||||
|
import { useTokenStore } from "@/stores/tokens";
|
||||||
|
|
||||||
import { Swiper, SwiperSlide } from "swiper/vue";
|
import { Swiper, SwiperSlide } from "swiper/vue";
|
||||||
|
|
||||||
// Import Swiper styles
|
// Import Swiper styles
|
||||||
@@ -107,6 +109,7 @@ import "swiper/css/navigation";
|
|||||||
import "swiper/css/pagination";
|
import "swiper/css/pagination";
|
||||||
|
|
||||||
const cycleStore = useCycleStore();
|
const cycleStore = useCycleStore();
|
||||||
|
const tokenStore = useTokenStore();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: Object,
|
data: Object,
|
||||||
|
|||||||
@@ -244,24 +244,24 @@ function Blood3() {
|
|||||||
|
|
||||||
<style lang="sass">
|
<style lang="sass">
|
||||||
.blood-svg
|
.blood-svg
|
||||||
width: 40vmax
|
position: fixed
|
||||||
position: absolute
|
top: 50%
|
||||||
top: 50%
|
left: 50%
|
||||||
left: 50%
|
transform: translate(-50%,-50%)
|
||||||
transform: translate(-50%,-50%)
|
pointer-events: none
|
||||||
pointer-events: none
|
width: 100%
|
||||||
|
|
||||||
|
|
||||||
.blood-svg
|
.blood-svg
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
|
|
||||||
.blood-splash-2
|
.blood-splash-2
|
||||||
width: 70vmax
|
width: 100%
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.blood-splash-3
|
.blood-splash-3
|
||||||
width: 60vmax
|
width: 100%
|
||||||
|
|
||||||
|
|
||||||
p
|
p
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<token-name-price
|
<token-name-price
|
||||||
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
|
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
|
||||||
:price="walletStore.memeToken?.unclaimedRewards"
|
:price="walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals"
|
||||||
></token-name-price>
|
></token-name-price>
|
||||||
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline logo'"></token-logo>
|
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline logo'"></token-logo>
|
||||||
</template>
|
</template>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
@close="stakeMenu = false"
|
@close="stakeMenu = false"
|
||||||
:amount="walletStore.memeToken?.unclaimedRewards"
|
:amount="walletStore.memeToken?.unclaimedRewards"
|
||||||
:stake="stake"
|
:stake="stake"
|
||||||
v-if="stakeMenu"
|
v-if="stakeMenu && walletStore.memeToken?.unclaimedRewards"
|
||||||
>
|
>
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<div class="btn btn-immortal stake-button" disabled v-if="stateClaimComp === 0">
|
<div class="btn btn-immortal stake-button" disabled v-if="stateClaimComp === 0">
|
||||||
@@ -55,8 +55,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:message-end>
|
<template v-slot:message-end>
|
||||||
<div class="input-balance">
|
<div class="input-balance" v-if="walletStore.memeToken?.unclaimedRewards">
|
||||||
Balance: {{ formatNumber(walletStore.memeToken?.unclaimedRewards) }}
|
Balance:
|
||||||
|
{{
|
||||||
|
formatNumber(
|
||||||
|
walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals
|
||||||
|
)
|
||||||
|
}}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</stake-menu>
|
</stake-menu>
|
||||||
@@ -127,9 +132,10 @@ function openStake() {
|
|||||||
|
|
||||||
async function stakeAndClaimAllCycles() {
|
async function stakeAndClaimAllCycles() {
|
||||||
try {
|
try {
|
||||||
const unclaimedRewards = walletStore.memeToken?.unclaimedRewards;
|
const unclaimedRewards = walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals;
|
||||||
stateClaim.value = 2;
|
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);
|
var hash = await rewardLockerStore.stakeAndClaimAllCycles(coefficient);
|
||||||
stateClaim.value = 3;
|
stateClaim.value = 3;
|
||||||
const data = await waitForTransaction({
|
const data = await waitForTransaction({
|
||||||
@@ -144,7 +150,7 @@ async function stakeAndClaimAllCycles() {
|
|||||||
//
|
//
|
||||||
console.log("rewardData", rewardData);
|
console.log("rewardData", rewardData);
|
||||||
//ClaimedReward (address staker, uint256 reward)
|
//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(
|
showSuccessToast(
|
||||||
formatNumber(outputClaim),
|
formatNumber(outputClaim),
|
||||||
"Success!",
|
"Success!",
|
||||||
@@ -175,7 +181,7 @@ async function claimAll() {
|
|||||||
//
|
//
|
||||||
console.log("rewardData", rewardData);
|
console.log("rewardData", rewardData);
|
||||||
//ClaimedReward (address staker, uint256 reward)
|
//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(
|
showSuccessToast(
|
||||||
formatNumber(outputClaim),
|
formatNumber(outputClaim),
|
||||||
"Success!",
|
"Success!",
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<div class="connected-token" v-for="token in walletStore.token">
|
<div class="connected-token" v-for="token in walletStore.token">
|
||||||
<token-name-price
|
<token-name-price
|
||||||
:name="tokenStore.getToken(token.contractAddress).name"
|
:name="tokenStore.getToken(token.contractAddress).name"
|
||||||
:price="token.balanceOf"
|
:price="token.balanceOf / 10n ** tokenStore.getToken(token.contractAddress).decimals"
|
||||||
></token-name-price>
|
></token-name-price>
|
||||||
<div class="connected-token-button">
|
<div class="connected-token-button">
|
||||||
<div class="bloodline-badge grey" @click="badgeClick(token)">
|
<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
|
//we could also show buy, if there is no pepe
|
||||||
function badgeClick(token) {
|
function badgeClick(token) {
|
||||||
var tokenData = tokenStore.getToken(token.contractAddress);
|
var tokenData = tokenStore.getToken(token.contractAddress);
|
||||||
tokenStore.activeToken = tokenData;
|
|
||||||
if (tokenStore.memeToken.contractAddress === token.contractAddress) {
|
if (tokenStore.memeToken.contractAddress === token.contractAddress) {
|
||||||
//buy
|
//buy
|
||||||
window.open(
|
window.open(
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="sacrifice-wrapper card card--glow">
|
<div class="sacrifice-wrapper card card--glow">
|
||||||
<div class="sacrifice-headline">Select Sacrifice</div>
|
<div class="sacrifice-headline">Select Sacrifice {{ splashBlood }}</div>
|
||||||
<button @click="splashBlood++">splash</button>
|
|
||||||
<div class="sacrifice-select-tokens">
|
<div class="sacrifice-select-tokens">
|
||||||
<div class="sacrifice-tokens">
|
<div class="sacrifice-tokens">
|
||||||
<div
|
<div
|
||||||
@@ -26,20 +25,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sacrifice-from-to-wrapper" v-if="activeToken.contractAddress">
|
<div class="sacrifice-from-to-wrapper" v-if="activeToken.contractAddress">
|
||||||
<div
|
<div class="sacrifice-from-wrapper bloodline-border bloodline-border--variant1 purple">
|
||||||
:class="{
|
|
||||||
'sacrifice-from-wrapper': true,
|
|
||||||
'bloodline-border': true,
|
|
||||||
'bloodline-border--variant1': true,
|
|
||||||
purple: true,
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<token-input
|
<token-input
|
||||||
:modelValue="sacrificeStore.sacrificeNumber"
|
:modelValue="sacrificeStore.sacrificeNumber / 10n ** activeToken.decimals"
|
||||||
@input="
|
@input="
|
||||||
($event) => {
|
($event) => {
|
||||||
sacrificeStore.sacrificeNumber = $event.target.value;
|
const value = BigInt($event.target.value) * 10n ** 18n;
|
||||||
processChange($event.target.value);
|
sacrificeStore.sacrificeNumber = value;
|
||||||
|
processChange(value);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
:max="activeWalletToken?.balanceOf"
|
:max="activeWalletToken?.balanceOf"
|
||||||
@@ -66,7 +59,7 @@
|
|||||||
<template v-slot:message-end v-if="activeWalletToken?.balanceOf">
|
<template v-slot:message-end v-if="activeWalletToken?.balanceOf">
|
||||||
<div class="input-balance tiny-text">
|
<div class="input-balance tiny-text">
|
||||||
Balance:
|
Balance:
|
||||||
{{ activeWalletToken?.balanceOf }}
|
{{ BigInt(activeWalletToken?.balanceOf) / 10n ** activeToken.decimals }}
|
||||||
</div>
|
</div>
|
||||||
<div class="input-max tiny-text" @click="addMaxTokens">Max</div>
|
<div class="input-max tiny-text" @click="addMaxTokens">Max</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -232,7 +225,7 @@ const stateComputed = computed(() => {
|
|||||||
if (
|
if (
|
||||||
sacrificeStore.sacrificeNumber === null ||
|
sacrificeStore.sacrificeNumber === null ||
|
||||||
sacrificeStore.sacrificeNumber === "" ||
|
sacrificeStore.sacrificeNumber === "" ||
|
||||||
sacrificeStore.sacrificeNumber === 0
|
sacrificeStore.sacrificeNumber === 0n
|
||||||
) {
|
) {
|
||||||
returnState = 0;
|
returnState = 0;
|
||||||
} else if (sacrificeStore.sacrificeState === 2) {
|
} else if (sacrificeStore.sacrificeState === 2) {
|
||||||
@@ -275,6 +268,7 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
async function approveToken(amount) {
|
async function approveToken(amount) {
|
||||||
try {
|
try {
|
||||||
|
console.log("amount", amount);
|
||||||
sacrificeStore.sacrificeState = 2;
|
sacrificeStore.sacrificeState = 2;
|
||||||
const hash = await tokenStore.approveToken(amount);
|
const hash = await tokenStore.approveToken(amount);
|
||||||
sacrificeStore.sacrificeState = 3;
|
sacrificeStore.sacrificeState = 3;
|
||||||
@@ -295,11 +289,11 @@ async function approveToken(amount) {
|
|||||||
|
|
||||||
async function addTokens(value) {
|
async function addTokens(value) {
|
||||||
if (!walletStore.connected || sacrificeStore.sacrificeNumber < activeWalletToken.value?.balanceOf) {
|
if (!walletStore.connected || sacrificeStore.sacrificeNumber < activeWalletToken.value?.balanceOf) {
|
||||||
sacrificeStore.sacrificeNumber = Number(sacrificeStore.sacrificeNumber) + Number(value);
|
sacrificeStore.sacrificeNumber = BigInt(sacrificeStore.sacrificeNumber) + value;
|
||||||
} else {
|
} else {
|
||||||
sacrificeStore.sacrificeNumber = Number(sacrificeStore.sacrificeNumber) - Number(value);
|
sacrificeStore.sacrificeNumber = sacrificeStore.sacrificeNumber - value;
|
||||||
if (sacrificeStore.sacrificeNumber < 0) {
|
if (sacrificeStore.sacrificeNumber < 0n) {
|
||||||
sacrificeStore.sacrificeNumber = 0;
|
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
|
// Listen and react to events using callbacks. In this case we listen for
|
||||||
// the "click" event emitted when clicking the toast button
|
// the "click" event emitted when clicking the toast button
|
||||||
listeners: {},
|
listeners: {
|
||||||
|
sacrificed: showSplash,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Render the toast and its contents
|
// 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,
|
//call function in the store and remove icon,
|
||||||
async function sacrificeToken() {
|
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);
|
toast.dismiss(approveToast.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,9 @@
|
|||||||
<div class="connected-stake-body">
|
<div class="connected-stake-body">
|
||||||
<slot name="body">
|
<slot name="body">
|
||||||
<token-name-price
|
<token-name-price
|
||||||
|
v-if="walletStore.memeToken?.staked"
|
||||||
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
|
: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-name-price>
|
||||||
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline-token'"></token-logo>
|
<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>
|
<token-name-price class="stake-reward" name="Extra Reward" price="+25%"></token-name-price>
|
||||||
@@ -103,7 +104,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:message-end>
|
<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>
|
</template>
|
||||||
</stake-menu>
|
</stake-menu>
|
||||||
<div class="unstake-menu" v-else-if="stakeMenu & unstakeMenu">
|
<div class="unstake-menu" v-else-if="stakeMenu & unstakeMenu">
|
||||||
@@ -222,7 +225,7 @@ async function orderUnstake() {
|
|||||||
});
|
});
|
||||||
console.log("rewardData", rewardData);
|
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(
|
showSuccessToast(
|
||||||
formatNumber(outputClaim),
|
formatNumber(outputClaim),
|
||||||
"Success!",
|
"Success!",
|
||||||
@@ -239,6 +242,7 @@ async function orderUnstake() {
|
|||||||
|
|
||||||
async function stakeToken() {
|
async function stakeToken() {
|
||||||
try {
|
try {
|
||||||
|
console.log("stakeToken");
|
||||||
state.value = 2;
|
state.value = 2;
|
||||||
const hash = await rewardLockerStore.stakeBloodline(tokenNumber.value);
|
const hash = await rewardLockerStore.stakeBloodline(tokenNumber.value);
|
||||||
state.value = 3;
|
state.value = 3;
|
||||||
@@ -253,9 +257,9 @@ async function stakeToken() {
|
|||||||
//
|
//
|
||||||
console.log("rewardData", rewardData);
|
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);
|
console.log("data", data);
|
||||||
state.value = 4;
|
state.value = 0;
|
||||||
await walletStore.loadWalletData();
|
await walletStore.loadWalletData();
|
||||||
showSuccessToast(
|
showSuccessToast(
|
||||||
formatNumber(outputClaim),
|
formatNumber(outputClaim),
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
<div class="stake-menu">
|
<div class="stake-menu">
|
||||||
<token-input :modelValue="props.modelValue" @input="emit('update:modelValue', Number($event.target.value))">
|
<token-input :modelValue="props.modelValue" @input="emit('update:modelValue', Number($event.target.value))">
|
||||||
<template v-slot:message>
|
<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(25n)">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(50n)">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(75n)">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(100n)">100%</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:message-end>
|
<template v-slot:message-end>
|
||||||
<slot name="message-end"> </slot>
|
<slot name="message-end"> </slot>
|
||||||
@@ -47,15 +47,18 @@ const emit = defineEmits(["close", "update:modelValue"]);
|
|||||||
|
|
||||||
async function addTokensPercent(value) {
|
async function addTokensPercent(value) {
|
||||||
console.log("value", 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;
|
let amount;
|
||||||
if (props.amount !== undefined || props.amount !== null) {
|
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) {
|
} else if (props.stake) {
|
||||||
amount = (walletStore.memeToken.balanceOf * value) / 100;
|
amount = ((walletStore.memeToken.balanceOf / 10n ** tokenStore.memeToken.decimals) * value) / 100n;
|
||||||
} else {
|
} 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));
|
emit("update:modelValue", Number(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,11 +81,12 @@ async function unstakeBloodline() {
|
|||||||
|
|
||||||
async function stakeBloodline() {
|
async function stakeBloodline() {
|
||||||
try {
|
try {
|
||||||
|
console.log("stakeBloodline");
|
||||||
const fromAddress = walletStore.address;
|
const fromAddress = walletStore.address;
|
||||||
const spender = rewardLockerStore.config.contractAddress;
|
const spender = rewardLockerStore.config.contractAddress;
|
||||||
const deadline = Date.now() + 20 * 60;
|
const deadline = Date.now() + 20 * 60;
|
||||||
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
|
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 nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
|
||||||
const { types, message, domain, primaryType } = createPermitObject(
|
const { types, message, domain, primaryType } = createPermitObject(
|
||||||
fromAddress,
|
fromAddress,
|
||||||
|
|||||||
@@ -21,22 +21,25 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
<div class="rewards-list">
|
<div class="rewards-list">
|
||||||
<rewards-wrapper
|
<rewards-wrapper
|
||||||
|
v-if="getCurrentCycleData?.rewards_sacrifice !== undefined"
|
||||||
title="Sacrafice Reward"
|
title="Sacrafice Reward"
|
||||||
coin="$BLOOD"
|
coin="$BLOOD"
|
||||||
:amount="formatNumber(getCurrentCycleData?.rewards_sacrifice)"
|
:amount="formatNumber(getCurrentCycleData?.rewards_sacrifice / 10n ** tokenStore.memeToken.decimals)"
|
||||||
image="/assets/img/vampir.png"
|
image="/assets/img/vampir.png"
|
||||||
/>
|
/>
|
||||||
<rewards-wrapper
|
<rewards-wrapper
|
||||||
|
v-if="getCurrentCycleData?.rewards_staking !== undefined"
|
||||||
title="Staking Bonus"
|
title="Staking Bonus"
|
||||||
coin="$BLOOD"
|
coin="$BLOOD"
|
||||||
:amount="formatNumber(getCurrentCycleData?.rewards_staking)"
|
:amount="formatNumber(getCurrentCycleData?.rewards_staking / 10n ** tokenStore.memeToken.decimals)"
|
||||||
info="max: 312m"
|
info="max: 312m"
|
||||||
image="/assets/img/vampir.png"
|
image="/assets/img/vampir.png"
|
||||||
/>
|
/>
|
||||||
<rewards-wrapper
|
<rewards-wrapper
|
||||||
|
v-if="getCurrentCycleData?.rewards_clan !== undefined"
|
||||||
title="Clan Bonus"
|
title="Clan Bonus"
|
||||||
coin="$BLOOD"
|
coin="$BLOOD"
|
||||||
:amount="formatNumber(getCurrentCycleData?.rewards_clan)"
|
:amount="formatNumber(getCurrentCycleData?.rewards_clan / 10n ** tokenStore.memeToken.decimals)"
|
||||||
image="/assets/img/vampir.png"
|
image="/assets/img/vampir.png"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,8 +47,9 @@
|
|||||||
<div class="rewards-total-headline sub-header">Total Reward</div>
|
<div class="rewards-total-headline sub-header">Total Reward</div>
|
||||||
<div class="rewards-total-inner bloodline-border bloodline-border--variant1">
|
<div class="rewards-total-inner bloodline-border bloodline-border--variant1">
|
||||||
<token-name-price
|
<token-name-price
|
||||||
|
v-if="getCurrentCycleData?.rewards_total !== undefined"
|
||||||
name="$BLOOD"
|
name="$BLOOD"
|
||||||
:price="formatNumber(getCurrentCycleData?.rewards_total)"
|
:price="formatNumber(getCurrentCycleData?.rewards_total / 10n ** tokenStore.memeToken.decimals)"
|
||||||
></token-name-price>
|
></token-name-price>
|
||||||
<token-logo img="/assets/img/vampir.png" :alt="'vampire'"></token-logo>
|
<token-logo img="/assets/img/vampir.png" :alt="'vampire'"></token-logo>
|
||||||
</div>
|
</div>
|
||||||
@@ -171,8 +175,9 @@ async function stakeAndClaim() {
|
|||||||
});
|
});
|
||||||
//
|
//
|
||||||
console.log("rewardData", rewardData);
|
console.log("rewardData", rewardData);
|
||||||
const outputClaim = Number(rewardData?.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
|
console.log("stakeData", stakeData);
|
||||||
const outputStaked = Number(stakeData?.topics[3]) / Math.pow(10, tokenStore.memeToken.decimals);
|
const outputClaim = Number(rewardData?.topics[2]) / 10 ** tokenStore.memeToken.decimals;
|
||||||
|
const outputStaked = Number(stakeData?.topics[3]) / 10 ** tokenStore.memeToken.decimals;
|
||||||
showSuccessToast(
|
showSuccessToast(
|
||||||
formatNumber(outputClaim + outputStaked),
|
formatNumber(outputClaim + outputStaked),
|
||||||
"Success!",
|
"Success!",
|
||||||
@@ -220,7 +225,7 @@ async function claimRewards() {
|
|||||||
//
|
//
|
||||||
console.log("rewardData", rewardData);
|
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(
|
showSuccessToast(
|
||||||
formatNumber(outputClaim),
|
formatNumber(outputClaim),
|
||||||
"Success!",
|
"Success!",
|
||||||
|
|||||||
@@ -62,10 +62,12 @@ const emit = defineEmits(["update:modelValue"]);
|
|||||||
.stake-adder-step
|
.stake-adder-step
|
||||||
padding: 4px 16px
|
padding: 4px 16px
|
||||||
color: var(--black)
|
color: var(--black)
|
||||||
font-size: 14px
|
font-size: 12px
|
||||||
border-width: 1px
|
border-width: 1px
|
||||||
border-color: transparent
|
border-color: transparent
|
||||||
border-style: solid
|
border-style: solid
|
||||||
|
@media (min-width: 992px)
|
||||||
|
font-size: 14px
|
||||||
&:hover,&:active, &:focus
|
&:hover,&:active, &:focus
|
||||||
background-color: var(--grey-light)
|
background-color: var(--grey-light)
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
|
|||||||
@@ -17,13 +17,15 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import LoadingComponent from "@/components/LoadingComponent.vue";
|
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 { useTokenStore } from "@/stores/tokens";
|
||||||
import { useSacrificeStore } from "@/stores/sacrifice";
|
import { useSacrificeStore } from "@/stores/sacrifice";
|
||||||
|
|
||||||
import CardComponent from "@/components/CardComponent.vue";
|
import CardComponent from "@/components/CardComponent.vue";
|
||||||
import { useToast } from "vue-toastification";
|
import { useToast } from "vue-toastification";
|
||||||
|
|
||||||
|
const emit = defineEmits(["sacrificed"]);
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: String,
|
value: String,
|
||||||
header: String,
|
header: String,
|
||||||
@@ -37,6 +39,8 @@ const sacrificeStore = useSacrificeStore();
|
|||||||
|
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
const id = instance.attrs["toast-id"];
|
const id = instance.attrs["toast-id"];
|
||||||
|
const splashBlood = inject("splashBlood");
|
||||||
|
|
||||||
function closeToast() {
|
function closeToast() {
|
||||||
toast.dismiss(id);
|
toast.dismiss(id);
|
||||||
}
|
}
|
||||||
@@ -64,8 +68,16 @@ const stateComputed = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function sacrificeClick() {
|
async function sacrificeClick() {
|
||||||
await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, tokenStore.activeToken);
|
try {
|
||||||
closeToast();
|
var result = await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, tokenStore.activeToken);
|
||||||
|
if (result) {
|
||||||
|
emit("sacrificed");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("error", error);
|
||||||
|
} finally {
|
||||||
|
closeToast();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="sass">
|
<style lang="sass">
|
||||||
|
|||||||
+2
-1
@@ -193,7 +193,8 @@ try {
|
|||||||
await tokenStore.initV2();
|
await tokenStore.initV2();
|
||||||
await rewardLockerStore.init();
|
await rewardLockerStore.init();
|
||||||
await walletStore.loadWalletData();
|
await walletStore.loadWalletData();
|
||||||
await cycleStore.fillCycle(cycleStore.currentCycle);
|
// console.log("cycleStore.currentCycle", cycleStore.currentCycle);
|
||||||
|
// await cycleStore.fillCycle(cycleStore.currentCycle);
|
||||||
await uniswapStore.init();
|
await uniswapStore.init();
|
||||||
} else {
|
} else {
|
||||||
walletStore.address = null;
|
walletStore.address = null;
|
||||||
|
|||||||
+33
-34
@@ -62,7 +62,6 @@ export const useCycleStore = defineStore("cycles", {
|
|||||||
//todo check if needed, or use fillcycle
|
//todo check if needed, or use fillcycle
|
||||||
async updateCurrentCycle(sacrificedToken) {
|
async updateCurrentCycle(sacrificedToken) {
|
||||||
console.log("updateCurrentCycle");
|
console.log("updateCurrentCycle");
|
||||||
const tokenStore = useTokenStore();
|
|
||||||
const memeBurnerStore = useMemeburnerStore();
|
const memeBurnerStore = useMemeburnerStore();
|
||||||
var data = await memeBurnerStore.getSacrificedCycle(this.currentCycle);
|
var data = await memeBurnerStore.getSacrificedCycle(this.currentCycle);
|
||||||
console.log("this.currentCycle", this.currentCycle);
|
console.log("this.currentCycle", this.currentCycle);
|
||||||
@@ -71,10 +70,8 @@ export const useCycleStore = defineStore("cycles", {
|
|||||||
var tokenIndex = this.cycles[this.currentCycle].token.findIndex(
|
var tokenIndex = this.cycles[this.currentCycle].token.findIndex(
|
||||||
(tokenData) => tokenData.contractAddress === sacrificedToken
|
(tokenData) => tokenData.contractAddress === sacrificedToken
|
||||||
);
|
);
|
||||||
console.log("tokenIndex", tokenIndex);
|
|
||||||
const token = tokenStore.getToken(sacrificedToken);
|
|
||||||
this.cycles[this.currentCycle].token[tokenIndex].amount =
|
this.cycles[this.currentCycle].token[tokenIndex].amount =
|
||||||
Number(data[tokenIndex].result[1]) / Math.pow(10, token.decimals);
|
data[tokenIndex].result[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -83,7 +80,7 @@ export const useCycleStore = defineStore("cycles", {
|
|||||||
* you can use the refillcycle to overwrite information, because if you claim or stake the values will change
|
* you can use the refillcycle to overwrite information, because if you claim or stake the values will change
|
||||||
*/
|
*/
|
||||||
async fillCycle(cycleNumber, refillCycle = false) {
|
async fillCycle(cycleNumber, refillCycle = false) {
|
||||||
console.log("fillCycle");
|
console.log("fillCycle", cycleNumber);
|
||||||
const memeBurnerStore = useMemeburnerStore();
|
const memeBurnerStore = useMemeburnerStore();
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
const walletStore = useWalletStoreV2();
|
const walletStore = useWalletStoreV2();
|
||||||
@@ -100,14 +97,18 @@ export const useCycleStore = defineStore("cycles", {
|
|||||||
rewardData = await rewardLockerStore.getRewardsForAllToken(cycleNumber);
|
rewardData = await rewardLockerStore.getRewardsForAllToken(cycleNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("hier");
|
||||||
//getTotalSacrificeRewardsForToken multicall for all tokens
|
//getTotalSacrificeRewardsForToken multicall for all tokens
|
||||||
const tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(cycleNumber);
|
const tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(cycleNumber);
|
||||||
|
console.log("hier1");
|
||||||
var goal = await memeBurnerStore.getGoal(cycleNumber);
|
var goal = await memeBurnerStore.getGoal(cycleNumber);
|
||||||
|
console.log("hier123");
|
||||||
var tokenArray = [];
|
var tokenArray = [];
|
||||||
var rewards_clan = 0;
|
var rewards_clan = 0n;
|
||||||
var rewards_sacrifice = 0;
|
var rewards_sacrifice = 0n;
|
||||||
var rewards_staking = 0;
|
var rewards_staking = 0n;
|
||||||
|
|
||||||
|
console.log("hier123");
|
||||||
for (let index = 0; index < data.length; index++) {
|
for (let index = 0; index < data.length; index++) {
|
||||||
var tokenData = {};
|
var tokenData = {};
|
||||||
const token = tokenStore.token[index];
|
const token = tokenStore.token[index];
|
||||||
@@ -117,47 +118,45 @@ export const useCycleStore = defineStore("cycles", {
|
|||||||
token.contractAddress
|
token.contractAddress
|
||||||
);
|
);
|
||||||
console.log("coefficent", coefficent);
|
console.log("coefficent", coefficent);
|
||||||
|
|
||||||
tokenData.name = token.name;
|
tokenData.name = token.name;
|
||||||
tokenData.contractAddress = token.contractAddress;
|
tokenData.contractAddress = token.contractAddress;
|
||||||
tokenData.vamplogo = token.vamp.logo;
|
tokenData.vamplogo = token.vamp.logo;
|
||||||
tokenData.vampwinner = token.vamp.winner;
|
tokenData.vampwinner = token.vamp.winner;
|
||||||
tokenData.vampwinner2 = token.vamp.winner2;
|
tokenData.vampwinner2 = token.vamp.winner2;
|
||||||
tokenData.vampname = token.vamp.name;
|
tokenData.vampname = token.vamp.name;
|
||||||
tokenData.amount = Number(data[index].result[1]) / Math.pow(10, token.decimals);
|
tokenData.amount = data[index].result[1]
|
||||||
tokenData.amountInBLD = Number(tokenTotalSacrificed[index].result) / Math.pow(10, token.decimals);
|
tokenData.amountInBLD = tokenTotalSacrificed[index].result
|
||||||
|
|
||||||
if (walletStore.connected) {
|
if (walletStore.connected) {
|
||||||
//if user is connected fill user specific data for the token
|
//if user is connected fill user specific data for the token
|
||||||
const sacrificeClanReward = Number(rewardData[index].result[1]);
|
const sacrificeClanReward = rewardData[index].result[1];
|
||||||
let clanwin = 0;
|
let clanwin = 0n;
|
||||||
if (cycleNumber !== this.currentCycle) {
|
if (cycleNumber !== this.currentCycle) {
|
||||||
clanwin = (Number(coefficent) / 10000 - 1) * sacrificeClanReward;
|
clanwin = (coefficent / 10000n - 1n) * sacrificeClanReward;
|
||||||
console.log("clanwin", clanwin);
|
console.log("clanwin", clanwin);
|
||||||
}
|
}
|
||||||
const sacrificeRewards = Number(sacrificeClanReward);
|
const sacrificeRewards = sacrificeClanReward;
|
||||||
|
|
||||||
tokenData.rewards_ges = Number(
|
tokenData.rewards_ges =
|
||||||
rewardData[index].result[1] / BigInt(Math.pow(10, token.decimals)) +
|
rewardData[index].result[1] +
|
||||||
rewardData[index].result[0] / BigInt(Math.pow(10, token.decimals))
|
rewardData[index].result[0]
|
||||||
);
|
|
||||||
|
|
||||||
tokenData.rewards_clan = clanwin / Math.pow(10, token.decimals);
|
tokenData.rewards_clan = clanwin
|
||||||
|
|
||||||
tokenData.rewards_staking = Number(
|
tokenData.rewards_staking = rewardData[index].result[0]
|
||||||
rewardData[index].result[0] / BigInt(Math.pow(10, token.decimals))
|
tokenData.rewards_sacrifice = sacrificeRewards
|
||||||
);
|
|
||||||
tokenData.rewards_sacrifice = sacrificeRewards / Math.pow(10, token.decimals);
|
|
||||||
|
|
||||||
|
console.log("rewards_clan", rewards_clan);
|
||||||
|
console.log("tokenData.rewards_clan", tokenData.rewards_clan);
|
||||||
|
console.log("tokenData.rewards_sacrifice", tokenData.rewards_sacrifice);
|
||||||
rewards_clan = rewards_clan + tokenData.rewards_clan;
|
rewards_clan = rewards_clan + tokenData.rewards_clan;
|
||||||
rewards_sacrifice = rewards_sacrifice + tokenData.rewards_sacrifice;
|
rewards_sacrifice = rewards_sacrifice + tokenData.rewards_sacrifice;
|
||||||
rewards_staking = rewards_staking + tokenData.rewards_staking;
|
rewards_staking = rewards_staking + tokenData.rewards_staking;
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenArray.push(tokenData);
|
tokenArray.push(tokenData);
|
||||||
}
|
}
|
||||||
|
|
||||||
const goalDecimal = Number(goal[0]) / Math.pow(10, tokenStore.memeToken.decimals);
|
const goalDecimal = goal[0]
|
||||||
const winner = tokenArray.find((token) => token.amount === goalDecimal);
|
const winner = tokenArray.find((token) => token.amount === goalDecimal);
|
||||||
const goalInBLD = await memeBurnerStore.getGoalInBLOOD(cycleNumber);
|
const goalInBLD = await memeBurnerStore.getGoalInBLOOD(cycleNumber);
|
||||||
//replace vamplogo cause it will automatically change the token for the cycle view (new design)
|
//replace vamplogo cause it will automatically change the token for the cycle view (new design)
|
||||||
@@ -165,13 +164,13 @@ export const useCycleStore = defineStore("cycles", {
|
|||||||
winner.vamplogo = winner.vampwinner;
|
winner.vamplogo = winner.vampwinner;
|
||||||
}
|
}
|
||||||
this.cycles[cycleNumber] = {
|
this.cycles[cycleNumber] = {
|
||||||
goal: Number(goal[0]) / Math.pow(10, tokenStore.memeToken.decimals),
|
goal: goal[0],
|
||||||
goalInBLD: Number(goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals))),
|
goalInBLD: goalInBLD,
|
||||||
expirationTimestamp: Number(goal[2]),
|
expirationTimestamp: goal[2],
|
||||||
rewards_clan: Number(rewards_clan),
|
rewards_clan: rewards_clan,
|
||||||
rewards_staking: Number(rewards_staking),
|
rewards_staking: rewards_staking,
|
||||||
rewards_sacrifice: Number(rewards_sacrifice),
|
rewards_sacrifice: rewards_sacrifice,
|
||||||
rewards_total: Number(rewards_clan) + Number(rewards_sacrifice) + Number(rewards_staking),
|
rewards_total: rewards_clan + rewards_sacrifice + rewards_staking,
|
||||||
token: tokenArray,
|
token: tokenArray,
|
||||||
connected: walletStore.connected,
|
connected: walletStore.connected,
|
||||||
winner: winner,
|
winner: winner,
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
async getCurrentCycle() {
|
async getCurrentCycle() {
|
||||||
return await this.contract.read.currentCycle();
|
return await this.contract.read.currentCycle();
|
||||||
},
|
},
|
||||||
async getGoal(cycleNumber) {
|
async getGoal(cycleNumber) {
|
||||||
|
console.log("hier123", cycleNumber);
|
||||||
return await this.contract.read.cycles([cycleNumber]);
|
return await this.contract.read.cycles([cycleNumber]);
|
||||||
},
|
},
|
||||||
//returns participated, amount achieved
|
//returns participated, amount achieved
|
||||||
@@ -79,11 +80,10 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals));
|
|
||||||
var hash = await this.contract.write.sacrificeMeme([
|
var hash = await this.contract.write.sacrificeMeme([
|
||||||
tokenStore.activeToken.contractAddress,
|
tokenStore.activeToken.contractAddress,
|
||||||
amountDecimal.toString(),
|
amount,
|
||||||
0
|
0,
|
||||||
]);
|
]);
|
||||||
return hash;
|
return hash;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -96,10 +96,9 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
async sacrificeMemeAndBuyBLOOD(amount) {
|
async sacrificeMemeAndBuyBLOOD(amount) {
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
|
|
||||||
const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals));
|
|
||||||
var hash = await this.contract.write.sacrificeMemeAndBuyBLOOD([
|
var hash = await this.contract.write.sacrificeMemeAndBuyBLOOD([
|
||||||
tokenStore.activeToken.contractAddress,
|
tokenStore.activeToken.contractAddress,
|
||||||
amountDecimal.toString(),
|
amount,
|
||||||
0,
|
0,
|
||||||
]);
|
]);
|
||||||
return hash;
|
return hash;
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
|||||||
functionName: "getRewards",
|
functionName: "getRewards",
|
||||||
args: [walletStore.address, cycleNumber, token.contractAddress],
|
args: [walletStore.address, cycleNumber, token.contractAddress],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const data = await multicall({
|
const data = await multicall({
|
||||||
contracts,
|
contracts,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
@@ -132,7 +132,7 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
|||||||
const spender = this.config.contractAddress;
|
const spender = this.config.contractAddress;
|
||||||
const deadline = Date.now() + 20 * 60;
|
const deadline = Date.now() + 20 * 60;
|
||||||
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
|
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
|
||||||
const value = BigInt(tokenNumber * Math.pow(10, decimals));
|
const value = BigInt(tokenNumber) * 10n ** decimals;
|
||||||
const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
|
const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
|
||||||
console.log("nonce", nonce);
|
console.log("nonce", nonce);
|
||||||
const { types, message, domain, primaryType } = createPermitObject(
|
const { types, message, domain, primaryType } = createPermitObject(
|
||||||
@@ -166,13 +166,12 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
|||||||
return hash;
|
return hash;
|
||||||
},
|
},
|
||||||
async stakeAndClaimAllCycles(stakeCoefficient) {
|
async stakeAndClaimAllCycles(stakeCoefficient) {
|
||||||
console.log("stakeAndClaimAllCycles");
|
console.log("stakeAndClaimAllCycles", stakeCoefficient);
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
const cycleStore = useCycleStore();
|
const cycleStore = useCycleStore();
|
||||||
const cycles = await cycleStore.getFinshedCycleNumbers();
|
const cycles = await cycleStore.getFinshedCycleNumbers();
|
||||||
const addresses = tokenStore.sacrificeToken.map((obj) => obj.contractAddress);
|
const addresses = tokenStore.sacrificeToken.map((obj) => obj.contractAddress);
|
||||||
var stakeCoefficientInt = Math.round(stakeCoefficient);
|
const hash = await this.contract.write.stakeAndClaim([stakeCoefficient, cycles, addresses]);
|
||||||
const hash = await this.contract.write.stakeAndClaim([stakeCoefficientInt, cycles, addresses]);
|
|
||||||
return hash;
|
return hash;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+31
-29
@@ -13,13 +13,14 @@ import { formatNumber } from "@/helper/helper.js";
|
|||||||
|
|
||||||
export const useSacrificeStore = defineStore("sacrifice", {
|
export const useSacrificeStore = defineStore("sacrifice", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
sacrificeNumber: null,
|
sacrificeNumber: 0n,
|
||||||
sacrificeState: 0,
|
sacrificeState: 0,
|
||||||
}),
|
}),
|
||||||
getters: {},
|
getters: {},
|
||||||
actions: {
|
actions: {
|
||||||
async sacrificeToken(amount, token) {
|
async sacrificeToken(amount, token) {
|
||||||
console.log("sacrificeToken", {amount, token});
|
console.log("sacrificeToken", { amount, token });
|
||||||
|
|
||||||
const memeburnerStore = useMemeburnerStore();
|
const memeburnerStore = useMemeburnerStore();
|
||||||
const walletStore = useWalletStoreV2();
|
const walletStore = useWalletStoreV2();
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
@@ -60,22 +61,24 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
console.log("rewardData", rewardData);
|
console.log("rewardData", rewardData);
|
||||||
|
//output
|
||||||
const outputSacrifice = rewardData.reduce((x, y) => {
|
const outputSacrifice = rewardData.reduce((x, y) => {
|
||||||
return x + Number(y.data) / Math.pow(10, token.decimals);
|
return x + BigInt(y.data) / 10n ** token.decimals;
|
||||||
}, 0);
|
}, 0n);
|
||||||
console.log("outputSacrifice", outputSacrifice);
|
console.log("outputSacrifice", outputSacrifice);
|
||||||
// const outputSacrifice = Number(rewardData.data) / Math.pow(10, token.decimals);
|
|
||||||
token.allowance = await tokenStore.allowance();
|
token.allowance = await tokenStore.allowance();
|
||||||
this.sacrificeState = 4;
|
this.sacrificeState = 4;
|
||||||
|
|
||||||
showSuccessToast(
|
showSuccessToast(
|
||||||
formatNumber(outputSacrifice),
|
formatNumber(outputSacrifice),
|
||||||
"Success!",
|
"Success!",
|
||||||
"You turned your meme into:",
|
"You turned your meme into:",
|
||||||
"You can claim once the current cycle is finished and your clan bonus was calculated."
|
"You can claim once the current cycle is finished and your clan bonus was calculated."
|
||||||
);
|
);
|
||||||
await walletStore.loadWalletData();
|
await walletStore.loadWalletData();
|
||||||
|
console.log("cycleStore.currentCycle", cycleStore.currentCycle);
|
||||||
await cycleStore.fillCycle(cycleStore.currentCycle, true);
|
await cycleStore.fillCycle(cycleStore.currentCycle, true);
|
||||||
return;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//we should show the user an issue
|
//we should show the user an issue
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
@@ -92,22 +95,22 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
|||||||
|
|
||||||
|
|
||||||
let output = 0;
|
let output = 0;
|
||||||
try {
|
try {
|
||||||
if (!value || isNaN(value)) {
|
if (!value) {
|
||||||
this.sacrificeState = 0;
|
this.sacrificeState = 0;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
const rewardsForResult = await memeburnerStore.getRewardFor(
|
const rewardsForResult = await memeburnerStore.getRewardFor(value);
|
||||||
BigInt(value * Math.pow(10, token.decimals))
|
console.log("rewardsForResult", rewardsForResult);
|
||||||
);
|
const rewardsForResultNumber = rewardsForResult.reduce((x, y) => {
|
||||||
const rewardsForResultNumber = rewardsForResult.reduce((x, y) => {
|
return x + y
|
||||||
return x + Number(y) / Math.pow(10, token.decimals);
|
}, 0n);
|
||||||
}, 0);
|
var quoteRewards = await uniswapStore.quoteExactInputSingle(value);
|
||||||
var quoteRewards = await uniswapStore.quoteExactInputSingle(value * Math.pow(10, token.decimals));
|
|
||||||
let variant = "sacrifice";
|
let variant = "sacrifice";
|
||||||
if (quoteRewards.result) {
|
if (quoteRewards.result) {
|
||||||
const quoteRewardsNumber = Number(quoteRewards.amount) / Math.pow(10, token.decimals);
|
const quoteRewardsNumber = quoteRewards.amount;
|
||||||
if (quoteRewardsNumber * 0.995 > rewardsForResultNumber) {
|
if ((quoteRewardsNumber * 995n) / 1000n > rewardsForResultNumber) {
|
||||||
variant = "buy";
|
variant = "buy";
|
||||||
console.log("use Buy-function", {
|
console.log("use Buy-function", {
|
||||||
quoteRewardsNumber: quoteRewardsNumber,
|
quoteRewardsNumber: quoteRewardsNumber,
|
||||||
@@ -128,8 +131,6 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
|||||||
output = rewardsForResultNumber;
|
output = rewardsForResultNumber;
|
||||||
}
|
}
|
||||||
console.log("variant", variant);
|
console.log("variant", variant);
|
||||||
const amountDecimal = BigInt(value * Math.pow(10, token.decimals));
|
|
||||||
console.log("amountDecimal", amountDecimal);
|
|
||||||
if (!walletStore.connected || (walletStore.connected && token.allowance < value)) {
|
if (!walletStore.connected || (walletStore.connected && token.allowance < value)) {
|
||||||
/**
|
/**
|
||||||
* case 1
|
* case 1
|
||||||
@@ -164,8 +165,8 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
|||||||
args: [token.contractAddress, amountDecimal.toString(), 0],
|
args: [token.contractAddress, amountDecimal.toString(), 0],
|
||||||
account: walletStore.address,
|
account: walletStore.address,
|
||||||
});
|
});
|
||||||
const amountBuyNumber = Number(amountBuy) / Math.pow(10, token.decimals);
|
const amountBuyNumber = amountBuy
|
||||||
const amountSacrificeNumber = Number(amountSacrifice) / Math.pow(10, token.decimals);
|
const amountSacrificeNumber = amountSacrifice
|
||||||
|
|
||||||
if (amountBuyNumber * 0.995 > amountSacrificeNumber) {
|
if (amountBuyNumber * 0.995 > amountSacrificeNumber) {
|
||||||
variant = "buy";
|
variant = "buy";
|
||||||
@@ -182,11 +183,12 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
|||||||
if (output > 0 && walletStore.connected) {
|
if (output > 0 && walletStore.connected) {
|
||||||
const stakingReward = await rewardLockerStore.getStakeRewardForSacrificeReward(
|
const stakingReward = await rewardLockerStore.getStakeRewardForSacrificeReward(
|
||||||
token.contractAddress,
|
token.contractAddress,
|
||||||
output * Math.pow(10, token.decimals)
|
output
|
||||||
);
|
);
|
||||||
stakingRewardsNumber = (Number(stakingReward) / Math.pow(10, token.decimals)).toFixed(2);
|
stakingRewardsNumber = stakingReward / 10n ** token.decimals
|
||||||
}
|
}
|
||||||
return { output: output, variant: variant, staking: stakingRewardsNumber };
|
const outputNumber = output / 10n ** BigInt(token.decimals);
|
||||||
|
return { output: outputNumber, variant: variant, staking: stakingRewardsNumber };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("getRewardsFor", error);
|
console.error("getRewardsFor", error);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-17
@@ -30,15 +30,15 @@ export const useTokenStore = defineStore("token", {
|
|||||||
contractAddress: Meme1Json.contractAddress,
|
contractAddress: Meme1Json.contractAddress,
|
||||||
addSteps: [
|
addSteps: [
|
||||||
{
|
{
|
||||||
amount: 10000000,
|
amount: 10000000000000000000000000n,
|
||||||
name: "10m",
|
name: "10m",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
amount: 100000000,
|
amount: 100000000000000000000000000n,
|
||||||
name: "100m",
|
name: "100m",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
amount: 1000000000,
|
amount: 1000000000000000000000000000n,
|
||||||
name: "1b",
|
name: "1b",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -57,17 +57,17 @@ export const useTokenStore = defineStore("token", {
|
|||||||
contractAddress: Meme2Json.contractAddress,
|
contractAddress: Meme2Json.contractAddress,
|
||||||
addSteps: [
|
addSteps: [
|
||||||
{
|
{
|
||||||
amount: 1000000,
|
amount: 1000000000000000000000000n,
|
||||||
name: "1m",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
amount: 10000000,
|
|
||||||
name: "10m",
|
name: "10m",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
amount: 100000000,
|
amount: 10000000000000000000000000n,
|
||||||
name: "100m",
|
name: "100m",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
amount: 100000000000000000000000000n,
|
||||||
|
name: "1b",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -84,15 +84,15 @@ export const useTokenStore = defineStore("token", {
|
|||||||
contractAddress: Meme3Json.contractAddress,
|
contractAddress: Meme3Json.contractAddress,
|
||||||
addSteps: [
|
addSteps: [
|
||||||
{
|
{
|
||||||
amount: 10000000,
|
amount: 10000000000000000000000000n,
|
||||||
name: "10m",
|
name: "10m",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
amount: 100000000,
|
amount: 100000000000000000000000000n,
|
||||||
name: "100m",
|
name: "100m",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
amount: 1000000000,
|
amount: 1000000000000000000000000000n,
|
||||||
name: "1b",
|
name: "1b",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -166,8 +166,8 @@ export const useTokenStore = defineStore("token", {
|
|||||||
contracts.push({ ...token.contract, functionName: "totalSupply" });
|
contracts.push({ ...token.contract, functionName: "totalSupply" });
|
||||||
const data = await multicall({
|
const data = await multicall({
|
||||||
contracts,
|
contracts,
|
||||||
});
|
});
|
||||||
token.decimals = data[0].result;
|
token.decimals = BigInt(data[0].result);
|
||||||
token.name = data[1].result;
|
token.name = data[1].result;
|
||||||
token.symbol = data[2].result;
|
token.symbol = data[2].result;
|
||||||
token.totalSupply = data[3].result;
|
token.totalSupply = data[3].result;
|
||||||
@@ -184,9 +184,7 @@ export const useTokenStore = defineStore("token", {
|
|||||||
walletStore.address,
|
walletStore.address,
|
||||||
memeBurnerStore.config.contractAddress,
|
memeBurnerStore.config.contractAddress,
|
||||||
]);
|
]);
|
||||||
const decimals = this.activeToken.decimals;
|
|
||||||
|
|
||||||
allowance = BigInt(allowance / BigInt(Math.pow(10, decimals)));
|
|
||||||
console.log("allowance", allowance);
|
console.log("allowance", allowance);
|
||||||
return allowance;
|
return allowance;
|
||||||
},
|
},
|
||||||
@@ -197,7 +195,7 @@ export const useTokenStore = defineStore("token", {
|
|||||||
const memeBurnerStore = useMemeburnerStore();
|
const memeBurnerStore = useMemeburnerStore();
|
||||||
var approveHash = await this.activeToken.contract.write.approve([
|
var approveHash = await this.activeToken.contract.write.approve([
|
||||||
memeBurnerStore.config.contractAddress,
|
memeBurnerStore.config.contractAddress,
|
||||||
amount * Math.pow(10, this.activeToken.decimals),
|
amount,
|
||||||
]);
|
]);
|
||||||
console.log("approveHash", approveHash);
|
console.log("approveHash", approveHash);
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ export const useUniswapStore = defineStore("uniswap", {
|
|||||||
this.poolData.fee,
|
this.poolData.fee,
|
||||||
amountEthBase[0],
|
amountEthBase[0],
|
||||||
0, //sqrtPriceLimitX96
|
0, //sqrtPriceLimitX96
|
||||||
]);
|
]);
|
||||||
|
console.log("quotedAmountOut", quotedAmountOut);
|
||||||
return {result: true, amount: quotedAmountOut};
|
return {result: true, amount: quotedAmountOut};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { result: false, amount: null };
|
return { result: false, amount: null };
|
||||||
|
|||||||
@@ -101,10 +101,9 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
|||||||
});
|
});
|
||||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||||
const token = tokenStore.token[index];
|
const token = tokenStore.token[index];
|
||||||
const balanceOfDecimal = data[index].result / BigInt(Math.pow(10, token.decimals));
|
|
||||||
this.token.push({
|
this.token.push({
|
||||||
contractAddress: token.contractAddress,
|
contractAddress: token.contractAddress,
|
||||||
balanceOf: Number(balanceOfDecimal),
|
balanceOf: data[index].result
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -118,11 +117,10 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
|||||||
await this.getTokenBalances();
|
await this.getTokenBalances();
|
||||||
//MemeToken Staked
|
//MemeToken Staked
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
const staked = await rewardlockerStore.getStaked(this.address);
|
this.memeToken.staked = await rewardlockerStore.getStaked(this.address);
|
||||||
this.memeToken.staked = Number(staked) / Math.pow(10, tokenStore.memeToken.decimals);
|
|
||||||
const unclaimedRewardsArray = await rewardlockerStore.getTotalRewards(this.address);
|
const unclaimedRewardsArray = await rewardlockerStore.getTotalRewards(this.address);
|
||||||
const unclaimedRewards = unclaimedRewardsArray[0] + unclaimedRewardsArray[1];
|
const unclaimedRewards = unclaimedRewardsArray[0] + unclaimedRewardsArray[1];
|
||||||
this.memeToken.unclaimedRewards = Number(unclaimedRewards) / Math.pow(10, tokenStore.memeToken.decimals)
|
this.memeToken.unclaimedRewards = unclaimedRewards
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,7 +27,9 @@
|
|||||||
>
|
>
|
||||||
<template v-if="difference > 0">
|
<template v-if="difference > 0">
|
||||||
<div class="round-finish-info-key">Sacrifice Goal:</div>
|
<div class="round-finish-info-key">Sacrifice Goal:</div>
|
||||||
<div class="round-finish-info-value">{{ cycleStore.getCurrentCycleData?.goalInBLD }} $BDL</div>
|
<div class="round-finish-info-value">
|
||||||
|
{{ cycleStore.getCurrentCycleData?.goalInBLD / 10n ** tokenStore.memeToken.decimals }} $BDL
|
||||||
|
</div>
|
||||||
<div class="round-finish-info-key">Time left:</div>
|
<div class="round-finish-info-key">Time left:</div>
|
||||||
<div class="round-finish-info-value">{{ days }} {{ hours }} {{ minutes }}</div>
|
<div class="round-finish-info-value">{{ days }} {{ hours }} {{ minutes }}</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -88,6 +90,8 @@ import { inject, ref, onMounted, onBeforeUnmount } from "vue";
|
|||||||
|
|
||||||
import BloodChart from "@/components/BloodChart.vue";
|
import BloodChart from "@/components/BloodChart.vue";
|
||||||
import TokenClaim from "@/components/TokenClaim.vue";
|
import TokenClaim from "@/components/TokenClaim.vue";
|
||||||
|
import { useTokenStore } from "@/stores/tokens";
|
||||||
|
|
||||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||||
import LoadingComponent from "@/components/LoadingComponent.vue";
|
import LoadingComponent from "@/components/LoadingComponent.vue";
|
||||||
|
|
||||||
@@ -95,6 +99,7 @@ import { useCycleStore } from "@/stores/cycles";
|
|||||||
import { useRewardLockerStore } from "@/stores/rewardlocker";
|
import { useRewardLockerStore } from "@/stores/rewardlocker";
|
||||||
|
|
||||||
const cycleStore = useCycleStore();
|
const cycleStore = useCycleStore();
|
||||||
|
const tokenStore = useTokenStore();
|
||||||
|
|
||||||
const days = ref(null);
|
const days = ref(null);
|
||||||
const hours = ref(null);
|
const hours = ref(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user