diff --git a/packages/canonical-bridge-widget/src/modules/aggregator/adapters/stargate/hooks/useGetStarGateFees.ts b/packages/canonical-bridge-widget/src/modules/aggregator/adapters/stargate/hooks/useGetStarGateFees.ts index e6632085..de2f7507 100644 --- a/packages/canonical-bridge-widget/src/modules/aggregator/adapters/stargate/hooks/useGetStarGateFees.ts +++ b/packages/canonical-bridge-widget/src/modules/aggregator/adapters/stargate/hooks/useGetStarGateFees.ts @@ -77,12 +77,21 @@ export const useGetStargateFees = () => { const receiver = address || DEFAULT_ADDRESS; const bridgeAddress = selectedToken?.stargate?.raw?.address as `0x${string}`; const decimal = selectedToken?.stargate?.raw?.token?.decimals ?? (18 as number); + const maxDecimals = selectedToken?.stargate?.raw?.sharedDecimals ?? 18; const allowedMin = Number(formatUnits(fees[0].minAmountLD, decimal)); const allowedMax = Number(formatUnits(fees[0].maxAmountLD, decimal)); const amount = parseUnits(sendValue, decimal); // Can not retrieve other fees if token amount is out of range if (Number(sendValue) >= allowedMin && Number(sendValue) <= allowedMax && !!args) { + if (sendValue.split('.')[1]?.length > maxDecimals) { + dispatch( + setRouteError({ + stargate: `The amount exceeds the maximum of ${maxDecimals} decimals`, + }), + ); + return { isDisplayError: true }; + } if (!!Number(fees?.[2].amountReceivedLD)) { if (fees?.[2].amountReceivedLD) { args.minAmountLD = BigInt(fees[2].amountReceivedLD); @@ -144,6 +153,7 @@ export const useGetStargateFees = () => { isDisplayError = true; } } + try { if (chain && fromChain?.id === chain?.id && address && selectedToken?.address) { // gas fee