SocioCryptoPolygon: USDC bridge
Updated 2023-04-13
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
›
⌄
--bridge
with flow as (
SELECT a.*, b.label_type as from_address_label, b.label_subtype as from_address_sub_label, b.address_name as from_address_name,
c.label_type as to_address_label, c.label_subtype as to_address_sub_label, c.address_name as to_address_name
FROM polygon.core.fact_token_transfers a
LEFT JOIN polygon.core.dim_labels b
ON a.from_address = b.address
LEFT JOIN polygon.core.dim_labels c
ON a.to_address = c.address
WHERE contract_address = '0x2791bca1f2de4661ed88a30c99a7a9449aa84174'
--WHERE date_trunc('day',block_timestamp) = current_date-1
)
SELECT date_trunc('day',block_timestamp) as date,
sum(CASE WHEN f.to_address_label = 'layer2' THEN f.raw_amount ELSE 0 END)/pow(10,6) as dai_flow_out,
sum(CASE WHEN f.from_address_label = 'layer2' THEN f.raw_amount ELSE 0 END)/pow(10,6) as dai_flow_in,
dai_flow_in-dai_flow_out as dai_net_flow
FROM flow f
WHERE date >= '2023-01-01'-- CURRENT_DATE-1
GROUP BY DATE
ORDER BY DATE DESC
Run a query to Download Data