advanced 35 min

Native DEX order books recap and reliable trading software

A quick recap of how order books behave, then the habits that make trading software reliable: reading result codes, recovering after a dropped connection, and keeping signing keys safe.

Prerequisites

Complete these before starting this module:

What you'll learn

  • Recap order-book quality, funding, and AMM interaction before the capstone.
  • Separate build, signing, submission, and validated result states.
  • Classify XRPL result families correctly.
  • Reconcile uncertain submissions without duplication.
  • Keep signing material out of application logs and source.
Complete this module by a quiz. Jump to assessment

Order books, one more time

Before the capstone, recap what you learned on Day 1 so the console pulls it together. An order book is defined by two assets. TakerGets is what the taker receives; TakerPays is what the taker pays. Rank offers by quality, then by age at equal quality, and always trust the funded fields over the nominal size. Remember that a single payment or offer can consume order-book liquidity, AMM liquidity, or both. Your capstone will read both sources from one validated view.

Treat each step as its own stage

Build, autofill, sign, submit, validate, reconcile: treat each as a distinct stage and always know which one you are in. Record the transaction hash the moment you sign, and keep the seed and signed transaction out of your logs. A tesSUCCESS you have not yet seen validated is provisional; the validated result is the one that sticks.

Let the result code tell you what to do next

Every transaction ends with a result code, and its first three letters put it in a family:

  • tesSUCCESS — it worked, and it is final once a validated ledger holds it.
  • tec... — it made it into a ledger and paid its fee, but the action itself failed (tecPATH_DRY, say, when the path had no liquidity). Also final, so resubmitting the same thing gets you nowhere.
  • tem... — the transaction was malformed, usually a mistake in how you built it. Fix the code before you retry.
  • tef / tel / ter... — the grey area. Some are permanent, some are local to one server, and some may still apply later, so gather more information before you act.

Whatever you do, do not answer a timeout by rebuilding and resubmitting on reflex — that is how you pay twice.

Recovering when the outcome is unclear

LastLedgerSequence gives each transaction a deadline: past that ledger it can no longer succeed. If the connection drops before you see an outcome, reconnect, look the transaction up by the hash you recorded, and run account_tx to sweep up anything you missed.

Keep a set of the transaction hashes you have already handled, so an event that shows up twice — once from a live subscription, once from your catch-up query — is only acted on once. That habit is idempotency, and your application needs it as much as the ledger does.

Assignments

0 of 1 complete

Unlocks

Finishing this module opens up: