Solana Tracker LogoSolana Tracker
Swap
Developers
⌘K
Affiliate
All Resources
Track Solana Liquidity Adds and Removes with SDK 0.5
Data APITypeScriptSeptember 20, 20264 min readSolana Tracker

Track Solana Liquidity Adds and Removes with SDK 0.5

Build a Solana LP activity feed with SDK 0.5.0. Query mixed history, preserve exact token amounts, stream liquidity, and reconcile provisional events.

  • data-api,
  • liquidity,
  • websocket,
  • typescript

A swap-only tape cannot show when liquidity enters or leaves a pool. SDK 0.5.0 adds opt-in liquidity history and live subscriptions so you can display swaps, LP additions, and LP removals without pretending they share the same amount fields.

Select a history mode

The new history methods accept events: 'trades', 'liquidity', or 'all'. Existing getTokenTrades calls retain their swaps-only behavior. Use a new history method when adding an All / Swaps / Liquidity control to a product.

Run the Node.js example

Use Node.js 24 LTS and keep the API credentials on your server. Create an empty directory, then install:

npm init -y
npm install @solana-tracker/[email protected]
npm install --save-dev tsx typescript @types/node

Save the TypeScript block as index.mts. Put ST_API_KEY in an uncommitted .env file. Streaming examples also need ST_DATASTREAM_URL, the full private WebSocket URL from your Data API dashboard. REST and streaming access depend on your plan.

node --env-file=.env --import tsx index.mts
import { Client } from '@solana-tracker/data-api';
const apiKey = process.env.ST_API_KEY;
if (!apiKey) throw new Error('Set ST_API_KEY');
const client = new Client({ apiKey });
const mint = process.env.TOKEN_MINT ?? 'So11111111111111111111111111111111111111112';
const options = { events: 'all', enrich: 'identity', limit: 100,
  sortDirection: 'DESC' } as const;
const page = await client.getTokenTradeHistory(mint, options);
for (const event of page.trades) {
  switch (event.type) {
    case 'buy':
    case 'sell':
      console.log('Swap:', event.amount, event.priceUsd);
      break;
    case 'add_liquidity':
    case 'remove_liquidity':
      console.log('LP action:', event.pool, event.tokens);
      break;
  }
}
if (page.hasNextPage && page.nextCursor != null) {
  const next = await client.getTokenTradeHistory(mint, {
    ...options, cursor: page.nextCursor,
  });
  console.log('Next page:', next.trades.length);
}

The array is named trades even for liquidity and mixed modes. limit accepts 1–500 rows. Keep cursor values unchanged: liquidity and mixed feeds use opaque strings, while swaps use timestamp cursors. Do not parse a string cursor as a date or discard a numeric zero with a truthiness check.

Preserve exact LP amounts

Each liquidity token has string amount and amountRaw values. Store those strings or use decimal/integer arithmetic. Converting a large raw amount to JavaScript Number can silently round it.

amountBasis distinguishes transfer observations from principal accounting. Transfer amounts can be gross of Token-2022 withholding; principal amounts separate the position amount from fees or internal reallocations. Optional fee and transferred-amount fields carry additional context.

An LP row has no swap price, swap volume, or PnL field. Keep the token units visible. If you calculate a USD estimate, identify the price source and observation time, and label it as a derived estimate.

Add live liquidity to a separate process

Save the next block as stream.mts, set ST_DATASTREAM_URL, and run it with the same Node command used above, replacing the filename.

import { Datastream } from '@solana-tracker/data-api';
const wsUrl = process.env.ST_DATASTREAM_URL;
if (!wsUrl) throw new Error('Set ST_DATASTREAM_URL from your dashboard');
const ds = new Datastream({ wsUrl });
ds.on('error', () => console.error('Datastream connection error'));
process.once('SIGINT', () => ds.disconnect());
const mint = process.env.TOKEN_MINT ?? 'So11111111111111111111111111111111111111112';
ds.subscribe.liquidity.token(mint, { enriched: true }).on((event) => {
  console.log(event.type, event.tokens, event.identity);
});

Use token, pool, wallet, token+pool, or token+pool+wallet scope according to the screen. A combined live feed also needs a swap subscription. Choose scopes that minimize overlapping delivery.

Reconcile instead of assuming exactly-once delivery

Live LP events are provisional at processed commitment. There are no rollback notifications. After reconnecting, load REST history for the affected window and reconcile it; live and historical timestamps can differ.

Do not deduplicate LP activity by signature alone, or even by signature plus pool plus wallet. Several distinct actions can share those fields. When the available event identity cannot distinguish live observations reliably, replace a bounded window from REST rather than collapsing valid actions.

Identity is current enrichment, not a historical identity snapshot. Partial enriched notifications do not receive a later correction automatically.

FAQ

Will existing trade subscriptions start sending LP events?

No. Existing transaction rooms remain swaps-only.

Can LP amounts be summed into trade volume?

No. They are token-unit position actions, not swap USD volume.

Does removing liquidity prove a rug?

No. It can reflect ordinary position management. Inspect pool depth and context before interpreting it.

References

  • Liquidity API workflow
  • SDK 0.5.0 release notes

Related Guides

Stream Solana Trades: Backfill and Live Activity
Data API

Stream Solana Trades: Backfill and Live Activity

Read more
Stream Solana Token Prices with WebSocket
Data API

Stream Solana Token Prices with WebSocket

Read more
Track Jupiter DCA Orders with REST and WebSocket
Data API

Track Jupiter DCA Orders with REST and WebSocket

Read more

Products

  • Data API
  • Pump.fun API
  • Solana RPC
  • Dedicated Nodes
  • Yellowstone gRPC
  • Raptor Swap API
  • Enterprise

Trading

  • Swap
  • Latest Tokens
  • Trending
  • Top Gainers
  • Memescope
  • Whale Watch
  • KOL Tracker

Tools

  • Wallet Tracker
  • Rugcheck
  • PnL Leaderboard
  • KOLScan
  • Axiom Leaderboard
  • Photon Leaderboard
  • Bloom Leaderboard
  • FOMO Leaderboard
  • GMGN Leaderboard
  • Pump.fun App Leaderboard
  • Terminal Leaderboard
  • Platform Compare
  • My Positions
  • Teams

Resources

  • Developer Guides
  • Blog
  • Documentation
  • API Reference
  • Status
  • Affiliate Program — 25% recurring, uncapped
Solana TrackerSolana Tracker© 2026
Terms of ServicePrivacy PolicyContact