1

I am trying to find the current and past reserves for a coin pair of a certain pool from the smart contract. I can't seem to find any smart contract that can return that. (can't get find them on google though)

I searched in the code for the masterChef smart contract (0x73feaa1eE314F8c655E354234017bE2193C9E24E) and the cakeToken smart contract (0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82) but to no use.

Where do I find this kind of data ? event logs? of which contract and which event?

I would like to get the same data that I can get from this API

enter image description here

1
  • the PancakeSwap Subgraph doesn't give realtime data, is there a way to get the data realtime?
    – notObvious
    Jun 24 at 15:57
1

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 ....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.