Pine Analyticstest
Updated 2024-07-31
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 tab1 as (
select
decoded_log:pool::string as pool,
decoded_log:token0::string as token0,
decoded_log:token1::string as token1,
case when ORIGIN_TO_ADDRESS ILIKE '0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A' then 'Slipstream' else 'Not Slipstream' end as Pool_type
from base.core.ez_decoded_event_logs
where (ORIGIN_TO_ADDRESS ILIKE '0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A' or ORIGIN_TO_ADDRESS ILIKE '0x420DD381b31aEf6683db6B902084cB0FFECe40Da')
and event_name like 'PoolCreated'
and tx_status = 'SUCCESS'
)
, tab2 as (
SELECT
tx_hash,
contract_address, --Pool
contract_name, -- Pool name
decoded_log:sender::string as Sender, -- sender
decoded_log:to::string as Reciever -- (Doesn't really matter)
from base.core.ez_decoded_event_logs
where contract_address in (select pool from tab1)
and event_name like 'Swap'
and tx_status = 'SUCCESS'
)
select
date_trunc('week', block_timestamp) as Date,
sum(AMOUNT_USD),
count(distinct tx_hash) as Swap,
count(distinct from_address) as Swappers
from base.core.ez_token_transfers
where tx_hash in (select tx_hash from tab2)
group by 1
QueryRunArchived: QueryRun has been archived