Fetch and query a Raydium Launchpad Bonding Curve or other pool info based on pool address.
Each Launchpad pool uses a bonding curve to manage price and token distribution. By querying the pool using its address, we can fetch detailed curve parameters like virtual reserves, tokens sold, and total funds raised. Shyft's GraphQL API enables us to query and filter pool data based on any available field. Here, we filter by the pubkey field to fetch the bonding curve details for the corresponding pool.
You can directly copy paste this code on replit and see it in action.
Fetch parsed Bonding curve pool info
async function getBondingCurveByPoolAddress(address) {
const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
//query to get Bonding Curve details on Launchpad by pool address
const operationsDoc = `
query MyQuery {
raydium_launchpad_PoolState(
where: {pubkey: {_eq: ${JSON.stringify(address)}}}
) {
supply
total_base_sell
total_quote_fund_raising
virtual_base
virtual_quote
real_base
real_quote
pubkey
}
}`; //you can cherrypick the fields as per your requirement
const result = await fetch(
`https://programs.shyft.to/v0/graphql/accounts?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
{
method: "POST",
body: JSON.stringify({
query: operationsDoc,
variables: {},
operationName: "MyQuery",
}),
}
);
const { errors, data } = await result.json();
if (errors) {
console.error(errors);
console.log(
"Failed to fetch data, please provide correct API key or pool address."
);
return;
}
console.dir(data, { depth: null });
}
getBondingCurveByPoolAddress("4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU");
The response contains the following fields which involves the fields of the bonding curve
supply: Total base token supply in the bonding curve.
total_base_sell: Total base tokens sold so far via the curve.
total_quote_fund_raising: Total SOL (quote tokens) raised from buyers.
virtual_base & virtual_quote: Curve parameters that define price behavior depending on the curve type (e.g., for Constant Product or Fixed Price).
real_base & real_quote: Actual on-chain token balances in the pool vaults (useful for pricing and tracking liquidity backing).
curveType (Available on Global Config): A curvetype 0 indicates a constant curve, 1 means constant price, and 2 means linear. This data is essential for token price calculation.
However, these are not the only fields available in the PoolState account, other fields such as quote_mint, base_mint can also be cherrypicked, or omitted as per your requirement.
In the next example we will explore how we can fetch more Pool details on Raydium Launchpad, which is as simple as adding more fields on the request query.
Fetch parsed Bonding curve pool info
async function getDetailsByPoolAddress(address) {
const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
//query to get Pool details on Launchpad by pool address
const operationsDoc = `
query MyQuery {
raydium_launchpad_PoolState(
where: {pubkey: {_eq: ${JSON.stringify(address)}}}
) {
supply
total_base_sell
total_quote_fund_raising
virtual_base
virtual_quote
real_base
real_quote
pubkey
migrate_type
migrate_fee
base_mint
base_vault
base_decimals
quote_vault
quote_mint
quote_decimals
}
}`; //more fields are selected here
const result = await fetch(
`https://programs.shyft.to/v0/graphql/accounts?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
{
method: "POST",
body: JSON.stringify({
query: operationsDoc,
variables: {},
operationName: "MyQuery",
}),
}
);
const { errors, data } = await result.json();
if (errors) {
console.error(errors);
console.log(
"Failed to fetch data, please provide correct API key or pool address."
);
return;
}
console.dir(data, { depth: null });
}
getDetailsByPoolAddress("4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU");