Uniswap / v3-sdk

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

TickDataProvider.getTick() should be typed with a generic #114

Closed dalechyn closed 2 years ago

dalechyn commented 2 years ago

https://github.com/Uniswap/v3-sdk/blob/4459663920b558cc100239081a1d3782ee512264/src/entities/tickDataProvider.ts#L11

Currently returns { liquidityNet: BigintIsh }, but the general way to get ticks data is through the TickLens contract or SubGraph API. The first one returns the whole Tick which may be used for further computations, in cases where you need liquidityGross.

I think that TickDataProvider should be typed with something like TDataType in order to be able to extract more data that is held in Tick.

export interface TickDataProvider<TDataType extends = { liquidityNet: BigintIsh } = { liquidityNet: BigintIsh }> {
  /**
   * Return information corresponding to a specific tick
   * @param tick the tick to load
   */
  getTick(tick: number): Promise<TDataType>

  /**
   * Return the next tick that is initialized within a single word
   * @param tick The current tick
   * @param lte Whether the next tick should be lte the current tick
   * @param tickSpacing The tick spacing of the pool
   */
  nextInitializedTickWithinOneWord(tick: number, lte: boolean, tickSpacing: number): Promise<[number, boolean]>
}
dalechyn commented 2 years ago

nevermind, TickListDataProvider resolves that issue