rajsUntitled Query
Updated 2022-10-14Copy Reference Fork
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
›
⌄
with reqd_tab as
(
SELECT
origin_from_address,
sum(event_inputs:amount0In) / pow(10,18) as amount_sold,
sum(event_inputs:amount0Out) / pow(10,18) as amount_bought,
sum(event_inputs:amount1In) / pow(10,18) as amount_bought_for,
sum(event_inputs:amount1Out) / pow(10,18) as amount_sold_for
-- *
from bsc.core.fact_event_logs
-- where tx_hash = '0x2d8108234443f5be1ba407be4671d9e26b8385de04a144f31c9b1f5ee30daa35'
where contract_address = '0x8a1a550e144fe6200b606881307cf51cafe98157'
and event_name = 'Swap'
and block_timestamp
-- and event_inputs:amount0in <> 0
group by 1
order by 2 desc
-- order by event_index
-- limit 3
)
SELECT
*,
((amount_sold_for / amount_sold) - (amount_bought_for / amount_bought)) * amount_sold as profit
from reqd_tab
where amount_sold > 0
and amount_bought > 0
Run a query to Download Data