# Collect rewards

When you provide liquidity within a valid price range, when transactions occurring within this range,  the rewards will be distributed every second based on the proportional share of effective liquidity from all positions within the current range.  If you intend to harvest rewards separately,  please follow the method below.

### 1. Collect rewards

Use `sdk.Position.collectRewarderPayload()` method.

#### Function Parameters

* `pool_id`: The object id about which pool you want to operation
* `pos_id`: The object id about which position you want to operation
* `coin_type_a`: The coin type address about coinA
* `coin_type_b`: The coin type address about coinB
* `collect_fee`: you can select weather collect fees while Collect rewards
* `rewarder_coin_types`: If these not empty,  it will collect rewarders in this position, if you already open the position.  You can even determine which types of rewards you want to harvest by specifying the coin types you pass

#### Example

```typescript
const pool = await sdk.Pool.getPool(pool_id)

const reward_coin_types = pool.rewarder_infos.map((rewarder) => rewarder.coin_type)

const collect_rewarder_params: CollectRewarderParams = {
  pool_id: pool.id,
  pos_id,
  rewarder_coin_types: reward_coin_types,
  coin_type_a: pool.coin_type_a,
  coin_type_b: pool.coin_type_b,
  collect_fee: true,
}

const collect_rewarder_payload = await sdk.Rewarder.collectRewarderPayload(collect_rewarder_params)
const send_key_pair = 'THE_KEY_PAIR_GENERATED_BY_YOUR_PRIVATE_KEY'
const transfer_txn = await sdk.FullClient.executeTx(send_key_pair, collect_rewarder_payload, true)
```


---

# 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-sdk-v2/sdk-modules/cetusprotocol-sui-clmm-sdk/collect-rewards.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.
