adriaparcerisassquid directions polygon
Updated 2023-04-14
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
--inspired by jackguy
WITH usdc_transactions AS (
SELECT
x.tx_hash,
date_trunc('day', x.block_timestamp) AS day,
decoded_log:amount / power(10, 6) AS volume,
decoded_log:destinationChain AS to_chain,
from_address
FROM polygon.core.fact_decoded_event_logs x
join polygon.core.fact_transactions y on x.tx_hash=y.tx_hash
WHERE event_name LIKE 'ContractCallWithToken'
AND contract_address LIKE '0x6f015f16de9fc8791b234ef68d486d2bf203fba8'
AND NOT to_chain IS NULL
), daily_volume AS (
SELECT
tx_hash AS tx_id,
project_name AS dex_name
FROM polygon.core.fact_decoded_event_logs
LEFT OUTER JOIN crosschain.core.address_labels
ON address = contract_address
WHERE event_name LIKE 'Swap'
AND blockchain = 'polygon'
AND tx_hash IN (SELECT tx_hash FROM usdc_transactions)
), dex_volume AS (
SELECT
usdc_transactions.tx_hash AS txs,
COUNT(DISTINCT dex_name) AS swaps
FROM usdc_transactions
LEFT OUTER JOIN daily_volume
ON usdc_transactions.tx_hash = tx_id
GROUP BY 1
HAVING swaps > 1
)
SELECT
Run a query to Download Data