Initialize the incentives contract
emission_manager: Address authorized to configure rewardslending_pool: Address authorized to call handle_actionfn initialize(
env: soroban_sdk::Env,
emission_manager: soroban_sdk::Address,
lending_pool: soroban_sdk::Address,
) -> Result<(), IncentivesError>
Handle action called by token contracts (aToken/debtToken) when balances change
This is the core function that updates reward indices and calculates user rewards. Called after balance updates (mint/burn) to update rewards.
token_address: The aToken or debtToken address (the asset identifier)user: The user address whose balance changedtotal_supply: Total scaled supply/borrow for the assetuser_balance: User's scaled balancereward_type: 0 for supply, 1 for borrowtoken_address parameterfn handle_action(
env: soroban_sdk::Env,
token_address: soroban_sdk::Address,
user: soroban_sdk::Address,
total_supply: u128,
user_balance: u128,
reward_type: u32,
) -> Result<(), IncentivesError>
Claim rewards for specific assets and reward token
caller: Address calling the function (must be authorized)assets: List of assets to claim rewards forreward_token: The reward token to claimamount: Amount to claim (0 = claim all available)to: Address to receive the rewardsThe amount of rewards actually claimed
Returns InsufficientRewards if amount > 0 and the requested amount exceeds
the total claimable rewards across all assets and reward types.
fn claim_rewards(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
assets: soroban_sdk::Vec,
reward_token: soroban_sdk::Address,
amount: u128,
to: soroban_sdk::Address,
) -> Result
Claim all rewards for all configured reward tokens
This function batches transfers by reward token to reduce gas costs. Instead of one transfer per (asset, reward_token, reward_type) combination, it accumulates all rewards per reward token and does a single transfer per token.
caller: Address calling the function (must be authorized)assets: List of assets to claim rewards forto: Address to receive the rewardsfn claim_all_rewards(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
assets: soroban_sdk::Vec,
to: soroban_sdk::Address,
) -> Result<(), IncentivesError>
Configure asset rewards (admin function)
Following Aave's pattern: rewards are configured per token contract (aToken/debtToken),
not per underlying asset. The asset parameter is the token address that will call handle_action.
caller: Must be emission_managerasset: The token address (aToken or debtToken) - this is the asset identifierreward_token: The reward token to distributereward_type: 0 for supply, 1 for borrowemission_per_second: Emission rate in reward tokens per seconddistribution_end: Distribution end timestamp (0 = no end)fn configure_asset_rewards(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
reward_type: u32,
emission_per_second: u128,
distribution_end: u64,
) -> Result<(), IncentivesError>
Set emission per second for an asset reward (admin function)
caller: Must be emission_managerasset: The underlying asset addressreward_token: The reward token addressreward_type: 0 for supply, 1 for borrownew_emission_per_second: New emission ratefn set_emission_per_second(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
reward_type: u32,
new_emission_per_second: u128,
) -> Result<(), IncentivesError>
Set distribution end timestamp (admin function)
caller: Must be emission_managerasset: The underlying asset addressreward_token: The reward token addressreward_type: 0 for supply, 1 for borrownew_distribution_end: New distribution end timestamp (0 = no end)fn set_distribution_end(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
reward_type: u32,
new_distribution_end: u64,
) -> Result<(), IncentivesError>
Remove/deactivate asset reward (admin function)
caller: Must be emission_managerasset: The underlying asset addressreward_token: The reward token addressreward_type: 0 for supply, 1 for borrowfn remove_asset_reward(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
reward_type: u32,
) -> Result<(), IncentivesError>
Permanently delete a reward token from an asset's registered list.
Unlike remove_asset_reward which only deactivates, this removes the token
from the enumeration list entirely. Both supply and borrow configs for this
reward token must be inactive before deletion.
caller: Must be emission_managerasset: The aToken or debtToken addressreward_token: The reward token to unregisterfn delete_reward_token(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
) -> Result<(), IncentivesError>
Pause the incentives contract (emergency admin function)
When paused, users cannot claim rewards. Admin functions remain available.
Rewards continue to accrue via handle_action, but claims are blocked.
caller: Must be emission_managerfn pause(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
) -> Result<(), IncentivesError>
Unpause the incentives contract (emergency admin function)
caller: Must be emission_managerfn unpause(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
) -> Result<(), IncentivesError>
Check if the contract is paused
true if paused, false otherwise
fn is_paused(env: soroban_sdk::Env) -> bool
Fund the contract with reward tokens (admin function)
Transfers reward tokens from the emission manager to the contract. The contract must be funded before users can claim rewards.
caller: Must be emission_managerreward_token: The reward token address to fundamount: Amount of reward tokens to transfer to the contractfn fund_rewards(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
amount: u128,
) -> Result<(), IncentivesError>
Get asset reward configuration
fn get_asset_reward_config(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
reward_type: u32,
) -> Option
Get asset reward index
fn get_asset_reward_index(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
reward_type: u32,
) -> AssetRewardIndex
Get user reward data
fn get_user_reward_data(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
user: soroban_sdk::Address,
reward_type: u32,
) -> UserRewardData
Get user's accrued rewards
fn get_user_accrued_rewards(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
reward_token: soroban_sdk::Address,
user: soroban_sdk::Address,
reward_type: u32,
) -> u128
Get all configured assets
fn get_assets(env: soroban_sdk::Env) -> soroban_sdk::Vec
Get reward tokens for an asset
fn get_reward_tokens(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
) -> soroban_sdk::Vec
Get the contract's balance for a reward token
Returns the amount of reward tokens held by the contract. This can be used to check if the contract has sufficient funds to cover pending reward claims.
reward_token: The reward token address to checkThe contract's balance of the reward token
fn get_reward_token_balance(
env: soroban_sdk::Env,
reward_token: soroban_sdk::Address,
) -> u128