Uniswap / v3-sdk

🛠 An SDK for building applications on top of Uniswap V3
MIT License
548 stars 422 forks source link

Doesn't seem like this library can execute trades without a TickDataProvider #52

Open drachs opened 3 years ago

drachs commented 3 years ago

The library doesn't include the code for one (Just the interface), and there's no instructions for how to write one in the documents. None of the functionality for executing trades or estimating the price of trades works without one.

Am I missing something?

NoahChoi00 commented 3 years ago

Can someone please give a solution for this problem? Can’t implement anything without TickDataProvider and no one tells me how I can make it.

NoahZinsmeister commented 3 years ago

a common pattern is to use createUncheckedTrade and use the Quoter, see e.g. https://github.com/Uniswap/uniswap-interface/blob/main/src/hooks/useBestV3Trade.ts

sorry, docs on this coming soon.

Ryanklingert commented 3 years ago

Any update here ?

eliotstock commented 2 years ago

Related: Using Trade.exactIn() fails with error No tick data provider was given:

const swapRoute = new Route([swapPool], wethToken, usdcToken)
const trade: Trade<Currency, Currency, TradeType> = await Trade.exactIn(swapRoute, amountToSwap)

I don't want to use Trade.createUncheckedTrade(). That takes an input amount and an output amount. I don't know or care much what the output amount is. I know my input amount (and my route).

Are you saying that Trade.exactIn() isn't really implemented in the SDK?

Also, the source URL above from @NoahZinsmeister is now a 404.

a-straus commented 2 years ago

Hey, bumping this up. Having the same issue

a-straus commented 2 years ago

https://discord.com/channels/597638925346930701/607978109089611786/972959141402386482

This seemed to help. I am not sure why the code requires that there be an equal amount of netLiquidity between all ticks in a tickListDataProvider.

@NoahZinsmeister could you perhaps comment on this? I'm happy to put in a PR that gets rid of this necessity, because it seems unnecessary. If I remove the invariant() that requires netLiquidity=ZERO from my local package, then my pool swaps work just fine in their estimation. It seems needlessly complicated to require users to have a tickList that has net 0 liquidity

EDIT: @Yorkemartin because I see this has been assigned to you

emadtps commented 2 years ago

I too have the same issue. any pointers?

bsproul commented 1 year ago

I'm having this exact same issue, seems this is not resolved yet? I see that the example uses quote (https://github.com/Uniswap/examples/blob/main/v3-sdk/trading/src/libs/trading.ts#L58), which I will have to do as well I suppose, but as mentioned above, I don't want to care about the output amount if there's an exactIn function.

Taha-daboussi commented 1 year ago

Any Clear solution for that Trying to use Trade.bestTradeExactIn but getting this error

Florian-S-A-W commented 11 months ago

If you construct a Pool without a TickDataProvider it's not possible to make accurate simulations. You can read the whitepaper to understand why Pools will always have 0 net liquidity in total. If you try to make a trade on any Uniswap Pool and "not care" about the output, i.e. accept 100% slippage, a sandwich bot will exploit your trade and steal most of it.

There are solutions to prevent that, for example using an MEV protection service, but this was not available when this sdk was written.