Contract 256108b48b9e9e26f4f42a68c093d2d1c3049ec26be7363de28a9267185e6055

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.90.0

Interface

Initialize the lending pool contract

Arguments

  • env - The Soroban environment
  • pool_admin - Address with pool admin privileges
  • emergency_admin - Address with emergency admin privileges
  • price_oracle - Address of the price oracle contract
  • treasury - Address of the treasury (receives protocol fees)
  • dex_router - Address of DEX router (Soroswap router)
fn initialize(
    env: soroban_sdk::Env,
    pool_admin: soroban_sdk::Address,
    emergency_admin: soroban_sdk::Address,
    price_oracle: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
    dex_router: soroban_sdk::Address,
    incentives_contract: Option,
) -> Result<(), KineticRouterError>

Supply assets to the protocol

Arguments

  • env - The Soroban environment
  • caller - The address calling this function
  • asset - The address of the underlying asset to supply
  • amount - The amount to be supplied
  • on_behalf_of - The address that will receive the aTokens
  • _referral_code - Code used to register the integrator (unused for now)

Returns

  • Ok(()) - Supply successful
  • Err(KineticRouterError) - Supply failed due to validation or cap limits

Cap Enforcement

This function enforces supply caps if configured. Caps are stored as whole tokens and converted to smallest units during enforcement to maximize the effective range.

fn supply(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    amount: u128,
    on_behalf_of: soroban_sdk::Address,
    _referral_code: u32,
) -> Result<(), KineticRouterError>
fn withdraw(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    amount: u128,
    to: soroban_sdk::Address,
) -> Result
fn swap_collateral(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    from_asset: soroban_sdk::Address,
    to_asset: soroban_sdk::Address,
    amount: u128,
    min_amount_out: u128,
) -> Result

Set DEX router address (admin only)

fn set_dex_router(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    router: soroban_sdk::Address,
) -> Result<(), KineticRouterError>

Get DEX router address

fn get_dex_router(env: soroban_sdk::Env) -> Option

Set DEX factory address (admin only)

fn set_dex_factory(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    factory: soroban_sdk::Address,
) -> Result<(), KineticRouterError>

Get DEX factory address

fn get_dex_factory(env: soroban_sdk::Env) -> Option
fn borrow(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    amount: u128,
    interest_rate_mode: u32,
    _referral_code: u32,
    on_behalf_of: soroban_sdk::Address,
) -> Result<(), KineticRouterError>
fn repay(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    amount: u128,
    rate_mode: u32,
    on_behalf_of: soroban_sdk::Address,
) -> Result

Liquidate a position

Arguments

  • collateral_asset - The address of the underlying asset used as collateral
  • debt_asset - The address of the underlying borrowed asset to be repaid
  • user - The address of the borrower getting liquidated
  • debt_to_cover - The debt amount of borrowed asset to liquidate
  • receive_a_token - True if liquidator receives aTokens, false for underlying asset
fn liquidation_call(
    env: soroban_sdk::Env,
    liquidator: soroban_sdk::Address,
    collateral_asset: soroban_sdk::Address,
    debt_asset: soroban_sdk::Address,
    user: soroban_sdk::Address,
    debt_to_cover: u128,
    _receive_a_token: bool,
) -> Result<(), KineticRouterError>
fn execute_operation(
    env: soroban_sdk::Env,
    _assets: soroban_sdk::Vec,
    _amounts: soroban_sdk::Vec,
    premiums: soroban_sdk::Vec,
    initiator: soroban_sdk::Address,
    _params: soroban_sdk::Bytes,
) -> bool
fn set_flash_loan_premium(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    premium_bps: u128,
) -> Result<(), KineticRouterError>

Set maximum flash loan premium allowed (admin only)

Arguments

  • caller - Pool admin address (must be authorized)
  • max_premium_bps - Maximum premium in basis points (e.g., 100 = 1%)

Returns

  • Ok(()) if max premium updated successfully
  • Err(Unauthorized) if caller is not admin
fn set_flash_loan_premium_max(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    max_premium_bps: u128,
) -> Result<(), KineticRouterError>
fn get_flash_loan_premium_max(env: soroban_sdk::Env) -> u128
fn set_hf_liquidation_threshold(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    threshold: u128,
) -> Result<(), KineticRouterError>
fn get_hf_liquidation_threshold(env: soroban_sdk::Env) -> u128
fn set_min_swap_output_bps(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    min_output_bps: u128,
) -> Result<(), KineticRouterError>
fn get_min_swap_output_bps(env: soroban_sdk::Env) -> u128
fn set_partial_liq_hf_threshold(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    threshold: u128,
) -> Result<(), KineticRouterError>
fn get_partial_liq_hf_threshold(env: soroban_sdk::Env) -> u128
fn get_flash_loan_premium(env: soroban_sdk::Env) -> u128

Execute a flash loan

Flash loans are permissionless - anyone can initiate them. The receiver contract must implement execute_operation callback.

Parameters

  • initiator: Address initiating the flash loan (must authorize)
  • receiver: Contract that will receive the loan and execute callback
  • assets: Assets to borrow
  • amounts: Amounts to borrow for each asset
  • params: Arbitrary data passed to receiver

Receiver Callback

The receiver must implement execute_operation with the standard flash loan interface.

Authorization

Initiator must authorize the call, but anyone can be an initiator. The receiver handles its own authorization logic.

Errors

  • InvalidFlashLoanParams: Invalid parameters
  • InsufficientLiquidityForFlashLoan: Not enough liquidity
  • FlashLoanExecutionFailed: Receiver callback failed
  • FlashLoanNotRepaid: Loan not fully repaid
fn flash_loan(
    env: soroban_sdk::Env,
    initiator: soroban_sdk::Address,
    receiver: soroban_sdk::Address,
    assets: soroban_sdk::Vec,
    amounts: soroban_sdk::Vec,
    params: soroban_sdk::Bytes,
) -> Result<(), KineticRouterError>

Flash liquidation - atomic liquidation using flash loan

Arguments

  • liquidator - Address of the liquidator (must be authorized)
  • user - Address of the user being liquidated
  • debt_asset - Address of the debt asset
  • collateral_asset - Address of the collateral asset
  • debt_to_cover - Amount of debt to cover
  • collateral_to_seize - Amount of collateral to seize
  • min_swap_out - Minimum amount of debt asset to receive from swap
  • deadline - Transaction deadline timestamp

Returns

  • Ok(()) if liquidation successful
fn flash_liquidation(
    env: soroban_sdk::Env,
    liquidator: soroban_sdk::Address,
    user: soroban_sdk::Address,
    debt_asset: soroban_sdk::Address,
    collateral_asset: soroban_sdk::Address,
    debt_to_cover: u128,
    collateral_to_seize: u128,
    min_swap_out: u128,
    deadline: u64,
) -> Result<(), KineticRouterError>

Set treasury address for protocol fees (admin only)

Arguments

  • caller - Pool admin address (must be authorized)
  • treasury - New treasury address for protocol fee collection

Returns

  • Ok(()) if treasury updated successfully
  • Err(Unauthorized) if caller is not admin
fn set_treasury(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
) -> Result<(), KineticRouterError>
fn get_treasury(env: soroban_sdk::Env) -> Option
fn set_flash_liquidation_helper(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    helper: soroban_sdk::Address,
) -> Result<(), KineticRouterError>
fn get_flash_liquidation_helper(env: soroban_sdk::Env) -> Option

Set pool configurator contract address (admin only)

Arguments

  • caller - Pool admin address (must be authorized)
  • configurator - Pool configurator contract address

Returns

  • Ok(()) if configurator address updated successfully
  • Err(Unauthorized) if caller is not admin
fn set_pool_configurator(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    configurator: soroban_sdk::Address,
) -> Result<(), KineticRouterError>
fn get_pool_configurator(env: soroban_sdk::Env) -> Option

Get available protocol reserves for an asset

Protocol reserves accumulate due to the reserve factor, which reduces supplier APY. Reserves = underlying_balance_in_atoken - total_withdrawable_supply

Arguments

  • asset - The address of the underlying asset

Returns

  • Ok(u128) - Available reserves in smallest units
  • Err - If reserve not found or calculation fails
fn get_protocol_reserves(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> Result

Get swap quote and maximum safe swap amount for collateral swap

Returns a tuple of:

  • swap_quote: Expected output amount from DEX for the given input amount
  • max_swapable: Maximum amount that can be swapped while maintaining HF >= 1.0
  • current_hf: Current health factor before swap
  • projected_hf: Projected health factor after swapping max_swapable amount

Arguments

  • env - Soroban environment
  • user - User address to check swap limits for
  • from_asset - Asset to swap from
  • to_asset - Asset to swap to
  • amount_in - Amount to get quote for (used to calculate DEX ratio)

Returns

  • Ok((u128, u128, u128, u128)) - (quote, max_swapable, current_hf, projected_hf)
  • Err - If calculation fails
fn get_swap_collateral_quote(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    from_asset: soroban_sdk::Address,
    to_asset: soroban_sdk::Address,
    amount_in: u128,
) -> Result<(u128, u128, u128, u128), KineticRouterError>
fn collect_protocol_reserves(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
) -> Result
fn set_user_use_reserve_as_coll(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    use_as_collateral: bool,
) -> Result<(), KineticRouterError>

Get user account data

Arguments

  • user - The address of the user
fn get_user_account_data(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> Result
fn get_reserve_data(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> Result
fn get_current_reserve_data(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> Result
fn get_current_liquidity_index(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> Result
fn get_current_var_borrow_idx(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> Result

Get incentives contract address

Arguments

  • env - The Soroban environment

Returns

  • Option<Address> - The incentives contract address if set, None otherwise
fn get_incentives_contract(env: soroban_sdk::Env) -> Option
fn set_incentives_contract(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    incentives: soroban_sdk::Address,
) -> Result

Get user configuration

Arguments

  • user - The address of the user
fn get_user_configuration(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> UserConfiguration
fn get_reserves_list(env: soroban_sdk::Env) -> soroban_sdk::Vec
fn update_reserve_state(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> Result
fn get_utilization_rate(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> Result
fn is_paused(env: soroban_sdk::Env) -> bool
fn pause(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), KineticRouterError>
fn unpause(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), KineticRouterError>

Initialize a new reserve

Note

This function should be called by the pool configurator contract. The pool configurator should validate authorization before calling this function.

Arguments

  • underlying_asset - The address of the underlying asset
  • a_token_impl - The address of the aToken implementation
  • variable_debt_impl - The address of the variable debt token implementation
  • interest_rate_strategy - The address of the interest rate strategy
  • treasury - The address of the treasury
  • params - Reserve initialization parameters
fn init_reserve(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    underlying_asset: soroban_sdk::Address,
    a_token_impl: soroban_sdk::Address,
    variable_debt_impl: soroban_sdk::Address,
    interest_rate_strategy: soroban_sdk::Address,
    _treasury: soroban_sdk::Address,
    params: InitReserveParams,
) -> Result<(), KineticRouterError>

Get user's total collateral value (for testing/debugging)

fn get_user_collateral_value(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> Result
fn get_user_debt_value(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> Result

Updates the supply cap for a reserve.

The supply cap limits the total amount that can be supplied to a reserve. Caps are stored as whole tokens (not smallest units) to maximize the effective range within the 32-bit storage limit.

Arguments

  • env: The Soroban environment
  • caller: The address calling this function (must be admin)
  • asset: The underlying asset address
  • supply_cap: New supply cap in whole tokens (0 = no cap, virtually unlimited)

Returns

  • Ok(()): Supply cap updated successfully
  • Err(KineticRouterError::InvalidAmount): Invalid cap value
  • Err(KineticRouterError::Unauthorized): Caller is not admin

Events

Emits (sup_cap, asset) event with the new supply cap value.

fn set_reserve_supply_cap(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    supply_cap: u128,
) -> Result<(), KineticRouterError>

Updates the borrow cap for a reserve.

The borrow cap limits the total amount that can be borrowed from a reserve. Caps are stored as whole tokens (not smallest units) to maximize the effective range within the 32-bit storage limit.

Arguments

  • env: The Soroban environment
  • caller: The address calling this function (must be admin)
  • asset: The underlying asset address
  • borrow_cap: New borrow cap in whole tokens (0 = no cap, virtually unlimited)

Returns

  • Ok(()): Borrow cap updated successfully
  • Err(KineticRouterError::InvalidAmount): Invalid cap value
  • Err(KineticRouterError::Unauthorized): Caller is not admin

Events

Emits (bor_cap, asset) event with the new borrow cap value.

fn set_reserve_borrow_cap(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    borrow_cap: u128,
) -> Result<(), KineticRouterError>

Update reserve configuration (called by pool configurator)

Arguments

  • caller: The address calling this function (must be pool configurator)
  • asset: The underlying asset address
  • configuration: New reserve configuration
fn update_reserve_configuration(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    configuration: ReserveConfiguration,
) -> Result<(), KineticRouterError>
fn update_reserve_rate_strategy(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    interest_rate_strategy: soroban_sdk::Address,
) -> Result<(), KineticRouterError>
fn update_atoken_implementation(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    a_token_impl: soroban_sdk::BytesN<32>,
) -> Result<(), KineticRouterError>
fn update_debt_token_implementation(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    debt_token_impl: soroban_sdk::BytesN<32>,
) -> Result<(), KineticRouterError>
fn drop_reserve(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
) -> Result<(), KineticRouterError>

Upgrade contract WASM (admin only)

Arguments

  • new_wasm_hash - Hash of new WASM binary

Errors

  • Unauthorized - Caller is not admin
fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), KineticRouterError>
fn version(env: soroban_sdk::Env) -> u32
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Transfer admin to a new address (current admin only) This transfers the upgrade admin. Use this to assign a multisig as admin.

Arguments

  • caller - Current admin address (must be authorized)
  • new_admin - New admin address (can be a multisig contract)

Errors

  • Unauthorized - Caller is not current admin
fn transfer_admin(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_admin: soroban_sdk::Address,
) -> Result<(), KineticRouterError>

Transfer pool admin to a new address (current pool admin only)

Arguments

  • caller - Current pool admin address (must be authorized)
  • new_admin - New pool admin address (can be a multisig contract)

Errors

  • Unauthorized - Caller is not current pool admin
fn transfer_pool_admin(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_admin: soroban_sdk::Address,
) -> Result<(), KineticRouterError>

Transfer emergency admin to a new address (current pool admin only)

Arguments

  • caller - Current pool admin address (must be authorized)
  • new_admin - New emergency admin address (can be a multisig contract)

Errors

  • Unauthorized - Caller is not current pool admin
fn transfer_emergency_admin(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_admin: soroban_sdk::Address,
) -> Result<(), KineticRouterError>

Set reserve whitelist (admin only)

Arguments

  • caller - Pool admin address
  • asset - Underlying asset address
  • whitelist - Addresses allowed to interact with this reserve

Behavior

  • Empty whitelist: open access
  • Non-empty whitelist: restricted to listed addresses

** Note **: This function replaces the entire whitelist. To add/remove addresses, first get the current list, modify it, then set the complete new list.

Errors

  • Unauthorized - Caller is not admin
fn set_reserve_whitelist(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    whitelist: soroban_sdk::Vec,
) -> Result<(), KineticRouterError>
fn get_reserve_whitelist(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> soroban_sdk::Vec
fn is_whitelisted_for_reserve(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    address: soroban_sdk::Address,
) -> bool
fn set_liquidation_whitelist(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    whitelist: soroban_sdk::Vec,
) -> Result<(), KineticRouterError>
fn get_liquidation_whitelist(
    env: soroban_sdk::Env,
) -> soroban_sdk::Vec
fn is_whitelisted_for_liquidation(
    env: soroban_sdk::Env,
    address: soroban_sdk::Address,
) -> bool
fn set_reserve_blacklist(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    blacklist: soroban_sdk::Vec,
) -> Result<(), KineticRouterError>
fn get_reserve_blacklist(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
) -> soroban_sdk::Vec
fn is_blacklisted_for_reserve(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    address: soroban_sdk::Address,
) -> bool
fn set_liquidation_blacklist(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    blacklist: soroban_sdk::Vec,
) -> Result<(), KineticRouterError>
fn get_liquidation_blacklist(
    env: soroban_sdk::Env,
) -> soroban_sdk::Vec
fn is_blacklisted_for_liquidation(
    env: soroban_sdk::Env,
    address: soroban_sdk::Address,
) -> bool

Imports

WebAssembly Text (WAT) ▶