Uniswap / examples

120 stars 147 forks source link

quote.ts problem with direction #55

Open rico2009 opened 12 months ago

rico2009 commented 12 months ago

examples/v3-sdk/quoting/src/libs/quote.ts

line 21: const quotedAmountOut = await quoterContract.callStatic.quoteExactInputSingle( poolConstants.token0, poolConstants.token1, poolConstants.fee, fromReadableAmount( CurrentConfig.tokens.amountIn, CurrentConfig.tokens.in.decimals ).toString(), 0 )

poolConstants.token0 and token1=> two tokens of the pool , sorted by address some time will reverse input and output address ~

michaeltang608 commented 9 months ago

@rico2009 hi, i encountered the same issue and agreed with your opinion. Finally I solved this by changing poolConstants.token0 to CurrentConfig.tokens.in.address, and poolConstants.token1 to CurrentConfig.tokens.out.address.

davedavinci commented 6 months ago

@rico2009 hi, i encountered the same issue and agreed with your opinion. Finally I solved this by changing poolConstants.token0 to CurrentConfig.tokens.in.address, and poolConstants.token1 to CurrentConfig.tokens.out.address.

I second this.