Contract 446f601635f38d2f7550cff14e784c26b7abd4138170cfa9ae1692e972cda357

← Back to Index 📥 Download WASM

Meta

cliver 26.1.0#1228cff8022b804659750b94b315932b0e0f3f6a
rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.95.0

Instances

  • CALU3LXG6NI3LREMGX6AWTUV4WMSV6HFBUMR5AKF52B2J3ZK7QUZGRV4

Interface

Initiate Order Refund (Step 1: State Update)

Description:

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.

Authorization:

  • relayer: Must authorize the state change

Validation:

  • Order must exist and not be fulfilled/refunded
  • No pending settlement must exist for this order

State Changes:

  • Marks order as refunded
  • Zeros out order amounts
  • Stores pending refund for transfer execution

Events:

  • ("OrderRefunded", order_id)
fn refund(
    env: soroban_sdk::Env,
    order_id: soroban_sdk::Bytes,
) -> Result<(), ContractError>

Settle an order (Step 1: State Update)

Description:

Updates order state and calculates settlement amounts. This is the first step in the two-step settlement process. No tokens are transferred here.

Authorization:

  • relayer: Must authorize the state change

Validation:

  • Order must exist and not be fulfilled/refunded
  • Settle percent must be valid (0 < percent ≤ 100,000)
  • Order must have sufficient remaining BPS

State Changes:

  • Updates order amount and current_bps
  • Marks order as fulfilled if current_bps reaches 0
  • Stores pending settlement for transfer execution

Events:

  • ("OrderSettled", order_id, liquidity_provider) with settle_percent

Parameters:

  • order_id: Unique identifier for the order
  • liquidity_provider: Address to receive settled funds
  • settle_percent: Percentage to settle (in basis points, 100,000 = 100%)

Returns:

  • Ok(true) on successful state update
  • Err(ContractError) on failure
fn settle(
    env: soroban_sdk::Env,
    order_id: soroban_sdk::Bytes,
    liquidity_provider: soroban_sdk::Address,
    settle_percent: i128,
) -> Result

Upgrade Contract WASM

Description:

Updates the contract's WASM code for upgrades and bug fixes.

Authorization:

  • admin: Must authorize the upgrade

Note:

  • Only admin can upgrade the contract
  • Ensures contract upgradeability while maintaining state
fn 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>

Create a new liquidity order

Description:

Creates a new order and transfers funds from sender to temporary wallet. The order enters a pending state until settled or refunded.

Authorization:

  • params.sender: Must authorize the token transfer

Validation:

  • Contract must not be paused
  • Amount must be positive
  • Message hash must not be empty
  • Order ID must not already exist

Events:

  • ("OrderCreated", order_id, sender) with order details

Parameters:

  • env: Soroban environment
  • params: Order creation parameters

Returns:

  • Ok(()) on success
  • Err(ContractError) on failure
fn create_order(
    env: soroban_sdk::Env,
    params: OrderParams,
) -> Result<(), ContractError>

Get the current fee percentage for a tier

fn get_tier_fee(env: soroban_sdk::Env, tier: ProtocolFees) -> i64

Initialize the LP Contract with Tiered Fees

Description:

Sets up the contract with required addresses and configures tier fees.

Fee Configuration:

  • BasicProvider: 0.4% (400 basis points)
  • AlphaProvider: 0.3% (300 basis points)
  • UltimateProvider: 0.2% (200 basis points)
fn __constructor(
    env: soroban_sdk::Env,
    usdc_asset: soroban_sdk::Address,
    settings_contract: soroban_sdk::Address,
)

Get complete order information

Returns:

  • Full Order struct if order exists
  • Error if order not found
fn get_order_info(
    env: soroban_sdk::Env,
    order_id: soroban_sdk::Bytes,
) -> Result

Update fee percentage for a tier (admin only)

Description:

Allows admin to update the fee percentage for any tier.

Parameters:

  • tier: The tier to update
  • fee_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)

Get token balance for a user

Returns:

  • USDC balance of the specified user
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

Execute Refund Transfers (Step 2: Token Transfer)

Description:

Executes the actual token transfers for a previously refunded order. This is the second step in the two-step refund process.

Authorization:

  • order.temporary_wallet_address: Must authorize the token transfers

Transfers:

  1. Full amount to refund address

Note:

  • Only executes if pending refund exists
  • Clears pending refund after execution
fn 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>

Execute Settlement Transfers (Step 2: Token Transfer)

Description:

Executes the actual token transfers for a previously settled order. This is the second step in the two-step settlement process.

Authorization:

  • order.temporary_wallet_address: Must authorize the token transfers

Transfers:

  1. Protocol fee to treasury (if any)
  2. Remaining amount to liquidity provider

Events:

  • ("SettlementTransferred", order_id) with settle_percent

Note:

  • Only executes if pending settlement exists
  • Clears pending settlement after execution
  • Temporary wallet maintains control of funds until this point
fn execute_settlement_transfer(
    env: soroban_sdk::Env,
    order_id: soroban_sdk::Bytes,
    token_address: soroban_sdk::Address,
) -> Result<(), ContractError>

Imports

WebAssembly Text (WAT) ▶