Data Structure

1. Pool

struct Pool has key {
    extend_ref: ExtendRef,

    coin_a_store: Object<FungibleStore>,
    coin_b_store: Object<FungibleStore>,

    /// The tick spacing
    tick_spacing: u32,

    /// The numerator of fee rate, the denominator is 1_000_000.
    fee_rate: u64,

    /// The liquidity of current tick index
    liquidity: u128,

    /// The current sqrt price
    current_sqrt_price: u128,

    /// The current tick index
    current_tick_index: I32,

    /// The global fee growth of coin a,b as Q64.64
    fee_growth_global_a: u128,
    fee_growth_global_b: u128,

    /// The amounts of coin a,b owned to protocol
    fee_protocol_coin_a: u64,
    fee_protocol_coin_b: u64,

    /// The tick manager
    tick_manager: TickManager,

    /// The rewarder manager
    rewarder_manager: RewarderManager,

    /// The position collection
    position_collection: Object<PositionNftCollection>,

    /// is the pool pause
    is_pause: bool,
}

2. Rewarder


/// Rewarder store the information of a rewarder.
/// `reward_metadata` is the type of reward coin.
/// `emissions_per_second` is the amount of reward coin emit per second.
/// `growth_global` is Q64.X64,  is reward emited per liquidity.
struct Rewarder has copy, drop, store {
    reward_metadata: Object<Metadata>,
    emissions_per_second: u128,
    growth_global: u128,
    released: u256,
    harvested: u64,
    end_time: u64
}

3. Position

/// `PositionNftCollection` Stores into NFT Collection Object
struct PositionNftCollection has key {
    pool_name: String,
    mutator_ref: MutatorRef,
    metadata_a: Object<Metadata>,
    metadata_b: Object<Metadata>,
    tick_spacing: u32,
    position_index: u64,
    position_uri: String,
}

/// The Tucana_clmm pool's position.
struct PositionNft has key, store {
    mutator_ref: nft::MutatorRef,
    burn_ref: nft::BurnRef,
    metadata: PositionMetadata,
    rewards: vector<PositionReward>,
}

struct PositionMetadata has store, copy, drop {
    pool_id: address,
    liquidity: u128,
    tick_lower_index: I32,
    tick_upper_index: I32,
    fee_growth_inside_a: u128,
    fee_growth_inside_b: u128,
    fee_owned_a: u64,
    fee_owned_b: u64,
}

/// The Position's rewarder
struct PositionReward has drop, copy, store {
    growth_inside: u128,
    amount_owned: u64,
}

4. AddLiquidityReceipt

struct AddLiquidityReceipt {
    pool_addr: address,
    amount_a: u64,
    amount_b: u64
}

5. FlashSwapReceipt

/// Flash loan resource for swap.
/// There is no way in Move to pass calldata and make dynamic calls, but a resource can be used for this purpose.
/// To make the execution into a single transaction, the flash loan function must return a resource
/// that cannot be copied, cannot be saved, cannot be dropped, or cloned.
struct FlashSwapReceipt {
    pool_addr: address,
    memadata: Object<Metadata>,
    partner_addr: address,
    pay_amount: u64,
    ref_fee_amount: u64
}

Last updated