Collect Reward

You can directly collect position reward through the collect_position_reward method in the Cetus DLMM pool module.

/// Collects accumulated rewards of a specific type from a position.
///
/// This function extracts the accumulated rewards of the specified type
/// from a position and returns them as a token balance.
///
/// ## Type Parameters
/// - `CoinTypeA`: First token type in the pool
/// - `CoinTypeB`: Second token type in the pool
/// - `RewardType`: Type of reward token to collect
///
/// ## Parameters
/// - `pool`: Mutable reference to the pool
/// - `position`: Mutable reference to the position
/// - `config`: Global configuration
/// - `versioned`: Versioned object for compatibility check
/// - `ctx`: Transaction context
///
/// ## Returns
/// - `Balance<RewardType>`: Collected reward balance
///
/// ## Events Emitted
/// - `CollectRewardEvent`: Contains position, reward type, and amount
///
/// ## Errors
/// - `EPositionPoolNotMatch`: If position doesn't belong to this pool
public fun collect_position_reward<CoinTypeA, CoinTypeB, RewardType>(
    pool: &mut Pool<CoinTypeA, CoinTypeB>,
    position: &mut Position,
    config: &GlobalConfig,
    versioned: &Versioned,
    ctx: &TxContext,
): (Balance<RewardType>) {
    ...
}

Last updated