Themis V2 developer docs
Search…
⌃K
Links

RewardsController*

RewardsController

Abstract contract template to build Distributors contracts for ERC20 rewards to protocol participants

Write Methods

setClaimer

function setClaimer(address user, address claimer) external
Whitelists an address to claim the rewards on behalf of another address

Call Params

Name
Type
Description
user
address
The address of the user
claimer
address
The address of the claimer

setTransferStrategy

function setTransferStrategy(address reward, ITransferStrategyBase transferStrategy) external
Sets a TransferStrategy logic contract that determines the logic of the rewards transfer

Call Params

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

setRewardOracle

function setRewardOracle(address reward, IEACAggregatorProxy rewardOracle) external
Sets an 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 be able to show incentives at the current UI without the need to setup an external price registry

Call Params

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

configureAssets

function configureAssets(RewardsDataTypes.RewardsConfigInput[] memory config) external
Configure assets to incentivize with an emission of rewards per second until the end of distribution.

Call Params

Name
Type
Description
config
RewardsDataTypes.RewardsConfigInput[]
config The assets configuration input, the list of structs contains the following fields

struts RewardsConfigInput

Name
Type
Description
emissionPerSecond
uint88
The emission per second following rewards unit decimals.
distributionStart
uint256
The start of the distribution of the incentives for an asset
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
ITransferStrategyBase
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.
m0EmissionTotal
uint256
M0 Total reward quantity
m1ExtraEmissionTotal
uint256
M1 Total number of additional rewards
m1ExtraEmissionRatio
uint256
Compared with M0 total reward coefficient
rewardPeriod
uint256
Number of incentive periods

handleAction

function handleAction( address user, uint256 userBalance, uint256 totalSupply ) external;
Called by the corresponding asset on any update that affects the rewards distribution.Default borrow type m0.

Call Params

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

handleAction

function handleAction( address user, uint256 m0UserBalance, uint256 m1UserBalance, uint256 m0TotalSupply, uint256 m1totalSupply ) external
Called by the corresponding asset on any update that affects the rewards distribution

Call Params

Name
Type
Description
user
address
The address of the user
m0UserBalance
uint256
The user balance of the m0 asset
m1UserBalance
uint256
The user balance of the m1 asset
m0TotalSupply
uint256
The total supply of the m0 asset
m1totalSupply
uint256
The total supply of the m1 asset

claimRewards

function claimRewards( address[] calldata assets, uint256 amount, address to, address reward ) external returns (uint256,uint256);
Claims reward for a user to the desired address, on all the assets of the pool, accumulating the pending rewards

Call Params

Name
Type
Description
assets
address[]
assets List of assets to check eligible distributions before claiming rewards
amount
uint256
The amount of rewards to claim
to
address
The address that will be receiving the rewards
reward
address
The address of the reward token

Return Values

Type
Description
uint256
The m0 amount of rewards claimed
uint256
The m1 amount of rewards claimed

claimRewardsOnBehalf

function claimRewardsOnBehalf( address[] calldata assets, uint256 amount, address user, address to, address reward ) external returns (uint256,uint256);
Claims reward for a user on behalf, on all the assets of the pool, accumulating the pending rewards. The caller must be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager

Call Params

Name
Type
Description
assets
address[]
assets List of assets to check eligible distributions before claiming rewards
amount
uint256
The amount of rewards to claim
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

Return Values

Type
Description
uint256
The m0 amount of rewards claimed
uint256
The m1 amount of rewards claimed

claimRewardsToSelf

function claimRewardsToSelf( address[] calldata assets, uint256 amount, address reward, uint256 borrowType ) external returns (uint256,uint256);
Claims reward for msg.sender, on all the assets of the pool, accumulating the pending rewards

Call Params

Name
Type
Description
assets
address[]
assets List of assets to check eligible distributions before claiming rewards
amount
uint256
The amount of rewards to claim
reward
address
The address of the reward token

Return Values

  • @return The m0 amount of rewards claimed
  • @return The m1 amount of rewards claimed

claimAllRewards

function claimAllRewards(address[] calldata assets, address to) external 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

Call Params

Name
Type
Description
assets
address[]
The list of assets to check eligible distributions before claiming rewards
to
address
The address that will be receiving the rewards

Return Values

Name
Type
Description
rewardsList
address[]
List of addresses of the reward tokens
claimedAmounts
uint256[]
List that contains the claimed amount per reward, following same order as rewardList

claimAllRewardsOnBehalf

function claimAllRewardsOnBehalf( address[] calldata assets, address user, address to, uint256 borrowType ) external returns (address[] memory rewardsList, uint256[] memory claimedAmounts);

Call Params

Name
Type
Description
assets
address[]
The list of assets to check eligible distributions before claiming rewards
user
address
The address to check and claim rewards
to
address
The address that will be receiving the rewards
borrowType
uint256
The borrow type

Return Values

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

claimAllRewardsToSelf

function claimAllRewardsToSelf(address[] calldata assets,uint256 borrowType) external returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
Claims all reward for msg.sender, on all the assets of the pool, accumulating the pending rewards

Call Params

Name
Type
Description
assets
address[]
The list of assets to check eligible distributions before claiming rewards

Return Values

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

View Methods

getRewardOracle

function getRewardOracle(address reward) external view returns (address)
Get the price aggregator oracle address

Call Params

Name
Type
Description
reward
address
The address of the reward

Return Values

Type
Description
address
The price oracle of the reward

getClaimer

function getClaimer(address user) external view returns (address)
Returns the whitelisted claimer for a certain address (0x0 if not set)

Call Params

Name
Type
Description
user
address
user The address of the user

Return Values

Type
Description
address
The claimer address

getTransferStrategy

function getTransferStrategy(address reward) external view returns (address)
Returns the Transfer Strategy implementation contract address being used for a reward address

Call Params

Name
Type
Description
reward
address
reward The address of the reward

Return Values

Type
Description
address
The address of the TransferStrategy contract

getUserAssetBalances

function getTransferStrategy(address reward) external view returns (address)
Returns the Transfer Strategy implementation contract address being used for a reward address

Call Params

Name
Type
Description
assets
address[]
The list of assets to check eligible distributions before claiming rewards
user
address
User address

Return Values

Type
Description
asset
The address of the TransferStrategy contract
userM0Balance
The user m0 balance of the asset
userM1Balance
The user m1 balance of the asset
m0TotalSupply
The m0 total supply of the asset to incentivize
m1TotalSupply
The m1 total supply of the asset to incentivize
totalSupply
The total supply of the asset to incentivize