fill round update + notification update + visual fixes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user