💡Query TheGraph
Retrieve the TVL for the top 500 UniswapV3 Pools on Polygon using LiveQuery and TheGraph
Last updated
Retrieve the TVL for the top 500 UniswapV3 Pools on Polygon using LiveQuery and TheGraph
Last updated
In this example, we'll use LiveQuery to query The Graph.
Here we'll leverage the udf_api
function to call The Graph directly and retrieve the top 500 Uniswap V3 Liquidity Pools by total value locked USD on Polygon.
Video Walkthrough:
Fork It!
Fork the example above here.
Step-By-Step
In the video above we first create our GraphQL query that we'll be sending to TheGraph via LiveQuery:
We'll issue a POST
call to the Uniswap V3 Polygon subgraph curated by Messari:
Our LiveQuery SQL (fork it here).
Two Call-outs for the above SQL:
Since udf_api
returns a JSON Variant Object we can call it directly in our SQL select statement (unlike our EVM functions, which return a table
and must be included in a from clause with a table(<function>)
wrapper.
We use LATERAL FLATTEN
to extract each liquidity pool from the API response as it's own row.