# RewardMath

Allows computing rewards given some parameters of stakes and incentives

### Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/staker/libraries/RewardMath#functions) <a href="#functions" id="functions"></a>

#### computeRewardAmount[​](https://docs.uniswap.org/contracts/v3/reference/periphery/staker/libraries/RewardMath#computerewardamount) <a href="#computerewardamount" id="computerewardamount"></a>

```solidity
  function computeRewardAmount(
    uint256 totalRewardUnclaimed,
    uint160 totalSecondsClaimedX128,
    uint256 startTime,
    uint256 endTime,
    uint128 liquidity,
    uint160 secondsPerLiquidityInsideInitialX128,
    uint160 secondsPerLiquidityInsideX128,
    uint256 currentTime
  ) internal pure returns (uint256 reward, uint160 secondsInsideX128)
```

Compute the amount of rewards owed given parameters of the incentive and stake

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/staker/libraries/RewardMath#parameters)

| Name                                   | Type    | Description                                                                                           |
| -------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| `totalRewardUnclaimed`                 | uint256 | The total amount of unclaimed rewards left for an incentive                                           |
| `totalSecondsClaimedX128`              | uint160 | How many full liquidity-seconds have been already claimed for the incentive                           |
| `startTime`                            | uint256 | When the incentive rewards began in epoch seconds                                                     |
| `endTime`                              | uint256 | When rewards are no longer being dripped out in epoch seconds                                         |
| `liquidity`                            | uint128 | The amount of liquidity, assumed to be constant over the period over which the snapshots are measured |
| `secondsPerLiquidityInsideInitialX128` | uint160 | The seconds per liquidity of the liquidity tick range as of the beginning of the period               |
| `secondsPerLiquidityInsideX128`        | uint160 | The seconds per liquidity of the liquidity tick range as of the current block timestamp               |
| `currentTime`                          | uint256 | The current block timestamp, which must be greater than or equal to the start time                    |

**Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/staker/libraries/RewardMath#return-values)

| Name                | Type    | Description                                                                           |
| ------------------- | ------- | ------------------------------------------------------------------------------------- |
| `reward`            | uint256 | The amount of rewards owed                                                            |
| `secondsInsideX128` | uint160 | The total liquidity seconds inside the position's range for the duration of the stake |


---

# 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://docs.dragonswap.app/dragonswap/resources/developer-resources/smart-contracts/dragonswapv2/staker/libraries/rewardmath.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.
