Skip to main content

DLMM Rust Types - Additional Definitions

Complete type reference for advanced DLMM Rust development
Supplementary type definitions, constants, and configuration structures for the DLMM Rust SDK. These types support core functionality and provide configuration options for advanced use cases.

Constants and Configuration Types

BIN_ARRAY_SIZE - Core Constants

Key constants from the actual source code.
/// Number of bins per bin array
pub const BIN_ARRAY_SIZE: u32 = 256;
pub const BIN_ARRAY_SIZE_USIZE: usize = 256;

/// Maximum bins that can be crossed in a single swap
pub const MAX_BIN_CROSSING: u32 = 30;

/// Program constants from SarosDlmm implementation
impl SarosDlmm {
    const ASSOCIATED_TOKEN_PROGRAM_ADDRESS: Pubkey = 
        pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
    const MEMO_TOKEN_PROGRAM: Pubkey = 
        pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
    const HOOK_PROGRAM_ID: Pubkey = 
        pubkey!("mdmavMvJpF4ZcLJNg6VSjuKVMiBo5uKwERTg1ZB9yUH");
    const HOOK_CONFIG: Pubkey = 
        pubkey!("DgW5ARD9sU3W6SJqtyJSH3QPivxWt7EMvjER9hfFKWXF");
}

Supporting Types

TokenTransferFee - Token Transfer Fee Information

Handles token transfer fees for both SPL Token and Token-2022.
pub struct TokenTransferFee {
    pub epoch_transfer_fee_x: EpochTransferFee,
    pub epoch_transfer_fee_y: EpochTransferFee,
}

impl TokenTransferFee {
    pub fn new(
        previous: &mut Self,
        mint_x_data: &[u8],
        mint_x_owner: &Pubkey,
        mint_y_data: &[u8],
        mint_y_owner: &Pubkey,
    ) -> Result<Self> {
        // Implementation handles both Token and Token-2022 fee structures
    }
    
    pub fn default() -> Self {
        Self {
            epoch_transfer_fee_x: EpochTransferFee::default(),
            epoch_transfer_fee_y: EpochTransferFee::default(),
        }
    }
}

BinArray and BinArrayPair - Bin Storage

Efficient storage and management of liquidity bins.
#[derive(Default, Clone)]
pub struct BinArray {
    pub bins: [Bin; BIN_ARRAY_SIZE_USIZE],
    // Additional metadata
}

pub struct BinArrayPair {
    // Merged bin array pair for efficient operations
}

impl BinArrayPair {
    /// Merge two bin arrays for swap operations
    pub fn merge(lower: BinArray, upper: BinArray) -> Result<Self> {
        // Combines lower and upper bin arrays
    }
    
    /// Get mutable reference to bin by ID
    pub fn get_bin_mut(&mut self, bin_id: u32) -> Result<&mut Bin> {
        // Efficient bin lookup across arrays
    }
}

Reference Documentation