winnie-fsNEAR Capital Flow copy
Updated 2024-08-09
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
›
⌄
-- forked from gregoriustanley / NEAR Capital Flow @ https://flipsidecrypto.xyz/gregoriustanley/q/1HTsv5cQtnkd/near-capital-flow
WITH duplicate_tx_hashes AS (
SELECT
tx_hash
FROM
NEAR.DEFI.EZ_BRIDGE_ACTIVITY
GROUP BY
tx_hash
HAVING
COUNT(*) > 1
),
filtered_transactions AS (
SELECT
block_timestamp,
DATE_TRUNC('day', CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', block_timestamp)) AS date_pt,
amount_usd,
direction,
tx_hash,
CASE
WHEN direction = 'inbound' AND destination_chain = 'near' THEN amount_usd
ELSE 0
END AS inflow,
CASE
WHEN direction = 'outbound' AND source_chain = 'near' THEN amount_usd
ELSE 0
END AS outflow
FROM
NEAR.DEFI.EZ_BRIDGE_ACTIVITY
WHERE
receipt_succeeded = TRUE
AND NOT (direction = 'inbound' AND destination_chain = 'aurora')
AND tx_hash NOT IN (SELECT tx_hash FROM duplicate_tx_hashes)
),
aggregated_data AS (
SELECT
QueryRunArchived: QueryRun has been archived