datavortexenchanting-coffee
Updated 2025-02-08
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 Deposits AS (
SELECT
contract_name,
contract_address,
CASE
WHEN decoded_log:wad IS NOT NULL
THEN (decoded_log:wad::int)
WHEN decoded_log:assets IS NOT NULL
THEN CAST(PARSE_JSON(decoded_log:assets)[0] AS BIGINT)
END AS deposit_amount
FROM swell.core.ez_decoded_event_logs
WHERE event_name IN ('Deposit', 'Deposits')
),
Withdrawals AS (
SELECT
contract_name,
contract_address,
CASE
WHEN decoded_log:wad IS NOT NULL
THEN (decoded_log:wad::int)
WHEN decoded_log:assets IS NOT NULL
THEN CAST(PARSE_JSON(decoded_log:assets)[0] AS BIGINT)
END AS withdrawal_amount
FROM swell.core.ez_decoded_event_logs
WHERE event_name IN ('Withdraw', 'Withdrawal')
),
prices AS (
SELECT
LOWER(name) AS name,
LOWER(symbol) AS symbol,
price,
decimals,
ROW_NUMBER() OVER (PARTITION BY LOWER(symbol) ORDER BY hour DESC) AS rn
FROM ethereum.price.ez_prices_hourly
QueryRunArchived: QueryRun has been archived