tomingtraders_swaps
Updated 2024-07-23
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 buyers as (
select
SYMBOL_OUT as buy_token,
AMOUNT_OUT as Buy_Volume,
AMOUNT_IN as Buy_Cost,
from ethereum.defi.ez_dex_swaps
-- where TOKEN_OUT = '0x38e382f74dfb84608f3c1f10187f6bef5951de93'
where ORIGIN_FROM_ADDRESS = '0x09c35d9dfd9deefd5c03864f2da533b80d7631fb'
and SYMBOL_IN = 'WETH'
and EVENT_NAME = 'Swap'
and BLOCK_NUMBER > 20200000
),
sellers as (
select
-- ORIGIN_FROM_ADDRESS as seller,
SYMBOL_IN as sell_token,
AMOUNT_IN as Sell_Volume,
AMOUNT_OUT as Sell_Income
from ethereum.defi.ez_dex_swaps
-- where TOKEN_IN = '0x38e382f74dfb84608f3c1f10187f6bef5951de93'
where ORIGIN_FROM_ADDRESS = '0x09c35d9dfd9deefd5c03864f2da533b80d7631fb'
and SYMBOL_OUT = 'WETH'
and EVENT_NAME = 'Swap'
and BLOCK_NUMBER > 20200000
)
SELECT
buy_token,
sum(Sell_Income) - sum(Buy_Cost) as trade_Profit,
(sum(Sell_Income) - sum(Buy_Cost))/sum(Buy_Cost) as profit_rate,
sum(Sell_Volume)/sum(Buy_Volume) as selled_rate
from buyers b left outer join sellers s on buy_token = sell_token
group by 1
-- having trade_Profit > 0
order by 3 desc
QueryRunArchived: QueryRun has been archived