Afonso_DiazGrouping transactions
Updated 2024-10-05
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 t as (
select
tx_hash,
block_timestamp,
trader,
a.symbol_out,
b.symbol_in
from near.defi.ez_dex_swaps a
join near.defi.ez_dex_swaps b
using (tx_hash)
where platform = 'v2.ref-finance.near'
and a.swap_index = (select min(swap_index) from near.defi.ez_dex_swaps c
where a.tx_hash = c.tx_hash)
and b.swap_index = (select max(swap_index) from near.defi.ez_dex_swaps c
where b.tx_hash = c.tx_hash)
qualify row_number() over (partition by tx_hash order by block_timestamp) = 1
),
t2 as (
select
tx_hash,
block_timestamp,
trader,
(select sum(amount_out_usd) from near.defi.ez_dex_swaps b where t.tx_hash = b.tx_hash and t.symbol_out = b.symbol_out) as amount_in_usd, --Issue with flipside tables
(select sum(amount_in_usd) from near.defi.ez_dex_swaps b where t.tx_hash = b.tx_hash and t.symbol_in = b.symbol_in) as amount_out_usd, -- Issue with flipside tables
(select sum(amount_out) from near.defi.ez_dex_swaps b where t.tx_hash = b.tx_hash and t.symbol_out = b.symbol_out) as amount_in, --Issue with flipside tables
(select sum(amount_in) from near.defi.ez_dex_swaps b where t.tx_hash = b.tx_hash and t.symbol_in = b.symbol_in) as amount_out, -- Issue with flipside tables
symbol_out as symbol_in,
symbol_in as symbol_out
from t
),
t3 as (
select *,
QueryRunArchived: QueryRun has been archived