Skip to content

Commit

Permalink
fix: wrong unit displayed in claim rewards modal (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwbabylonlab authored Jan 13, 2025
1 parent 72f2313 commit 60f3f9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/app/components/Modals/ClaimRewardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PropsWithChildren } from "react";

import { shouldDisplayTestingMsg } from "@/config";
import { getNetworkConfigBBN } from "@/config/network/bbn";
import { ubbnToBaby } from "@/utils/bbn";
import { trim } from "@/utils/trim";

import { LoadingSmall } from "../Loading/Loading";
Expand Down Expand Up @@ -62,7 +63,7 @@ export const ClaimRewardModal = ({
<LoadingSmall />
) : (
<Text variant="body1">
{transactionFee} {coinSymbol}
{ubbnToBaby(transactionFee)} {coinSymbol}
</Text>
)}
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/PersonalBalance/PersonalBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useRewardsState } from "@/app/state/RewardState";
import { AuthGuard } from "@/components/common/AuthGuard";
import { getNetworkConfigBBN } from "@/config/network/bbn";
import { getNetworkConfigBTC } from "@/config/network/btc";
import { ubbnToBbn } from "@/utils/bbn";
import { ubbnToBaby } from "@/utils/bbn";
import { satoshiToBtc } from "@/utils/btc";

import { ClaimRewardModal } from "../Modals/ClaimRewardModal";
Expand Down Expand Up @@ -37,7 +37,7 @@ export function PersonalBalance() {
[btcBalance, getStakedBalance],
);

const formattedRewardBalance = ubbnToBbn(rewardBalance);
const formattedRewardBalance = ubbnToBaby(rewardBalance);

return (
<AuthGuard>
Expand All @@ -62,7 +62,7 @@ export function PersonalBalance() {
<StatItem
loading={loading}
title={`${bbnNetworkName} Balance`}
value={`${ubbnToBbn(bbnBalance)} ${bbnCoinSymbol}`}
value={`${ubbnToBaby(bbnBalance)} ${bbnCoinSymbol}`}
/>

<div className="divider mx-0 my-2 md:divider-horizontal" />
Expand Down
12 changes: 6 additions & 6 deletions src/utils/bbn.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Converts BBN to uBBN (micro BBN).
* Converts BABY to uBBN (micro BABY).
* should be used internally in the app
* @param bbn The amount in BBN.
* @param bbn The amount in BABY.
* @returns The equivalent amount in uBBN.
*/
export function bbnToUbbn(bbn: number): number {
export function babyToUbbn(bbn: number): number {
return Math.round(bbn * 1e6);
}

/**
* Converts uBBN (micro BBN) to BBN.
* Converts uBBN (micro BABY) to BABY.
* should be used only in the UI
* @param ubbn The amount in uBBN.
* @returns The equivalent amount in BBN.
* @returns The equivalent amount in BABY.
*/
export function ubbnToBbn(ubbn: number): number {
export function ubbnToBaby(ubbn: number): number {
return ubbn / 1e6;
}

0 comments on commit 60f3f9f

Please sign in to comment.