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/ModifySuperToken/DepositSuperToken.tsx b/src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx index 07a26d23a9..e6e1b13646 100644 --- a/src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx +++ b/src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx @@ -135,11 +135,11 @@ export const DepositSuperToken: FC = ({ } else { superTokenAsset = await sf.loadWrapperSuperToken(superToken.id); } - if (token && token.decimals === 6) { + if (token && (token.decimals === 6 || token.decimals === 8)) { const divisor = BigInt(10 ** token.decimals); const currentAmount = Number(amount) / Number(divisor); newAmount = ethers.utils - .parseUnits(currentAmount.toString(), 18) + .parseUnits(currentAmount.toFixed(8), 18) .toBigInt(); } const upgradeOperation = await superTokenAsset.upgrade({ 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()} diff --git a/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx b/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx index e2f86d091e..5cd6dcb96d 100644 --- a/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx +++ b/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx @@ -117,9 +117,13 @@ const EndStreamInnerModal: FC = ({ superToken = await sf.loadWrapperSuperToken(_superToken.id); } + const matchingContract = donation.project.anchorContracts.find( + contract => contract.networkId === recurringNetworkId, + ); + const deleteOp = superToken.deleteFlow({ sender: address, - receiver: donation.project.anchorContracts[0].address, + receiver: matchingContract?.address || '', }); const tx = await deleteOp.exec(signer);