Get Pools Created Between Time
Query pools created between a time range.
Here we see how we can apply filter on number fields. We are searching for pools created within an hour. For that we check for poolOpenTime to between a start and end range using _gte (greater than equal to) and _lte (less than equal to). Moreover, we sort them based on lpReserve field.
import { gql, GraphQLClient } from "graphql-request";
const endpoint = `https://programs.shyft.to/v0/graphql/?api_key=YOUR-KEY`;
const graphQLClient = new GraphQLClient(endpoint, {
method: `POST`,
jsonSerializer: {
parse: JSON.parse,
stringify: JSON.stringify,
},
});
function queryLpsBetween(start: number, end: number) {
const query = gql`
query MyQuery {
Raydium_LiquidityPoolv4(
where: {poolOpenTime: {_gte: ${start}}, _and: {poolOpenTime: {_lte: ${end}}}}
order_by: {lpReserve: desc}
) {
_updatedAt
amountWaveRatio
baseDecimal
baseLotSize
baseMint
baseNeedTakePnl
baseTotalPnl
baseVault
depth
lpMint
lpReserve
lpVault
marketId
marketProgramId
maxOrder
maxPriceMultiplier
minPriceMultiplier
minSeparateDenominator
minSeparateNumerator
minSize
nonce
openOrders
orderbookToInitTime
owner
pnlDenominator
pnlNumerator
poolOpenTime
punishCoinAmount
punishPcAmount
quoteDecimal
quoteLotSize
quoteMint
quoteNeedTakePnl
quoteTotalPnl
quoteVault
resetFlag
state
status
swapBase2QuoteFee
swapBaseInAmount
swapBaseOutAmount
swapFeeDenominator
swapFeeNumerator
swapQuote2BaseFee
swapQuoteInAmount
swapQuoteOutAmount
systemDecimalValue
targetOrders
tradeFeeDenominator
tradeFeeNumerator
volMaxCutRatio
withdrawQueue
}
}`;
graphQLClient.request(query).then(console.log);
}
//Querying between an hour
queryLpsBetween(1708702200, 1708705800);
{
"data": {
"Raydium_LiquidityPoolv4": [
{
"_updatedAt": "2024-02-23T16:31:44.221",
"amountWaveRatio": 5000000,
"baseDecimal": 9,
"baseLotSize": 1000000000000,
"baseMint": "BhvWrmAxDv4d3RshcBM9jg5HcKG5F6oMTyZp2TnHfPA2",
"baseNeedTakePnl": 0,
"baseTotalPnl": 0,
"baseVault": "4cuwMEomF9U57gkvpwhwNNu9eGyJmZxgau6EdM41NEoN",
"depth": 3,
"lpMint": "2nm766H9xiRZXBipSh5XihNujtTauyV6M3iBMsAFYd2w",
"lpReserve": 237170824512628,
"lpVault": "11111111111111111111111111111111",
"marketId": "5PSHUatzhAECAZcrnL6bAhsNBvqiotyvoz8EMeG5Y6H1",
"marketProgramId": "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX",
"maxOrder": 7,
"maxPriceMultiplier": 1000000000,
"minPriceMultiplier": 1,
"minSeparateDenominator": 10000,
"minSeparateNumerator": 5,
"minSize": 1000000000000,
"nonce": 254,
"openOrders": "C3PVqfK9MS2syZdNKLPgLjVRGAgyCmXjbkiMh23ST2ik",
"orderbookToInitTime": 0,
"owner": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ",
"pnlDenominator": 100,
"pnlNumerator": 12,
"poolOpenTime": 1708705674,
"punishCoinAmount": 0,
"punishPcAmount": 0,
"quoteDecimal": 9,
"quoteLotSize": 1,
"quoteMint": "So11111111111111111111111111111111111111112",
"quoteNeedTakePnl": 0,
"quoteTotalPnl": 0,
"quoteVault": "J5AVUTNJPwZ6jjRZPXNxiov9st4JuXzjeQ7sWg1ehYPe",
"resetFlag": 0,
"state": 1,
"status": 6,
"swapBase2QuoteFee": 41691883,
"swapBaseInAmount": 3477515652498138000,
"swapBaseOutAmount": 5631497824252430000,
"swapFeeDenominator": 10000,
"swapFeeNumerator": 25,
"swapQuote2BaseFee": 8693789131245359,
"swapQuoteInAmount": 16676752627,
"swapQuoteOutAmount": 11875480110,
"systemDecimalValue": 1000000000,
"targetOrders": "7tsJvz3DhnttoPmKc64BfHQSwJxRmsTCZUU1owcKoNyQ",
"tradeFeeDenominator": 10000,
"tradeFeeNumerator": 25,
"volMaxCutRatio": 500,
"withdrawQueue": "11111111111111111111111111111111"
},
<Array of more responses . . . >
]
}
}
Last updated