Query editor
-- RWA realised slippage: what does it actually cost to trade size?-- Execution price of every DEX fill vs the hourly consensus price for the same token,-- bucketed by clip size. This is *realised* impact from filled trades, not quoted depth.---- Sources: tokens_ethereum.rwa, dex.trades | free tables only-- by @aardashevwith reg as (select contract_address, symbol, backingfrom tokens_ethereum.rwa), fills as (selectr.symbol, r.backing, d.block_time, d.amount_usd, if(d.token_bought_address = r.contract_address, 'buy', 'sell') as side, d.amount_usd / nullif(if(d.token_bought_address = r.contract_address, d.token_bought_amount, d.token_sold_amount), 0) as exec_pxfrom dex.trades djoin reg r on r.contract_address in (d.token_bought_address, d.token_sold_address)where d.blockchain = 'ethereum'and d.block_time >= now() - interval '90' dayand d.amount_usd > 0), hourly_mid as (selectsymbol, date_trunc('hour', block_time) as hr, approx_percentile(exec_px, 0.5) as mid_px, count(*) as fills_in_hourfrom fillswhere exec_px > 0group by 1, 2), impact as (selectf.symbol, f.backing, f.side, f.amount_usd, abs(f.exec_px - m.mid_px) / nullif(m.mid_px, 0) as slippagefrom fills fjoin hourly_mid mon m.symbol = f.symboland m.hr = date_trunc('hour', f.block_time)where f.exec_px > 0and m.mid_px > 0and m.fills_in_hour >= 5 -- need a credible hourly consensus)selectsymbol, backing, case when amount_usd < 1000 then '1. under $1k'