Query editor
-- Ondo volume through OKX DexRouter (BNB + Ethereum)-- Identify: tx emits OKX OrderRecord topic0-- GMV: MAX(amount_usd) per tx to avoid multi-hop double count in result_dex_ondoWITH ondo AS (SELECTblockchain,block_date AS day,tx_hash,MAX(amount_usd) AS amount_usdFROM dune.ondo_team.result_dex_ondoWHERE blockchain IN ('bnb', 'ethereum')AND block_date >= CURRENT_DATE - INTERVAL '30' DAYAND COALESCE(symbol, '') != 'USDon'GROUP BY 1, 2, 3),bnb_okx AS (SELECT DISTINCT tx_hash, block_dateFROM bnb.logsWHERE block_date >= CURRENT_DATE - INTERVAL '30' DAYAND topic0 = 0x1bb43f2da90e35f7b0cf38521ca95a49e68eb42fac49924930a5bd73cdf7576c),eth_okx AS (SELECT DISTINCT tx_hash, block_dateFROM ethereum.logsWHERE block_date >= CURRENT_DATE - INTERVAL '30' DAYAND topic0 = 0x1bb43f2da90e35f7b0cf38521ca95a49e68eb42fac49924930a5bd73cdf7576c),matched AS (SELECT o.day, o.blockchain, o.tx_hash, o.amount_usdFROM ondo oJOIN bnb_okx kON o.blockchain = 'bnb'AND k.tx_hash = o.tx_hashAND k.block_date = o.dayUNION ALLSELECT o.day, o.blockchain, o.tx_hash, o.amount_usdFROM ondo oJOIN eth_okx kON o.blockchain = 'ethereum'AND k.tx_hash = o.tx_hashAND k.block_date = o.day)SELECTday,COUNT(*) AS tx_count,ROUND(SUM(amount_usd), 2) AS gmv_usd,ROUND(SUM(CASE WHEN blockchain = 'bnb' THEN amount_usd ELSE 0 END), 2) AS gmv_bnb,ROUND(SUM(CASE WHEN blockchain = 'ethereum' THEN amount_usd ELSE 0 END), 2) AS gmv_ethFROM matchedGROUP BY 1ORDER BY 1 DESC