# IRewardManager

> Facilitates the claiming and distribution of rewards to voters, delegators, and stakers.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

Source: https://dev.flare.network/network/fsp/solidity-reference/IRewardManager

Facilitates the claiming and distribution of rewards to voters, delegators, and stakers.

Sourced from `IRewardManager.sol` on [GitHub](https://github.com/flare-foundation/flare-smart-contracts-v2/blob/main/contracts/userInterfaces/IRewardManager.sol).

## Functions[​](#functions "Direct link to Functions")

### active[​](#active "Direct link to active")

Indicates if the contract is active - claims are enabled.

```
function active() external view returns (    bool);
```

### autoClaim[​](#autoclaim "Direct link to autoClaim")

Claim rewards for `_rewardOwners` and their PDAs. Rewards are deposited to the WNat (to reward owner or PDA if enabled). It can be called by reward owner or its authorized executor. Only claiming from weight based claims is supported.

```
function autoClaim(    address[] _rewardOwners,    uint24 _rewardEpochId,    struct RewardsV2Interface.RewardClaimWithProof[] _proofs) external;
```

#### Parameters[​](#parameters "Direct link to Parameters")

-   `_rewardOwners`: Array of reward owners.
-   `_rewardEpochId`: Id of the reward epoch up to which the rewards are claimed.
-   `_proofs`: Array of reward claims with merkle proofs.

### claim[​](#claim "Direct link to claim")

Claim rewards for `_rewardOwner` and transfer them to `_recipient`. It can be called by reward owner or its authorized executor.

```
function claim(    address _rewardOwner,    address payable _recipient,    uint24 _rewardEpochId,    bool _wrap,    struct RewardsV2Interface.RewardClaimWithProof[] _proofs) external returns (    uint256 _rewardAmountWei);
```

#### Parameters[​](#parameters-1 "Direct link to Parameters")

-   `_rewardOwner`: Address of the reward owner.
-   `_recipient`: Address of the reward recipient.
-   `_rewardEpochId`: Id of the reward epoch up to which the rewards are claimed.
-   `_wrap`: Indicates if the reward should be wrapped (deposited) to the WNat contract.
-   `_proofs`: Array of reward claims with merkle proofs.

#### Returns[​](#returns "Direct link to Returns")

-   `_rewardAmountWei`: Amount of rewarded native tokens (wei).

### cleanupBlockNumber[​](#cleanupblocknumber "Direct link to cleanupBlockNumber")

Get the current cleanup block number.

```
function cleanupBlockNumber() external view returns (    uint256);
```

#### Returns[​](#returns-1 "Direct link to Returns")

-   \`\`: The currently set cleanup block number.

### firstClaimableRewardEpochId[​](#firstclaimablerewardepochid "Direct link to firstClaimableRewardEpochId")

The first reward epoch id that was claimable.

```
function firstClaimableRewardEpochId() external view returns (    uint24);
```

### getCurrentRewardEpochId[​](#getcurrentrewardepochid "Direct link to getCurrentRewardEpochId")

Returns current reward epoch id.

```
function getCurrentRewardEpochId() external view returns (    uint24);
```

### getInitialRewardEpochId[​](#getinitialrewardepochid "Direct link to getInitialRewardEpochId")

Returns initial reward epoch id.

```
function getInitialRewardEpochId() external view returns (    uint256);
```

### getNextClaimableRewardEpochId[​](#getnextclaimablerewardepochid "Direct link to getNextClaimableRewardEpochId")

Returns the next claimable reward epoch for a reward owner.

```
function getNextClaimableRewardEpochId(    address _rewardOwner) external view returns (    uint256);
```

#### Parameters[​](#parameters-2 "Direct link to Parameters")

-   `_rewardOwner`: Address of the reward owner to query.

### getRewardEpochIdToExpireNext[​](#getrewardepochidtoexpirenext "Direct link to getRewardEpochIdToExpireNext")

Returns the reward epoch id that will expire next once a new reward epoch starts.

```
function getRewardEpochIdToExpireNext() external view returns (    uint256);
```

### getRewardEpochIdsWithClaimableRewards[​](#getrewardepochidswithclaimablerewards "Direct link to getRewardEpochIdsWithClaimableRewards")

Returns the start and the end of the reward epoch range for which the reward is claimable.

```
function getRewardEpochIdsWithClaimableRewards() external view returns (    uint24 _startEpochId,    uint24 _endEpochId);
```

#### Returns[​](#returns-2 "Direct link to Returns")

-   `_startEpochId`: The oldest epoch id that allows reward claiming.
-   `_endEpochId`: The newest epoch id that allows reward claiming.

### getRewardEpochTotals[​](#getrewardepochtotals "Direct link to getRewardEpochTotals")

Returns reward epoch totals.

```
function getRewardEpochTotals(    uint24 _rewardEpochId) external view returns (    uint256 _totalRewardsWei,    uint256 _totalInflationRewardsWei,    uint256 _initialisedRewardsWei,    uint256 _claimedRewardsWei,    uint256 _burnedRewardsWei);
```

#### Parameters[​](#parameters-3 "Direct link to Parameters")

-   `_rewardEpochId`: Reward epoch id.

#### Returns[​](#returns-3 "Direct link to Returns")

-   `_totalRewardsWei`: Total rewards (inflation + community) for the epoch (wei).
-   `_totalInflationRewardsWei`: Total inflation rewards for the epoch (wei).
-   `_initialisedRewardsWei`: Initialised rewards of all claim types for the epoch (wei).
-   `_claimedRewardsWei`: Claimed rewards for the epoch (wei).
-   `_burnedRewardsWei`: Burned rewards for the epoch (wei).

### getStateOfRewards[​](#getstateofrewards "Direct link to getStateOfRewards")

Returns the state of rewards for a given address for all unclaimed reward epochs with claimable rewards.

```
function getStateOfRewards(    address _rewardOwner) external view returns (    struct RewardsV2Interface.RewardState[][] _rewardStates);
```

#### Parameters[​](#parameters-4 "Direct link to Parameters")

-   `_rewardOwner`: Address of the reward owner.

#### Returns[​](#returns-4 "Direct link to Returns")

-   `_rewardStates`: Array of reward states.

### getStateOfRewardsAt[​](#getstateofrewardsat "Direct link to getStateOfRewardsAt")

Returns the state of rewards for a given address at a specific reward epoch.

```
function getStateOfRewardsAt(    address _rewardOwner,    uint24 _rewardEpochId) external view returns (    struct RewardsV2Interface.RewardState[] _rewardStates);
```

#### Parameters[​](#parameters-5 "Direct link to Parameters")

-   `_rewardOwner`: Address of the reward owner.
-   `_rewardEpochId`: Reward epoch id.

#### Returns[​](#returns-5 "Direct link to Returns")

-   `_rewardStates`: Array of reward states.

### getTotals[​](#gettotals "Direct link to getTotals")

Returns totals.

```
function getTotals() external view returns (    uint256 _totalRewardsWei,    uint256 _totalInflationRewardsWei,    uint256 _totalClaimedWei,    uint256 _totalBurnedWei);
```

#### Returns[​](#returns-6 "Direct link to Returns")

-   `_totalRewardsWei`: Total rewards (wei).
-   `_totalInflationRewardsWei`: Total inflation rewards (wei).
-   `_totalClaimedWei`: Total claimed rewards (wei).
-   `_totalBurnedWei`: Total burned rewards (wei).

### getUnclaimedRewardState[​](#getunclaimedrewardstate "Direct link to getUnclaimedRewardState")

Gets the unclaimed reward state for a beneficiary, reward epoch id and claim type.

```
function getUnclaimedRewardState(    address _beneficiary,    uint24 _rewardEpochId,    enum RewardsV2Interface.ClaimType _claimType) external view returns (    struct IRewardManager.UnclaimedRewardState _state);
```

#### Parameters[​](#parameters-6 "Direct link to Parameters")

-   `_beneficiary`: Address of the beneficiary to query.
-   `_rewardEpochId`: Id of the reward epoch to query.
-   `_claimType`: Claim type to query.

#### Returns[​](#returns-7 "Direct link to Returns")

-   `_state`: Unclaimed reward state.

### initialiseWeightBasedClaims[​](#initialiseweightbasedclaims "Direct link to initialiseWeightBasedClaims")

Initialises weight based claims.

```
function initialiseWeightBasedClaims(    struct RewardsV2Interface.RewardClaimWithProof[] _proofs) external;
```

#### Parameters[​](#parameters-7 "Direct link to Parameters")

-   `_proofs`: Array of reward claims with merkle proofs.

### noOfInitialisedWeightBasedClaims[​](#noofinitialisedweightbasedclaims "Direct link to noOfInitialisedWeightBasedClaims")

Returns the number of weight based claims that have been initialised.

```
function noOfInitialisedWeightBasedClaims(    uint256 _rewardEpochId) external view returns (    uint256);
```

#### Parameters[​](#parameters-8 "Direct link to Parameters")

-   `_rewardEpochId`: Reward epoch id.

## Events[​](#events "Direct link to Events")

### RewardClaimed[​](#rewardclaimed "Direct link to RewardClaimed")

Emitted when rewards are claimed.

```
event RewardClaimed(    address beneficiary,    address rewardOwner,    address recipient,    uint24 rewardEpochId,    enum RewardsV2Interface.ClaimType claimType,    uint120 amount)
```

#### Parameters[​](#parameters-9 "Direct link to Parameters")

-   `beneficiary`: Address of the beneficiary (voter or node id) that accrued the reward.
-   `rewardOwner`: Address that was eligible for the rewards.
-   `recipient`: Address that received the reward.
-   `rewardEpochId`: Id of the reward epoch where the reward was accrued.
-   `claimType`: Claim type
-   `amount`: Amount of rewarded native tokens (wei).

### RewardClaimsEnabled[​](#rewardclaimsenabled "Direct link to RewardClaimsEnabled")

Emitted when reward claims have been enabled.

```
event RewardClaimsEnabled(    uint256 rewardEpochId)
```

#### Parameters[​](#parameters-10 "Direct link to Parameters")

-   `rewardEpochId`: First claimable reward epoch.

### RewardClaimsExpired[​](#rewardclaimsexpired "Direct link to RewardClaimsExpired")

Unclaimed rewards have expired and are now inaccessible.

`getUnclaimedRewardState()` can be used to retrieve more information.

```
event RewardClaimsExpired(    uint256 rewardEpochId)
```

#### Parameters[​](#parameters-11 "Direct link to Parameters")

-   `rewardEpochId`: Id of the reward epoch that has just expired.

## Structures[​](#structures "Direct link to Structures")

### RewardClaim[​](#rewardclaim "Direct link to RewardClaim")

Struct used in Merkle tree for storing reward claims.

```
struct RewardClaim {  uint24 rewardEpochId;  bytes20 beneficiary;  uint120 amount;  enum RewardsV2Interface.ClaimType claimType;}
```

### RewardClaimWithProof[​](#rewardclaimwithproof "Direct link to RewardClaimWithProof")

Struct used for claiming rewards with Merkle proof.

```
struct RewardClaimWithProof {  bytes32[] merkleProof;  struct RewardsV2Interface.RewardClaim body;}
```

### RewardState[​](#rewardstate "Direct link to RewardState")

Struct used for returning state of rewards.

```
struct RewardState {  uint24 rewardEpochId;  bytes20 beneficiary;  uint120 amount;  enum RewardsV2Interface.ClaimType claimType;  bool initialised;}
```

### UnclaimedRewardState[​](#unclaimedrewardstate "Direct link to UnclaimedRewardState")

Struct used for storing unclaimed reward data.

```
struct UnclaimedRewardState {  bool initialised;  uint120 amount;  uint128 weight;}
```
