# Collect Reward

## 1.  Collect Reward By Position

You can directly collect position reward through the collect\_position\_reward method in the Cetus DLMM pool module.

```rust
/// 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>) {
    ...
}
```

## 2. Collect Reward By Close Position Cert

Extracts reward tokens of a specific type from the `ClosePositionCert`; must be called before destroying the certificate to collect all rewards.

```move
/// Takes rewards of a specific type from a close position certificate.
///
/// This function extracts rewards of the specified type from a close position
/// certificate 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 extract
///
/// ## Parameters
/// - `pool`: Mutable reference to the pool
/// - `cert`: Mutable reference to the close position certificate
/// - `versioned`: Versioned object for compatibility check
///
/// ## Returns
/// - `Balance<RewardType>`: Extracted reward balance
public fun take_reward_from_close_position_cert<CoinTypeA, CoinTypeB, RewardType>(
    pool: &mut Pool<CoinTypeA, CoinTypeB>,
    cert: &mut ClosePositionCert,
    versioned: &Versioned,
): Balance<RewardType> {
    ...
}
```
