Skip to content

Commit

Permalink
fix: uniswap buy order with native
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsambugs committed Dec 17, 2023
1 parent ca30f19 commit 4fed22c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/services/quotes/quote-sources/uniswap-quote-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ export class UniswapQuoteSource extends AlwaysValidConfigAndContextSource<Uniswa
methodParameters: { calldata },
gasUseEstimate,
} = await response.json();
const value = isSellTokenNativeToken && order.type === 'sell' ? order.sellAmount : undefined;
const sellAmount = order.type === 'sell' ? order.sellAmount : BigInt(quoteAmount);
const buyAmount = order.type === 'sell' ? BigInt(quoteAmount) : order.buyAmount;
const value = isSellTokenNativeToken ? sellAmount : undefined;

if (isBuyTokenNativeToken) {
// Use multicall to unwrap wToken
Expand All @@ -101,7 +102,7 @@ export class UniswapQuoteSource extends AlwaysValidConfigAndContextSource<Uniswa
}

const quote = {
sellAmount: order.type === 'sell' ? order.sellAmount : BigInt(quoteAmount),
sellAmount,
buyAmount,
estimatedGas: BigInt(gasUseEstimate),
allowanceTarget: calculateAllowanceTarget(sellToken, router),
Expand Down

0 comments on commit 4fed22c

Please sign in to comment.