tick.ts
path: /src/utils/tick.ts
createTick()
Params:
- tickId (String): ID of the tick instance to create. Format: <pool address>#<tick index>
- tickIdx (i32): Tick index
- poolId (string): PoolId
- event (MintEvent): The mint event where liquidity was added to the tick
ReturnType: Tick
- Other-Chains
- Arbitrum-One
Initializes a new Tick to store the liquidity present at the specific tick.
Sets tick.id, tick.tickIdx, tick.pool and tick.poolId from the parametrs. Sets tick.creatdAtTimeStamp and tick.createdAtBlockNumber from event.block.timestamp and event.block.number respectively.
tick.price0 is calcualted as 1.0001^tickIdx and tick.price1 as safeDiv(ONE_BD, price0).
All the other parameters are initialized to ZERO_BD or ZERO_BI.
Entites:
- Tick - Create
Dependencies:
Invoked at:
- Logic same as mainnet, except doesn't initialize the variables
tick.feeGrowthOutside0X128andtick.feeGrowthOutside1X128
createTickBurn()
Only in Optimism
This function exists only in optimism subgraph
Params:
- tickId (String): ID of the tick instance to initialize. Format: <pool address>#<tick index>
- tickIdx (i32): Tick index
- poolId (string): PoolId
- event (MintEvent): The event where the liquidity from the tick is removed
ReturnType: Tick
Instantiate a tick that already exists from previous transactions.
- Uses the same logic as createTick() to initialize a new tick entity
- Later reads the Pool contract ticks data for
tickIdxand sets thetick.liquidityGross,tick.liquidityNet,tick.feeGrowthOutside0X128andtick.feeGrowthOutside1X128vlaues.
Entites:
- Tick - Create * Write
ABI Dependencies:
- pool.json
Dependencies:
Invoked at:
feeTierToTickSpacing()
Params:
- feeTier (BigInt): The fee tier specified for the pool
ReturnType: BigInt
- Other-Chains
- Arbitrum-One
Given a specific fee tier, returns a BigInt value for the respective tick spacing used in the pool contract.
| Fee Tier | TickSpaceing Returned |
|---|---|
| 10000 | 200 |
| 3000 | 60 |
| 500 | 10 |
| 100 | 1 |
| Anything Else | Error: 'Unexpected fee tier' |
Invoked at:
- Doesn't have the Fee Tier
100, Tick Space1entry.