CryptoIcicleAave - 5. Fees in Aave v2 and v3
Updated 2022-12-17
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
›
⌄
-- Compare the premium fees earned in AAVE v2 and AAVE v3 in the last 90 days. Which one is the leading fees generator?
-- Has Aave v3 eaten Aave v2's premium fee share?
-- If appropriate, set a daily refresh rate for your data.
-- Note (July 26): because premium fees is not official Aave terminology, submissions comparing total fees in Aave v2
-- compared to v3 will also be accepted.
with contracts as (
select
iff(address_name ilike '%v2%','v2', 'v3') as type,
*
from flipside_prod_db.crosschain.address_labels
where project_name = 'aave'
and (
address_name ilike '%v2%'
or address_name ilike '%v3%'
)
),
v2_txns as (
select
e.*,
c.type,
c.address_name as symbol
from (
select
e.contract_address,
e.tx_hash,
e.block_timestamp,
max(t.tx_fee) as fee_eth
from ethereum.core.fact_event_logs e
join ethereum.core.fact_transactions t on e.tx_hash = t.tx_hash
where e.block_timestamp >= CURRENT_DATE - {{n_days}}
group by 1,2,3
) e
join contracts c on c.address = e.contract_address
),
Run a query to Download Data