mlhUntitled Query
Updated 2022-08-01Copy Reference Fork
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
›
⌄
with price as (
SELECT date(HOUR) as date,
TOKEN_ADDRESS,
SYMBOL,
DECIMALS,
avg(PRICE) as avg_price
from ethereum.core.fact_hourly_token_prices
GROUP by 1,2,3,4
)
SELECT
case when CONTRACT_ADDRESS ='0x8f3cf7ad23cd3cadbd9735aff958023239c6a063' then 'DAI'
when CONTRACT_ADDRESS ='0x7ceb23fd6bc0add59e62ac25578270cff1b9f619' then 'WETH'
when CONTRACT_ADDRESS ='0x2791bca1f2de4661ed88a30c99a7a9449aa84174' then 'USDC'
else 'REVV'
end as token,
sum((RAW_AMOUNT/pow(10,decimals))*p.avg_price) as amount_usd
from polygon.core.fact_token_transfers a
join price p on p.date = date(a.block_timestamp)
and p.symbol = (case when CONTRACT_ADDRESS ='0x8f3cf7ad23cd3cadbd9735aff958023239c6a063' then 'DAI'
when CONTRACT_ADDRESS ='0x7ceb23fd6bc0add59e62ac25578270cff1b9f619' then 'WETH'
when CONTRACT_ADDRESS ='0x2791bca1f2de4661ed88a30c99a7a9449aa84174' then 'USDC'
else 'REVV' end)
where TO_ADDRESS in ('0x8de9c5a032463c561423387a9648c5c7bcc5bc90', '0x5b3256965e7c3cf26e11fcaf296dfc8807c01073')
and FROM_ADDRESS = '0xf715beb51ec8f63317d66f491e37e7bb048fcc2d'
GROUP by 1
Run a query to Download Data