Contract bf65ed1b9bd21bc1306d3cde5e55370194bfa7e9e5acf9d71ce50d3ab1f4c7b4

← Back to Index 📥 Download WASM

Meta

cliver 23.4.0#
rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.91.1

Instances

  • CALU3LXG6NI3LREMGX6AWTUV4WMSV6HFBUMR5AKF52B2J3ZK7QUZGRV4

Interface

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 init(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    usdc_asset: soroban_sdk::Address,
    settings_contract: soroban_sdk::Address,
)

Initiate Order Refund (Step 1: State Update)

Description:

Marks an order for refund and calculates refund amounts. This is the first step in the two-step refund process.

Authorization:

  • relayer: Must authorize the state change

Validation:

  • Order must exist and not be fulfilled/refunded
  • Fee must not exceed accumulated protocol fee

State Changes:

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

Events:

  • ("OrderRefunded", order_id) with fee amount
fn refund(
    env: soroban_sdk::Env,
    order_id: soroban_sdk::Bytes,
    fee: i128,
) -> 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, new_wasm_hash: soroban_sdk::BytesN<32>)

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

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,
    tier: ProtocolFees,
    fee_bps: i64,
) -> Result<(), ContractError>

Register a new Liquidity Provider Node

fn register_lp_node(
    env: soroban_sdk::Env,
    lp_node_id: soroban_sdk::Bytes,
    capacity: i128,
) -> Result<(), ContractError>

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

Uses 12 decimal places of internal precision

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. Protocol fee to treasury (if any)
  2. Remaining 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,
) -> 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,
) -> Result<(), ContractError>

Pause Contract Operations

Description:

Emergency function to pause all order creation and settlements.

Authorization:

  • admin: Must authorize the pause

Events:

  • ("Paused",) when contract is paused

Note:

  • Prevents new order creation
  • Existing orders can still be settled/refunded
fn pause(env: soroban_sdk::Env) -> Result<(), ContractError>

Unpause Contract Operations

Description:

Resumes normal contract operations after a pause.

Authorization:

  • admin: Must authorize the unpause

Events:

  • ("Unpaused",) when contract is unpaused
fn unpause(env: soroban_sdk::Env) -> Result<(), ContractError>

Check if Contract is Paused

Returns:

  • true if contract operations are paused
  • false if contract is operational
fn is_paused(env: soroban_sdk::Env) -> bool

Initialize Settings Contract

Description:

Sets up initial protocol configuration with admin, treasury, and relayer addresses.

Default Configuration:

  • Protocol fee: 1% (1000 basis points)
  • Max BPS: 100,000 (100%)
  • Paused: false

Authorization:

  • admin: Must authorize initialization

Parameters:

  • treasury: Address to receive protocol fees
  • relayer_address: Authorized address for settlement operations
fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
    relayer_address: soroban_sdk::Address,
)

Check if Token is Supported

Description:

Currently hardcoded to only support USDC. Can be extended for multi-token support.

Returns:

  • true if token is supported for orders
  • false if token is not supported
fn is_token_supported(env: soroban_sdk::Env, token: soroban_sdk::Address) -> bool

Upgrade Settings Manager WASM

Description:

Updates the settings manager contract's WASM code.

Authorization:

  • admin: Must authorize the upgrade

Note:

  • Maintains all existing settings and state
  • Only admin can perform upgrades
fn upgrade_lp_manager(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

Get Relayer Address

Returns:

  • Current relayer address authorized for settlements
fn get_relayer_address(env: soroban_sdk::Env) -> soroban_sdk::Address

Get Treasury Address

Returns:

  • Current treasury address for fee collection
fn get_treasury_address(env: soroban_sdk::Env) -> soroban_sdk::Address

Update Protocol Addresses

Description:

Updates treasury or relayer addresses with proper validation.

Authorization:

  • admin: Must authorize the change

Parameters:

  • what: Type of address to update (Treasury or Aggregator/Relayer)
  • value: New address value
fn update_protocol_address(
    env: soroban_sdk::Env,
    what: ProtocolAddressType,
    value: soroban_sdk::Address,
) -> Result<(), ContractError>

Imports

WebAssembly Text (WAT) ▶