Skip to main content

1. Overview of Pool Monitoring

Fetching liquidity pool details helps developers gain insight into the current state of the pool, whether it is initialized or uninitialized, and retrieve relevant metrics like liquidity, price, and fee rates.

Fetching Accounts

The TypeScript SDK has types setup to help you parse the corresponding accounts on-chain.

1. Account Fetcher

Use the AccountFetcher class’s get functions to fetch and parse the Whirlpool account that you need. Note that this class also provides caching options.
TypeScript

2. Parsing fetched AccountInfo data

If you already have the Buffer from fetching the AccountInfo, use the Parsables classes (eg. ParsableWhirlpool) in the SDK to parse account buffer data into readable types.
TypeScript

Whirlpool Client

If you are already using WhirlpoolClient, you can fetch the data from the Whirlpool or Position class directly.
TypeScript

Deriving Account Addresses

Almost all Whirlpools accounts are Program Derived Addresses. Use the PDAUtil class to derive the required addresses to access on-chain accounts.

3. Using Pool Data

After fetching pool information, you can use it to:
  1. Check if Pool Exists: Determine if a pool for a specific token pair and tick spacing has been created.
  2. Monitor Liquidity: Track the amount of liquidity in the pool over time.
  3. Track Prices: Monitor the current price of tokens in the pool.
  4. Calculate Fees: Calculate expected fees based on the pool’s fee rate and volume.
  5. Data Analytics: Build analytics dashboards tracking pool performance and metrics.

4. Best Practices

When monitoring pools, consider these best practices:
  • Caching: Implement caching to reduce RPC calls, especially for frequently accessed pools.
  • Error Handling: Properly handle cases where pools might not exist.
  • Batch Requests: When possible, batch your requests to reduce the number of RPC calls.
  • Rate Limiting: Be mindful of RPC rate limits when monitoring multiple pools.
  • Data Freshness: Determine how recent the data needs to be for your application.