Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- dictGet('d_addresses_2', 'name', coin) AS coin,
- argMax(price, block_number) AS max_price,
- argMin(price, block_number) AS min_price,
- MAX(block_number) AS max_blck,
- MIN(block_number) AS min_blck,
- max_price - min_price AS delta,
- argMin(TRANSACTION, block_number) AS first_trx,
- argMax(TRANSACTION, block_number) AS last_trx
- FROM (
- SELECT any(transaction_hash) AS TRANSACTION,
- block_number,
- argMaxIf(address_id, log_index,
- arrayElement(topics, 1) =
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' AND
- address_id != 7255236872428775134) AS coin,
- arrayElement(reserves_0_1, coin_pos) / arrayElement(reserves_0_1, eth_pos) AS price,
- IF(arrayElement(swap_arr_decoded, 1) = last_eth_wad[1] OR
- arrayElement(swap_arr_decoded, 3) = last_eth_wad[1],
- 1, 2) AS eth_pos,
- eth_pos = 1 ? 2 : 1 AS coin_pos,
- arrayMap(x -> reinterpretAsUInt128(reverse(unhex(x))), sync_arr) AS reserves_0_1,
- array(
- SUBSTRING(SUBSTRING(sync_data, 3), 1, 64),
- SUBSTRING(SUBSTRING(sync_data, 3), 65, 64)
- ) AS sync_arr,
- argMaxIf(DATA, log_index,
- arrayElement(topics, 1) =
- '0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1') AS sync_data,
- arrayMap(x -> reinterpretAsUInt128(reverse(unhex(x))), transfer_eth_arr) AS last_eth_wad,
- array(
- SUBSTRING(SUBSTRING(transfer_eth_data, 3), 1, 64)
- ) AS transfer_eth_arr,
- argMaxIf(DATA, log_index,
- arrayElement(topics, 1) =
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' AND
- address_id = 7255236872428775134) AS transfer_eth_data,
- arrayMap(x -> reinterpretAsUInt128(reverse(unhex(x))), swap_arr) AS swap_arr_decoded,
- array(
- SUBSTRING(SUBSTRING(swap_data, 3), 1, 64),
- SUBSTRING(SUBSTRING(swap_data, 3), 65, 64),
- SUBSTRING(SUBSTRING(swap_data, 3), 129, 64),
- SUBSTRING(SUBSTRING(swap_data, 3), 193, 64)
- ) AS swap_arr,
- argMaxIf(DATA, log_index,
- arrayElement(topics, 1) =
- '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822') AS swap_data
- FROM etherium_logs_new
- prewhere block_number BETWEEN 20406885 AND 20460000
- GROUP BY block_number, transaction_index
- ORDER BY block_number, transaction_index
- ) AS sub
- WHERE NOT isNaN(price)
- GROUP BY coin
- HAVING delta > 0
- ORDER BY delta DESC;
- CREATE TABLE trxs_5 engine = Log AS
- SELECT DISTINCT block_number, transaction_index FROM etherium_logs_new
- WHERE block_number BETWEEN 20406885 AND 20414095 AND address_id = 7255236872428775134;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement