Skip to content

DBU-577: Add market order slippage protection#1158

Draft
emmazzz wants to merge 1 commit into
mainfrom
emma/dbu-577-max-slippage-protection
Draft

DBU-577: Add market order slippage protection#1158
emmazzz wants to merge 1 commit into
mainfrom
emma/dbu-577-max-slippage-protection

Conversation

@emmazzz

@emmazzz emmazzz commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a caller-supplied price_limit to DeepBook core account market orders.
  • Enforce the limit against actual executed base and cumulative quote quantities using overflow-safe u128 arithmetic.
  • Add bid, ask, partial-fill, no-fill, custody, and exact-boundary coverage.

Why

  • Core account market orders currently route through DeepBook's extreme IOC price and provide app callers no execution bound.
  • App users need transactions to abort atomically when the realized execution price exceeds their acceptable slippage.

Key decisions

  • Change the existing pre-deploy API signature because there are no in-repository callers requiring compatibility.
  • Interpret price_limit as the maximum average execution price for bids and minimum average execution price for asks, using DeepBook's fixed-point price units.
  • Skip the price check when nothing fills; partial fills are checked using only the quantity that actually executed.

Test plan

  • sui move test --path packages/deepbook_core_account --gas-limit 100000000000
  • Verify exact-boundary bid and ask executions succeed.
  • Verify one-unit-outside bid and ask executions abort.
  • Verify partial-fill and no-fill custody behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant