You could use the PancakeSwap Subgraph on theGraph.
You might need to play around with it to get exactly what you want, but a query like the one below will get you reserve data on hourly intervals.
[This query gets the top 5 pairs, and then gets the hourly data for each pair for the past 100 hours. You'll need to use the contract address for the pair you're interested in, and then get the hourly data for that pair.]
{
pairs(first:5) {
id
pairHourData(first:100) {
reserve0
reserve1
hourlyVolumeToken0
hourlyVolumeToken1
}
}
}
Gives data of the form:
{
"data": {
"pairs": [
{
"id": "0x30328f3b15e9ce61521d5bf83c0442a0dd0e68bb",
"pairHourData": [
{
"hourlyVolumeToken0": "0",
"hourlyVolumeToken1": "0",
"reserve0": "100",
"reserve1": "1"
},
{
"hourlyVolumeToken0": "0",
"hourlyVolumeToken1": "0",
"reserve0": "75.0000000000000025",
"reserve1": "0.750000000000000025"
}
]
},
.... Lots more data here ....
Sorry to add an answer but i can't comment.
I am also looking to add a token/BNB or token/WBNB pair in testnet but it doesn't work. Tried using https://testnet.bscscan.com/address/0xD99D1c33F9fC3444f8101754aBC46c52416550D1#writeContract, remix, truffle, web3, and none allow it.
I am able to add a token1/token2 pair but doing the BNB or WBNB doesn't work.
Ive tried using ganache with bsc as well and same thing. I think they currently don't have tthis set up because everyone is asking but i haven't yet seen an answer and I've read about every post anywhere
If you find the solution, please let me know and i will do the same.
Best Answer
The factory contract -
PancakeFactory
- is here:https://bscscan.com/address/0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73
If you read the contract, you'll see that
allPairsLength
gives you 14,690 pairs. This refers to the number ofPancakePair
-type contracts.The addresses can be found by reading the
allPairs
array inPancakeFactory
by specifying the index you want. In the absence of anything clever, like Uniswap's Subgraph API (see "All Pairs In Uniswap") you'll probably just have to write a simple looping function to iterate through the array.Edit:
Actually, this API will give you the top 1,000 pairs... (sorted by reserves)
https://api.pancakeswap.info/api/v2/pairs
Filter on
pair_address
.