Saros
  • SAROS
  • SAROS DLMM
  • SAROS AMM
  • SAROS PERPS
  • SAROS MOBILE APP
  • SAROS DLMM
    • Onboarding and Guides
      • Saros DLMM: Introduction
      • Liquidity Lifecycle: Deployment, Management & Rebalancing
      • Permissionless Saros DLMM Pools
      • Understanding Your Risks as a Liquidity Provider on Saros DLMM
    • Shapes and Strategies
      • Liquidity Shapes
      • Getting Started with Basic Liquidity Strategies
      • Advanced Liquidity Strategies on Saros
      • Managing Out-of-Range Liquidity on Saros
      • Single-Sided Liquidity Strategies on Saros
    • Rewards
      • Concentrated Incentives (CI) on Saros
    • Technical Design
    • Technical Guides
      • Add liquidity
      • Create a pair
      • User Position
      • Swap tokens
      • Removing Liquidity
  • SAROS MOBILE APP
    • Mobile App
      • How to install Saros Super App
      • How to set up Saros Super App
      • How to add a new Hot Wallet
      • How to add View-only wallet
      • How to log in to Social Account
      • How to manage wallets
      • How to send or receive a token
      • How to send or receive NFTs
      • How to send multiple NFTs to an address
      • How to swap tokens
      • How to add a custom token
      • How to manage tokens
      • General Settings
      • How to use DApp browser
      • How to turn on Biometric and change Passcode
      • Migrate Ramper V2 on Super App
      • How to use Discover
      • How to buy crypto
    • Extension
      • How to install Saros Wallet Extension
      • How to set up Saros Extension Wallet
      • How to add a new Hot Wallet on Saros Extension
      • How to Add view-only wallet
      • How to manage wallets
      • How to send or receive a token
      • How to send or receive NFTs
      • How to add a custom token?
      • How to manage tokens
      • General settings
      • How to change the password?
      • Migrate Ramper V2 on Extension
      • How to log in to Social Account
      • How to use Discover
      • How to buy crypto
      • How to send multiple NFTs in one transaction with Multisend
      • How to Manage Notifications
      • How to swap on Saros Extension
      • Action on X
    • FAQs
  • SAROS AMM
    • SarosSwap
      • How To Swap on SarosSwap
    • SarosFarm
      • How to Add Liquidity
      • How to Remove Liquidity
      • How to Farm on SarosFarm
      • How to Claim the Reward
    • SarosStake
      • How to stake
      • How to unstake
      • How to harvest
    • SarosSnapShot
    • SarosPerpetual
      • Trading Basics
      • Getting Started
      • Deposit/Withdraw
      • Order Management
    • FAQs
      • Is Saros safe? Has Saros been audited?
      • Why did my transaction fail?
      • How to resolve the "No wallet" error when connecting wallet to Saros Finance
      • What is the difference between APY and APR?
      • How to get farming pool Txid
      • What are liquidity provider tokens?
      • When will you open more pools?
      • What wallets can I use with Saros? How do I connect my wallet to Saros?
      • My LP tokens aren’t showing up on the site or in my wallet?
      • How do I get airdrops?
      • Can I use Saros on my phone?
      • What is price impact?
      • What is slippage tolerance? How can I adjust it when swapping?
      • What fees do I pay when I exchange tokens?
      • Are there any fees associated with the SarosFarm?
      • How to calculate and distribute the reward on SarosFarm?
      • Can I withdraw my liquidity anytime?
      • Where can I check Saros Analytics?
      • I can't find an answer for my question. Where do I find an answer?
      • How could I report a bug?
      • How to check wallet information on Saros
    • Go to DEX
  • SAROS GARDEN
    • Introduction
    • How to stake on Saros Garden
    • How to unstake from Saros Garden
  • ALL ABOUT $SAROS
    • Saros Token ($SAROS)
  • INTEGRATION
    • Saros Super App
    • Saros DEX
  • Saros DLMM
  • LEGAL
    • TERMS OF SERVICE
    • Privacy Policy
  • AUDITS
    • SarosSwap
    • SarosFarm & SarosStake
  • OFFICIAL LINKS
    • Saros Community
    • Brand Assets
Powered by GitBook
On this page
  • Overview
  • Fetching User Positions​
  • 1. Fetch Bin-Level Positions​
  • 2. Fetch Pool-Level Positions​
  1. SAROS DLMM
  2. Technical Guides

User Position

PreviousCreate a pairNextSwap tokens

Last updated 16 days ago

Overview

Once liquidity has been provided, you can retrieve your positions via the Saros DLMM REST API. Two endpoints are offered:

  1. Bin-Level Positions: Retrieves granular details for each bin in your positions.

  2. Pool-Level Positions: Returns aggregated summaries per pool.

Fetching User Positions

After adding liquidity, you can fetch your positions using the Liquidity Book API. There are two endpoints available

1. Fetch Bin-Level Positions

This endpoint returns detailed information about each bin in your positions:

// Fetch bin-level positions
const fetchBinPositions = async (userId: string, pairId?: string) => {
  const params = new URLSearchParams({
    user_id: userId,
    page_num: "1",
    page_size: "100",
  });

  if (pairId) {
    params.append("pair_id", pairId);
  }

  const response = await fetch(`/api/bin-position?${params.toString()}`);
  if (!response.ok) {
    throw new Error("Failed to fetch bin positions");
  }

  return await response.json();
};

// Example usage
const binPositions = await fetchBinPositions(wallet.publicKey.toString());
console.log("Bin positions:", binPositions);

The response includes detailed information about each bin in your positions, including:

  • Bin ID

  • Token amounts in each bin

  • Liquidity shares

  • Price information

This endpoint aggregates your positions by pool, providing a summary of your total liquidity in each pool:

// Fetch pool-level positions
const fetchPoolPositions = async (userId: string, pairId?: string) => {
  const params = new URLSearchParams({
    user_id: userId,
    page_num: "1",
    page_size: "100",
  });

  if (pairId) {
    params.append("pair_id", pairId);
  }

  const response = await fetch(`/api/pool-position?${params.toString()}`);
  if (!response.ok) {
    throw new Error("Failed to fetch pool positions");
  }

  return await response.json();
};

// Example usage
const poolPositions = await fetchPoolPositions(wallet.publicKey.toString());
console.log("Pool positions:", poolPositions);

The response includes aggregated information about your positions in each pool, including:

  • Total liquidity

  • Total token amounts

  • Pool information (fees, token details)

  • Price information

2. Fetch Pool-Level Positions

​
​
​