v3-sdk
v3-sdk copied to clipboard
TickDataProvider not defined in docs for creating new pool
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?
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.
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.
The Graph API Code:
const query = gql
query 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 }); })