Alexaytop 5 traders
Updated 2022-08-25Copy 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
29
30
31
32
33
34
35
36
›
⌄
-- https://app.flipsidecrypto.com/velocity/queries/880fd837-ff5f-4cfc-9149-d81aa0a2ea6f
with overtime_markets as ( select concat('0x',substr(data,27,40)) as market_address
from optimism.core.fact_event_logs
where contract_address = '0x2b91c14ce9aa828ed124d12541452a017d8a2148'
and topics[0]::string = '0x889e2060e46779287c2fcbf489c195ef20f5b44a74e3dcb58d491ae073c1370f'
and tx_status = 'SUCCESS'),
buy_positions as ( select txs.from_address as user_address, - sum(raw_amount / pow(10,decimals) * price) as buy_usd,
count(distinct market_address) as markets_played, count(txs.tx_hash) as positions_played
from optimism.core.fact_transactions txs
left join optimism.core.fact_token_transfers t on txs.tx_hash = t.tx_hash
and txs.from_address = t.origin_from_address
and t.origin_from_address = t.from_address
left join optimism.core.fact_hourly_token_prices p on t.contract_address = p.token_address
and date_trunc('hour',t.block_timestamp) = p.hour
inner join overtime_markets om on concat('0x',substr(txs.input_data,35,40)) = om.market_address
where substr(input_data,0,10) in ('0x8875eb84','0x9f916c9f','0x6cc5a6ff')
and status = 'SUCCESS' and txs.block_timestamp >= current_date() - 14
group by 1),
sell_positions as ( select txs.from_address as user_address, sum(raw_amount / pow(10,decimals) * price) as sell_usd
from optimism.core.fact_transactions txs
left join optimism.core.fact_token_transfers t on txs.tx_hash = t.tx_hash
and txs.from_address = t.origin_from_address
and t.origin_from_address = t.to_address
left join optimism.core.fact_hourly_token_prices p
on t.contract_address = p.token_address
and date_trunc('hour',t.block_timestamp) = p.hour
inner join overtime_markets om on concat('0x',substr(txs.input_data,35,40)) = om.market_address
where substr(input_data,0,10) in ('0x3ce1108d')
and status = 'SUCCESS' and txs.block_timestamp >= current_date() - 14
group by 1),
claim_positions as ( select origin_from_address as user_address, sum(raw_amount / pow(10,decimals) * price) as claim_usd
from optimism.core.fact_token_transfers t
Run a query to Download Data