Get Tick Info

1. Fetch Ticks

  • Description: Retrieves the ticks value from a given Pool.

  • Params:

    • pool: the object of the pool.

    • start: use the vector to be option.

    • limit: the max return tick amounts.

  • Return:

    • ticks

struct Tick has copy, drop, store {
    index: I32,
    sqrt_price: u128,
    liquidity_net: I128,
    liquidity_gross: u128,
    fee_growth_outside_a: u128,
    fee_growth_outside_b: u128,
    rewards_growth_outside: vector<u128>,
}

// tucana_clmm::tick
#[view]
public fun fetch_ticks(
    pool: Object<Pool>, 
    start: vector<u32>, 
    limit: u64
): vector<Tick> acquires Pool {
    ...
}

2. Get tick spacing

  • Description: Retrieves the tick_spacing value from a given TickManager.

  • Parameters:

    • manager: Reference to a TickManager object from which the tick_spacing is fetched.

  • Return: Returns the tick_spacing value as an unsigned 32-bit integer (u32).

// module tucana_clmm::tick
public fun tick_spacing(manager: &TickManager): u32 {
    manager.tick_spacing
}

3. Get tick index

  • Description: Gets the index of a specific Tick.

  • Parameters:

    • tick: Reference to a Tick object from which the index is fetched.

  • Return: Returns the index of the tick as a signed 32-bit integer (I32).

// tucana_clmm::tick
public fun index(tick: &Tick): I32 {
    tick.index
}

4. Get sqrt price

  • Description: Retrieves the square root price for a specific Tick.

  • Parameters:

    • tick: Reference to a Tick object from which the square root price is obtained.

  • Return: Returns the square root price as an unsigned 128-bit integer (u128).

// tucana_clmm::tick
public fun sqrt_price(tick: &Tick): u128 {
    tick.sqrt_price
}

5. Get liquidity net

  • Description: Fetches the net liquidity for a specific Tick.

  • Parameters:

    • tick: Reference to a Tick object from which the net liquidity value is fetched.

  • Return: Returns the net liquidity as a signed 128-bit integer (I128).

// tucana_clmm::tick
public fun liquidity_net(tick: &Tick): I128 {
    tick.liquidity_net
}

6. Get liquidity gross

  • Description: Retrieves the gross liquidity for a specific Tick.

  • Parameters:

    • tick: Reference to a Tick object from which the gross liquidity is obtained.

  • Return: Returns the gross liquidity as an unsigned 128-bit integer (u128).

// tucana_clmm::tick
public fun liquidity_gross(tick: &Tick): u128 {
    tick.liquidity_gross
}

7. Gets the outside fee growth for Tick

  • Description: Gets the outside fee growth for a specific Tick, consisting of two components.

  • Parameters:

    • tick: Reference to a Tick object.

  • Return: Returns a tuple of two unsigned 128-bit integers ((u128, u128)) representing the outside fee growth.

// tucana_clmm::tick
public fun fee_growth_outside(tick: &Tick): (u128, u128) {
    (tick.fee_growth_outside_a, tick.fee_growth_outside_b)
}

8. Get the rewards growth outside

  • Description: Provides a reference to a vector containing the rewards growth data for a specific Tick.

  • Parameters:

    • tick: Reference to a Tick object.

  • Return: Returns a reference to a vector of unsigned 128-bit integers (&vector<u128>) that holds the rewards growth data.

// tucana_clmm::tick
public fun rewards_growth_outside(tick: &Tick): &vector<u128> {
    &tick.rewards_growth_outside
}

Last updated