SaucerSwap
AppMerchBlog
Developer
Developer
  • Developer Resources
  • REST API
    • Stats
    • Farms
    • Tokens
    • Pools (V1)
    • Pools and Positions (V2)
  • SaucerSwap V1
    • Swap Operations
      • Swap Quote
      • Swap HBAR for Tokens
      • Swap Tokens for Tokens
      • Swap Tokens for HBAR
      • Track Swap Events
    • Liquidity Operations
      • Fetch All Pools
      • Check if a Pool Exists
      • Pool Creation Fee
      • Create a New Pool
      • Get Pool Reserves
      • Track Pool Updates
      • Adding Liquidity
      • Removing Liquidity
  • SaucerSwap V2
    • Swap Operations
      • Swap Quote
      • Swap HBAR for Tokens
      • Swap Tokens for Tokens
      • Swap Tokens for HBAR
      • Track Swap Events
    • Liquidity Operations
      • Fetch all Pools
      • Check if a Pool Exists
      • Fetch Pool Token Ratio
      • Liquidity Position Fee
      • New Liquidity Position
      • Increasing Liquidity
      • Get User Positions
      • Claiming Fees
      • Decreasing Liquidity
  • Staking Operations
    • Single-Sided Staking
    • Yield Farming
  • WHBAR
    • Wrap HBAR for WHBAR
    • Unwrap WHBAR for HBAR
  • Contract Deployments
Powered by GitBook
On this page
  • Data JSON Schema
  • Code Overview
  1. SaucerSwap V2
  2. Liquidity Operations

Get User Positions

Get all liquidity positions for an account.

PreviousIncreasing LiquidityNextClaiming Fees

Last updated 1 year ago

SaucerSwap offers a public endpoint to retrieve all positions for a user, accompanied by useful metadata for each position, including liquidity and fees earned, and their associated tokens. Use the following URL options to access the data.

Hedera Network
URL (where 0.0.xxxx is user's Hedera account, eg. 0.0.1234)

Mainnet

https://api.saucerswap.finance/V2/nfts/0.0.xxxx/positions

Testnet

https://test-api.saucerswap.finance/V2/nfts/0.0.xxxx/positions

Previewnet

Not supported

Data JSON Schema

type ApiNftPositionV2 = {
  tokenSN: number
  accountId: string
  token0: ApiToken | undefined
  token1: ApiToken | undefined
  fee: number
  tickLower: number
  tickUpper: number
  liquidity: number
  feeGrowthInside0LastX128: number
  feeGrowthInside1LastX128: number
  tokensOwed0: number
  tokensOwed1: number
  createdAt: number
  updatedAt: number
  lastSyncedAt: number
  deleted: boolean
}

type ApiToken = {
  decimals: number
  icon?: string
  id: string
  name: string
  price: string
  priceUsd: number
  symbol: string
  dueDiligenceComplete: boolean
  isFeeOnTransferToken: boolean
  timestampSecondsLastListingChange: number
  description: string | null
  website: string | null
  twitterHandle: string | null
  sentinelReport: string | null
}

Code Overview

⛽ No gas cost

const accountId = '0.0.1234';
const url = `https://api.saucerswap.finance/V2/nfts/${accountId}/positions`;  
const response = await axios.get(url);
const positions = response.data;
for (const position of positions as ApiNftPositionV2[] ) {

  const symbol0 = position.token0?.symbol;
  const symbol1 = position.token1?.symbol;
  const feeTier = position.fee / 10_000.0;
  const tickLower = position.tickLower;
  const tickUpper = position.tickLower;

  let output = '';
  output += `NFT SN: ${position.tokenSN}`;
  output += ` - ${symbol0}/${symbol1} @ ${feeTier}%`;
  output += ` - Tick range: ${tickLower} to ${tickUpper}`;

  console.log(output);
}
REST API