Moeaxl.new 5
Updated 2023-08-08Copy 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
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with raw as (
select * ,
case when symbols = 'ETH' then 'WETH' else symbols end as symbol from
(select *, replace(replace(TOKENs,'axl'),'st') symbols
from (select *,
iff (TOKEN_SYMBOL ilike '%.%',split(TOKEN_SYMBOL,'.')[1] ,TOKEN_SYMBOL) TOKENs
from axelar.core.ez_satellite
))
)
, p_t as (select
date(HOUR) as days,
symbol token ,
avg(PRICE) as price
from
ethereum.core.fact_hourly_token_prices
group by 1,2)
, base as (
select
*,
AMOUNT*price as amount_usd
from
raw
inner join p_t
on token = SYMBOL and BLOCK_TIMESTAMP::date = days)
select
date_trunc(week,BLOCK_TIMESTAMP)::date as date ,
concat(SOURCE_CHAIN,'->',DESTINATION_CHAIN) as path ,
count(distinct SENDER) as senders ,
sum(amount_usd) as usd_amt,
row_number()over(partition by date order by usd_amt desc) as n
from
base
where BLOCK_TIMESTAMP >= CURRENT_DATE - {{days_back}}
Run a query to Download Data