forked from Uniswap/v3-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtickDataProvider.ts
39 lines (35 loc) · 1.25 KB
/
tickDataProvider.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { BigintIsh } from '@uniswap/sdk-core'
/**
* Provides information about ticks
*/
export interface TickDataProvider {
/**
* Return information corresponding to a specific tick
* @param tick the tick to load
*/
getTick(tick: number): Promise<{ liquidityNet: BigintIsh }>
/**
* 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]>
}
/**
* This tick data provider does not know how to fetch any tick data. It throws whenever it is required. Useful if you
* do not need to load tick data for your use case.
*/
export class NoTickDataProvider implements TickDataProvider {
private static ERROR_MESSAGE = 'No tick data provider was given'
async getTick(_tick: number): Promise<{ liquidityNet: BigintIsh }> {
throw new Error(NoTickDataProvider.ERROR_MESSAGE)
}
async nextInitializedTickWithinOneWord(
_tick: number,
_lte: boolean,
_tickSpacing: number
): Promise<[number, boolean]> {
throw new Error(NoTickDataProvider.ERROR_MESSAGE)
}
}