Contract 52c650a38b4b1688a20eccae73f6dabe1457a6fb024dc8e729455d53c320711e

← Back to Index 📥 Download WASM

Meta

rssdkver 23.0.2#a97daf8b07cdf24e9bd45e344db51a21b9ea77d3
rsver 1.88.0

Instances

  • CBQ5FHBALQNHTMPM7SEBCU24YKW36LW5GSC47OG7G7DUCHMU4DYGO2FA
  • CCYBGAFJ2J3HGOT367ZIMQVOGLU3IBLQ6I5M66QZGP5SBXZ6FVI4KRVB

Interface

Initialize the contract @param env The Soroban environment @param admin The admin address for the contract @param base_uri The base URI for token metadata

fn init(
    env: soroban_sdk::Env,
    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>

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>

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>
fn collect(
    env: soroban_sdk::Env,
    params: CollectParams,
) -> 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

Arguments

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

Imports

WebAssembly Text (WAT) ▶