Marks an order for refund and returns the full remaining amount to the user. This is the first step in the two-step refund process. Supports partial-settle-then-refund flows — if a prior settle() has been called, its execute_settlement_transfer() must complete before refund() can be initiated. No fee is charged on refund — unsuccessful orders are returned in full.
relayer: Must authorize the state change("OrderRefunded", order_id)fn refund(
env: soroban_sdk::Env,
order_id: soroban_sdk::Bytes,
) -> 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,
caller: soroban_sdk::Address,
new_wasm_hash: soroban_sdk::BytesN<32>,
new_settings_contract: soroban_sdk::Address,
) -> Result<(), ContractError>
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
Sets up the contract with required addresses and configures tier fees.
fn __constructor(
env: soroban_sdk::Env,
usdc_asset: soroban_sdk::Address,
settings_contract: soroban_sdk::Address,
)
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,
caller: soroban_sdk::Address,
tier: ProtocolFees,
fee_bps: i64,
) -> Result<(), ContractError>
fn emergency_refund(
env: soroban_sdk::Env,
order_id: soroban_sdk::Bytes,
) -> Result<(), ContractError>
fn extend_config_ttl(env: soroban_sdk::Env)
fn get_token_balance(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128
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,
token_address: soroban_sdk::Address,
) -> Result<(), ContractError>
fn update_settings_contract(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
new_settings_contract: soroban_sdk::Address,
) -> 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,
token_address: soroban_sdk::Address,
) -> Result<(), ContractError>