hmxinternFees over time
Updated 2024-09-16
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 trading_fees_log as (
select date_trunc('day', block_timestamp) as time,
sum(case
when EVENT_NAME = 'LogSettleTradingFeeAmount' then DECODED_LOG['feeUsd']
when EVENT_NAME = 'LogSettleBorrowingFeeValue' then DECODED_LOG['feeUsd']
when EVENT_NAME = 'LogSettleLiquidationFeeValue' then DECODED_LOG['usd']
end) / pow(10, 30) as usd,
case
when EVENT_NAME = 'LogSettleTradingFeeAmount' then 'tradingFees'
when EVENT_NAME = 'LogSettleBorrowingFeeValue' then 'BorrowingFees'
when EVENT_NAME = 'LogSettleLiquidationFeeValue' then 'LiquidationFees'
end as type
from blast.core.fact_decoded_event_logs
where CONTRACT_ADDRESS = lower('0x9F1f13eBC178122C3ef6c14FA3A523680563F58b')
and EVENT_NAME in (
'LogSettleTradingFeeAmount',
'LogSettleBorrowingFeeValue',
'LogSettleLiquidationFeeValue'
)
group by 1, 3
),
hlp_fees as (
select date_trunc('day', block_timestamp) as time,
sum(decoded_log['feeUsd']) / pow(10, 30) as usd,
'HlpFees' as type,
from blast.core.fact_decoded_event_logs
where contract_address = lower('0xF0D92907236418Fa8Ee900E384b4c6928f7cADfc')
and event_name in ('CollectAddLiquidityFee', 'CollectRemoveLiquidityFee')
group by 1, 3
)
select *, avg("Total fees") over (order by time ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) as "7 days avg."
from (
select time,
sum(iff(type = 'tradingFees', usd, 0)) as "Trading fees",
sum(iff(type = 'BorrowingFees', usd, 0)) as "Borrowing fees",
QueryRunArchived: QueryRun has been archived