Spectersummary
Updated 2024-11-20
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
›
⌄
WITH ETHprice AS (
SELECT
TRUNC(hour, 'day') AS day,
AVG(price) AS price
FROM ethereum.price.ez_prices_hourly
WHERE token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
GROUP BY day
),
BridgeData AS (
SELECT
TRUNC(block_timestamp, 'day') AS day,
tx_id,
tx_to AS bridger,
amount / POW(10, decimal) AS amounts,
(amount / POW(10, decimal)) * ep.price AS amount_usd,
CASE
WHEN tx_from = 'F7p3dFrjRTbtRp8FRF6qHLomXbKRBzpvBLjtQcfcgmNe' THEN 'deposit'
WHEN tx_to = 'F7p3dFrjRTbtRp8FRF6qHLomXbKRBzpvBLjtQcfcgmNe' THEN 'withdraw'
END AS transaction_type
FROM eclipse.core.fact_transfers ft
JOIN ETHprice ep ON TRUNC(ft.block_timestamp, 'day') = ep.day
WHERE (tx_to = 'F7p3dFrjRTbtRp8FRF6qHLomXbKRBzpvBLjtQcfcgmNe'
OR tx_from = 'F7p3dFrjRTbtRp8FRF6qHLomXbKRBzpvBLjtQcfcgmNe')
AND succeeded = 'TRUE'
)
SELECT
-- Total deposit and withdraw amounts (USD and ETH)
SUM(CASE WHEN transaction_type = 'deposit' THEN amounts ELSE 0 END) AS total_deposit_eth,
SUM(CASE WHEN transaction_type = 'deposit' THEN amount_usd ELSE 0 END) AS total_deposit_usd,
SUM(CASE WHEN transaction_type = 'withdraw' THEN amounts ELSE 0 END) AS total_withdraw_eth,
SUM(CASE WHEN transaction_type = 'withdraw' THEN amount_usd ELSE 0 END) AS total_withdraw_usd,
-- Net deposit/withdrawal (ETH and USD)
SUM(CASE WHEN transaction_type = 'deposit' THEN amounts ELSE 0 END) -
QueryRunArchived: QueryRun has been archived