Skip to content

Commit

Permalink
added comment on decimals scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters committed Oct 14, 2024
1 parent b6c3a07 commit 5c08daf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions connect/src/routes/portico/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ export class AutomaticPorticoRoute<N extends Network>
try {
const swapAmounts = await this.fetchSwapQuote(request, params);

// destination token may have a different number of decimals than the source token
// so we need to scale the amounts to the token with the most decimals
// before comparing them
const maxDecimals = Math.max(request.source.decimals, request.destination.decimals);
const scaledAmount = amount.units(amount.scale(params.normalizedParams.amount, maxDecimals));
const scaledMinAmountFinish = amount.units(
Expand Down

0 comments on commit 5c08daf

Please sign in to comment.