Contract a8e494180c0683a17671f9d14ea2add484927907b021d0c8d2ed23cecd705e02

← Back to Index 📥 Download WASM

Meta

rssdkver 20.5.0#9e2c3022b4355b224a7a814e13ba51761eeb14bb
rsver 1.77.2

Instances

  • CCBKDA7BGP7RZW27LWAMZXXB6FN26JE6YWYLGFZXLGOKQUM2UPAVENWK
  • CDY42XTTOMEXFYXWCEHYYBB4NY4XCA56RNZKKLYUCSRIMTNQD4GIYTGR

Interface

Initializes the contract and sets the factory address

fn initialize(
    env: soroban_sdk::Env,
    factory: soroban_sdk::Address,
) -> Result<(), RouterErrorsForLibrary>

Adds liquidity to a token pair's pool, creating it if it doesn't exist. Ensures that exactly the desired amounts of both tokens are added, subject to minimum requirements. This function is responsible for transferring tokens from the user to the pool and minting liquidity tokens in return.

Returns

A tuple containing: amounts of token A and B added to the pool. plus the amount of liquidity tokens minted.

fn add_liquidity(
    env: soroban_sdk::Env,
    token_a: soroban_sdk::Address,
    token_b: soroban_sdk::Address,
    amount_a_desired: i128,
    amount_b_desired: i128,
    amount_a_min: i128,
    amount_b_min: i128,
    to: soroban_sdk::Address,
    deadline: u64,
) -> Result<(i128, i128, i128), RouterErrorsForLibrary>

Removes liquidity from a token pair's pool.

This function facilitates the removal of liquidity from a RaumFi Liquidity Pool by burning a specified amount of Liquidity Pool tokens (liquidity) owned by the caller. In return, it transfers back the corresponding amounts of the paired tokens (token_a and token_b) to the caller's specified address (to).

Returns

A tuple containing the amounts of token_a and token_b withdrawn from the pool.

fn remove_liquidity(
    env: soroban_sdk::Env,
    token_a: soroban_sdk::Address,
    token_b: soroban_sdk::Address,
    liquidity: i128,
    amount_a_min: i128,
    amount_b_min: i128,
    to: soroban_sdk::Address,
    deadline: u64,
) -> Result<(i128, i128), RouterErrorsForLibrary>

Swaps an exact amount of input tokens for as many output tokens as possible along the specified trading route. The route is determined by the path vector, where the first element is the input token, the last is the output token, and any intermediate elements represent pairs to trade through if a direct pair does not exist.

Returns

A vector containing the amounts of tokens received at each step of the trading route.

fn swap_exact_tokens_for_tokens(
    env: soroban_sdk::Env,
    amount_in: i128,
    amount_out_min: i128,
    path: soroban_sdk::Vec,
    to: soroban_sdk::Address,
    deadline: u64,
) -> Result, RouterErrorsForLibrary>

Swaps tokens for an exact amount of output token, following the specified trading route. The route is determined by the path vector, where the first element is the input token, the last is the output token, and any intermediate elements represent pairs to trade through.

Returns

A vector containing the amounts of tokens used at each step of the trading route.

fn swap_tokens_for_exact_tokens(
    env: soroban_sdk::Env,
    amount_out: i128,
    amount_in_max: i128,
    path: soroban_sdk::Vec,
    to: soroban_sdk::Address,
    deadline: u64,
) -> Result, RouterErrorsForLibrary>

This function retrieves the factory contract's address associated with the provided environment. It also checks if the factory has been initialized and raises an assertion error if not. If the factory is not initialized, this code will raise an assertion error with the message "RaumFiRouter: not yet initialized".

Arguments

  • e - The contract environment (Env) in which the contract is executing.
fn get_factory(
    env: soroban_sdk::Env,
) -> Result

Calculates the deterministic address for a pair without making any external calls. check https://github.com/paltalabs/deterministic-address-soroban

Returns

Returns Result<Address, RaumFiLibraryError> where Ok contains the deterministic address for the pair, and Err indicates an error such as identical tokens or an issue with sorting.

fn router_pair_for(
    env: soroban_sdk::Env,
    token_a: soroban_sdk::Address,
    token_b: soroban_sdk::Address,
) -> Result

Given some amount of an asset and pair reserves, returns an equivalent amount of the other asset.

Returns

Returns Result<i128, RaumFiLibraryError> where Ok contains the calculated equivalent amount, and Err indicates an error such as insufficient amount or liquidity

fn router_quote(
    env: soroban_sdk::Env,
    amount_a: i128,
    reserve_a: i128,
    reserve_b: i128,
) -> Result

Given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset.

Returns

Returns Result<i128, RaumFiLibraryError> where Ok contains the calculated maximum output amount, and Err indicates an error such as insufficient input amount or liquidity.

fn router_get_amount_out(
    env: soroban_sdk::Env,
    amount_in: i128,
    reserve_in: i128,
    reserve_out: i128,
) -> Result

Given an output amount of an asset and pair reserves, returns a required input amount of the other asset.

Returns

Returns Result<i128, RaumFiLibraryError> where Ok contains the required input amount, and Err indicates an error such as insufficient output amount or liquidity.

fn router_get_amount_in(
    env: soroban_sdk::Env,
    amount_out: i128,
    reserve_in: i128,
    reserve_out: i128,
) -> Result

Performs chained get_amount_out calculations on any number of pairs.

Returns

Returns Result<Vec<i128>, RaumFiLibraryError> where Ok contains a vector of calculated amounts, and Err indicates an error such as an invalid path.

fn router_get_amounts_out(
    env: soroban_sdk::Env,
    amount_in: i128,
    path: soroban_sdk::Vec,
) -> Result, RouterErrorsForLibrary>

Performs chained get_amount_in calculations on any number of pairs.

Returns

Returns Result<Vec<i128>, RaumFiLibraryError> where Ok contains a vector of calculated amounts, and Err indicates an error such as an invalid path.

fn router_get_amounts_in(
    env: soroban_sdk::Env,
    amount_out: i128,
    path: soroban_sdk::Vec,
) -> Result, RouterErrorsForLibrary>

Imports

WebAssembly Text (WAT) ▶