Aquarius Soroban Functions

Brief overview of the available Aquarius Soroban functions

Contract Address

The Aquarius Smart Contractarrow-up-right serving as an entry point for all the AMM functionality is CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUKarrow-up-right

Available Functions

Deposit

The depositarrow-up-right function is used to increase pool liquidity by exchanging tokens for pool share tokens:

fn deposit(
  e: Env,
  user: Address,
  tokens: Vec<Address>,
  pool_index: BytesN<32>,
  desired_amounts: Vec<u128>,
  min_shares: u128,
) -> (Vec<u128>, u128);

Parameters: - user: The address of the user executing withdraw - tokens: Ordered tokens vector - pool_index: Pool hash (see get pools list section) - desired_amounts: Vector of desired amounts to deposit - min_shares: Minimum amount of shares to receive on deposit

The function returns the actual amounts of deposited tokens and minted shares amount.

Withdraw

The withdrawarrow-up-right function is used to remove liquidity from pool, by exchanging pool shares for pool tokens:

Parameters: - user: The address of the user executing withdraw. - tokens: Ordered tokens vector - pool_index: Pool hash (see get pools list section) - share_amount: Amount of shares to withdraw - min_amounts: Vector of minimum amounts to withdraw

The function returns the actual amounts of withdrawn tokens.

Swap Chained

The swap_chainedarrow-up-right function in the Soroban Rust smart contract is used to execute a chain of token swaps to exchange an input token for an output token. The function signature is as follows:

Parameters: - user: The address of the user executing the swaps. - swaps_chain: The series of swaps to be executed. (No need to generate swap chain manually, since this is available in find-path response as SCVal XDR encoded value). Each element in swap chain is represented by a tuple containing:

    • A vector of token addresses liquidity pool belongs to

    • Pool index hash

    • The token to obtain

- token_in: The address of the input token to be swapped. - in_amount: The amount of the input token to be swapped. - out_min: The minimum amount of the output token to be received.

The function returns the amount of the output token received after all swaps have been executed.

Limitations:

  • Up to 4 pools are allowed currently due to Soroban limitations. No contract validation error shall be raised, but transaction wonโ€™t pass simulation and fail with BudgetExceed error.

Last updated