Pause the incentives contract (emergency admin function)
When paused, users cannot claim rewards. Admin functions remain available.
Rewards continue through handle_action_with_revision, 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>
Upgrade contract WASM. Only the stored upgrade admin can authorize this.
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), IncentivesError>
Get the contract implementation version.
fn version(env: soroban_sdk::Env) -> u32
Get the current upgrade admin.
fn get_admin(env: soroban_sdk::Env) -> Result
Check if the contract is paused
true if paused, false otherwise
fn is_paused(env: soroban_sdk::Env) -> bool
Get all configured assets
fn get_assets(env: soroban_sdk::Env) -> soroban_sdk::Vec
Accept the upgrade admin role.
fn accept_admin(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
) -> Result<(), IncentivesError>
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>
Initialize the incentives contract
emission_manager: Address authorized to configure rewardslending_pool: Associated lending pool addressfn __constructor(
env: soroban_sdk::Env,
emission_manager: soroban_sdk::Address,
lending_pool: soroban_sdk::Address,
) -> 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
Legacy balance hook retained for mixed-version token/controller compatibility.
Revision-aware tokens must call handle_action_with_revision.
fn 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>
Propose a new upgrade admin. The pending admin must accept.
fn propose_admin(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
pending_admin: soroban_sdk::Address,
) -> Result<(), IncentivesError>
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>
Get the pending upgrade admin.
fn get_pending_admin(
env: soroban_sdk::Env,
) -> Result
Get reward tokens for an asset
fn get_reward_tokens(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
) -> soroban_sdk::Vec
Permanently delete a reward token from an asset's registered list.
Both reward types must be inactive and the asset must have zero scaled
supply. Deletion preserves the frozen index and creation history.
Deleted pairs cannot be configured again. Proven recorded entitlement
remains available through claim_rewards; claim_all_rewards omits the pair.
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>
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>
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
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>
Cancel a pending upgrade admin proposal.
fn cancel_admin_proposal(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
) -> Result<(), IncentivesError>
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
Configure asset rewards (admin function)
Following Aave's pattern: rewards are configured per token contract (aToken/debtToken). New streams bind to the token's trusted continuity revision through handle_action_with_revision. Existing streams cannot change after a controller change or failed hook.
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>
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
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>
Get the contract's balance for a reward token
Returns the amount of reward tokens held by the contract. Call this 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
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
Legacy pre/post balance hook retained for mixed-version token/controller compatibility. It authenticates the token and tolerates the callback without trusting legacy continuity.
fn handle_action_with_balances(
env: soroban_sdk::Env,
token_address: soroban_sdk::Address,
user: soroban_sdk::Address,
total_supply: u128,
previous_user_balance: u128,
new_user_balance: u128,
reward_type: u32,
) -> Result<(), IncentivesError>
Revision-aware hook called by upgraded token contracts after balance changes.
fn handle_action_with_revision(
env: soroban_sdk::Env,
token_address: soroban_sdk::Address,
user: soroban_sdk::Address,
total_supply: u128,
previous_user_balance: u128,
new_user_balance: u128,
reward_type: u32,
incentives_revision: u64,
) -> Result<(), IncentivesError>