scottincryptoStader MaticX LP Token Prices using event_logs
Updated 2022-09-28
999
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 dates as (
select
date_day as block_day
from ethereum.core.dim_dates
where date_day > '2022-04-20'
and date_day <= current_date
)
, matic_price as (
select
date_trunc('day', hour) as block_day
, avg(price) as matic_price
from ethereum.core.fact_hourly_token_prices
where symbol = 'MATIC'
and hour > '2022-04-20'
group by block_day
)
, maticx_exchange as (
select
date_trunc('day', block_timestamp) as block_day
, (sum(event_inputs:amount0In::int) + sum(event_inputs:amount0Out::int)) / 1e18 as matic_amount
, (sum(event_inputs:amount1In::int) + sum(event_inputs:amount1Out::int)) / 1e18 as maticx_amount
, matic_amount / maticx_amount as maticx_exchange_rate
from polygon.core.fact_event_logs
where 1=1
and contract_address = '0xb0e69f24982791dd49e316313fd3a791020b8bf7'
and event_name = 'Swap'
group by block_day
)
-- Get LP Token TotalSupply
, mints as (
select
date_trunc('day', block_timestamp) as block_day
Run a query to Download Data