Contract d1ffa05ee5eba9b02eaa510d8deab61afe7855006d219175e83184d05283fdfa

← Back to Index 📥 Download WASM

Meta

cliver 25.2.0#28484880988199233a7e8e87c97cb12dac323cb3
rssdkver 25.3.1#e50d95af029c83196dd122f0154bac3f1302394b
rsver 1.94.1

Instances

  • CCRDMPUFJPXYPR24JN6DRAP4FICYDUNI74V6N4P62ZXJX35WQG4ZDXH6
  • CDGLSOL6VRGIKNPLV2FYSH2KELTHY7EJI6OM6WUTOFLFHWMCTJWYTULI

Interface

Pause the incentives contract (emergency admin function)

When paused, users cannot claim rewards. Admin functions remain available. Rewards continue through handle_action_with_balances, 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

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>

Initialize the incentives contract

Arguments

  • emission_manager: Address authorized to configure rewards
  • lending_pool: Associated lending pool address
fn __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

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

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.

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.

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 token calls handle_action_with_balances. New streams bind to the token's trusted continuity revision. Existing streams cannot change after a controller change or failed hook.

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

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, with the pre-action supply and both balances.

Arguments

  • token_address: The aToken or debtToken address (the asset identifier)
  • user: The user address whose balance changed
  • total_supply: Total scaled supply/borrow before the balance change
  • previous_user_balance: User's scaled balance before the change
  • new_user_balance: User's scaled balance after the change
  • reward_type: 0 for supply, 1 for borrow
  • incentives_revision: Token's current continuity revision

Security

  • Only the token contract itself can call this function (enforced via require_auth)
  • Asset is determined by token_address parameter
  • Unconfigured or quarantined streams do not change reward state
  • The calling token supplies its revision; this hook never queries that token
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,
    incentives_revision: u64,
) -> Result<(), IncentivesError>

Imports

WebAssembly Text (WAT) ▶