Contract 5a37631f2c1bd57f131848db266bbad707d500005beaafd28757506efae12dc1

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.91.0-nightly

Instances

  • CA5DUZZRD3JRDQLUIFLYAJILFZQDVVVPD7OJ7WNXGHVZCFV6WGFL4ACR
  • CCEAT4ZVH7NF6CQEC4BVP4SBPWKSKN4JFL7OGPXNLAXKHTZ5MH4GJXTV

Interface

Initializes the Lobster contract with owner, multisig admin, token pair, and fee configuration.

Parameters

  • owner: The address of the pool owner who can manage positions
  • multisig: The address of the multisig admin (LOBSTER) that can also manage positions
  • token0: Address of the first token in the pair
  • token1: Address of the second token in the pair
  • fee_cut_bps: Fee percentage in basis points (0-10000, where 10000 = 100%)

Panics

  • If contract is already initialized
  • If fee_cut_bps exceeds 10000
fn __constructor(
    env: soroban_sdk::Env,
    owner: soroban_sdk::Address,
    multisig: soroban_sdk::Address,
    token0: soroban_sdk::Address,
    token1: soroban_sdk::Address,
    fee_cut_bps: u32,
)

Reentrancy guard exit: clears the temporary flag.

fn exit_reentrancy(env: soroban_sdk::Env)

Emergency function to reset reentrancy flag if it gets stuck. This can happen if a panic occurs after enter_reentrancy but before exit_reentrancy. The flag will eventually expire with temporary storage TTL, but this provides immediate recovery.

Parameters

  • caller: The address calling this function (must be owner or admin)

Access

Only owner or multisig admin

Panics

  • If caller is not owner or admin
fn reset_reentrancy(env: soroban_sdk::Env, caller: soroban_sdk::Address)

Returns the address of the contract owner.

Returns

The owner address stored during initialization

Panics

If contract is not initialized

fn get_owner(env: soroban_sdk::Env) -> soroban_sdk::Address

Returns the address of the multisig admin (LOBSTER).

Returns

The multisig admin address stored during initialization

Panics

If contract is not initialized

fn get_multisig(env: soroban_sdk::Env) -> soroban_sdk::Address

Updates the multisig admin (LOBSTER) address.

Parameters

  • caller: Must be either the pool owner or current multisig admin
  • new_multisig: The new multisig admin address to store

Access

Only owner or multisig admin

Panics

  • If contract is not initialized
  • If caller is not authorized
fn set_multisig(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_multisig: soroban_sdk::Address,
)

Returns the address of the first token (token0) in the pair.

Returns

The token0 address stored during initialization

Panics

If contract is not initialized

fn get_token0(env: soroban_sdk::Env) -> soroban_sdk::Address

Returns the address of the second token (token1) in the pair.

Returns

The token1 address stored during initialization

Panics

If contract is not initialized

fn get_token1(env: soroban_sdk::Env) -> soroban_sdk::Address

Returns the currently active DEX protocol identifier.

Returns

Protocol identifier: 0 = Soroswap, 1 = Phoenix, 2 = Aquarius, 5 = No active position

Panics

If contract is not initialized

fn get_active_protocol(env: soroban_sdk::Env) -> i128

Returns the address of the currently active liquidity pool.

Returns

The pool address where liquidity is currently deployed

Panics

If contract is not initialized or no active pool exists

fn get_actual_pool(env: soroban_sdk::Env) -> soroban_sdk::Address

Returns the address of the currently active router (for Soroswap).

Returns

The router address used for Soroswap operations

Panics

If contract is not initialized or no active router exists

fn get_actual_router(env: soroban_sdk::Env) -> soroban_sdk::Address

Returns the address of the LP token/share token for the active position.

Returns

The LP token address representing the current liquidity position

Panics

If contract is not initialized or no active position exists

fn get_actual_share(env: soroban_sdk::Env) -> soroban_sdk::Address

Pull tokens from caller into this contract using transfer_from. Access: only owner or multisig admin.

fn deposit(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    amount0: i128,
    amount1: i128,
)

Public entry point for adding liquidity to a Phoenix pool. Validates access and delegates to internal implementation.

Parameters

  • caller: Address of the caller (must be owner or multisig admin)
  • amount0: Desired amount of token0 to add
  • amount1: Desired amount of token1 to add
  • amount0_min: Minimum amount of token0 to accept (slippage protection)
  • amount1_min: Minimum amount of token1 to accept (slippage protection)
  • pool_address: Address of the Phoenix pool
  • deadline: Ledger number deadline for the transaction
  • slippage: Allowed slippage in basis points

Access

Only owner or multisig admin

fn add_liquidity_phoenix(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    amount0: i128,
    amount1: i128,
    amount0_min: i128,
    amount1_min: i128,
    pool_address: soroban_sdk::Address,
    deadline: u64,
    slippage: i64,
)

Calculates optimal deposit amounts for adding liquidity while maintaining pool ratio. Ensures amounts respect minimum requirements and allowed slippage.

Parameters

  • desired_a: Desired amount of token A to deposit
  • min_a: Optional minimum amount of token A (slippage protection)
  • desired_b: Desired amount of token B to deposit
  • min_b: Optional minimum amount of token B (slippage protection)
  • pool_balance_a: Current balance of token A in the pool
  • pool_balance_b: Current balance of token B in the pool
  • my_allowed_slippage: Allowed slippage in basis points

Returns

Tuple of (optimal_amount_a, optimal_amount_b) that maintains pool ratio

Panics

  • If desired amounts are <= 0
  • If min amounts are negative
  • If calculated amounts exceed allowed slippage
  • If calculated amounts are below minimum requirements
fn get_deposit_amounts(
    env: soroban_sdk::Env,
    desired_a: i128,
    min_a: Option,
    desired_b: i128,
    min_b: Option,
    pool_balance_a: i128,
    pool_balance_b: i128,
    my_allowed_slippage: i64,
) -> (i128, i128)

Public entry point for adding liquidity to a Soroswap pool via router. Validates access and delegates to internal implementation.

Parameters

  • caller: Address of the caller (must be owner or multisig admin)
  • amount0: Desired amount of token0 to add
  • amount1: Desired amount of token1 to add
  • amount0_min: Minimum amount of token0 to accept (slippage protection)
  • amount1_min: Minimum amount of token1 to accept (slippage protection)
  • deadline_ledger: Ledger number deadline for the transaction
  • router_address: Address of the Soroswap router

Access

Only owner or multisig admin

fn add_liquidity_soroswap(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    amount0: i128,
    amount1: i128,
    amount0_min: i128,
    amount1_min: i128,
    deadline_ledger: u64,
    router_address: soroban_sdk::Address,
)

Public entry point for adding liquidity to an Aquarius pool. Validates access and delegates to internal implementation.

Parameters

  • caller: Address of the caller (must be owner or multisig admin)
  • amount0: Amount of token0 to add
  • amount1: Amount of token1 to add
  • pool_address: Address of the Aquarius pool

Access

Only owner or multisig admin

fn add_liquidity_aquarius(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    amount0: i128,
    amount1: i128,
    pool_address: soroban_sdk::Address,
)

Public entry point for withdrawing all liquidity from an Aquarius pool. Validates access and delegates to internal implementation.

Parameters

  • caller: Address of the caller (must be owner or multisig admin)
  • pool_address: Address of the Aquarius pool to withdraw from
  • amount0_min: Minimum amount of token0 to receive (slippage protection)
  • amount1_min: Minimum amount of token1 to receive (slippage protection)

Access

Only owner or multisig admin

fn withdraw_aquarius(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    pool_address: soroban_sdk::Address,
    amount0_min: u128,
    amount1_min: u128,
)

Returns the current LP token balance and LP token address for an Aquarius pool.

Parameters

  • pool_address: Address of the Aquarius pool

Returns

Tuple of (lp_balance, lp_token_address) - current LP balance and LP token contract address

Panics

If pool queries fail

fn get_lp_aquarius(
    env: soroban_sdk::Env,
    pool_address: soroban_sdk::Address,
) -> (i128, soroban_sdk::Address)

Public entry point for withdrawing all liquidity from a Phoenix pool. Validates access and delegates to internal implementation.

Parameters

  • caller: Address of the caller (must be owner or multisig admin)
  • pool_address: Address of the Phoenix pool to withdraw from
  • amount0_min: Minimum amount of token0 to receive (slippage protection)
  • amount1_min: Minimum amount of token1 to receive (slippage protection)
  • deadline: Ledger number deadline for the transaction

Access

Only owner or multisig admin

fn withdraw_phoenix(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    pool_address: soroban_sdk::Address,
    amount0_min: i128,
    amount1_min: i128,
    deadline: u64,
)

Returns the current LP token balance and LP token address for a Phoenix pool.

Parameters

  • pool_address: Address of the Phoenix pool

Returns

Tuple of (lp_balance, lp_token_address) - current LP balance and LP token contract address

Panics

If pool queries fail

fn get_lp_phoenix(
    env: soroban_sdk::Env,
    pool_address: soroban_sdk::Address,
) -> (i128, soroban_sdk::Address)

Public entry point for withdrawing all liquidity from a Soroswap pool via router. Validates access and delegates to internal implementation.

Parameters

  • caller: Address of the caller (must be owner or multisig admin)
  • amount0_min: Minimum amount of token0 to receive (slippage protection)
  • amount1_min: Minimum amount of token1 to receive (slippage protection)
  • pool_address: Address of the Soroswap pool to withdraw from
  • router_address: Address of the Soroswap router
  • deadline: Ledger number deadline for the transaction

Access

Only owner or multisig admin

fn withdraw_soroswap(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    amount0_min: i128,
    amount1_min: i128,
    pool_address: soroban_sdk::Address,
    router_address: soroban_sdk::Address,
    deadline: u64,
)

Returns the current LP token balance for a Soroswap pool. In Soroswap, the LP token is the pool address itself.

Parameters

  • pool_address: Address of the Soroswap pool (also the LP token address)

Returns

Current LP token balance held by this contract

Panics

If balance query fails

fn get_lp_soroswap(env: soroban_sdk::Env, pool_address: soroban_sdk::Address) -> i128

Public entry point for withdrawing tokens directly from the contract balance. Transfers tokens from contract to owner without interacting with pools.

Parameters

  • caller: Address of the caller (must be owner or multisig admin)
  • amount0: Amount of token0 to withdraw
  • amount1: Amount of token1 to withdraw

Access

Only owner or multisig admin

fn withdraw_contract(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    amount0: i128,
    amount1: i128,
)

Retrieves token reserves from a pool, handling different DEX protocols. Returns reserves in pool order (not contract order) to maintain consistency with amounts from correct_token_order and TVL calculations.

Parameters

  • pool_address: Address of the liquidity pool
  • protocol_tvl: Protocol identifier (0 = Soroswap, 1 = Phoenix, 2 = Aquarius)

Returns

Tuple of (reserve0, reserve1) in pool order (pool's token0, pool's token1)

Panics

  • If protocol is invalid
  • If reserves are zero
  • If pool query fails
fn get_reserves(
    env: soroban_sdk::Env,
    pool_address: soroban_sdk::Address,
    protocol_tvl: u32,
) -> (i128, i128)

Calculates token prices from pool reserves.

Parameters

  • reserve0: Reserve amount of token0 in the pool
  • reserve1: Reserve amount of token1 in the pool

Returns

Tuple of (price_0_in_1, price_1_in_0) where:

  • price_0_in_1: Price of token0 denominated in token1
  • price_1_in_0: Price of token1 denominated in token0

Panics

  • If reserves are zero (division by zero)
  • On arithmetic overflow
fn get_prices_from_reserves(
    env: soroban_sdk::Env,
    reserve0: i128,
    reserve1: i128,
) -> (i128, i128)

Calculates Total Value Locked (TVL) for both tokens in the position. TVL represents the total value of tokens, accounting for their relative prices.

Parameters

  • amount0: Amount of token0
  • amount1: Amount of token1
  • price0_in_1: Price of token0 in terms of token1
  • price1_in_0: Price of token1 in terms of token0

Returns

Tuple of (token0_tvl, token1_tvl) where:

  • token0_tvl: Total value of position in token0 terms
  • token1_tvl: Total value of position in token1 terms

Panics

On arithmetic overflow

fn get_token_tvl_from_reserves(
    env: soroban_sdk::Env,
    amount0: i128,
    amount1: i128,
    price0_in_1: i128,
    price1_in_0: i128,
) -> (i128, i128)

Calculates the fee amount to be deducted from profits on each token. Fee is calculated as a percentage of total profit, distributed proportionally.

Parameters

  • init_tvl0: Initial TVL in token0 terms when position was opened
  • init_tvl1: Initial TVL in token1 terms when position was opened
  • current_tvl0: Current TVL in token0 terms
  • current_tvl1: Current TVL in token1 terms
  • current_amount0: Current amount of token0
  • current_amount1: Current amount of token1

Returns

Tuple of (fee_token0, fee_token1) - fee amounts in each token Returns (0, 0) if there's no profit or total TVL is zero

Panics

On arithmetic overflow

fn get_fee_cut(
    env: soroban_sdk::Env,
    init_tvl0: i128,
    init_tvl1: i128,
    current_tvl0: i128,
    current_tvl1: i128,
    current_amount0: i128,
    current_amount1: i128,
) -> (i128, i128)

Retrieves the underlying token amounts represented by LP position in a Phoenix pool.

Parameters

  • pool_address: Address of the Phoenix pool

Returns

Tuple of (amount_a, amount_b) ordered to match contract's token0/token1

Panics

If pool query fails or LP balance cannot be determined

fn get_amounts_from_phoenix(
    env: soroban_sdk::Env,
    pool_address: soroban_sdk::Address,
) -> (i128, i128)

Retrieves the underlying token amounts represented by LP position in a Soroswap pool. Calculates amounts proportionally based on LP share of total supply.

Parameters

  • pool_address: Address of the Soroswap pool

Returns

Tuple of (amount_a, amount_b) ordered to match contract's token0/token1

Panics

If pool query fails or calculation overflows

fn get_amounts_from_soroswap(
    env: soroban_sdk::Env,
    pool_address: soroban_sdk::Address,
) -> (i128, i128)

Retrieves the underlying token amounts represented by LP position in an Aquarius pool. Calculates amounts proportionally based on LP share of total supply.

Parameters

  • pool_address: Address of the Aquarius pool

Returns

Tuple of (amount_a, amount_b) ordered to match contract's token0/token1

Panics

If pool query fails or calculation overflows

fn get_amounts_from_aquarius(
    env: soroban_sdk::Env,
    pool_address: soroban_sdk::Address,
) -> (i128, i128)

Returns the current token balances held directly by this contract (not in pools).

Returns

Tuple of (amount0, amount1) - current balances of token0 and token1 in contract

Panics

If token balance queries fail

fn get_amounts_tokens(env: soroban_sdk::Env) -> (i128, i128)

Imports

WebAssembly Text (WAT) ▶