Data Structure

turbos clmm

position_manager.move Core Structs

// Represents a burned position NFT, used as proof of position burn.
struct TurbosPositionBurnNFT has store, key {
    id: UID,                        // Unique identifier for the burn NFT object
    name: String,                   // Name of the burn NFT
    description: String,            // Description of the burn NFT
    img_url: Url,                   // Image URL for the burn NFT
    position_nft: TurbosPositionNFT,// The original position NFT being burned
    position_id: ID,                // ID of the position
    pool_id: ID,                    // ID of the pool this position belongs to
    coin_type_a: TypeName,          // Type of token A
    coin_type_b: TypeName,          // Type of token B
    fee_type: TypeName,             // Type of fee
}

// Stores reward information for a position.
struct PositionRewardInfo has store {
    reward_growth_inside: u128,     // Accumulated reward growth inside the position's tick range
    amount_owed: u64,               // Amount of reward owed to the position
}

// Represents a user's liquidity position in a pool.
struct Position has key, store {
    id: UID,                        // Unique identifier for the position
    tick_lower_index: I32,          // Lower tick index of the position's range
    tick_upper_index: I32,          // Upper tick index of the position's range
    liquidity: u128,                // Amount of liquidity provided
    fee_growth_inside_a: u128,      // Fee growth for token A inside the position's range
    fee_growth_inside_b: u128,      // Fee growth for token B inside the position's range
    tokens_owed_a: u64,             // Amount of token A owed to the position
    tokens_owed_b: u64,             // Amount of token B owed to the position
    reward_infos: vector<PositionRewardInfo>, // List of reward info for each reward type
}

// Stores all positions and NFT metadata for a user.
struct Positions has key, store {
    id: UID,                        // Unique identifier for the Positions object
    nft_minted: u64,                // Number of NFTs minted
    user_position: Table<address, ID>, // Mapping from NFT address to position ID
    nft_name: String,               // Name for the position NFT
    nft_description: String,        // Description for the position NFT
    nft_img_url: String,            // Image URL for the position NFT
}

pool.move Core Structs

Summary

  • Position-related structs (Position, Positions, TurbosPositionBurnNFT, PositionRewardInfo) are used to track user liquidity, NFT metadata, and reward accruals for each position.

  • Pool-related structs (Pool, Tick, TickInfo, PoolRewardVault, PoolRewardInfo, Versioned) are used to manage the state of the pool, including liquidity, price, ticks, rewards, and protocol configuration.

  • All fields are carefully designed to support efficient and precise accounting of liquidity, fees, and rewards in a concentrated liquidity market maker (CLMM) system.

  • The use of generics and phantom types ensures type safety for different token and fee configurations.

  • The separation of reward, fee, and position tracking allows for extensibility and robust management of user and protocol assets.

Last updated