Skip to content

Commit

Permalink
Format balances after math (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpxl-dev authored Feb 15, 2024
1 parent de94877 commit 23ccfed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/features/staking/PieBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ export const PieBar = () => {
} = useTokenBalances();

const unstaked = formatNumber(astBalanceRaw, 4) || 0;
const staked = formatNumber(sAstBalanceRaw, 4) || 0;
const unstakable = formatNumber(unstakableSastBalanceRaw, 4) || 0;
const unstakableV4 =
formatNumber(unstakableSastBalanceV4_DeprecatedRaw, 4) || 0;
const stakedV4 = formatNumber(sAstBalanceV4_DeprecatedRaw, 4) || 0;

const totalStaked = String(Number(staked) + Number(stakedV4));
const totalUnstakable = String(Number(unstakable) + Number(unstakableV4));
const totalStaked = formatNumber(
sAstBalanceRaw + sAstBalanceV4_DeprecatedRaw,
4,
);
const totalUnstakable = formatNumber(
unstakableSastBalanceRaw + unstakableSastBalanceV4_DeprecatedRaw,
4,
);

// the following 2 values are only used for calculateTokenProportions
const totalUnstakableRaw =
Expand Down
8 changes: 4 additions & 4 deletions src/features/staking/StakingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const StakingButton = () => {
const { isConnected } = useAccount();
const { sAstBalanceRaw, sAstBalanceV4_DeprecatedRaw } = useTokenBalances();

const sAstBalance = formatNumber(sAstBalanceRaw, 4) || 0;
const sAstBalanceV4 = formatNumber(sAstBalanceV4_DeprecatedRaw, 4) || 0;

const totalSastBalance = Number(sAstBalance) + Number(sAstBalanceV4);
const totalSastBalance = formatNumber(
sAstBalanceRaw + sAstBalanceV4_DeprecatedRaw,
4,
);

return (
<>
Expand Down

0 comments on commit 23ccfed

Please sign in to comment.