IOTA EVM / Sui DeFi / DeepBook analysis · 05_defi_trading/DEFI_PLAN.md
Qalx — DeFi Trading System for the Qals Ecosystem (DEFI_PLAN.md)
Client: qalarc (Australia) · Chain: QALS chain (fork of iotaledger/iota — Sui-derived Move L1 + EVM, Delegated PoS)
Date: 2026-09-06 · Author: research+design agent · Status: DRAFT v1 for review
Companion docs: 03_qals_architecture/ (token), 04_credit_token_platform/ (qAUD), 10_roadmap/
1. Executive Summary
The Qals ecosystem needs trading infrastructure for three asset classes: QALS (native gas/staking token), qAUD (future AUD-pegged stablecoin), and bridged external assets (BTC/ETH/stables via the fork's EVM layer). Research verdicts:
- The IOTA DeFi market is tiny and therefore winnable. DefiLlama (2026-09-06) shows IOTA EVM TVL ≈ $604k, IOTA native listing ≈ $1.48M (api.llama.fi/v2/chains). The flagship DEX, Pools Finance, is an audited (Zokyo, Hacken) AMM-style DEX with smart routing (iota.org showcase). A treasury-seeded venue on the Qals fork can credibly be "day-one DeFi" for the ecosystem rather than a late entrant.
- DeepBook V3 (MystenLabs) is Apache-2.0 licensed — verified in the local clone (github.com/MystenLabs/deepbookv3): full Apache-2.0
LICENSE,SPDX-License-Identifier: Apache-2.0headers in sources, zero BUSL text anywhere. Forking it commercially is permitted. This de-risks Phase B massively. - Recommended path: Phase A = simple Move AMM (Uniswap-v2 logic) + React UI on
@iota/dapp-kit(verified to exist for IOTA). Phase B = "Qalbook" = DeepBook fork with DEEP tokenomics stripped and replaced by QALS. Phase C = router/aggregator + RFQ intents; perps later (licensing analysis first).
2. Research: State of DeFi (2026)
2.1 DeFi on IOTA today
- Pools Finance — the flagship IOTA EVM DEX. IOTA Foundation showcase describes it as "decentralized exchange providing core liquidity infrastructure" with liquidity pools, "smart routing" across pools, and audits by Zokyo and Hacken; positioned as composable infrastructure other protocols build on. Source: iota.org/learn/showcases/pools-finance.
- TVL (DefiLlama API, fetched 2026-09-06): IOTA EVM $604,470 (chainId 8822); "IOTA" native listing $1,482,748; ShimmerEVM $560,416. Comparators: Sui $471.6M, Aptos $55.6M, Sei $33.2M, Ethereum $49.3B, Hyperliquid L1 $1.53B. Source: api.llama.fi/v2/chains. Implication: IOTA's Move-era DeFi is nascent; the design target for "dominant DEX on our fork" is modest (~$0.5–5M TVL), which a treasury can seed.
- "Deep Liquidity" (IOTA EVM DEX) — [UNVERIFIED] could not confirm status/TVL; DefiLlama's IOTA EVM listing aggregates few protocols.
- PancakeSwap on IOTA EVM — [UNVERIFIED] no confirmation found of a deployment; do not assume.
- Liquid staking on IOTA — IOTA moved to Delegated PoS (IOTA 2.0/EVM era); a liquid-staking token (LST) ecosystem à la Sui's volo/SUIHive has not been verified on IOTA [UNVERIFIED]. If the Qals fork inherits dPoS, an LST (qALS) is a natural Phase C product that feeds AMM depth.
2.2 Sui DeFi stack (reference architecture)
- DeepBook V3 = on-chain CLOB as shared objects. Docs confirm: no end-user UI; integrators choose (a) Move dependency, (b) TS SDK (
@mysten/deepbook-v3) + programmable transaction blocks, or (c) read-only via DeepBook Indexer. Source: docs.sui.io/standards/deepbookv3. - Aggregators: Cetus aggregator and Flow (Sui) route across DeepBook + AMMs [UNVERIFIED — general knowledge, not re-verified this session]. Key enabler (verified in code): DeepBook exposes
swap_exact_*endpoints that take/return plainCoins with noBalanceManager, so routers compose it in one PTB. - Liquidity standards:
Coin<T>/Balance<T>objects; LP positions as transferrable Coin objects (AMMs) or balance records inside a sharedBalanceManager(CLOB). Sui's DeepBookV2 is deprecated; no "DeepBook v4" found as of 2026-09-06 [UNVERIFIED] — active MystenLabs development (last commit 2026-09-04) is expanding v3 sideways (margin, prediction markets, oracle lanes), not shipping a v4.
2.3 Order-book vs AMM for a bootstrapping ecosystem
The chicken-and-egg problem: a CLOB needs professional market makers quoting tight spreads; MMs need volume; volume needs tight spreads. With TVL targets under ~$5M, there is rarely enough organic MM interest on day one. An AMM bootstraps from one passive treasury deposit — anyone can be an LP, depth exists from block 1, and price discovery is automatic (pool ratio = price).
| Dimension | AMM (v2-style) | CLOB (DeepBook-style) |
|---|---|---|
| Bootstrap | Treasury seeds pool → instant depth | Needs 2+ committed MMs or the book is empty |
| Capital efficiency | Low (passive, full-range) | High (concentrated quotes) |
| Fees/pricing | Flat %, price impact on big orders | Spread + priority; near-zero impact for makers |
| MEV | Sandwich risk (mempPool-dependent) | Sui/IOTA-style chains have no public mempool; on-chain matching reduces sandwiching |
| Ops burden | ~1k lines Move | ~15k+ lines Move + indexer + keepers |
Hybrid models: UniswapX (intent-based auctions: user signs an off-chain intent, fillers compete, settlement on-chain; RFQ for size) solves both bootstrap and large-order slippage — the DEX protocol itself doesn't need inventory [UNVERIFIED — design knowledge; see uniswap.org/blog/uniswapx]. Recommended hybrid for Qalx: AMM = base layer of always-on liquidity; Qalbook CLOB = price discovery + large orders once MMs exist; RFQ/intents = bridge for whale flow in between.
Sui-style object CLOB vs EVM CLOBs (verified against code): custody is in a shared BalanceManager object (owner + up to 1000 delegated traders) or ephemeral coins for swaps — not an EOA-approved allowance; matching runs deterministically in Move inside consensus (match_against_book in book.move) — there is no off-chain matching operator with discretion (contrast dYdX-v4-style appchains / most EVM CLOBs where an operator sequences matches); flash loans exist natively in DeepBook v3 (borrow_flashloan_base/quote) — an EVM CLOB needs a separate Aave-style dependency for the same trick; shared-object contention serializes trades per pool — throughput is bounded by consensus, mitigated by Sui/IOTA parallel execution across different pools.
Note on "epoch-based matching / batch auctions": the v2 DeepBook whitepaper described matching at epoch boundaries (batch auctions) as an MEV mitigation [UNVERIFIED — whitepaper not fetched]. v3 does not do batch auctions: I grepped book/book.move — no epoch/batch tokens; matching is per-transaction, while epochs govern fee/rebate settlement and per-pool parameter votes (taker fee, maker fee, stake required).
2.4 Australia compliance snapshot (brief — agent H owns detail)
Running a swap front-end from Australia: exchanging digital currency (including crypto-to-crypto) for another digital currency is a designated service under the AML/CTF Act 2006 → AUSTRAC DCE registration + AML program, KYC/ID verification, transaction reporting (ITR/SMR) have applied to exchange-like businesses since 2018; the 2024 AML/CTF reforms (phased 2025–2026) broadened the designated-service net, and AUSTRAC's stated posture is that a business which facilitates swaps (front-end taking fees) can be in scope even if contracts are permissionless [UNVERIFIED specifics — agent H to confirm current instrument wording]. Perps/derivatives (Phase C+) are financial products under the Corporations Act → AFS licence territory; ASIC Info Sheet 225 governs crypto-asset disclosure. Design consequence: front-end fees should accrue via an AUSTRAC-registered qalarc entity; interface ships geo/AML gating hooks from day one.
3. DeepBook Code Review (local clone repos/deepbook = MystenLabs/deepbookv3 @ 1c968f9, 2026-09-04)
3.1 Repo structure
packages/(Move):deepbook(core CLOB),token(DEEP),usdc,dbtc(reference/wrapped assets),fixed_math(fixed-point math),account/deepbook_core_account/sessions(account abstraction),deepbook_margin+margin_liquidation(margin trading),predict+propbook(prediction markets + a Pyth-lane oracle model —oracle_lane::OracleLane<Payload>storinglatest+ exact-timestamp reads with stale/duplicate no-op guards).crates/(Rust):indexer,schema,server,dashboard.yaml— the off-chain read layer.- Core module layout:
pool.move,registry.move,balance_manager.move,order_query.move+book/(book, order, fill, order_info),state/(accounts, balances, ewma, governance, history, trade_params),vault/(vault, deep_price),helper/(big_vector, math, constants, utils — includes a crit-bit tree order book inbook.move). Extensivetests/(pool, book, vault, state, registry-pause).
3.2 Pool shared object design
Pool<BaseAsset, QuoteAsset> shared object = three internal parts (per README + code): Book (crit-bit tree of price levels; fills and places orders), State (per-user data, volumes, historic volumes, governance, EWMA), Vault (settlement of funds). BalanceManager = separate shared object holding one account's balances (owner + up to 1000 traders; traders can place/cancel but not withdraw). PoolRegistry gates pool creation (permissioned at launch; create_permissionless_pool also exists). Admin surface: adjust_tick_size_admin, update_allowed_versions, pause controls.
3.3 Order types & matching
From pool.move public API: place_limit_order, place_post_only_limit_order, place_market_order (taker), modify_order, cancel_order(s), cancel_all_orders, withdraw_settled_amounts(_permissionless). Events: OrderPlaced/Filled/Modified/Canceled/Expired/FullyFilled + Fill records (maker/taker attribution). Aggregator path: swap_exact_base_for_quote(_with_manager), swap_exact_quote_for_base(_with_manager), swap_exact_quantity(_with_manager) — plain Coin in/out. Matching is book::match_against_book per transaction (see §2.3 epoch note).
3.4 Fees
Fees are DEEP-denominated (both maker and taker pay in DEEP; alternative input-token payment costs ~20% more per Sui docs). Per-pool TradeParams { taker_fee, maker_fee, stake_required } — defaults set at pool creation, adjustable by epoch governance: staked users propose per-pool taker/maker fees + stake threshold; quorum = ½ of stake; effects next epoch. Staked takers reach 0.25 bps (stable) / 2.5 bps (volatile); staked makers earn rebates paid at epoch end; accumulated excess DEEP is burned (burn_deep). Whitelisted pools (DEEP/SUI, DEEP/USDC) trade at 0% so users can acquire fee tokens cheaply. vault/deep_price.move maintains the DEEP↔base/quote conversion via price points (min 1 minute apart, max age 1 day, max 100 points) — a bounded TWAP oracle.
3.5 Whitepaper v3 features vs repo reality
Whitepaper-listed v3 features: flash loans, governance, improved account abstraction, matching-engine enhancements, DEEP tokenomics (deepbook.tech whitepaper [UNVERIFIED — PDF not fetched; features cross-confirmed in code]). Repo adds beyond-classic features: referral program (mint_referral, multipliers, claimable rewards), margin + liquidation packages, prediction markets (predict/propbook) with a Pyth-style oracle lane, all actively developed as of 2026-09-04. "Dynamic fees" = the epoch-governed per-pool TradeParams; "passive liquidity" ≈ maker rebates for resting orders; "orderbook composition" [UNVERIFIED mapping — plausibly the registry/multi-pool + propbook feed composition; not confirmed against whitepaper text].
3.6 LICENSE VERDICT — Apache-2.0 (CRITICAL CHECK: PASSED)
LICENSE= full Apache License 2.0 text; every source file carriesSPDX-License-Identifier: Apache-2.0;rg -l "BUSL|Business Source"returns nothing. No CLA-only restrictions, no additional-terms overlay found.- What Apache-2.0 allows: commercial use, modification, distribution (source or object form), sublicensing, private use — including running a modified fork as the basis of a revenue-generating DEX ("Qalbook") with fees.
- Obligations: (1) retain the Apache-2.0 license text and copyright/attribution notices in derivative distributions; (2) if the package has a
NOTICEfile, carry it forward (none found in the repo); (3) state significant changes made to files (changelog/NOTICE in our fork); (4) patent grant: contributors grant users a patent license for the contribution (protective for us). - Not granted: trademarks. "DeepBook" name/logo are not licensed — rebranding is mandatory (we would use "Qalbook"), and we should not imply endorsement by Mysten Labs.
- Contrast with BUSL-1.1: BUSL would have forbidden production/commercial use for 2–4 years and required converting to a GPL-style license after the change date — a deal-breaker. Apache-2.0 has no time or commercial restrictions.
4. Design: "Qalx" — Phased Trading System
4.0 Principles
Move-native first (matches the fork's native asset model + object UX), EVM for bridged assets second; treasury seeds liquidity it later monetizes; every venue exposes a swap API the router can compose; fees accrue to the qalarc treasury via an AUSTRAC-registered entity (§2.4).
4.1 Phase A (weeks) — Qalx AMM + basic UI
Contract: qalx_amm Move package (Uniswap-v2 constant-product logic in Move; Cetus-style single-hop pools). Interface:
module qalx::pool {
public entry fun create_pool<Base, Quote>(admin: &qalx_treasury::TreasuryCap, ctx: &TxContext)
// creates shared object Pool<Base,Quote> + LP type LP<Base,Quote>
public fun swap_exact_base_for_quote<Base, Quote>(
pool: &mut Pool<Base, Quote>, coin_in: Coin<Base>,
min_out: u64, deadline: u64, ctx: &TxContext): Coin<Quote>
public fun swap_exact_quote_for_base<Base, Quote>(...): Coin<Base>
public entry fun add_liquidity<Base, Quote>(
pool: &mut Pool<Base, Quote>, base: Coin<Base>, quote: Coin<Quote>,
min_lp_minted: u64, ctx: &TxContext): Coin<LP<Base, Quote>> // LP coin = owned object
public entry fun remove_liquidity<Base, Quote>(
pool: &mut Pool<Base, Quote>, lp: Coin<LP<Base, Quote>>,
min_base: u64, min_quote: u64, ctx: &TxContext)
}
- Fee: 0.25% (25 bps) on swaps → split 20 bps to LPs / 5 bps to qalarc treasury (Uniswap-style fee switch, treasury share = 1/5). Fee numerator constant
FEE_BPS = 25; treasury take implemented as aTreasuryCap-controlled share, changeable only via upgrade + timelock. - LP token is a native Move
Coin<LP<Base,Quote>>— an ownable, transferable object (satisfies "LP coin as object"); no lockups at contract level. - Launch pools: QALS/qAUD (primary), QALS/wBTC or QALS/wETH (bridged), qAUD/wUSDC (stable-stable, consider 5 bps fee override via pool type parameter).
- UI: React + Vite +
@iota/dapp-kit+@iota/iota-sdk(verified IOTA port of Sui dApp Kit:createNetworkConfig,IotaClientProvider,WalletProvider,ConnectButton, wallet-standard,@iota/create-dappscaffolder — docs.iota.org/developer/ts-sdk/dapp-kit). Pages: swap, pool, positions. Quote client-side from on-chain reserves; PTB withmin_outslippage guard. - EVM side (A.5, optional): deploy a battle-tested UniswapV2 fork (Solidity) on the fork's EVM for bridged-asset pairs; keep Move-native venue canonical for QALS/qAUD.
4.2 Phase B — "Qalbook" CLOB (DeepBook fork)
License permits this (§3.6). Concretely, Apache-2.0 allows us to copy book/, state/, vault/, helper/ (fixed_math, crit-bit big_vector), balance_manager, registry, modify freely, and run it commercially as Qalbook, provided we keep the Apache-2.0 + copyright notices, mark our changes, and rebrand (no DeepBook marks).
- Keep: Pool=Book/State/Vault architecture, BalanceManager, order types + events, swap endpoints (router-ready), flash loans, crit-bit book,
fixed_math. - Strip: DEEP tokenomics → replace fee token with QALS (retune
deep_priceto QALS conversion), referral program, margin/liquidation, predict/propbook, dbtc/usdc sample packages. - Governance: start with
PoolRegistry+ admin caps held by qalarc multisig (permissioned pool creation, tick-size admin); epoch-governance of fees kept but whitelisted-staker-only until community DAO exists. - Alternative (if we reject even Apache obligations or want minimal audit surface): (a) write our own Move CLOB using DeepBook's batch-auction-inspired design ideas but fresh code (12+ months, not recommended); or (b) off-chain matching + on-chain settlement with signed intents — a qalarc matcher collects signed orders, submits matching PTBs, chain verifies signatures/balances (faster to build, reintroduces operator trust + AUSTRAC-market-facility questions). Recommendation: fork + strip + full third-party audit.
4.3 Phase C — Aggregator + RFQ intents; perps later
- Qalx Router (Move "quote" module + off-chain SDK): routes across Qalx AMM pools, Qalbook
swap_exact_*, and (via bridge adapters) EVM pools; returns best PTB. - RFQ/intent desk for large orders: user signs an intent (asset, amount, min-out, expiry); registered fillers (starting with a qalarc desk + partners) post signed quotes; settlement on-chain via PTB; UniswapX-style auction prevents the router itself from being the only counterparty.
- Perps (later, gated): needs oracle infra (§4.7), funding-rate engine, insurance fund — and a Corporations Act/AFS licensing decision (§2.4) before any Australian-facing launch.
4.4 Token flow diagram
┌────────────────────────── Qalx (qalarc) ──────────────────────────┐
│ │
Users ──wallet──▶ Qalx UI (React + @iota/dapp-kit) │
│ │ │ │ │
│ AMM swap │ CLOB order RFQ intent │
▼ ▼ ▼ ▼ │
Coin<QALS> ──▶ Qalx AMM ──▶ Qalbook (DeepBook fork) ──▶ RFQ filler │
Coin<qAUD> Pool<QALS,qAUD> Pool shared objects │ │
Coin<wBTC> (20bps→LPs, (taker/maker fees │ (quote fee to │
Coin<wUSDC> 5bps→Treasury) in QALS → Treasury) ▼ filler) │
│ │ │ │
│ └────────────┴───────► qalarc Treasury (multisig) ◄─────────────┘
│ │
│ ┌─────────────────────┼──────────────────────┐
│ ▼ ▼ ▼
│ LP/maker incentives QALS buyback&burn Protocol ops
│ (liquidity mining, (deflationary (audits, legal,
│ vesting escrow) pressure) market making)
│
└── Bridged assets enter via EVM bridge ──▶ EVM DEX (UniswapV2 fork) ──▶ Router aggregates
4.5 Fee & revenue model (qalarc treasury)
| Venue | Gross fee | LPs/makers | Treasury | Notes |
|---|---|---|---|---|
| AMM volatile pairs | 25 bps | 20 bps | 5 bps | Fee-switch enforced on-chain |
| AMM stable pairs | 5–10 bps | 4–8 bps | 1–2 bps | qAUD/wUSDC |
| Qalbook taker (default) | 10 bps vol / 5 bps stable (DeepBook-style, governed) | — | 100% of taker fee minus maker rebates | Pay-in-QALS gets 20% discount → drives QALS demand |
| Qalbook maker | 0 bps + up to 1–2 bps rebate | rebate | — | Rebates funded from taker fees |
| RFQ/intents | 5–15 bps spread capture | filler | 2–5 bps settlement fee | Phase C |
Illustrative: $10M monthly volume at blended 15 bps gross ≈ $15k/mo revenue at bootstrap scale — meaningful only with token buyback framing; volume is the KPI, fees the byproduct. Treasury also retains protocol-owned liquidity (§4.6) earning the LP share.
4.6 Liquidity bootstrap plan
- Treasury seed: qalarc deposits initial two-sided liquidity (e.g., target $250–500k notional across QALS/qAUD + QALS/wBTC; comparable to the entire IOTA EVM TVL today). Liquidity stays as protocol-owned liquidity (POL) — treasury earns its own LP fees forever.
- Liquidity mining: QALS emissions to LPs/makers, 6–12 month linear vesting, capped per pool per epoch, weighted by fee contribution not raw deposit (fee-earning = real volume). Anti-farm: min 24h stake before claim.
- Maker program on Qalbook: rebate kickbacks for MMs quoting within X% of a Pyth reference price, Y hours/day, funded from taker fees + a fixed QALS grant.
- Success metric: 1% depth on QALS/qAUD ≥ $100k and effective spread ≤ 30 bps before scaling emissions down (bond/LST flywheel later).
4.7 Oracle plan
- Primary external prices (BTC/ETH/AUD-USD): Pyth-style push oracle. No verified Pyth deployment on IOTA EVM found [UNVERIFIED]; plan A = permissionlessly deploy Pyth's standard EVM contracts on our fork's EVM (pyth.network/price-feeds); plan B for Move side = port the propbook
OracleLanepattern from the DeepBook repo (verified in code:latest+ exact-read storage, stale/duplicate/future-read no-op guards) with a qalarc-run pusher service pulling Pyth Hermes, moving to multisig/permissionless publishers later. - qAUD peg (internal): dual-source — (1) external AUD/USD feed; (2) TWAP of qAUD/qALS + qAUD/wUSDC pools; divergence > 50 bps for > 30 min triggers peg-defense module (mint/redeem arbitrage incentives, then PCV intervention). Design belongs to
04_credit_token_platform/but the trading layer must consume both. - Switchboard on IOTA [UNVERIFIED] — treat as unsupported until proven.
5. Risks & open questions
- Port cost (biggest technical risk): DeepBook targets Sui's framework (
sui::modules, Move2024.betaedition,Move.lockpinned deps). Our IOTA fork usesiota::/stdequivalents with API drift — every touched call site across ~15k lines must be reconciled, and any silent mismatch is consensus-critical. Budget: 2–3 Move engineers × ~2 months + external audit (~$150–400k) before mainnet Qalbook. - Shared-object throughput ceiling on the fork (all QALS/qAUD trades serialize on one Pool object) — monitor; sharded pool design is a known future escape hatch.
- Liquidity chicken-egg at smaller scale than assumed (if qAUD launch slips, seed QALS/wBTC first).
- Regulatory: DCE registration timeline; perps = AFS decision; geo-gating plan needed at UI level.
- DEEP-tokenomics removal touches fee settlement at epoch boundaries — the trickiest code to rewrite safely.
6. Sources
- IOTA Pools Finance showcase — https://iota.org/learn/showcases/pools-finance
- DefiLlama chains TVL API (2026-09-06) — https://api.llama.fi/v2/chains
- IOTA dApp Kit docs — https://docs.iota.org/developer/ts-sdk/dapp-kit
- DeepBookV3 standard docs — https://docs.sui.io/standards/deepbookv3
- DeepBook V3 repo/whitepaper — https://github.com/MystenLabs/deepbookv3 · whitepaper PDF (deepbook.tech) [UNVERIFIED — not fetched]
- Local clone audit —
repos/deepbook@1c968f9(2026-09-04): LICENSE,packages/deepbook/sources/*,packages/propbook/README.md - Pyth price feeds — https://www.pyth.network/price-feeds
- AUSTRAC (DCE registration) — https://www.austrac.gov.au [UNVERIFIED specifics — agent H]
- UniswapX intent design — https://uniswap.org/blog/uniswapx [UNVERIFIED — background knowledge]