update loading cycle + potential staking rewards
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
]"
|
||||
v-for="token in props.data"
|
||||
:key="token.contractAddress"
|
||||
@click="tokenStore.changeActiveToken(token)"
|
||||
@click="changeActiveToken(token)"
|
||||
>
|
||||
<div class="sacrifice-token-logo">
|
||||
<img v-if="isMobile" :src="token.logoMobile" alt="token logo" />
|
||||
@@ -90,7 +90,7 @@
|
||||
>
|
||||
No Staking Bonus
|
||||
</div>
|
||||
<div class="mid-mid-text" v-else>+ TODO Staking Bonus</div>
|
||||
<div class="mid-mid-text" v-else>+ {{ stakingOutput }} Staking Bonus</div>
|
||||
<div class="icon">
|
||||
<font-awesome-icon icon="chevron-down" />
|
||||
</div>
|
||||
@@ -189,6 +189,7 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const output = ref(0);
|
||||
const stakingOutput = ref(null);
|
||||
const blockEvent = ref(null);
|
||||
const approveToast = ref(null);
|
||||
/**
|
||||
@@ -231,8 +232,9 @@ const stateComputed = computed(() => {
|
||||
return returnState;
|
||||
});
|
||||
const processChange = debounce(async (value) => {
|
||||
const returnValue = await sacrificeStore.getRewardsFor(value, activeToken.value);
|
||||
output.value = returnValue.output;
|
||||
const rewardValue = await sacrificeStore.getRewardsFor(value, activeToken.value);
|
||||
output.value = rewardValue.output;
|
||||
stakingOutput.value = rewardValue.staking;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
@@ -244,6 +246,7 @@ onMounted(() => {
|
||||
console.log("blockNumber", blockNumber);
|
||||
var rewardValue = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value);
|
||||
output.value = rewardValue.output;
|
||||
stakingOutput.value = rewardValue.staking;
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -275,12 +278,16 @@ async function approveToken(amount) {
|
||||
|
||||
async function addTokens(value) {
|
||||
sacrificeStore.sacrificeNumber = Number(sacrificeStore.sacrificeNumber) + Number(value);
|
||||
output.value = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value).output;
|
||||
const rewardValue = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value);
|
||||
output.value = rewardValue.output;
|
||||
stakingOutput.value = rewardValue.staking;
|
||||
}
|
||||
|
||||
async function addMaxTokens() {
|
||||
sacrificeStore.sacrificeNumber = activeWalletToken.value.balanceOf;
|
||||
output.value = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value).output;
|
||||
const rewardValue = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value);
|
||||
output.value = rewardValue.output;
|
||||
stakingOutput.value = rewardValue.staking;
|
||||
}
|
||||
|
||||
function showApprovedToast(value, header, subheader, info) {
|
||||
@@ -310,11 +317,26 @@ function showApprovedToast(value, header, subheader, info) {
|
||||
toastClassName: "approve-toast toast-card",
|
||||
});
|
||||
}
|
||||
|
||||
//call function in the store and remove icon,
|
||||
async function sacrificeToken() {
|
||||
await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, activeToken.value);
|
||||
toast.dismiss(approveToast.value);
|
||||
}
|
||||
|
||||
async function changeActiveToken(token) {
|
||||
console.log("changeActiveToken");
|
||||
tokenStore.activeToken = token;
|
||||
if (walletStore.connected) {
|
||||
//TODO, wenn connected, dann all diese Daten laden?
|
||||
tokenStore.activeToken.balance = await walletStore.getTokenBalance(token);
|
||||
tokenStore.activeToken.allowance = Number(await tokenStore.allowance());
|
||||
}
|
||||
var rewards = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, token);
|
||||
console.log("rewards", rewards);
|
||||
output.value = rewards.output;
|
||||
stakingOutput.value = rewards.staking;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="sass">
|
||||
|
||||
Reference in New Issue
Block a user