Contract 01378d2861d40bba0ff6ea3ef970d25a8cb32bf38e90e1a53739f2ac672db5cd

← Back to Index 📥 Download WASM

Meta

rssdkver 23.2.1#ab415a33cc1f6bdce20ac4a12f0ddbe41a648949
rsver 1.90.0

Instances

  • CAR35HZH5UIZDDV5BXFRKP7WVD2HO5W5YYDE3GLFTXFYBW3JTK5EHHX6

Interface

Initialize the contract with admin and pool addresses

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

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

Helper to create default pool index (32 zero bytes)

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

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

Get the Aquarius router address

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

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
  2. If swap config is set, swaps tokens via Aquarius AMM
  3. Transfers output tokens to the caller (user)

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,
)

Create a supply collateral request

fn make_supply_collateral_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 repay request

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

Create a withdraw collateral request

fn make_withdraw_collateral_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

Imports

WebAssembly Text (WAT) ▶