# Incentives

The [UiIncentiveDataProvider](/developers/smart-contracts/view-contracts.md) contract provides methods to query all active incentive emissions and the claimable user incentives for a specific Tydro market. This contract is primarily used by frontends to display incentive information for suppliers and borrowers.

## RewardsController

* Rewards accrue automatically for users holding incentivised ERC-20 assets. No staking or locking is required.
* Users can claim all rewards in a single transaction or claim individual rewards with more granularity.
* On every transfer, incentivised assets call the `handleAction` method to account for updated reward balances.

Key properties:

The RewardsController is the main rewards contract where users interact to claim rewards from their Tydro positions. It is designed as an abstract template that can be extended to create distributor contracts for ERC-20 rewards.

The source code is available on [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/rewards/RewardsController.sol).

### Write Methods

#### initialize

```
function initialize(address) external initializer
```

Initialize RewardsController instance.

**Input Parameters:**

| Type    | Description                                                                        |
| ------- | ---------------------------------------------------------------------------------- |
| address | Unused but required due to being initialized by PoolAddressProvider.\_updateImpl() |

#### configureAssets

```
function configureAssets(RewardsDataTypes.RewardsConfigInput[] memory config) external override onlyEmissionManager
```

Configure assets to incentivize with an emission of rewards per second until the end of distribution.

**Input Parameters:**

| Name   | Type                                   | Description                                             |
| ------ | -------------------------------------- | ------------------------------------------------------- |
| config | RewardsDataTypes.RewardsConfigInput\[] | The emission per second following rewards unit decimals |

The [<mark style="color:blue;">RewardsDataTypes.RewardsConfigInput</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/rewards/libraries/RewardsDataTypes.sol) struct is composed of the following fields:

| Name              | Type                | Description                                                                                                                                                   |
| ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| emissionPerSecond | uint88              | The emission per second following rewards unit decimals                                                                                                       |
| totalSupply       | uint256             | The total supply of the asset to incentivize                                                                                                                  |
| distributionEnd   | uint32              | The end of the distribution of the incentives for an asset                                                                                                    |
| asset             | address             | The asset address to incentivize                                                                                                                              |
| reward            | address             | The reward token address                                                                                                                                      |
| transferStrategy  | ITransferStrategy   | The TransferStrategy address with the install hook and claim logic                                                                                            |
| rewardOracle      | IEACAggregatorProxy | The Price Oracle of a reward to visualize the incentives at the UI frontend. Must follow Chainlink Aggregator IEACAggregatorProxy interface to be compatible. |

#### setTransferStrategy

```
function setTransferStrategy(address reward, ITransferStrategyBase transferStrategy) external onlyEmissionManager
```

Sets a TransferStrategy logic contract that determines the logic of the rewards transfer.

**Input Parameters:**

| Name             | Type    | Description                                        |
| ---------------- | ------- | -------------------------------------------------- |
| reward           | address | The address of the reward token                    |
| transferStrategy | address | The address of the TransferStrategy logic contract |

#### setRewardOracle

```
function setRewardOracle(address reward, IEACAggregatorProxy rewardOracle) external onlyEmissionManager
```

Sets an Aave Oracle contract to enforce rewards with a source of value.

At the moment of reward configuration, the Incentives Controller performs a check to see if the reward asset oracle is compatible with IEACAggregator proxy. This check is enforced for integrators to show incentives at the current Aave UI without needing to set up an external price registry.

**Input Parameters:**

| Name         | Type                | Description                                                                    |
| ------------ | ------------------- | ------------------------------------------------------------------------------ |
| reward       | address             | The address of the reward to set the price aggregator                          |
| rewardOracle | IEACAggregatorProxy | The address of price aggregator that follows the IEACAggregatorProxy interface |

#### handleAction

```
function handleAction(address user, uint256 totalSupply, uint256 userBalance) external override
```

Called by the corresponding asset on transfer hook to update the rewards distribution of a user.

**Input Parameters:**

| Name        | Type    | Description                   |
| ----------- | ------- | ----------------------------- |
| user        | address | The address of the user       |
| totalSupply | uint256 | The user balance of the asset |
| userBalance | uint256 | The total supply of the asset |

#### claimRewards

```
function claimRewards(    address[] calldata assets,    uint256 amount,    address to,    address reward) external override returns (uint256)
```

Claims reward for a user to the desired address, on all the assets of the pool, accumulating the pending rewards. Rewards are received by the to address.

**Input Parameters:**

| Name   | Type       | Description                                                                                                   |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses         |
| amount | uint256    | The amount of rewards to claim, expressed in wei. Pass MAX\_UINT to claim the entire unclaimed reward balance |
| to     | address    | The address that will be receiving the rewards                                                                |
| reward | address    | The address of the reward token (e.g., stkAAVE)                                                               |

**Return Values:**

| Type    | Description                                           |
| ------- | ----------------------------------------------------- |
| uint256 | The amount of rewards claimed for one specific reward |

The msg.sender must be an authorized claimer set using the setClaimer() method

#### claimRewardsOnBehalf

```
function claimAllRewardsOnBehalf(
    address[] calldata assets,
    address user,
    address to
) external override onlyAuthorizedClaimers(msg.sender, user) returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims rewards for a user on behalf, on all the assets of the pool, accumulating the pending rewards of the assets passed by the first argument. The caller must be whitelisted via the <kbd>allowClaimOnBehalf</kbd> function by the EmissionManager role held by Tydro. Rewards are received by the Press <kbd>to</kbd> address. address.

**Input Parameters:**

| Name   | Type       | Description                                                                                                   |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses         |
| amount | uint256    | The amount of rewards to claim, expressed in wei. Pass MAX\_UINT to claim the entire unclaimed reward balance |
| user   | address    | The address to check and claim rewards                                                                        |
| to     | address    | The address that will be receiving the rewards                                                                |
| reward | address    | The address of the reward token being claimed (e.g., stkAAVE)                                                 |

**Return Values:**

| Type    | Description                   |
| ------- | ----------------------------- |
| uint256 | The amount of rewards claimed |

#### claimRewardsToSelf

```
function claimRewardsToSelf(address[] calldata assets, uint256 amount, address reward) external override returns (uint256)
```

Claims reward for msg.sender, on all the assets of the pool, accumulating the pending rewards passed by the first input parameter. Rewards are received by msg.sender.

**Input Parameters:**

| Name   | Type       | Description                                                                                                   |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses         |
| amount | uint256    | The amount of rewards to claim, expressed in wei. Pass MAX\_UINT to claim the entire unclaimed reward balance |
| reward | address    | The address of the reward token                                                                               |

**Return Values:**

| Type    | Description                                           |
| ------- | ----------------------------------------------------- |
| uint256 | The amount of rewards claimed for one specific reward |

#### claimAllRewards

```
function claimAllRewards(address[] calldata assets, address to) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims all rewards for a user to the desired address, on all the assets of the pool, accumulating the pending rewards passed by the first input parameter. Rewards are received by the toaddress.

**Input Parameters:**

| Name   | Type       | Description                                                                                                        |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------------ |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards (aToken or variableDebtToken addresses) |
| to     | address    | The address that will be receiving the rewards                                                                     |

**Return Values:**

| Name           | Type       | Description                                                                                   |
| -------------- | ---------- | --------------------------------------------------------------------------------------------- |
| rewardsList    | address\[] | The list of addresses of the reward tokens                                                    |
| claimedAmounts | uint256\[] | The list that contains the claimed amount per reward, following the same order as rewardsList |

#### claimAllRewardsOnBehalf

```
function claimAllRewardsOnBehalf(    address[] calldata assets,    address user,    address to) external override onlyAuthorizedClaimers(msg.sender, user) returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims all rewards for a user on behalf, on all the assets of the pool, accumulating the pending rewards passed by the first input parameter. The caller must be whitelisted via the allowClaimOnBehalf function by the EmissionManager role held by Tydro. Rewards are received by the to address.

**Input Parameters:**

| Name   | Type       | Description                                                                                           |
| ------ | ---------- | ----------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses |
| user   | address    | The address to check and claim rewards                                                                |
| to     | address    | The address that will be receiving the rewards                                                        |

**Return Values:**

| Name           | Type       | Description                                                                                   |
| -------------- | ---------- | --------------------------------------------------------------------------------------------- |
| rewardsList    | address\[] | The list of addresses of the reward tokens                                                    |
| claimedAmounts | uint256\[] | The list that contains the claimed amount per reward, following the same order as rewardsList |

#### claimAllRewardsToSelf

```
function claimAllRewardsToSelf(address[] calldata assets) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims all rewards accrued by msg.sender, on all assets of the pool, accumulating the pending rewards by the first input parameter. Rewards are received by msg.sender.

**Input Parameters:**

| Name   | Type       | Description                                                                                           |
| ------ | ---------- | ----------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses |

**Return Values:**

| Name           | Type       | Description                                                                                   |
| -------------- | ---------- | --------------------------------------------------------------------------------------------- |
| rewardsList    | address\[] | The list of addresses of the reward tokens                                                    |
| claimedAmounts | uint256\[] | The list that contains the claimed amount per reward, following the same order as rewardsList |

#### setClaimer

```
function setClaimer(address user, address caller) external override onlyEmissionManager
```

Whitelists an address to claim rewards on behalf of another address. Can only be called by the EmissionManager help by Tydro

**Input Parameters:**

| Name   | Type    | Description                |
| ------ | ------- | -------------------------- |
| user   | address | The address of the user    |
| caller | address | The address of the claimer |

### View Methods

#### getClaimer

```
function getClaimer(address user) external view override returns (address)
```

Returns the whitelisted claimer for a certain address. It returns the 0x0 address if it is not set.

**Input Parameters:**

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| user | address | The address of the user |

**Return Values:**

| Type    | Description         |
| ------- | ------------------- |
| address | The claimer address |

#### getRewardOracle

```
function getRewardOracle(address reward) external view override returns (address)
```

Get the price aggregator oracle address.

| Name   | Type    | Description                     |
| ------ | ------- | ------------------------------- |
| reward | address | The address of the reward token |

**Return Values:**

| Type    | Description                      |
| ------- | -------------------------------- |
| address | The address of the reward oracle |

#### getTransferStrategy

```
function getTransferStrategy(address reward) external view override returns (address)
```

Returns the Transfer Strategy implementation contract address being used for a reward address.

| Name   | Type    | Description               |
| ------ | ------- | ------------------------- |
| reward | address | The address of the reward |

**Return Values:**

| Type    | Description                                  |
| ------- | -------------------------------------------- |
| address | The address of the TransferStrategy contract |

### Pure Methods

```
function getRevision() internal pure override returns (uint256)
```

Returns the revision of the implementation contract.

**Return Values:**

| Type    | Description                  |
| ------- | ---------------------------- |
| uint256 | The current revision version |


---

# 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.tydro.com/developers/smart-contracts/incentives.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.
