Contract a72a67ac4b9fa0ad561032d8d433d4da0024100cdb27f9098cb89997243b8382

← Back to Index 📥 Download WASM

Meta

cliver 26.0.0#60f7458e7ecffddf2f2d91dc6d0d2db4fab03ecc
rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.91.0-nightly

Instances

  • CAJRGFQSJSWGDYWBYEMTL6YUCGCXAPKIMVJGSATO6HZBG3ZOFP5P5R3Z
  • CBEWCQWMKYRBHN2H6GIEYQS4UACN3DHC3KUXHX5F3AOZAKCG5VI7WGQ4
  • CBF2PQE2VFBZ5FTRMZJ33UVKVINRCC4LE34PZFKW3M7B5ULYTYG2QG4K
  • CCRPBDXYKFWJ7Y7LFU3CWJOCFSP3UQ7NG6BXEQ2MXFKPN3FU7OKDUXRQ
  • CCVM6VJEQSBS35VN4G4TOW423ZFH7KE7HKMS3RYOZUU7GIZ4QDDYCGG6
  • CD7XD52FCKLBM4P5S5VVQ6Q4UFUB2HHDIEZ4JPM77FH5B7W5AZNZQQOP

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: performance fee in basis points, capped at MAX_FEE_BPS (2000 = 20%)
  • soroswap_router: the trusted Soroswap router the add path routes through

Panics

  • If contract is already initialized
  • If fee_cut_bps exceeds MAX_FEE_BPS
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,
    soroswap_router: soroban_sdk::Address,
)

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 the pool owner
  • new_multisig: The new multisig admin address to store

Access

Owner only

Panics

  • If contract is not initialized
  • If caller is not the owner
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, 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 LP/share token address for the active position, derived from the active pool and protocol. ACT_SHARE stores the share count (an i128), not an address, so it is not returned here.

Returns

The LP token address representing the current liquidity position

Panics

If there is no active position, or a pool query fails

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 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 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, the only supported protocol)

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)

Fee taken on the position's gain, measured in a single numeraire (token0). Profit is current_tvl0 - init_tvl0 (both value the whole position in token0 terms); the fee is that gain times the bps, taken in kind as an equal fraction of each held token.

Parameters

  • init_tvl0: token0-denominated value of the position when it was opened
  • init_tvl1: token1-denominated value at open (only the sign is checked)
  • current_tvl0: token0-denominated value now
  • current_tvl1: token1-denominated value now (unused in the profit metric)
  • 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 the position did not gain value in token0 terms

Panics

On arithmetic overflow, or if an initial TVL is negative

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 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)

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) ▶