Skip to content

Commit

Permalink
fix routing swap
Browse files Browse the repository at this point in the history
  • Loading branch information
baymac committed Aug 9, 2024
1 parent 2c96e5f commit 305e8df
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,16 @@ async function _multiRoutingTxExample(
let lastAmountIn = amountA;
for (let i = 0; i < routings.length; i++) {
const pool = pools[i];
const routing = routings[i];
invariant(pool, "Pool not found");
const amountOut = DexV2Calculation.calculateAmountOut({
reserveIn: pool.reserveA,
reserveOut: pool.reserveB,
amountIn: lastAmountIn,
tradingFeeNumerator: pool.feeA[0],
tradingFeeNumerator:
routing.direction === OrderV2.Direction.A_TO_B
? pool.feeA[0]
: pool.feeB[0],
});
lastAmountIn = amountOut;
}
Expand Down

0 comments on commit 305e8df

Please sign in to comment.