Skip to content

Commit

Permalink
trancate balance (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeishulga authored Jun 11, 2024
1 parent 55fbbf2 commit 29a1829
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/UserBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defineProps<{
<ClientOnly>
<div>
<span class="text-4xl font-bold" v-if="isConnected">
{{ parseFloat(tokenBalance.formatted).toFixed(3) }}
{{ parseFloat(tokenBalance.formatted).toFixed(2) }}
<Ticker v-if="showTicker" />
</span>

Expand Down
14 changes: 10 additions & 4 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ const handleClaimAllRewards = async () => {
isRedeemLoading.value = false;
progressLoading.value = 0;
};
const trancateUserBalance = (userBalance: string | null | bigint) => {
const balance = formatEther(userBalance || '0');
const truncatedUserBalance = Number(balance).toFixed(2);
return truncatedUserBalance;
};
</script>

<template>
Expand Down Expand Up @@ -119,7 +125,7 @@ const handleClaimAllRewards = async () => {
</h3>
<div class="inline-flex items-baseline gap-2">
<span v-if="isConnected" class="text-4xl font-bold">
{{ formatEther(registratorStore.totalLockedTokens || '0') }}
{{ trancateUserBalance(registratorStore.totalLockedTokens) }}
</span>
<span v-if="!isConnected" class="text-4xl font-bold"> -- </span>
<Ticker />
Expand Down Expand Up @@ -187,7 +193,7 @@ const handleClaimAllRewards = async () => {
<h3>Claimed rewards</h3>
<div class="inline-flex items-baseline gap-2">
<span v-if="isConnected" class="text-4xl font-bold">
{{ formatEther(facilitatorStore.totalClaimedTokens || '0') }}
{{ trancateUserBalance(facilitatorStore.totalClaimedTokens) }}
</span>
<span v-if="!isConnected" class="text-4xl font-bold"> -- </span>
<Ticker />
Expand All @@ -198,8 +204,8 @@ const handleClaimAllRewards = async () => {
<div class="inline-flex items-baseline gap-2">
<span v-if="isConnected" class="text-4xl font-bold">
{{
formatEther(
facilitatorStore.avaliableAllocatedTokens || '0'
trancateUserBalance(
facilitatorStore.avaliableAllocatedTokens
)
}}
</span>
Expand Down

0 comments on commit 29a1829

Please sign in to comment.