0xC2eAf96831Cd62f8dC3B85674D749154F205562c2023-09-15 02:44 PM
Updated 2023-09-15
999
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 amount_values AS (
SELECT
ethereum_tx_amounts.amount / pow(10, ifnull(token_contracts.decimals, 18)) * latest_prices.price AS amount_usd_value
FROM
(
SELECT
iff(
input_table.value [0] = '0x0000000000000000000000000000000000000000',
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
input_table.value [0]
) as token,
SUM(input_table.value [1]) as amount
FROM
ethereum.core.fact_decoded_event_logs,
lateral flatten(input => decoded_log ['order'] [0]) as input_table
WHERE
CONTRACT_ADDRESS IN (
'0x50084c51f6d7e9801b6a7bdba85822db985465fe',
'0x2f6427d6437d69a2a2ae5cc7cd6496fd4c170365',
'0x87259d957709ff337a5969d7778e459262d1575c'
)
GROUP BY
1
) as ethereum_tx_amounts
LEFT JOIN ethereum.core.dim_contracts as token_contracts ON ethereum_tx_amounts.token = token_contracts.address
LEFT JOIN (
SELECT
TOKEN_ADDRESS,
PRICE
FROM
(
SELECT
TOKEN_ADDRESS,
price,
ROW_NUMBER() OVER (
PARTITION BY TOKEN_ADDRESS
Run a query to Download Data