Skip to content

fix(kuru): switch base_trades to OrderBook Trade for full CLOB volume#9695

Open
kkqzhou wants to merge 1 commit into
duneanalytics:mainfrom
kkqzhou:fix/monad-kuru-dex-trades-upgrade
Open

fix(kuru): switch base_trades to OrderBook Trade for full CLOB volume#9695
kkqzhou wants to merge 1 commit into
duneanalytics:mainfrom
kkqzhou:fix/monad-kuru-dex-trades-upgrade

Conversation

@kkqzhou
Copy link
Copy Markdown
Contributor

@kkqzhou kkqzhou commented May 22, 2026

The original source of the kuru trades in dex.trades was Router.KuruRouterSwap, which captures only ~3% of CLOB fills (just the aggregator-routed path). Direct limit orders, margin fills, and KuruFlow-routed swaps were entirely missing. The solution is to switch to per-market OrderBook.Trade joined with Router.MarketRegistered for (baseAsset, quoteAsset, sizePrecision). Conversion math verified against Router-OB matched txs:

base_atomic = filledSize * 10^base_dec / sizePrecision
quote_atomic = filledSize * price * 10^quote_dec / (sizePrecision * 10^18)

The price field is always scaled by 10^18 regardless of pricePrecision (which is UI tick metadata). Direction resolved from isBuy. taker/maker now populated from the event.


quick links for more information:

Source was Router.KuruRouterSwap, which captures only ~3% of CLOB
fills (just the aggregator-routed path). Direct limit orders,
margin fills, and KuruFlow-routed swaps were entirely missing —
$248k reported vs $13.4M actual for 2026-05-21.

Switch to per-market OrderBook.Trade joined with Router.MarketRegistered
for (baseAsset, quoteAsset, sizePrecision). Conversion math verified
against Router-OB matched txs: base_atomic = filledSize * 10^base_dec
/ sizePrecision; quote_atomic = filledSize * price * 10^quote_dec /
(sizePrecision * 10^18). The price field is always scaled by 10^18
regardless of pricePrecision (which is UI tick metadata). Direction
resolved from isBuy. taker/maker now populated from the event.

End-to-end Dune simulation for 2026-05-21: 47,905 rows, \$13.35M USD.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot marked this pull request as draft May 22, 2026 23:06
@github-actions github-actions Bot added WIP work in progress dbt: dex covers the DEX dbt subproject labels May 22, 2026
@kkqzhou kkqzhou marked this pull request as ready for review May 22, 2026 23:06
@github-actions github-actions Bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dbt: dex covers the DEX dbt subproject ready-for-review this PR development is complete, please review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant