saeide-ahmadi-7Total fee earned
Updated 2022-08-03
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 opensea_fees as (
select
block_timestamp::date as date ,
case when contract_address = '0x70c006878a5a50ed185ac4c87d837633923de296' then 'REVV'
when contract_address = '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619' then 'WETH'
when contract_address = '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' then 'USDC'
when contract_address = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063' then 'DAI'
end as token ,
raw_amount as amount
from polygon.core.fact_token_transfers
where origin_to_address = '0xf715beb51ec8f63317d66f491e37e7bb048fcc2d' and origin_function_signature = '0xbbbfa60c' and
to_address in ('0x5b3256965e7c3cf26e11fcaf296dfc8807c01073' , '0x8de9c5a032463c561423387a9648c5c7bcc5bc90')
),
opensea_fees_based_on_tokens as (
select date, token , sum(amount) as total_fee
from opensea_fees
group by 1 , 2
),
tokens_price as (
select
hour::date as date ,
token_address ,
symbol ,
avg(price) as price_usd
from flipside_prod_db.ethereum.token_prices_hourly
group by 1 , 2 , 3
),
daily_fee_earned as (
select
a.date , symbol , total_fee , price_usd as token_price_usd , a.token , b.token_address,
case
when token = '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' then ((total_fee/1e6)*price_usd)
else ((total_fee/1e18)*price_usd)
Run a query to Download Data