From d26bf42b07848128e3eb6ada5db3d5841604a0c9 Mon Sep 17 00:00:00 2001 From: kkatusic Date: Thu, 23 Jan 2025 13:29:12 +0100 Subject: [PATCH] Fix/cbBTC values --- src/components/AmountInput/AmountInput.tsx | 4 ++-- .../Recurring/RecurringDonationCard.tsx | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/components/AmountInput/AmountInput.tsx b/src/components/AmountInput/AmountInput.tsx index 32fa1f7b7e..8a7d3c05e1 100644 --- a/src/components/AmountInput/AmountInput.tsx +++ b/src/components/AmountInput/AmountInput.tsx @@ -52,7 +52,7 @@ export const AmountInput: FC = ({ const isZero = regex.test(displayAmount); if (amount === 0n && isZero) return; - const maxDecimals = decimals === 8 ? 8 : decimals / 3; + const maxDecimals = decimals === 8 ? 6 : decimals / 3; const _displayAmount = truncateToDecimalPlaces( formatUnits(amount, decimals), @@ -80,7 +80,7 @@ export const AmountInput: FC = ({ // Allow more decimals if token has 8 decimals if (decimals === 8) { - if (_decimals?.length > 8) return; // Limit to 8 decimals + if (_decimals?.length > 6) return; // Limit to 8 decimals } else { if (_decimals?.length > decimals / 3) return; // Limit to 6 or 2 decimals for other tokens } diff --git a/src/components/views/donate/Recurring/RecurringDonationCard.tsx b/src/components/views/donate/Recurring/RecurringDonationCard.tsx index aae0670c0c..bae140a0f4 100644 --- a/src/components/views/donate/Recurring/RecurringDonationCard.tsx +++ b/src/components/views/donate/Recurring/RecurringDonationCard.tsx @@ -157,7 +157,7 @@ export const RecurringDonationCard = () => { selectedRecurringToken?.token.decimals === 6 ? 10000n : selectedRecurringToken?.token.decimals === 8 - ? 100n + ? 1000000n : 1n; // total means project + giveth @@ -360,13 +360,21 @@ export const RecurringDonationCard = () => { id: 'label.available', })} :{' '} - {truncateToDecimalPlaces( - formatUnits( - balance.value, - balance.decimals, - ), - balance.decimals / 3, - )} + {balance.decimals === 8 + ? truncateToDecimalPlaces( + formatUnits( + balance.value, + balance.decimals, + ), + 18 / 3, + ) + : truncateToDecimalPlaces( + formatUnits( + balance.value, + balance.decimals, + ), + balance.decimals / 3, + )} !isRefetching && refetch()}