# 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> {
    ...
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cetus-1.gitbook.io/cetus-developer-docs/developer/via-dlmm-contract/features-available/collect-reward.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
