RewardsController

The RewardsController is designed to store and distribute rewards to accounts that interact with the Markets' different variable and fixed pools.

It calculates the total amount of rewards to distribute and determines the allocation between the pools based on a dynamic distribution model. Accounts can claim their rewards through the contract, and their claimable rewards can be queried at any time using the claimable function.

Public State Variables

UTILIZATION_CAP

function UTILIZATION_CAP() external view returns (uint256)

Max utilization supported by the sigmoid function not to cause a division by zero.

distribution

function distribution(contract Market) external view returns (uint8 availableRewardsCount, uint256 baseUnit)

Tracks the reward distribution data for a given market.

marketList

function marketList(uint256) external view returns (contract Market)

Retrieves Markets with distributions set.

rewardEnabled

function rewardEnabled(contract ERC20) external view returns (bool)

Tracks enabled asset rewards.

rewardList

function rewardList(uint256) external view returns (contract ERC20)

Stores registered asset rewards.

View Methods

accountOperation

function accountOperation(address account, contract Market market, bool operation, contract ERC20 reward) external view returns (uint256, uint256)

Gets the account data of a given account, Market, operation and reward asset.

Parameters

Returns

allClaimable

function allClaimable(address account, contract ERC20 reward) external view returns (uint256 unclaimedRewards)

Gets the claimable amount of rewards for a given account and reward asset.

Parameters

Returns

allMarketsOperations

function allMarketsOperations() external view returns (struct RewardsController.MarketOperation[] marketOps)

Gets all market and operations.

Returns

allRewards

function allRewards() external view returns (contract ERC20[])

Retrieves all rewards addresses.

Returns

availableRewardsCount

function availableRewardsCount(contract Market market) external view returns (uint256)

Gets the amount of reward assets that are being distributed for a Market.

Parameters

Returns

claimable

function claimable(RewardsController.MarketOperation[] marketOps, address account, contract ERC20 reward) external view returns (uint256 unclaimedRewards)

Gets the claimable amount of rewards for a given account, Market operations and reward asset.

Parameters

Returns

distributionTime

function distributionTime(contract Market market, contract ERC20 reward) external view returns (uint32, uint32, uint32)

Gets the distribution start, end and lastUpdate value of a given market and reward.

Parameters

Returns

previewAllocation

function previewAllocation(contract Market market, contract ERC20 reward, uint256 deltaTime) external view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed)

Retrieves projected distribution indexes and new undistributed amount for a given deltaTime.

Parameters

Returns

rewardConfig

function rewardConfig(contract Market market, contract ERC20 reward) external view returns (struct RewardsController.Config)

Gets the configuration of a given distribution.

Parameters

Returns

rewardIndexes

function rewardIndexes(contract Market market, contract ERC20 reward) external view returns (uint256, uint256, uint256)

Gets the reward indexes and last amount of undistributed rewards for a given market and reward asset.

Parameters

Returns

Write Methods

claim

function claim(RewardsController.MarketOperation[] marketOps, address to, contract ERC20[] rewardsList) external nonpayable returns (contract ERC20[], uint256[] claimedAmounts)

Claims msg.sender rewards for the given operations and reward assets to the given account.

Parameters

Returns

claimAll

function claimAll(address to) external nonpayable returns (contract ERC20[] rewardsList, uint256[] claimedAmounts)

Claims all msg.sender rewards to the given account.

Parameters

Returns

config

function config(RewardsController.Config[] configs) external nonpayable

Enables or updates the reward distribution for the given markets and rewards.

Parameters

handleBorrow

function handleBorrow(address account) external nonpayable

Hook to be called by the Market to update the index of the account that made a rewarded borrow.

Parameters

handleDeposit

function handleDeposit(address account) external nonpayable

Hook to be called by the Market to update the index of the account that made a rewarded deposit.

Parameters

withdraw

function withdraw(contract ERC20 asset, address to) external nonpayable

Withdraws the contract's balance of the given asset to the given address. Only to be called by ADMIN role accounts.

Parameters

Last updated