> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Decode Pump.fun Bonding Curves with Yellowstone gRPC

> Stream Pump.fun bonding curve accounts, decode them with the bundled Anchor IDL, and preserve raw reserve amounts.

Subscribe to Pump.fun bonding curve account writes and decode their reserves and completion flag.

Save the [quickstart helper](https://docs.solanatracker.io/yellowstone-grpc/quickstart.md) as `stream.mts` in the same directory. These examples use the same environment variables and dependencies.

## Install the decoder and IDL

```bash theme={null}
npm install @coral-xyz/anchor @solana/web3.js
curl -L https://docs.solanatracker.io/idl/pump.json -o pump.json
```

Use the [bundled Pump.fun IDL](https://docs.solanatracker.io/idl/pump.json) with this example. It supplies the program address, discriminators, and field names; check compatibility when updating it.

## Decode updates

```typescript pump-accounts.mts theme={null}
import { readFileSync } from "node:fs";
import { BorshAccountsCoder, type Idl } from "@coral-xyz/anchor";
import bs58 from "bs58";
import { subscribe } from "./stream.mts";

const idl = JSON.parse(readFileSync("pump.json", "utf8")) as Idl;
const coder = new BorshAccountsCoder(idl);
const definition = idl.accounts?.find(account => account.name === "BondingCurve");
if (!definition) throw new Error("BondingCurve is missing from the IDL");
const discriminator = Buffer.from(definition.discriminator);

for await (const update of subscribe({
  accounts: {
    curves: {
      account: [], owner: [idl.address],
      filters: [{ memcmp: { offset: "0", bytes: discriminator } }],
    },
  },
})) {
  const account = update.account?.account;
  if (!account) continue;
  try {
    const curve = coder.decode("BondingCurve", Buffer.from(account.data));
    console.log({
      address: bs58.encode(account.pubkey),
      slot: update.account!.slot,
      complete: curve.complete,
      quoteMint: curve.quote_mint.toString(),
      virtualTokenReserves: curve.virtual_token_reserves.toString(),
      virtualQuoteReserves: curve.virtual_quote_reserves.toString(),
    });
  } catch (error) {
    console.error("Bonding curve decode failed; check IDL compatibility", error);
  }
}
```

```bash theme={null}
npx tsx pump-accounts.mts
```

## Read reserves without rounding

The example prints raw reserve integers as strings. Derive display amounts with the token and quote mint decimals. A raw reserve ratio is not a price in SOL per token, and `quote_mint` is not always SOL. Check the current mint data before formatting a price.

## Handle layout changes

The discriminator filter identifies the account type without assuming a fixed total size. Decode errors remain visible rather than silently dropping updates. A completed curve does not provide the full migrated pool state; use the PumpSwap reference or Data API for the new pool.

## Related guides

> [card] [Pump.fun trades](https://docs.solanatracker.io/yellowstone-grpc/examples/pumpfun-transactions.md)

> [card] [Reliability and performance](https://docs.solanatracker.io/yellowstone-grpc/best-practices.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.