diff --git a/sdk/route/src/automatic.ts b/sdk/route/src/automatic.ts index f972855d2..b7a5481b6 100644 --- a/sdk/route/src/automatic.ts +++ b/sdk/route/src/automatic.ts @@ -122,7 +122,8 @@ export class NttAutomaticRoute ); const parsedAmount = amount.parse(params.amount, request.source.decimals); - const transferAmount = NttRoute.getTransferAmount( + // The trimmedAmount may differ from the parsedAmount if the parsedAmount includes dust + const trimmedAmount = NttRoute.getTrimmedAmount( parsedAmount, request.destination.decimals ); @@ -130,7 +131,7 @@ export class NttAutomaticRoute const validatedParams: Vp = { amount: params.amount, normalizedParams: { - amount: transferAmount, + amount: trimmedAmount, sourceContracts: NttRoute.resolveNttContracts( this.staticConfig, request.source.id diff --git a/sdk/route/src/manual.ts b/sdk/route/src/manual.ts index 55b0bdf04..f4712a9b9 100644 --- a/sdk/route/src/manual.ts +++ b/sdk/route/src/manual.ts @@ -103,7 +103,8 @@ export class NttManualRoute const options = params.options ?? this.getDefaultOptions(); const parsedAmount = amount.parse(params.amount, request.source.decimals); - const transferAmount = NttRoute.getTransferAmount( + // The trimmedAmount may differ from the parsedAmount if the parsedAmount includes dust + const trimmedAmount = NttRoute.getTrimmedAmount( parsedAmount, request.destination.decimals ); @@ -118,7 +119,7 @@ export class NttManualRoute const validatedParams: Vp = { amount: params.amount, normalizedParams: { - amount: transferAmount, + amount: trimmedAmount, sourceContracts: NttRoute.resolveNttContracts( this.staticConfig, request.source.id diff --git a/sdk/route/src/types.ts b/sdk/route/src/types.ts index 7ffa15d6c..afb18d66d 100644 --- a/sdk/route/src/types.ts +++ b/sdk/route/src/types.ts @@ -215,7 +215,7 @@ export namespace NttRoute { return amount > threshold; } - export function getTransferAmount( + export function getTrimmedAmount( amt: amount.Amount, dstTokenDecimals: number ): amount.Amount {