Skip to content

M4: trade (DEX orders, atomic swap, bridge_v2) - #6

Open
erubboli wants to merge 20 commits into
feat/m3-send-receivefrom
feat/m4-trade
Open

erubboli wants to merge 20 commits into
feat/m3-send-receivefrom
feat/m4-trade

Conversation

@erubboli

Copy link
Copy Markdown
Member

Summary

Milestone M4 (trade): DEX, atomic swap and bridge wired to real infrastructure.

  • DEX: live order book from the indexer orders endpoints (cursor walk with invalid-cursor restart, depth rows, stale/error states), side-derived give/ask tickets with honest non-Limit refusal, fill with price-band re-check + payout preview, create/fill/conclude flows over the bindings seam
  • Atomic swap: ML HTLC lock/claim/refund pipelines, persisted swap sessions, split initiate contract (lock bytes at rest BEFORE broadcast, offered->locked on success, stranded-row refund from stored bytes), secret handling per spec (never persisted, never logged)
  • Bridge: full bridge_v2 api provider (config/fees/status, M2E treasury deposit flow, m2e confirmations), E2M honestly gated per R5 (EVM signer requirement stated in copy)
  • Bindings TS seam reshaped to the vendored UniFFI surface, pinned by checksum parity tests (D16)
  • Honest gating throughout: ML broadcast (A1), testnet (A2), bindings call-through (device builds) - no fabricated success states
  • Gate: OCR + security + DRY + UX + mobile/i18n audits across 5 cycles, 0 critical / 0 medium at close

Known follow-ups (tracked)

  • Bindings native call-through + device builds (EAS/Mac mini) unlock ML order/swap signing
  • bridge_v2 api-server base URL config pending; A1/A2 Mintlayer inquiries pending
  • E2M direction pending the EVM-signer decision (R5 record)
  • Real swap offers entry UI (counterparty offers) before real-mode initiation unlocks

The TS mirror matched an imagined UniFFI API: getOrderId now derives from the create tx inputs, fill and conclude inputs carry the account nonce and the tip block height, the HTLC output encodes a hex secret hash with an encodeLockForSeconds timelock blob and no spend pubkey, and extractHtlcSecret consumes the encodeOutpointSourceId blob. A parity test pins both directions. Claim and refund feed the locally captured lock tx bytes to the decode (persisted in the swap session), and real-mode swap locking is gated with a typed unsupported until an offer entry supplies the counterparty spend path, with the refund address taken from the wallet's own allocation.
The DEX ticket now derives the give and ask legs from the selected side and refuses non-limit order types with honest copy, dedicated i18n keys replace every wrong-key reuse, the fill runs a payout preview with an effective-price re-check against the book mid band inside the flows, the market header renders a typed unavailable state instead of the fixture row on a snapshot miss, the six dead M0 fixture seams leave the WalletData surface, the no-console secret guard scans src/trade and src/screens, and swap sessions persist the offer in a scalar form with the secret hash bytes rebuilt from hex on load.
finishTx and the HTLC broadcast apply the local-txid equality contract, the dead secret parameter and the unreachable HTLC-spend branch leave the multi-input signer, the fee and input estimates use the real HTLC output index, checkSlippage answers a typed result on a non-finite band, extractSecret sanity-checks the claim bytes and documents the strict-byte-size choice, the DEX conclude button gets a real label, the bridge quote refresh is debounced, the parseAmount object form documents the rational-atom exception, allUtxos and coinStatistics are trimmed per the D13 consume-or-trim rule, and the decisions log consolidates the M4 deviations.
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