Problem statement
Design the service that quotes and executes foreign-exchange conversions for a multi-currency wallet. It ingests rates from several market data providers, serves a firm quote for a requested currency pair and amount, and — if the user accepts — executes the conversion by posting the debit and credit legs to the ledger at the quoted rate. The delicate part is honoring a quote: the rate a user saw must be the rate they get, even as the market moves underneath.
Operating context. Rates update sub-second and differ across providers; the service applies a spread/margin and serves quotes that are firm for a short hold window. Execution must be atomic across two currencies and must never apply a stale or manipulated rate. Assume 200 currency pairs, 15000 quote requests/sec at peak, execution volume far lower, and a duty to prove exactly which rate and timestamp priced any historical conversion.
Out of scope. Hedging and treasury/position management, the market-data providers' internals, the ledger's internal correctness, and the wallet UI. Assume separate teams own treasury, the rate providers, the ledger, and the app.
What to produce. A high-level architecture covering: ingesting and blending multiple rate feeds into a canonical priced rate, the low-latency quote path with spread applied, making a quote firm for its hold window and honoring it at execution, atomic two-currency execution against the ledger, rejecting stale/out-of-band rates, an auditable record of the rate that priced each conversion, and scaling quotes to tens of thousands per second. Sketch the components and request flow; we will probe specifics in checkpoints.
Must do 5
Functional requirements
- Ingest rate feeds from multiple providers and derive a canonical mid rate per currency pair with staleness and outlier filtering.
- Serve a firm quote for a requested pair and amount with the applicable spread applied, valid for a bounded hold window.
- Execute an accepted quote atomically, posting the source-currency debit and target-currency credit to the ledger at the quoted rate.