Contract 6c6224428fdbfd6194d861f5948298183630985eb9dac67646b7bf63b8f793fb

← Back to Index 📥 Download WASM

Meta

rssdkver 23.2.1#ab415a33cc1f6bdce20ac4a12f0ddbe41a648949
rsver 1.94.0

Instances

  • CAJDT2GIDPCRX7HSTB2U2TBNRL6Y4YDO2ZXMJTCBFCFVWEPLW7RCIZ3F

Interface

exec_op - The callback function called by Blend Pool during flash loan

This is the Modified ERC-3156 interface that Blend uses. The pool calls this function after transferring the flash loan tokens.

Behavior:

  1. Receives flash loaned tokens and immediately transfers them to caller
  2. If swap config is set, caller swaps tokens via Aquarius AMM
  3. Swapped tokens stay with caller for use in subsequent pool requests

Arguments:

  • caller: The address that initiated the flash loan
  • token: The token address being flash loaned (token_in for swap)
  • amount: The amount of tokens received
  • fee: The fee for the flash loan (currently 0 in Blend)
fn exec_op(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    token: soroban_sdk::Address,
    amount: i128,
    fee: i128,
)

Get the pool address

fn get_pool(env: soroban_sdk::Env) -> soroban_sdk::Address

Get the admin address

fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Initialize the contract with admin and pool addresses

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    pool: soroban_sdk::Address,
) -> Result<(), MarginManagerError>

Helper to create a SwapHop for use in swap_chain

fn make_swap_hop(
    env: soroban_sdk::Env,
    tokens_in_pool: soroban_sdk::Vec,
    pool_index: soroban_sdk::BytesN<32>,
    token_out: soroban_sdk::Address,
) -> SwapHop

Get the Aquarius router address

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

Set the Aquarius AMM router address

fn set_aqua_router(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    router: soroban_sdk::Address,
) -> Result<(), MarginManagerError>

Set the swap configuration for the next operation This should be called before initiating a flash loan

Arguments:

  • caller: The address setting the config (no auth required)
  • token_out: Final output token address
  • min_amount_out: Minimum output amount (slippage protection)
  • swap_chain: Custom swap chain (Vec of SwapHop). If empty, builds default direct swap.

Note: No auth required as this is a temporary config cleared after exec_op

fn set_swap_config(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    min_amount_out: i128,
    swap_chain: soroban_sdk::Vec,
)

Helper to create default pool index (32 zero bytes)

fn default_pool_index(env: soroban_sdk::Env) -> soroban_sdk::BytesN<32>

Create a repay request

fn make_repay_request(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    amount: i128,
) -> Request

Create a borrow request

fn make_borrow_request(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    amount: i128,
) -> Request

Create a supply request

fn make_supply_request(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    amount: i128,
) -> Request

Create a withdraw request

fn make_withdraw_request(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    amount: i128,
) -> Request

Create a supply collateral request

fn make_supply_collateral_request(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    amount: i128,
) -> Request

Set swap config for strict-receive mode. In this mode, swap_chained_strict_receive is called:

  • desired_amount_out = exact output tokens wanted
  • max_amount_in = upper bound on input (the flash loan amount) Unspent input tokens remain with the caller.
fn set_swap_config_strict_receive(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    desired_amount_out: i128,
    swap_chain: soroban_sdk::Vec,
)

Create a withdraw collateral request

fn make_withdraw_collateral_request(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    amount: i128,
) -> Request

Imports

WebAssembly Text (WAT) ▶