Swap amount_in of token_in for token_out, returning the output.
fn swap(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
token_in: soroban_sdk::Address,
amount_in: i128,
token_out: soroban_sdk::Address,
min_out: i128,
deadline: u64,
) -> Result
Quote the output of an exact-in swap without executing (view).
fn quote(
env: soroban_sdk::Env,
token_in: soroban_sdk::Address,
amount_in: i128,
token_out: soroban_sdk::Address,
) -> Result
fn paused(env: soroban_sdk::Env) -> Paused
Deposit amounts (parallel to tokens), minting LP shares (∝ Δs).
The first deposit must be balanced; later deposits must be proportional.
fn deposit(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
amounts: soroban_sdk::Vec,
min_shares: i128,
deadline: u64,
) -> Result
Burn shares, returning proportional reserves.
fn withdraw(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
shares: i128,
min_amounts: soroban_sdk::Vec,
deadline: u64,
) -> Result, OrbswapError>
Emergency: pause every mutating entrypoint at once.
fn pause_all(env: soroban_sdk::Env, pause: bool) -> Result<(), OrbswapError>
fn shares_of(env: soroban_sdk::Env, who: soroban_sdk::Address) -> i128
Whether concentrated-liquidity tick mode is enabled.
fn tick_mode(env: soroban_sdk::Env) -> bool
fn get_config(env: soroban_sdk::Env) -> Result
One-time configuration. alpha/beta are WAD shape params; for Circular
both must equal 2+√2. Token decimals are read from each token contract.
fn initialize(
env: soroban_sdk::Env,
tokens: soroban_sdk::Vec,
mode: PoolMode,
alpha: i128,
beta: i128,
fee_bps: i128,
admin: soroban_sdk::Address,
) -> Result<(), OrbswapError>
fn is_allowed(
env: soroban_sdk::Env,
token: soroban_sdk::Address,
) -> Result
Current price as [cos θc, sin θc] (WAD).
fn tick_price(env: soroban_sdk::Env) -> soroban_sdk::Vec
fn pause_swaps(env: soroban_sdk::Env, pause: bool) -> Result<(), OrbswapError>
Allow/disallow a token. A disallowed token cannot be swapped in and deposits freeze; swapping it out and withdrawals stay open, so LPs can exit and arbitrage can drain the depegged coin. Admin-gated.
fn set_allowed(
env: soroban_sdk::Env,
token: soroban_sdk::Address,
allowed: bool,
) -> Result<(), OrbswapError>
Current integer tick (floor of the price angle, 0..=90).
fn current_tick(env: soroban_sdk::Env) -> u32
Enable concentrated-liquidity tick mode. Circular pools only, before any liquidity is added; admin-gated and irreversible.
fn enable_ticks(env: soroban_sdk::Env) -> Result<(), OrbswapError>
fn get_reserves(env: soroban_sdk::Env) -> soroban_sdk::Vec
LP fees accrued outside the curve, parallel to tokens. Paid out pro-rata to LPs on withdraw; not part of the swap curve.
fn lp_fees_owed(env: soroban_sdk::Env) -> soroban_sdk::Vec
fn total_shares(env: soroban_sdk::Env) -> i128
Add concentrated liquidity over [lower, upper] (integer degrees, arc
[0,90]), pulling at most amounts = [x_max, y_max]. The first add must
be full-range [0,90] balanced (sets θc = 45°, locks MINIMUM_LIQUIDITY).
Returns the liquidity L credited to the caller's position.
fn add_liquidity(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
amounts: soroban_sdk::Vec,
lower: u32,
upper: u32,
min_liquidity: i128,
deadline: u64,
) -> Result
fn protocol_owed(env: soroban_sdk::Env) -> soroban_sdk::Vec
Marginal price of token0 in token1 (decimal-normalized, WAD; 1.0 at balance).
i128::MAX if at a price boundary or uninitialized.
fn get_spot_price(env: soroban_sdk::Env) -> i128
fn pause_deposits(env: soroban_sdk::Env, pause: bool) -> Result<(), OrbswapError>
Swap for an exact amount_out of token_out, pulling at most max_in
of token_in. Returns the input actually charged.
fn swap_exact_out(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
token_in: soroban_sdk::Address,
token_out: soroban_sdk::Address,
amount_out: i128,
max_in: i128,
deadline: u64,
) -> Result
Quote the input required for an exact-out swap (view).
fn quote_exact_out(
env: soroban_sdk::Env,
token_in: soroban_sdk::Address,
token_out: soroban_sdk::Address,
amount_out: i128,
) -> Result
Move amount LP shares from from to to.
fn transfer_shares(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: i128,
) -> Result<(), OrbswapError>
Active liquidity L spanning the current price.
fn active_liquidity(env: soroban_sdk::Env) -> i128
Oracle accumulator (Σ price·Δt, last_update_time). TWAP over [t0,t1] =
(cum1 − cum0) / (t1 − t0) computed off-chain (v2-style).
fn price_cumulative(env: soroban_sdk::Env) -> (i128, u64)
fn protocol_fee_bps(env: soroban_sdk::Env) -> i128
Remove liquidity from the caller's [lower, upper] position, returning the
tokens released at the current angle. Returns [x_out, y_out].
fn remove_liquidity(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
lower: u32,
upper: u32,
liquidity: i128,
min_amounts: soroban_sdk::Vec,
deadline: u64,
) -> Result, OrbswapError>
fn pause_withdrawals(env: soroban_sdk::Env, pause: bool) -> Result<(), OrbswapError>
Liquidity of a caller's [lower, upper] position (0 if none).
fn position_liquidity(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
lower: u32,
upper: u32,
) -> i128
fn get_liquidity_scale(env: soroban_sdk::Env) -> i128
Set the protocol's cut of the swap fee (bps of the fee, 0–10000). Admin only.
fn set_protocol_fee_bps(env: soroban_sdk::Env, bps: i128) -> Result<(), OrbswapError>
Transfer all accrued protocol fees to to, zeroing the accrual. Admin only.
fn collect_protocol_fees(
env: soroban_sdk::Env,
to: soroban_sdk::Address,
) -> Result, OrbswapError>