from subgrounds import Subgrounds

sg = Subgrounds()

CHAINSTACK_SUBGRAPH = "CHAINSTACK_SUBGRAPH_QUERY_URL"

subgraph = sg.load_subgraph(CHAINSTACK_SUBGRAPH)

latest_pairs = subgraph.Query.pairs(
  orderBy=subgraph.Pair.createdAtTimestamp,
  orderDirection='desc',
  first=5,
)

result = sg.query_df([
  latest_pairs.id,
  latest_pairs.token0.symbol,
  latest_pairs.token0.name,
  latest_pairs.token0.decimals,
  latest_pairs.token1.symbol,
  latest_pairs.token1.name,
  latest_pairs.token1.decimals,
  latest_pairs.reserve0,
  latest_pairs.reserve1,
  latest_pairs.token0Price,
  latest_pairs.token1Price,
  latest_pairs.createdAtTimestamp,
  latest_pairs.createdAtBlockNumber,
  latest_pairs.syncAtTimestamp,
])

print(result)
                                     pairs_id  ... pairs_syncAtTimestamp
0  0x51c2f70c7a0a00d256413efc2bfa5deb8505bc4d  ...            1692395664
1  0x53eea6e8d4594d77a0eb6ab10feaf1501562a3a9  ...                     0
2  0x54e557c357792a901725369d86b7190bf60acf6c  ...                     0
3  0xcfc7ed03aa9c3a23237bd48b401be775112c539d  ...                     0
4  0x130af79e6b376784ce6823754bd712e3c7d0064a  ...                     0

[5 rows x 14 columns]
from subgrounds import Subgrounds

sg = Subgrounds()

CHAINSTACK_SUBGRAPH = "CHAINSTACK_SUBGRAPH_QUERY_URL"

subgraph = sg.load_subgraph(CHAINSTACK_SUBGRAPH)

latest_pairs = subgraph.Query.pairs(
  orderBy=subgraph.Pair.createdAtTimestamp,
  orderDirection='desc',
  first=5,
)

result = sg.query_df([
  latest_pairs.id,
  latest_pairs.token0.symbol,
  latest_pairs.token0.name,
  latest_pairs.token0.decimals,
  latest_pairs.token1.symbol,
  latest_pairs.token1.name,
  latest_pairs.token1.decimals,
  latest_pairs.reserve0,
  latest_pairs.reserve1,
  latest_pairs.token0Price,
  latest_pairs.token1Price,
  latest_pairs.createdAtTimestamp,
  latest_pairs.createdAtBlockNumber,
  latest_pairs.syncAtTimestamp,
])

print(result)
                                     pairs_id  ... pairs_syncAtTimestamp
0  0x51c2f70c7a0a00d256413efc2bfa5deb8505bc4d  ...            1692395664
1  0x53eea6e8d4594d77a0eb6ab10feaf1501562a3a9  ...                     0
2  0x54e557c357792a901725369d86b7190bf60acf6c  ...                     0
3  0xcfc7ed03aa9c3a23237bd48b401be775112c539d  ...                     0
4  0x130af79e6b376784ce6823754bd712e3c7d0064a  ...                     0

[5 rows x 14 columns]