Initialize the contract. @param env The Soroban environment @param admin The admin address authorized for upgrades @param factory The factory address used to compute pool addresses @param xlm_address The native XLM SAC address @param token_descriptor The token descriptor contract for NFT metadata
fn init(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
factory: soroban_sdk::Address,
xlm_address: soroban_sdk::Address,
token_descriptor: soroban_sdk::Address,
)
fn positions(
env: soroban_sdk::Env,
token_id: u32,
) -> Result
Mint a new position NFT Returns (token_id, liquidity, amount0, amount1)
fn mint(
env: soroban_sdk::Env,
params: MintParams,
) -> Result<(u32, u128, u128, u128), soroban_sdk::Error>
Mint a new position NFT using caller-provided oracle hints
fn mint_with_hints(
env: soroban_sdk::Env,
params: MintParams,
hints: OracleHints,
) -> Result<(u32, u128, u128, u128), soroban_sdk::Error>
Increase liquidity in an existing position Returns (liquidity, amount0, amount1) - the liquidity and amounts added
fn increase_liquidity(
env: soroban_sdk::Env,
params: IncreaseLiquidityParams,
) -> Result<(u128, u128, u128), soroban_sdk::Error>
Increase liquidity using caller-provided oracle hints.
fn increase_liquidity_with_hints(
env: soroban_sdk::Env,
params: IncreaseLiquidityParams,
hints: OracleHints,
) -> Result<(u128, u128, u128), soroban_sdk::Error>
Decrease liquidity from a position Returns (amount0, amount1) - the amounts of tokens removed
fn decrease_liquidity(
env: soroban_sdk::Env,
params: DecreaseLiquidityParams,
) -> Result<(u128, u128), soroban_sdk::Error>
Decrease liquidity from a position using caller-provided oracle hints.
fn decrease_liquidity_with_hints(
env: soroban_sdk::Env,
params: DecreaseLiquidityParams,
hints: OracleHints,
) -> Result<(u128, u128), soroban_sdk::Error>
fn collect(
env: soroban_sdk::Env,
params: CollectParams,
) -> Result<(u128, u128), soroban_sdk::Error>
Collect fees from a position using caller-provided oracle hints.
fn collect_with_hints(
env: soroban_sdk::Env,
params: CollectParams,
hints: OracleHints,
) -> Result<(u128, u128), soroban_sdk::Error>
fn get_token_descriptor(env: soroban_sdk::Env) -> soroban_sdk::Address
fn get_factory(env: soroban_sdk::Env) -> soroban_sdk::Address
fn get_xlm_address(env: soroban_sdk::Env) -> soroban_sdk::Address
Get the owner of a token
fn owner_of(env: soroban_sdk::Env, token_id: u32) -> soroban_sdk::Address
NFT name (for wallets / explorers)
fn name(env: soroban_sdk::Env) -> soroban_sdk::String
NFT symbol (for wallets / explorers)
fn symbol(env: soroban_sdk::Env) -> soroban_sdk::String
Number of position NFTs owned by an address
fn balance(env: soroban_sdk::Env, owner: soroban_sdk::Address) -> u32
Transfer a token from one address to another Requires authorization from the current owner
fn transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
token_id: u32,
)
Approve another address to transfer this token Requires authorization from the owner
fn approve(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
spender: soroban_sdk::Address,
token_id: u32,
expiration_ledger: u32,
)
Get the approved address for a token
fn get_approved(env: soroban_sdk::Env, token_id: u32) -> Option
Set or revoke approval for an operator to manage all of the owner's NFTs Delegates to Base NFT contract's approve_for_all functionality
live_until_ledger - The ledger number at which the approval expires.
If 0, the approval is revoked.fn approve_for_all(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
operator: soroban_sdk::Address,
live_until_ledger: u32,
)
Returns true if operator is approved to manage all of the owner's NFTs Delegates to Base NFT contract's is_approved_for_all functionality
fn is_approved_for_all(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
operator: soroban_sdk::Address,
) -> bool
Transfer from an address (used by approved addresses) The spender must provide authorization
fn transfer_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
token_id: u32,
)
Check if token exists
fn exists(env: soroban_sdk::Env, token_id: u32) -> bool
tokenURI-compatible: gathers all data and passes to descriptor
fn token_uri(env: soroban_sdk::Env, token_id: u32) -> soroban_sdk::String
Burn an NFT position Requires the position to have 0 liquidity and no tokens owed
Matches OpenZeppelin Stellar and Uniswap V3 standard: returns () and panics on error
fn burn(env: soroban_sdk::Env, token_id: u32)
Get all position token IDs owned by a user with pagination Similar to Uniswap V3's Position Helper getUserPositions
Gas Optimization: O(1) lookup using ownership mapping
@param owner The address to query positions for @param skip Number of positions to skip (for pagination) @param take Maximum number of positions to return @return Vec of token IDs
fn get_user_token_ids(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
skip: u32,
take: u32,
) -> soroban_sdk::Vec
Get a single position with live fee calculations Mirrors Solidity V3PositionHelper.getPosition Unlike positions(), this calculates up-to-date fees by querying the pool @param token_id The NFT token ID @return UserPositionInfo with live tokensOwed values
fn get_position_with_fees(
env: soroban_sdk::Env,
token_id: u32,
) -> Result
Get multiple positions with live fee calculations Mirrors Solidity V3PositionHelper.getPositions Unlike positions(), this calculates up-to-date fees by querying the pool @param token_ids Vec of token IDs to query @return Vec of UserPositionInfo with live tokensOwed values
fn get_positions_with_fees(
env: soroban_sdk::Env,
token_ids: soroban_sdk::Vec,
) -> Result, soroban_sdk::Error>
Get all positions owned by a user with pagination and live fee calculations Mirrors Solidity V3PositionHelper.getUserPositions Returns positions with up-to-date fees automatically calculated
Gas Optimization: O(1) lookup using ownership mapping
@param owner The address to query positions for @param skip Number of positions to skip (for pagination) @param take Maximum number of positions to return @return Vec of UserPositionInfo structs with live tokensOwed values
fn get_user_positions_with_fees(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
skip: u32,
take: u32,
) -> Result, soroban_sdk::Error>
Calculate the principal amounts of token0 and token1 for a position's liquidity at a given sqrt price. Mirrors Uniswap V3's PositionValue.principal @param token_id The NFT token ID @param sqrt_price_x96 The sqrt price to use for calculation @return (amount0, amount1) The principal amounts
fn position_principal(
env: soroban_sdk::Env,
token_id: u32,
sqrt_price_x96: soroban_sdk::U256,
) -> Result<(u128, u128), soroban_sdk::Error>
Calculate the uncollected fees for a position Mirrors Uniswap V3's PositionValue.fees @param token_id The NFT token ID @return (fees0, fees1) The uncollected fee amounts
fn position_fees(
env: soroban_sdk::Env,
token_id: u32,
) -> Result<(u128, u128), soroban_sdk::Error>
Calculate the total value of a position (principal + fees) Mirrors Uniswap V3's PositionValue.total @param token_id The NFT token ID @param sqrt_price_x96 The sqrt price to use for principal calculation @return (total0, total1) The total amounts of token0 and token1
fn position_total(
env: soroban_sdk::Env,
token_id: u32,
sqrt_price_x96: soroban_sdk::U256,
) -> Result<(u128, u128), soroban_sdk::Error>
Upgrades this contract's WASM code in place. Only callable by the admin.
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>
Runs post-upgrade migrations. Idempotent. Only callable by the admin.
fn migrate(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
Returns contract code version.
fn version(env: soroban_sdk::Env) -> u32
Returns stored schema version (defaults to 0 for pre-upgrade contracts).
fn schema_version(env: soroban_sdk::Env) -> u32
Transfers admin rights to a new address. Only callable by the current admin.
fn set_admin(
env: soroban_sdk::Env,
new_admin: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
Returns the current admin address.
fn get_admin(env: soroban_sdk::Env) -> Result
Permanently revokes upgradeability by removing the admin key. Only callable by the current admin. This is irreversible.
fn revoke_upgrades_permanently(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>