Contract 91f315db02a9be02b13147622aad92beefc61771e72f8aa4f0904ec2c1e10427

← Back to Index 📥 Download WASM

Meta

cliver 25.2.0#28484880988199233a7e8e87c97cb12dac323cb3
rssdkver 25.3.1#e50d95af029c83196dd122f0154bac3f1302394b
rsver 1.94.1

Instances

  • CAAMA46SQXQKHZDWAS2CNZVAX67TOMGBVH3DVSZSMDKKVP25VGTDQIRX

Interface

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.

Arguments

  • caller: Must be emission_manager
fn pause(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), IncentivesError>

Unpause the incentives contract (emergency admin function)

Arguments

  • caller: Must be emission_manager
fn 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

Returns

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

Initialize the incentives contract

Arguments

  • emission_manager: Address authorized to configure rewards
  • lending_pool: Address authorized to call handle_action
fn initialize(
    env: soroban_sdk::Env,
    emission_manager: soroban_sdk::Address,
    lending_pool: soroban_sdk::Address,
) -> Result<(), IncentivesError>

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.

Arguments

  • caller: Must be emission_manager
  • reward_token: The reward token address to fund
  • amount: Amount of reward tokens to transfer to the contract
fn fund_rewards(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    reward_token: soroban_sdk::Address,
    amount: u128,
) -> Result<(), IncentivesError>

Claim rewards for specific assets and reward token

Arguments

  • caller: Address calling the function (must be authorized)
  • assets: List of assets to claim rewards for
  • reward_token: The reward token to claim
  • amount: Amount to claim (0 = claim all available)
  • to: Address to receive the rewards

Returns

The amount of rewards actually claimed

Errors

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

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.

Arguments

  • token_address: The aToken or debtToken address (the asset identifier)
  • user: The user address whose balance changed
  • total_supply: Total scaled supply/borrow for the asset
  • user_balance: User's scaled balance
  • reward_type: 0 for supply, 1 for borrow

Security

  • Only the token contract itself can call this function (enforced via require_auth)
  • Asset is determined by token_address parameter
  • If token_address is not a registered asset, function returns early (no-op)
  • Parameters cannot affect rewards unless token_address is a whitelisted token contract
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.

Gas Optimization

  • Before: N transfers for N reward positions (e.g., 3 assets × 2 tokens × 2 types = 12 transfers)
  • After: M transfers for M unique reward tokens (e.g., 2 transfers for 2 unique tokens)
  • Savings: Reduces transfers from O(assets × tokens × types) to O(unique_tokens)

Arguments

  • caller: Address calling the function (must be authorized)
  • assets: List of assets to claim rewards for
  • to: Address to receive the rewards
fn 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.

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.

Arguments

  • caller: Must be emission_manager
  • asset: The aToken or debtToken address
  • reward_token: The reward token to unregister
fn 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)

Arguments

  • caller: Must be emission_manager
  • asset: The underlying asset address
  • reward_token: The reward token address
  • reward_type: 0 for supply, 1 for borrow
fn 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)

Arguments

  • caller: Must be emission_manager
  • asset: The underlying asset address
  • reward_token: The reward token address
  • reward_type: 0 for supply, 1 for borrow
  • new_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), not per underlying asset. The asset parameter is the token address that will call handle_action.

Arguments

  • caller: Must be emission_manager
  • asset: The token address (aToken or debtToken) - this is the asset identifier
  • reward_token: The reward token to distribute
  • reward_type: 0 for supply, 1 for borrow
  • emission_per_second: Emission rate in reward tokens per second
  • distribution_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)

Arguments

  • caller: Must be emission_manager
  • asset: The underlying asset address
  • reward_token: The reward token address
  • reward_type: 0 for supply, 1 for borrow
  • new_emission_per_second: New emission rate
fn 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.

Arguments

  • reward_token: The reward token address to check

Returns

The 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
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>

Imports

WebAssembly Text (WAT) ▶