Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
订阅 Pump.fun bonding curve 账户,用配套 Anchor IDL 解码,并保留原始储备金额。
stream.mts
npm install @coral-xyz/anchor @solana/web3.js curl -L https://docs.solanatracker.io/idl/pump.json -o pump.json
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); } }
npx tsx pump-accounts.mts
quote_mint
此页面对您有帮助吗?