Skip to content

Commit

Permalink
rename, added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters committed Nov 28, 2024
1 parent 88447d4 commit d0c7a9f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions sdk/route/src/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ export class NttAutomaticRoute<N extends Network>
);

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
);

const validatedParams: Vp = {
amount: params.amount,
normalizedParams: {
amount: transferAmount,
amount: trimmedAmount,
sourceContracts: NttRoute.resolveNttContracts(
this.staticConfig,
request.source.id
Expand Down
5 changes: 3 additions & 2 deletions sdk/route/src/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export class NttManualRoute<N extends Network>
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
);
Expand All @@ -118,7 +119,7 @@ export class NttManualRoute<N extends Network>
const validatedParams: Vp = {
amount: params.amount,
normalizedParams: {
amount: transferAmount,
amount: trimmedAmount,
sourceContracts: NttRoute.resolveNttContracts(
this.staticConfig,
request.source.id
Expand Down
2 changes: 1 addition & 1 deletion sdk/route/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export namespace NttRoute {
return amount > threshold;
}

export function getTransferAmount(
export function getTrimmedAmount(
amt: amount.Amount,
dstTokenDecimals: number
): amount.Amount {
Expand Down

0 comments on commit d0c7a9f

Please sign in to comment.