Query editor
WITH trade_prices as (SELECT CASEWHEN token_bought_symbol = 'stETH' THEN cast(token_sold_amount_raw as double)/cast(token_bought_amount_raw as double)ELSE cast(token_bought_amount_raw as double)/cast(token_sold_amount_raw as double)END as price, casewhen token_sold_symbol = 'stETH' THEN cast(token_sold_amount_raw as double)/1e18else -cast(token_sold_amount_raw as double)/1e18end as amount, block_time, evt_index, token_sold_symbol, "number"FROM dex.trades d LEFT JOIN ethereum.blocks b ON d.block_time = b.timeWHERE blockchain = 'ethereum'AND project_contract_address = 0xdc24316b9ae028f1497c275eb9192a3ea0f67022AND block_date > date('2023-07-09'))--SELECT FLOOR(price*10000)/10000 as bin_floor, count(price) as num_obs--FROM trade_prices--WHERE price > 0.5-- AND price < 2.0--GROUP BY 1--ORDER BY 1--low_px AS (--SELECT *--from trade_prices--WHERE price > 0.5-- AND price < 0.999-- AND token_sold_symbol = 'stETH'--ORDER BY price--), big_sells as (SELECT "number", block_time, amountFROM trade_prices--WHERE amount > 800-- AND token_sold_symbol = 'stETH')SELECT b."number", b.block_time, b.amount as amount_sell, sum(t.amount) as net_block_amount, min(t.price) as min_price, max(t.price) as max_price, count(t.price) as num_tradesFROM big_sells b LEFT JOIN trade_prices t ON b."number" = t."number"GROUP BY 1, 2, 3