winnie-fsbar sort test
Updated 2023-03-21
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
›
⌄
-- forked from 6f01d1b4-81d9-464d-ace1-b3a05b837681
-- forked from c418dba7-c2f0-417e-a5b3-ff46177b4222
-- forked from 7f09b8f5-07ea-4e46-876d-cb0805a6f4e7
-- forked from de044202-d0d1-4621-94ac-a69870256c23
-- forked from 76e75d3a-dbcb-40e1-a942-3f259f85feb6
with excluded_protocols(protocols) as (SELECT * FROM values(
'chainlink'), ('uniswap'), ('balancer'), ('traderjoe')
, ('kyberswap'), ('aave'), ('dodo'), ('curve'), ('sushiswap'))
,
fees_one_month as (
SELECT sum(fees) as monthly_fees, sum(52 * fees) as annualized_fees, protocol FROM external.defillama.fact_protocol_fees_revenue
where chain = 'arbitrum'
and date > sysdate() - interval '7 days'
and protocol not in (SELECT protocols FROM excluded_protocols)
and fees > 0
GROUP BY 3)
,
fees_two_month as (
SELECT sum(fees) as monthly_fees, sum(52 * fees) as annualized_fees, protocol FROM external.defillama.fact_protocol_fees_revenue
where chain = 'arbitrum'
and date > sysdate() - interval '14 days' and date < sysdate() - interval '7 days'
and protocol not in (SELECT protocols FROM excluded_protocols)
and fees > 0
GROUP BY 3)
SELECT a.annualized_fees as annualized_weekly_fees,
a.monthly_fees as current_week_fees,
b.monthly_fees as last_week_fees,
case when b.monthly_fees > 0 then 100 * (a.monthly_fees - b.monthly_fees) / b.monthly_fees else null end as weekly_change
,
a.protocol
Run a query to Download Data