Sets up the contract with required addresses and configures tier fees.
fn init(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
usdc_asset: soroban_sdk::Address,
settings_contract: soroban_sdk::Address,
)
Marks an order for refund and calculates refund amounts. This is the first step in the two-step refund process.
relayer: Must authorize the state change("OrderRefunded", order_id) with fee amountfn refund(
env: soroban_sdk::Env,
order_id: soroban_sdk::Bytes,
fee: i128,
) -> Result<(), ContractError>
Updates order state and calculates settlement amounts. This is the first step in the two-step settlement process. No tokens are transferred here.
relayer: Must authorize the state change("OrderSettled", order_id, liquidity_provider) with settle_percentorder_id: Unique identifier for the orderliquidity_provider: Address to receive settled fundssettle_percent: Percentage to settle (in basis points, 100,000 = 100%)Ok(true) on successful state updateErr(ContractError) on failurefn settle(
env: soroban_sdk::Env,
order_id: soroban_sdk::Bytes,
liquidity_provider: soroban_sdk::Address,
settle_percent: i128,
) -> Result
Updates the contract's WASM code for upgrades and bug fixes.
admin: Must authorize the upgradefn upgrade_lp(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Creates a new order and transfers funds from sender to temporary wallet. The order enters a pending state until settled or refunded.
params.sender: Must authorize the token transfer("OrderCreated", order_id, sender) with order detailsenv: Soroban environmentparams: Order creation parametersOk(()) on successErr(ContractError) on failurefn create_order(
env: soroban_sdk::Env,
params: OrderParams,
) -> Result<(), ContractError>
fn get_tier_fee(env: soroban_sdk::Env, tier: ProtocolFees) -> i64
fn get_order_info(
env: soroban_sdk::Env,
order_id: soroban_sdk::Bytes,
) -> Result
Allows admin to update the fee percentage for any tier.
tier: The tier to updatefee_bps: New fee in basis points (e.g., 400 = 0.4%)fn update_tier_fee(
env: soroban_sdk::Env,
tier: ProtocolFees,
fee_bps: i64,
) -> Result<(), ContractError>
fn register_lp_node(
env: soroban_sdk::Env,
lp_node_id: soroban_sdk::Bytes,
capacity: i128,
) -> Result<(), ContractError>
fn get_token_balance(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128
Uses 12 decimal places of internal precision
fn calculate_protocol_fee(
env: soroban_sdk::Env,
amount: i128,
tier: ProtocolFees,
) -> Result
Executes the actual token transfers for a previously refunded order. This is the second step in the two-step refund process.
order.temporary_wallet_address: Must authorize the token transfersfn execute_refund_transfer(
env: soroban_sdk::Env,
order_id: soroban_sdk::Bytes,
) -> Result<(), ContractError>
Executes the actual token transfers for a previously settled order. This is the second step in the two-step settlement process.
order.temporary_wallet_address: Must authorize the token transfers("SettlementTransferred", order_id) with settle_percentfn execute_settlement_transfer(
env: soroban_sdk::Env,
order_id: soroban_sdk::Bytes,
) -> Result<(), ContractError>
Emergency function to pause all order creation and settlements.
admin: Must authorize the pause("Paused",) when contract is pausedfn pause(env: soroban_sdk::Env) -> Result<(), ContractError>
Resumes normal contract operations after a pause.
admin: Must authorize the unpause("Unpaused",) when contract is unpausedfn unpause(env: soroban_sdk::Env) -> Result<(), ContractError>
true if contract operations are pausedfalse if contract is operationalfn is_paused(env: soroban_sdk::Env) -> bool
Sets up initial protocol configuration with admin, treasury, and relayer addresses.
admin: Must authorize initializationtreasury: Address to receive protocol feesrelayer_address: Authorized address for settlement operationsfn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
treasury: soroban_sdk::Address,
relayer_address: soroban_sdk::Address,
)
Currently hardcoded to only support USDC. Can be extended for multi-token support.
true if token is supported for ordersfalse if token is not supportedfn is_token_supported(env: soroban_sdk::Env, token: soroban_sdk::Address) -> bool
Updates the settings manager contract's WASM code.
admin: Must authorize the upgradefn upgrade_lp_manager(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
fn get_relayer_address(env: soroban_sdk::Env) -> soroban_sdk::Address
fn get_treasury_address(env: soroban_sdk::Env) -> soroban_sdk::Address
Updates treasury or relayer addresses with proper validation.
admin: Must authorize the changewhat: Type of address to update (Treasury or Aggregator/Relayer)value: New address valuefn update_protocol_address(
env: soroban_sdk::Env,
what: ProtocolAddressType,
value: soroban_sdk::Address,
) -> Result<(), ContractError>