deepbookv3-swaps

Installation
SKILL.md

DeepBook V3: Swaps

DeepBook V3 offers an AMM-style swap interface. This is highly suitable for decentralized exchanges, routers, or applications that need instant execution without locking assets in a BalanceManager or managing order cancellations.


1. Key Concepts

Two Operational Modes

Swaps can be executed in two ways depending on system architecture:

  1. Without a BalanceManager: Perfect for user-facing dApps. Traders swap raw Coin objects directly. The function returns the bought asset coin, any leftover input asset coin, and any remaining/unused fee tokens.
  2. With a BalanceManager: Leverages the user's on-chain balance manager. Fees are paid using the manager's DEEP balance.

Mechanics & Constraints

  • Direction: Swapping from base to quote requires base_in > 0 and quote_in = 0. Swapping from quote to base requires quote_in > 0 and base_in = 0.
  • Trading Fees: Swapping requires DEEP tokens to pay for trading fees.
  • Overestimating Fees: For swaps without a balance manager, you can safely overestimate the DEEP fee coin input. DeepBook V3 calculates the exact fee, takes what is needed, and returns the rest.
  • Divisibility: If the input quantity is not perfectly divisible by the pool's lot size, some input token quantity might remain unswapped and be returned.
Installs
1
First Seen
Sep 4, 2026
deepbookv3-swaps — nickthelegend/sui-deepbook-skills