Contract 3406081bd6c7ebc9f7371a1edf3ba5fc4115b04c8f36b91ff4d14bfdc6069d45

← Back to Index 📥 Download WASM

Meta

cliver 26.0.0#60f7458e7ecffddf2f2d91dc6d0d2db4fab03ecc
rssdkver 22.0.11#34f7f53ae31e0fd02aab436a9872e79fa671ca02
rsver 1.94.1

Instances

  • CAAPFJFF6IGWVZDYQC3OCXJ4ZLVTO3VVJYSVXBDVNSXSDC5U2LTKEK6R
  • CBWQQKHFLNFXAHVMXBOFPZPPVX77JD7C7DMJ5ZCGBMRVWG7H34W3CVFU

Interface

Swap amount_in of from_asset for to_asset via Soroswap router.

Output tokens go directly to vault. Uses same-ledger approval.

fn swap(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    from_asset: soroban_sdk::Address,
    to_asset: soroban_sdk::Address,
    amount_in: i128,
    min_out: i128,
)
fn get_name(env: soroban_sdk::Env) -> soroban_sdk::String

Return the total base-asset value of all LP positions.

fn get_value(env: soroban_sdk::Env, vault: soroban_sdk::Address) -> i128
fn get_router(env: soroban_sdk::Env) -> soroban_sdk::Address

Initialize the strategy for a vault.

No pair-specific arguments — pairs are registered dynamically on first add_liquidity call.

Auth

The vault's current on-chain manager must authorise this call.

fn initialize(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    router: soroban_sdk::Address,
    name: soroban_sdk::String,
)

Return true if any active position involves asset.

fn asset_in_use(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    asset: soroban_sdk::Address,
) -> bool

Add liquidity to the Soroswap pair identified by lp_token.

On first call for a given lp_token, pair.token0() is called once to cache the reserve-to-asset mapping; subsequent calls use the cache.

Returns (amount_a_used, amount_b_used, lp_received).

fn add_liquidity(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    lp_token: soroban_sdk::Address,
    asset_a: soroban_sdk::Address,
    asset_b: soroban_sdk::Address,
    amount_a: i128,
    amount_b: i128,
    min_a: i128,
    min_b: i128,
) -> (i128, i128, i128)

Return the LP balance for a specific pair (lp_token).

fn get_lp_balance(env: soroban_sdk::Env, lp_token: soroban_sdk::Address) -> i128

Return total base-asset value of all positions for vault.

fn get_total_value(env: soroban_sdk::Env, vault: soroban_sdk::Address) -> i128

Remove lp_amount from the pair identified by lp_token.

Underlying tokens go directly to vault. Uses same-ledger approval (no zero-revoke).

Returns (amount_a, amount_b) received from the router so the vault can compute post-operation value without a redundant deep LP revaluation.

fn remove_liquidity(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    lp_token: soroban_sdk::Address,
    asset_a: soroban_sdk::Address,
    asset_b: soroban_sdk::Address,
    lp_amount: i128,
    min_a: i128,
    min_b: i128,
) -> (i128, i128)

Return the number of active LP positions (> 0 means strategy holds LP).

Used by the vault's strategy-removal guard.

fn get_share_balance(env: soroban_sdk::Env) -> i128

Proportionally withdraw numerator/denominator of every active LP position and send underlying tokens directly to to.

fn withdraw_fraction(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    numerator: i128,
    denominator: i128,
    to: soroban_sdk::Address,
)

Return all LP token addresses with an active (non-zero) position.

fn get_active_positions(
    env: soroban_sdk::Env,
) -> soroban_sdk::Vec

Refresh the cached AssetHandler address from the vault's factory.

Call this after the factory's AssetHandler is updated post-deployment.

fn refresh_asset_handler(env: soroban_sdk::Env)

Return underlying token balances across all active LP positions.

For each active pair the strategy holds: computes amount_asset = lp_balance * reserve_asset / total_lp and sums across all positions per asset.

The vault uses this to price all assets in a single batch call instead of triggering a full get_total_value (which nests factory + AssetHandler + oracle calls inside the strategy).

fn get_underlying_asset_balances(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
) -> soroban_sdk::Map

Imports

WebAssembly Text (WAT) ▶