Remove liquidity

You can directly remove liquidity through the remove liquidity method in the Cetus DLMM pool module.

/// Removes liquidity from a position and returns the underlying tokens.
///
/// This function removes liquidity from the specified bins of a position
/// and returns the corresponding token amounts. It handles bin cleanup if empty.
///
/// ## Type Parameters
/// - `CoinTypeA`: First token type in the pool
/// - `CoinTypeB`: Second token type in the pool
///
/// ## Parameters
/// - `pool`: Mutable reference to the pool
/// - `position`: Mutable reference to the position
/// - `bins`: Vector of bin IDs for liquidity removal
/// - `liquidity_shares`: Vector of liquidity shares to remove from each bin
/// - `config`: Global configuration
/// - `versioned`: Versioned object for compatibility check
/// - `clk`: Clock for timestamp tracking
/// - `ctx`: Transaction context
///
/// ## Returns
/// - `(Balance<CoinTypeA>, Balance<CoinTypeB>)`: Token balances returned
///
/// ## Events Emitted
/// - `RemoveLiquidityEvent`: Contains position and liquidity delta information
public fun remove_liquidity<CoinTypeA, CoinTypeB>(
    pool: &mut Pool<CoinTypeA, CoinTypeB>,
    position: &mut Position,
    bins: vector<u32>,
    liquidity_shares: vector<u128>,
    config: &GlobalConfig,
    versioned: &Versioned,
    clk: &Clock,
    ctx: &TxContext,
): (Balance<CoinTypeA>, Balance<CoinTypeB>) {
    abort 1
}

Last updated