Current protocol fee as (numerator, denominator) — e.g. (100, 100000) = 10 bps. Denominator is always FEE_DENOMINATOR.
fn get_fee(env: soroban_sdk::Env) -> (i128, i128)
Set the protocol fee (per 100,000 of slice output). Admin only, hard-capped at MAX_FEE_PER_100K — the ceiling is compile-time and cannot be raised without a new contract makers would have to opt into. 0 is valid (fee holiday).
fn set_fee(env: soroban_sdk::Env, fee_per_100k: i128) -> Result<(), TwapError>
fn get_order(env: soroban_sdk::Env, order_id: u64) -> Result
fn get_venue(
env: soroban_sdk::Env,
venue_id: u32,
) -> Result
Place a TWAP order. Escrows total_in of token_in.
Pricing: pass limit_num/limit_den > 0 for a fixed floor (min token_out per token_in). Pass 0/0 to bound each slice by the SwapBook oracle instead — requires max_slippage_bps in 1..=1000 and a FRESH oracle price for the pair at placement time.
fn place_twap(
env: soroban_sdk::Env,
maker: soroban_sdk::Address,
token_in: soroban_sdk::Address,
token_out: soroban_sdk::Address,
total_in: i128,
end_ledger: u32,
limit_num: i128,
limit_den: i128,
max_slippage_bps: u32,
max_slice_in: i128,
min_slice_gap: u32,
pace_tolerance_bps: u32,
) -> Result
Cancel an active TWAP order — maker only. Refunds the unfilled remainder immediately; proceeds already streamed stay with the maker.
fn cancel_twap(env: soroban_sdk::Env, order_id: u64) -> Result<(), TwapError>
Permissionless cleanup after end_ledger: refund the unfilled remainder to the maker and close the order.
fn expire_twap(env: soroban_sdk::Env, order_id: u64) -> Result<(), TwapError>
Remove a venue. Admin only.
fn remove_venue(env: soroban_sdk::Env, venue_id: u32) -> Result<(), TwapError>
Deploy-time constructor — atomic with deployment, cannot be front-run.
fn __constructor(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
fee_vault: soroban_sdk::Address,
swap_book: soroban_sdk::Address,
)
Execute one slice of a TWAP order. PERMISSIONLESS — the contract enforces pace, price, and cadence; the caller only chooses timing, size (within caps), and the route.
fn execute_slice(
env: soroban_sdk::Env,
order_id: u64,
amount_in: i128,
segments: soroban_sdk::Vec,
) -> Result
Register a venue adapter (same push-funds interface as the Router's). Admin only.
fn register_venue(
env: soroban_sdk::Env,
venue_id: u32,
contract_address: soroban_sdk::Address,
) -> Result<(), TwapError>
fn get_active_orders(env: soroban_sdk::Env) -> soroban_sdk::Vec