Flipside Docs
Search…
Getting Started with Dai Events
This guide provides an introduction to exploring Dai related events by using theethereum.udm_events table over a series of simple queries that explore the data.
For a breakdown of the Ethereum Events table schema go here.
Let's familiarize ourselves with the table by first looking at the types of events that can be queried for Dai
1
SELECT
2
event_type,
3
event_name,
4
count(1) as event_count
5
FROM ethereum.udm_events
6
WHERE
7
symbol = 'DAI' AND
8
block_timestamp >= GETDATE() - interval'8 months'
9
GROUP BY event_type, event_name
10
ORDER BY event_count DESC
Copied!
event_type
event_name
event_count
erc20_transfer
transfer
3929409
event
Approval
630353
event
TransferEnabled
1
event
OperatorAdded
1
event
MinterAdded
1
event
OwnershipTransferred
1
From the results of this query we see the majority of events are dominated by transfer activity, with the second-highest being, calls to Approval on the Dai contract.
Note that in the above query, the event names have been decoded into English legible names.
In our next query let's take a look at the trend of DAI transfers over the prior 30 days:
1
SELECT
2
date_trunc('day', block_timestamp) as metric_date,
3
sum(amount) as total_amount
4
FROM ethereum.udm_events
5
WHERE
6
event_name = 'transfer' AND
7
symbol = 'DAI' AND
8
amount > 0 AND
9
block_timestamp >= GETDATE() - interval'30 days'
10
GROUP BY metric_date
11
ORDER BY metric_date ASC
Copied!
We can break this query down even further by leveraging Flipside's labels. Let's calculate the amount of DAI that is flowing to centralized exchanges using the distributor_cex label sub-type.
1
SELECT
2
date_trunc('day', block_timestamp) as metric_date,
3
sum(amount) as total_amount
4
FROM ethereum.udm_events
5
WHERE
6
event_name = 'transfer' AND
7
symbol = 'DAI' AND
8
to_label_subtype = 'distributor_cex' AND
9
amount > 0 AND
10
block_timestamp >= GETDATE() - interval'30 days'
11
GROUP BY metric_date
12
ORDER BY metric_date ASC
Copied!
From here, I encourage you to explore our labels even further by breaking down specifically which exchanges DAI is flowing to.
In our next tutorial, we'll explore the amount of activity of DAI that can be attributed to DeFi related activity vs. non DeFi activity and build Flipside's DeFi Activity Ratio metric.
Last modified 9mo ago
Copy link