Initialize the PoolLens with the factory address
env - The Soroban environmentfactory - The DEX factory contract addressfn __constructor(env: soroban_sdk::Env, factory: soroban_sdk::Address)
Get the stored factory address
The factory contract address
fn get_factory(env: soroban_sdk::Env) -> soroban_sdk::Address
Fetch pool data for multiple pools by their addresses
This is the most efficient method when you already know the pool addresses. Uses a single cross-contract call per pool.
env - The Soroban environmentpools - Vector of pool contract addresses to queryVector of PoolData structs in the same order as input.
Each PoolData contains result: Found(state) if initialized, NotFound otherwise.
fn get_pools_data(
env: soroban_sdk::Env,
pools: soroban_sdk::Vec,
) -> soroban_sdk::Vec
Fetch pool data for multiple pools by token pairs
Looks up pool addresses from the factory, then fetches their data. Useful when you have token pairs but not pool addresses.
env - The Soroban environmentpairs - Vector of token pair queries (token_a, token_b, fee)Vector of PoolData structs in the same order as input.
Each PoolData contains result: Found(state) if initialized, NotFound otherwise.
Token order in the query doesn't matter - tokens are sorted internally.
fn get_pools_by_pairs(
env: soroban_sdk::Env,
pairs: soroban_sdk::Vec,
) -> soroban_sdk::Vec
Fetch data for a single pool
env - The Soroban environmentpool - The pool contract addressPoolData struct with all pool information
fn get_pool_data(env: soroban_sdk::Env, pool: soroban_sdk::Address) -> PoolData
Fetch pool data with balances for multiple pools by their addresses.
Same as get_pools_data but includes token reserves (balances).
Costs ~1M extra CPU per pool due to balance lookups.
env - The Soroban environmentpools - Vector of pool contract addresses to queryVector of PoolDataWithBalances structs in the same order as input.
fn get_pools_data_with_bal(
env: soroban_sdk::Env,
pools: soroban_sdk::Vec,
) -> soroban_sdk::Vec
Fetch data with balances for a single pool
env - The Soroban environmentpool - The pool contract addressPoolDataWithBalances struct with pool state and reserves
fn get_pool_data_with_bal(
env: soroban_sdk::Env,
pool: soroban_sdk::Address,
) -> PoolDataWithBalances
Initialize the quoter with factory and WETH9 addresses @param factory The address of the pool factory contract @param xlm The address of the wrapped XLM token
Note: Panics on initialization failure (e.g., if already initialized). This is intentional - a contract that fails to initialize should not be usable.
fn init(
env: soroban_sdk::Env,
factory: soroban_sdk::Address,
xlm: soroban_sdk::Address,
)
Returns the amount out received for a given exact input swap without executing the swap @param token_in The token being swapped in @param token_out The token being swapped out @param fee The fee tier of the pool @param amount_in The amount of input tokens @param sqrt_price_limit_x96 The price limit; 0 for no limit @return amount_out The amount of output tokens that would be received
fn quote_exact_input_single(
env: soroban_sdk::Env,
token_in: soroban_sdk::Address,
token_out: soroban_sdk::Address,
fee: u32,
amount_in: i128,
sqrt_price_limit_x96: soroban_sdk::U256,
) -> Result
Returns the amount out received for a given exact input swap without executing the swap @param path The path of tokens to swap through, encoded as (token0, fee, token1, fee, token2, ...) @param amount_in The amount of the first token to swap @return amount_out The amount of the last token that would be received
fn quote_exact_input(
env: soroban_sdk::Env,
path: soroban_sdk::Bytes,
amount_in: i128,
) -> Result
Returns the amount in required for a given exact output swap without executing the swap @param token_in The token being swapped in @param token_out The token being swapped out @param fee The fee tier of the pool @param amount_out The amount of output tokens desired @param sqrt_price_limit_x96 The price limit; 0 for no limit @return amount_in The amount of input tokens required
fn quote_exact_output_single(
env: soroban_sdk::Env,
token_in: soroban_sdk::Address,
token_out: soroban_sdk::Address,
fee: u32,
amount_out: i128,
sqrt_price_limit_x96: soroban_sdk::U256,
) -> Result
Returns the amount in required to receive the given exact output amount but for a swap of multiple pools @param path The path of tokens to swap through, encoded in REVERSE order (tokenOut, fee, tokenIn, ...) Note: For exact output, the path must be reversed from exact input @param amount_out The amount of the last token to receive @return amount_in The amount of the first token required
fn quote_exact_output(
env: soroban_sdk::Env,
path: soroban_sdk::Bytes,
amount_out: i128,
) -> Result
Initialize the quoter with factory and XLM addresses
Note: Panics on initialization failure (e.g., if already initialized). This is intentional - a contract that fails to initialize should not be usable.
fn init_v2(
env: soroban_sdk::Env,
factory: soroban_sdk::Address,
xlm: soroban_sdk::Address,
)
fn quote_exact_input_v2(
env: soroban_sdk::Env,
path: soroban_sdk::Bytes,
amount_in: i128,
) -> Result
fn quote_exact_output_v2(
env: soroban_sdk::Env,
path: soroban_sdk::Bytes,
amount_out: i128,
) -> Result
fn quote_exact_input_single_v2(
env: soroban_sdk::Env,
params: QuoteExactInputSingleParams,
) -> Result
fn quote_exact_output_single_v2(
env: soroban_sdk::Env,
params: QuoteExactOutputSingleParams,
) -> Result
Gets all populated ticks in a specific word of the tick bitmap
env - The Soroban environmentpool - The address of the pool contracttick_bitmap_index - The index of the tick bitmap word to query (i32)A vector of PopulatedTick structs containing tick index, liquidity_net, and liquidity_gross
This function mirrors the behavior of Uniswap V3's TickLens.getPopulatedTicksInWord:
fn get_populated_ticks_in_word(
env: soroban_sdk::Env,
pool: soroban_sdk::Address,
tick_bitmap_index: i32,
) -> soroban_sdk::Vec