DEX Swaps: Tracking UniSwap

This guide will walk you through tracking DEX swaps using ZettaBlock's Data Lake API.

Tracking DEX Swaps via Data Lake API

Unlock the power of ZettaBlock's DEX abstraction layer to access a wealth of historical DEX data.

Our DEX tables offer data that's updated within a time range of 20 minutes to 3 hours.

Step 1: Write the SQL query

WITH recent_uni_trades AS (
  SELECT *
  FROM dex.ethereum_dex_swaps
  WHERE project = 'Uniswap'
    AND data_creation_date >= now() - interval '30' day
)
SELECT *
FROM recent_uni_trades
ORDER BY amount_usd DESC;

You can also check how fresh the data is by executing the following query:

(At the time of writing, the DEX table is 24 minutes behind.)

Step 2: Create an API with Incremental Refresh

In order to use our Compute Units wisely, it'll be more efficient to run the full historical query once (with the data from the past 30 days), and then only index newest data.

To use Incremental Refresh, enable it first:

Then, copy your API transformation code into the Incremental API code, changing the following:

AND data_creation_date >= now() - interval '30' day

To:

AND data_creation_date >= now() - interval '30' day

To learn more about Incremental Refresh and its efficiency, refer to this doc.

Finish creating the API:

And that's it! Your API is ready to be integrated. 🚀

Step 3: Integrate with your dApp/Monitoring System

Use the generated API endpoint to pull data into your dApp or monitoring system.

Soon to Come: Webhooks

Stay tuned for our upcoming feature - webhooks. 👀

With webhooks, you'll be able to get real-time alerts when a specific swap on UniSwap occurs.