v3-sdk icon indicating copy to clipboard operation
v3-sdk copied to clipboard

TickDataProvider not defined in docs for creating new pool

Open Ryanklingert opened this issue 3 years ago • 3 comments

I am trying to create a new pool so that I can use the getOutputAmount method to estimate probability of swaps. It appears nowhere in the docs is an example of a TickDataProvider provided. And everywhere a new pool is create in the uniswap-interface code a black array is used for this input. Are there any examples of where or how to get this tick data?

Ryanklingert avatar Aug 16 '21 19:08 Ryanklingert

There is an example in the test https://github.com/Uniswap/uniswap-v3-sdk/blob/aeb1b09d454dad50718a3517eb9e73b080ee4833/src/entities/pool.test.ts#L181

I tried with different liquidity for each tick but I always get the same result. I don't really understand the impact of the liquidity per tick on the output amount. To me it should depend on the liquidity available at each tick.

sydneyhenrard avatar Aug 22 '21 06:08 sydneyhenrard

I was able to make this work by getting all the tick data from TheGraph API. My understanding is that the impact of liquid per tick on output amount is only relevant if you are going to swap enough liquidity to move outside the current tick range.

Ryanklingert avatar Aug 24 '21 21:08 Ryanklingert

The Graph API Code: const query = gqlquery getPools($poolAddress: String!, $skipAmount: Int!){ pools(where: {id: $poolAddress}) { id tick ticks (skip: $skipAmount){ liquidityGross liquidityNet tickIdx } } }``

Tick Data Provider Format: const ticks = foundTicks.map(tick => { return new Tick({ index: tick.tickIdx, liquidityGross: tick.liquidityGross, liquidityNet: tick.liquidityNet }); })

Ryanklingert avatar Aug 24 '21 21:08 Ryanklingert