kky111synfutures open close matched data - usb margin
Updated 2024-04-29
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 token_lookup AS (
SELECT
address AS contract_address,
name AS token_name
FROM (
VALUES
('0x5430561b09c627264549fdb3a6154c34f5cabea7', 'wif'),
('0xb0ceff252f18710a3315e735b5e26481840ad286', 'steth')
) AS T(address, name)
)
, ranked_transfers AS (
SELECT
open_trades.BLOCK_TIMESTAMP AS open_timestamp,
close_trades.BLOCK_TIMESTAMP AS close_timestamp,
open_trades.ORIGIN_FROM_ADDRESS AS trader_address,
open_trades.TO_ADDRESS AS token_perps_address,
CASE WHEN open_trades.contract_address = '0x4300000000000000000000000000000000000003'
THEN open_trades.RAW_AMOUNT/1e18 END AS open_amount,
CASE WHEN close_trades.contract_address = '0x4300000000000000000000000000000000000003'
THEN close_trades.RAW_AMOUNT/1e18 END AS close_amount,
open_trades.tx_hash as open_tx_hash,
close_trades.tx_hash as close_tx_hash,
ROW_NUMBER() OVER(
PARTITION BY open_trades.tx_hash
ORDER BY ABS(DATEDIFF(MINUTE, open_trades.BLOCK_TIMESTAMP, close_trades.BLOCK_TIMESTAMP))
) AS row_num
FROM blast.core.fact_token_transfers AS open_trades
JOIN token_lookup AS t1
ON open_trades.TO_ADDRESS = t1.contract_address
JOIN blast.core.fact_token_transfers AS close_trades
ON open_trades.ORIGIN_FROM_ADDRESS = close_trades.ORIGIN_FROM_ADDRESS
JOIN token_lookup AS t2
ON close_trades.FROM_ADDRESS = t2.contract_address
WHERE
open_trades.FROM_ADDRESS = '0x6a372dbc1968f4a07cf2ce352f410962a972c257'
QueryRunArchived: QueryRun has been archived