Skip to content

Commit

Permalink
fix LST out decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s committed Sep 15, 2023
1 parent caf7ade commit 4642458
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SettingsModal } from "./SettingsModal";
import { SettingsIcon } from "./SettingsIcon";

const SOL_MINT = new PublicKey("So11111111111111111111111111111111111111112");
const LST_FORMATTER = makeTokenAmountFormatter(9);

export interface TokenData {
mint: PublicKey;
Expand Down Expand Up @@ -333,13 +334,13 @@ export const StakingCard: FC = () => {
<div className="flex flex-row justify-between w-full my-auto pt-2">
<Typography className="font-aeonik font-[400] text-lg">You will receive</Typography>
<Typography className="font-aeonik font-[700] text-xl text-[#DCE85D]">
{lstOutAmount ? numeralFormatter(lstOutAmount) : "-"} $LST
{lstOutAmount !== null && selectedMintInfo ? LST_FORMATTER.format(lstOutAmount) : "-"} $LST
</Typography>
</div>
<div className="py-7">
<PrimaryButton
className="h-[36px]"
disabled={connected && (!depositAmount || depositAmount == 0 || loadingQuotes || swapping)}
disabled={connected && (!depositAmount || depositAmount == 0 || lstOutAmount === 0 || lstOutAmount === null || loadingQuotes || swapping)}
onClick={connected ? onMint : openWalletSelector}
>
{swapping ? (
Expand Down Expand Up @@ -441,3 +442,11 @@ async function depositToken(

return sig;
}

function makeTokenAmountFormatter(decimals: number) {
return new Intl.NumberFormat("en-US", {
useGrouping: true,
minimumFractionDigits: 0,
maximumFractionDigits: decimals,
})
}

0 comments on commit 4642458

Please sign in to comment.