Swap over the CLOB
Swap wallet coins straight over a DeepBook order book with swapExactQuoteForBase. No BalanceManager: coins go in, coins come out in a single transaction, protected by a real on-chain slippage guard.
The lightest possible trade
- ›The simplest DeepBook trade: wallet coins through the pool, no account object in the middle.
- ›The [base, quote, deep] leftover-coin tuple the builder returns, which you must transfer back or the transaction aborts.
- ›minOut as an on-chain slippage guard, and reading the real fill from the transaction's balanceChanges.
Five sections, end to end
-
Connect
Load the deployment manifest and construct a SuiGrpcClient extended with the DeepBook SDK.
src/sandbox.ts -
Fund & execute
Mint and faucet-fund a fresh keypair, then send transactions that return balanceChanges so you can read results.
src/sandbox.ts -
Swap
Call swapExactQuoteForBase and transfer the [base, quote, deep] coins back to the sender, or the whole transaction aborts.
src/swap.ts -
Read the fill
Sum the positive delta of the base coin credited to you to report the genuine amount filled, not an estimate.
src/swap.ts -
Drive it
Wire the smoke UI and prove minOut reverts on chain with MoveAbort code 12 when slippage is unsatisfiable.
src/App.tsx · src/main.tsx
Start this lesson
/acc-deepbook-course:start # then pick "Swap over the CLOB"
Already installed? Run the start command and choose this lesson from the catalog.
New here? Follow the install steps first. The course brings up a local sandbox and gates each section with pnpm vitest run.