Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::rewards_controller
@title Rewards Controller Module @author Aave @notice Implements functionality to manage and distribute rewards for Aave protocol assets
- Resource
RewardsControllerData
- Struct
RewardsConfigInput
- Resource
AssetData
- Resource
RewardData
- Resource
UserData
- Struct
UserAssetBalance
- Struct
ClaimerSet
- Struct
Accrued
- Struct
AssetConfigUpdated
- Struct
PullRewardsTransferStrategyInstalled
- Function
rewards_controller_address
- Function
rewards_controller_object
- Function
get_claimer
- Function
get_pull_rewards_transfer_strategy
- Function
lookup_asset_data
- Function
lookup_rewards_data
- Function
lookup_user_data
- Function
get_rewards_data
- Function
get_user_data
- Function
get_asset_index
- Function
get_distribution_end
- Function
get_rewards_by_asset
- Function
get_rewards_list
- Function
get_user_asset_index
- Function
get_user_accrued_rewards
- Function
get_user_rewards
- Function
get_all_user_rewards
- Function
get_asset_decimals
- Function
get_reward_from_config
- Function
get_rewards_transfer_strategy_from_config
- Function
initialize
- Function
create_reward_input_config
- Function
configure_assets
- Function
set_pull_rewards_transfer_strategy
- Function
handle_action
- Function
set_claimer
- Function
claim_rewards_internal_update_data
- Function
claim_all_rewards_internal_update_data
- Function
set_distribution_end
- Function
set_emission_per_second
use 0x1::event;
use 0x1::fungible_asset;
use 0x1::object;
use 0x1::option;
use 0x1::primary_fungible_store;
use 0x1::simple_map;
use 0x1::smart_table;
use 0x1::timestamp;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xc1b23ac8ce67df6361b241bfa30a22c9b177fe39c471334a514eea977e6673a9::oracle;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::math_utils;
Resource RewardsControllerData
#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
struct RewardsControllerData has key
Struct RewardsConfigInput
struct RewardsConfigInput has drop, store
Resource AssetData
struct AssetData has copy, drop, store, key
Resource RewardData
struct RewardData has copy, drop, store, key
Resource UserData
struct UserData has copy, drop, store, key
Struct UserAssetBalance
struct UserAssetBalance has copy, drop, store
Struct ClaimerSet
#[event]
struct ClaimerSet has drop, store
Struct Accrued
#[event]
struct Accrued has drop, store
Struct AssetConfigUpdated
#[event]
struct AssetConfigUpdated has drop, store
Struct PullRewardsTransferStrategyInstalled
#[event]
struct PullRewardsTransferStrategyInstalled has drop, store
Function rewards_controller_address
@notice Gets the address of the rewards controller @param seed The seed used to create the rewards controller object @return The address of the rewards controller
#[view]
public fun rewards_controller_address(seed: vector<u8>): address
Function rewards_controller_object
@notice Gets the rewards controller object @param seed The seed used to create the rewards controller object @return The rewards controller object
#[view]
public fun rewards_controller_object(seed: vector<u8>): object::Object<rewards_controller::RewardsControllerData>
Function get_claimer
@notice Gets the claimer for a user @param user The user address @param rewards_controller_address The address of the rewards controller @return Option containing the claimer address if one exists
#[view]
public fun get_claimer(user: address, rewards_controller_address: address): option::Option<address>
Function get_pull_rewards_transfer_strategy
@notice Gets the pull rewards transfer strategy for a reward @param reward The reward address @param rewards_controller_address The address of the rewards controller @return Option containing the strategy address if one exists
#[view]
public fun get_pull_rewards_transfer_strategy(reward: address, rewards_controller_address: address): option::Option<address>
Function lookup_asset_data
@notice Looks up asset data for a specific asset @param asset The asset address @param rewards_controller_address The address of the rewards controller @return Option containing the asset data if it exists
#[view]
public fun lookup_asset_data(asset: address, rewards_controller_address: address): option::Option<rewards_controller::AssetData>
Function lookup_rewards_data
@notice Looks up rewards data for a specific asset and reward @param asset The asset address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return Tuple containing Options for asset data and reward data
#[view]
public fun lookup_rewards_data(asset: address, reward: address, rewards_controller_address: address): (option::Option<rewards_controller::AssetData>, option::Option<rewards_controller::RewardData>)
Function lookup_user_data
@notice Looks up user data for a specific asset, reward, and user @param asset The asset address @param reward The reward address @param user The user address @param rewards_controller_address The address of the rewards controller @return Tuple containing Options for asset data, reward data, and user data
#[view]
public fun lookup_user_data(asset: address, reward: address, user: address, rewards_controller_address: address): (option::Option<rewards_controller::AssetData>, option::Option<rewards_controller::RewardData>, option::Option<rewards_controller::UserData>)
Function get_rewards_data
@notice Gets rewards data for a specific asset and reward @param asset The asset address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return Tuple containing index, emission per second, last update timestamp, and distribution end
#[view]
public fun get_rewards_data(asset: address, reward: address, rewards_controller_address: address): (u256, u256, u256, u256)
Function get_user_data
@notice Gets user data for a specific asset, reward, and user @param asset The asset address @param reward The reward address @param user The user address @param rewards_controller_address The address of the rewards controller @return Tuple containing user index and accrued rewards
#[view]
public fun get_user_data(asset: address, reward: address, user: address, rewards_controller_address: address): (u256, u256)
Function get_asset_index
@notice Gets the asset index for a specific asset and reward @param asset The asset address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return Tuple containing the current asset index and new asset index
#[view]
public fun get_asset_index(asset: address, reward: address, rewards_controller_address: address): (u256, u256)
Function get_distribution_end
@notice Gets the distribution end for a specific asset and reward @param asset The asset address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return The distribution end timestamp
#[view]
public fun get_distribution_end(asset: address, reward: address, rewards_controller_address: address): u256
Function get_rewards_by_asset
@notice Gets all rewards for a specific asset @param asset The asset address @param rewards_controller_address The address of the rewards controller @return Vector of reward addresses
#[view]
public fun get_rewards_by_asset(asset: address, rewards_controller_address: address): vector<address>
Function get_rewards_list
@notice Gets all available rewards @param rewards_controller_address The address of the rewards controller @return Vector of reward addresses
#[view]
public fun get_rewards_list(rewards_controller_address: address): vector<address>
Function get_user_asset_index
@notice Gets the user asset index for a specific user, asset, and reward @param user The user address @param asset The asset address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return The user asset index
#[view]
public fun get_user_asset_index(user: address, asset: address, reward: address, rewards_controller_address: address): u256
Function get_user_accrued_rewards
@notice Gets the user accrued rewards for a specific user and reward @param user The user address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return The user accrued rewards
#[view]
public fun get_user_accrued_rewards(user: address, reward: address, rewards_controller_address: address): u256
Function get_user_rewards
@notice Gets the user rewards for specific assets, user and reward @param assets Vector of asset addresses @param user The user address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return The user rewards
#[view]
public fun get_user_rewards(assets: vector<address>, user: address, reward: address, rewards_controller_address: address): u256
Function get_all_user_rewards
@notice Gets all user rewards for specific assets and user @param assets Vector of asset addresses @param user The user address @param rewards_controller_address The address of the rewards controller @return Tuple containing vector of reward addresses and vector of reward amounts
#[view]
public fun get_all_user_rewards(assets: vector<address>, user: address, rewards_controller_address: address): (vector<address>, vector<u256>)
Function get_asset_decimals
@notice Gets the decimals for a specific asset @param asset The asset address @param rewards_controller_address The address of the rewards controller @return The asset decimals
#[view]
public fun get_asset_decimals(asset: address, rewards_controller_address: address): u8
Function get_reward_from_config
@notice Gets the reward from a reward config @param config The reward config @return The reward address
public fun get_reward_from_config(config: &rewards_controller::RewardsConfigInput): address
Function get_rewards_transfer_strategy_from_config
@notice Gets the rewards transfer strategy from a reward config @param config The reward config @return The rewards transfer strategy address
public fun get_rewards_transfer_strategy_from_config(config: &rewards_controller::RewardsConfigInput): address
Function initialize
@notice Initializes the rewards controller @param sender The sender account @param seed The seed used to create the rewards controller object
public(friend) fun initialize(sender: &signer, seed: vector<u8>)
Function create_reward_input_config
@notice Creates a reward input config @param emission_per_second The emission per second @param max_emission_rate The maximum emission rate @param total_supply The total supply @param distribution_end The distribution end timestamp @param asset The asset address @param reward The reward address @param pull_rewards_transfer_strategy The pull rewards transfer strategy address @return The created reward input config
public(friend) fun create_reward_input_config(emission_per_second: u128, max_emission_rate: u128, total_supply: u256, distribution_end: u32, asset: address, reward: address, pull_rewards_transfer_strategy: address): rewards_controller::RewardsConfigInput
Function configure_assets
@notice Configures assets with reward parameters @param config_inputs Vector of reward config inputs @param rewards_controller_address The address of the rewards controller
public(friend) fun configure_assets(config_inputs: vector<rewards_controller::RewardsConfigInput>, rewards_controller_address: address)
Function set_pull_rewards_transfer_strategy
@notice Sets the pull rewards transfer strategy for a reward @param reward The reward address @param strategy The strategy address @param rewards_controller_address The address of the rewards controller
public(friend) fun set_pull_rewards_transfer_strategy(reward: address, strategy: address, rewards_controller_address: address)
Function handle_action
@notice Handles an action for an asset, user, total supply, and user balance @dev This function is called when a user performs an action that will trigger the mint, burn, or transfer function of a ScaledBalanceToken @param asset The asset address @param user The user address @param total_supply The total supply @param user_balance The user balance @param rewards_controller_address The address of the rewards controller
public(friend) fun handle_action(asset: address, user: address, total_supply: u256, user_balance: u256, rewards_controller_address: address)
Function set_claimer
@notice Sets the claimer for a user @param user The user address @param claimer The claimer address @param rewards_controller_address The address of the rewards controller
public(friend) fun set_claimer(user: address, claimer: address, rewards_controller_address: address)
Function claim_rewards_internal_update_data
@notice Claims rewards internal update data @param assets Vector of asset addresses @param amount The amount to claim @param user The user address @param reward The reward address @param rewards_controller_address The address of the rewards controller @return The claimed amount
public(friend) fun claim_rewards_internal_update_data(assets: vector<address>, amount: u256, user: address, reward: address, rewards_controller_address: address): u256
Function claim_all_rewards_internal_update_data
@notice Claims all rewards internal update data @param assets Vector of asset addresses @param user The user address @param rewards_controller_address The address of the rewards controller @return Tuple containing vector of reward addresses and vector of claimed amounts
public(friend) fun claim_all_rewards_internal_update_data(assets: vector<address>, user: address, rewards_controller_address: address): (vector<address>, vector<u256>)
Function set_distribution_end
@notice Sets the distribution end for an asset and reward @param asset The asset address @param reward The reward address @param new_distribution_end The new distribution end timestamp @param rewards_controller_address The address of the rewards controller
public(friend) fun set_distribution_end(asset: address, reward: address, new_distribution_end: u32, rewards_controller_address: address)
Function set_emission_per_second
@notice Sets the emission per second for assets and rewards @param asset The asset address @param rewards Vector of reward addresses @param new_emissions_per_second Vector of new emissions per second @param rewards_controller_address The address of the rewards controller
public(friend) fun set_emission_per_second(asset: address, rewards: vector<address>, new_emissions_per_second: vector<u128>, rewards_controller_address: address)