Query editor
-- Per-pair × per-direction concurrent-fill exposure for a 3-token PMM market.---- Each fill consumes one of the maker's two tokens on its pair.-- "out_token" = the token leaving the maker's vault = taker's bought side.-- "pair" = sorted alphabetic pair label (so both directions of e.g. ETH/USDC-- group under the same pair value but stay split by out_token).---- For sizing per-token reserves, aggregate p99 USD across out-directions-- sharing the same out_token — that's the upper-bound demand on that-- token's inventory.---- Parameters:-- cap_usd : per-fill USD ceiling (only fills <= cap counted)-- window_seconds : rolling-window size, e.g. "5" or "10"-- start_date / end_date : block_date range (inclusive / exclusive)-- token_a, token_b, token_c: the 3 token symbols you trade (e.g. WETH, cbBTC, USDC)-- project_contract_address : settlement contract literal---- See docs/MAKER-SIZING-METHODOLOGY.md for the framework that uses this.WITH base AS (SELECTblock_time,amount_usd,token_bought_symbol AS bought,token_sold_symbol AS soldFROM bebop_base.tradesWHERE block_date >= DATE '{{start_date}}'AND block_date < DATE '{{end_date}}'AND project_contract_address = {{project_contract_address}}AND amount_usd > 0AND amount_usd <= {{cap_usd}}AND token_bought_symbol IN ('{{token_a}}','{{token_b}}','{{token_c}}')AND token_sold_symbol IN ('{{token_a}}','{{token_b}}','{{token_c}}')AND token_bought_symbol <> token_sold_symbol),labeled AS (SELECTblock_time,amount_usd,bought AS out_token,CASE WHEN bought < soldTHEN bought || '/' || soldELSE sold || '/' || boughtEND AS pairFROM base),rolled AS (SELECTpair,out_token,amount_usd,COUNT(*) OVER (PARTITION BY pair, out_tokenORDER BY block_timeRANGE BETWEEN INTERVAL '{{window_seconds}}' SECOND PRECEDING AND CURRENT ROW) AS cnt_w,SUM(amount_usd) OVER (PARTITION BY pair, out_token