CenturionDEX
Launch App

tick.ts

Last modified:

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

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:

  1. Tick - Create

Dependencies:

  1. ZERO_BI
  2. ONE_BD
  3. ZERO_BD
  4. bigDecimalExponated()
  5. safeDiv()

Invoked at:

  1. handleMint()

Arbitrum-One

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.

Entites:

  1. Tick - Create * Write

ABI Dependencies:

  1. pool.json

Dependencies:

  1. ZERO_BI
  2. ONE_BD
  3. ZERO_BD
  4. bigDecimalExponated()
  5. safeDiv()

Invoked at:

  1. handleBurn()

feeTierToTickSpacing()

Params:
 - feeTier (BigInt): The fee tier specified for the pool
 
ReturnType: BigInt

Other Chains

Given a specific fee tier, returns a BigInt value for the respective tick spacing used in the pool contract.

Fee TierTickSpaceing Returned
10000200
300060
50010
1001
Anything ElseError: 'Unexpected fee tier'

Invoked at:

  1. handleSwap()

Arbitrum-One