Skip to content

Commit 6a0e330

Browse files
committed
added comment on decimals scaling
1 parent eafb428 commit 6a0e330

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

connect/src/routes/portico/automatic.ts

+3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ export class AutomaticPorticoRoute<N extends Network>
201201
try {
202202
const swapAmounts = await this.fetchSwapQuote(request, params);
203203

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

0 commit comments

Comments
 (0)