cloudr3nDEX Aggregator Curve Top 3 Pool
Updated 2023-04-26Copy Reference Fork
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 aggregator_tb as (
select block_timestamp, tx_hash, contract_address, 'yes' as aggregator
from avalanche.core.fact_event_logs
where contract_address in ('0xc4729e56b831d74bbc18797e0e17a295fa77488c','0xdef171fe48cf0115b1d80b88dc8eab59176fee57','0x1111111254fb6c44bac0bed2854e76f90643097d')
),
px_tb as (
select date(block_timestamp) as dates, avg(eth_px) as avg_px
from (select
block_timestamp,
case when event_inputs:bought_id='0' then event_inputs:tokens_bought*pow(10,-18)
when event_inputs:sold_id='0' then event_inputs:tokens_sold*pow(10,-18)
else 0 end as crv_traded,
case when event_inputs:bought_id='2' then event_inputs:tokens_bought*pow(10,-18)
when event_inputs:sold_id='2' then event_inputs:tokens_sold*pow(10,-18)
else 0 end as eth_traded,
crv_traded/eth_traded as eth_px
from avalanche.core.fact_event_logs
where 1=1 AND
contract_address='0xb755b949c126c04e0348dd881a5cf55d424742b2' and -- atricrypto 0: av3rv, 1: wbtc.e , 2: weth.e
event_name in ('TokenExchangeUnderlying','TokenExchange') and crv_traded>0 and eth_traded>0
)
group by 1
),
atricrypto_swaps as (
select
block_timestamp, tx_hash, origin_from_address, origin_to_address, contract_address,
case when event_inputs:bought_id='0' then event_inputs:tokens_bought*pow(10,-18)
when event_inputs:sold_id='0' then event_inputs:tokens_sold*pow(10,-18)
else 0 end as crv_traded,
case when event_inputs:bought_id='1' then event_inputs:tokens_bought::integer*pow(10,-18)
when event_inputs:sold_id='1' then event_inputs:tokens_sold::integer*pow(10,-18)
else 0 end as btc_traded,
case when event_inputs:bought_id='2' then event_inputs:tokens_bought*pow(10,-18)
when event_inputs:sold_id='2' then event_inputs:tokens_sold*pow(10,-18)
else 0 end as eth_traded ,
case when crv_traded>0 then crv_traded
Run a query to Download Data