Skip to content

Commit

Permalink
Fix/cbBTC values
Browse files Browse the repository at this point in the history
  • Loading branch information
kkatusic committed Jan 23, 2025
1 parent 4e48fde commit d26bf42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/AmountInput/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const AmountInput: FC<IAmountInput> = ({
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),
Expand Down Expand Up @@ -80,7 +80,7 @@ export const AmountInput: FC<IAmountInput> = ({

// 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
}
Expand Down
24 changes: 16 additions & 8 deletions src/components/views/donate/Recurring/RecurringDonationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const RecurringDonationCard = () => {
selectedRecurringToken?.token.decimals === 6
? 10000n
: selectedRecurringToken?.token.decimals === 8
? 100n
? 1000000n
: 1n;

// total means project + giveth
Expand Down Expand Up @@ -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,
)}
</GLinkStyled>
<IconWrapper
onClick={() => !isRefetching && refetch()}
Expand Down

0 comments on commit d26bf42

Please sign in to comment.