MoeQS 2
Updated 2023-08-11
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
price as (
select
hour::date as date,
token_address,
avg(price) as avg_price
from
polygon.core.fact_hourly_token_prices
group by
1,
2
),
maintb as (
select
s.*,
amount_in * p.avg_price as amt_in_usd,
amount_out * pc.avg_price as amt_out_usd
from
polygon.core.ez_dex_swaps s
join price p on token_in = p.token_address
and block_timestamp::date = p.date
join price pc on token_out = pc.token_address
and block_timestamp::date = pc.date
where
platform like 'quickswap-v3'
and amount_in_usd is not null
and amount_in_usd != 0
),
final as (
select
m.*,
DECODED_LOG:"fee" / 1e6 as fee,
fee * amount_in_usd as fee_usd
from
polygon.core.ez_decoded_event_logs
left join maintb m using (tx_hash)
Run a query to Download Data