Exchange Layer
8.1 Dual-Engine Architecture
SB Chain operates two complementary trading mechanisms simultaneously: an Automated Market Maker (AMM) and an on-chain order book DEX inherited from BitShares. These engines coexist and are unified by a single exchange router that executes every trade at the best available price across both systems.
Most DEXes implement one or the other. The dual-engine architecture serves different user profiles:
- AMM: always-available liquidity, instant execution, no counterparty required, optimal for retail users and programmatic swaps
- Order book: precise price control, zero slippage on limit orders, familiar to professional traders and TradFi participants, optimal for market makers and algorithmic strategies
8.2 AMM: Automated Market Maker
The AMM pools hold reserves of two assets and price swaps using the constant product formula:
x × y = k
Where x is the balance of asset A, y is the balance of asset B, and k is the pool's constant, a value that can only increase (as taker fees accumulate) or remain the same.
When a user swaps asset A for asset B:
xincreases by the amount sold (after fees)ydecreases by the amount bought (before fees)kremains constant (plus fee accumulation)- The price the user receives is determined by where on the curve their trade lands
This construction has three important properties:
- Always liquid: the pool can always provide a price, regardless of order flow
- Self-pricing: no oracle or price feed is required; the curve determines the rate
- Permissionless: anyone can deposit into or withdraw from any pool at any time
8.3 Constant Product Pricing
Consider a pool with 100 wBTC and 3,000 wETH:
k = 100 × 3,000 = 300,000
Spot rate: 1 BTC = 30 ETH
A user sells 1 BTC:
New BTC balance: 101
Required ETH balance: 300,000 / 101 = 2,970.3
ETH received: 3,000 - 2,970.3 = 29.7 ETH
Effective rate: 1 BTC = 29.7 ETH
Price impact: -1.0% vs spot
The price impact increases with trade size relative to pool depth. Deeper pools (more total liquidity) produce less price impact for the same trade size, which is the primary reason liquidity is critical to user experience.
After the trade and fee accumulation, k is marginally larger than 300,000, reflecting the taker fee retained in the pool. This is how LP token value grows over time.
8.4 Pool Pairs
SwapBlok launches with the following AMM pools:
High-volume cross-asset pairs:
| Pair | Rationale |
|---|---|
| wETH / wUSDT | Highest global DEX volume pair |
| wBTC / wUSDT | Second-highest, BTC stablecoin anchor |
| wSOL / wUSDT | Solana stablecoin anchor |
| wETH / wSOL | Flagship cross-chain pair |
| wETH / wBTC | Cross-chain pair |
| wSOL / wBTC | Cross-chain pair |
SBT pairs (bridge entry/exit and SBT price discovery):
| Pair | Rationale |
|---|---|
| SBT / wETH | Primary ETH bridge entry point |
| SBT / wUSDT | Stablecoin anchor for SBT price |
| SBT / wBTC | BTC bridge entry point |
| SBT / wSOL | SOL bridge entry point |
8.5 Order Book DEX
The order book DEX is inherited directly from BitShares and operates fully on-chain. All orders (placed, cancelled, partially filled, or filled) are permanently recorded on SB Chain's immutable ledger. No off-chain matching engine exists; the matching is performed by the chain's consensus nodes.
Supported order types:
- Limit order: buy or sell at a specified price or better
- Stop order: trigger a market order when price reaches a specified level
- Fill-or-kill (FOK): fill the entire order immediately at the limit price or cancel
The order book uses price-time priority: orders at the same price are matched in the order they were submitted. This is the standard matching rule used in traditional financial markets.
The fully on-chain nature of the order book means every market participant sees the same state simultaneously, with no information asymmetry and no front-running by a privileged matching engine operator.
8.6 Exchange Router
Every swap request on SwapBlok is processed by the exchange router before execution. The router:
- Queries the current AMM pool price and depth for the requested pair
- Queries the current order book depth for the same pair
- Calculates the effective execution price in both venues (including fees and slippage)
- Routes the order to the venue offering the best net execution price
- For large orders, may split execution across both venues
For cross-chain swaps with no direct pool (e.g. wBTC to wSOL), the router identifies multi-hop paths through intermediate assets and selects the route with the lowest total fee and slippage impact.
8.7 Slippage and Price Impact
Slippage is the difference between the expected price at time of order submission and the actual execution price. It arises when a trade is large relative to pool depth, or when pool composition has drifted from equilibrium due to directional flow.
Slippage is not a fee and does not transfer value to any party. It represents the pool's price moving as a result of the trade; the value remains inside the pool as a changed asset ratio.
An imbalanced pool (heavy in one asset, light in another) presents an arbitrage opportunity. Arbitrageurs trade against the imbalanced pool to bring it back to market price, paying the full fee schedule in the process. The fees generated by arbitrage activity represent a significant portion of LP income on high-volume pairs.
Users can set a maximum slippage tolerance on all swaps. If the execution price would exceed the tolerance, the transaction is rejected before submission.