ProjectsLattice

Lattice

A weekend systems prototype Nevin and I built in Rust to explore cross-border payment state machines, idempotent retries, and FX order routing.

Execute a programmable payout

Compare live stablecoin-to-local-rail routes, test sub-wallet policy gates, or inject a downstream rail timeout to step through idempotent recovery.

Payment intent parameters
POST /v1/payIdempotency-Key: idem_pay_0104
Router objective
Fault injection
Sub-wallet policy cleared (auto-approve ≤$10k)FX ref: 1 USD = 5.10 BRL · 17.20 MXN · 0.92 EUR
Recipient receives21,385.42 BRL

USD → USDC on Polygon → Pix · ~117s · fee 6.78 USD

Live route book (3 available)Click to override router pick
Intent state machine · pay_0104Ready
  1. 1Quote locked
  2. 2Policy gate
  3. 3USDC settlement
  4. 4Local payout
Event stream
01intent.ready (awaiting POST /v1/pay)
Ledger preview
Wallet debit
4,200.00 USD
All-in route fee
6.78 USD
Recipient credit
21,385.42 BRL
Settlement rail
USDC (Polygon) → Pix
Reconciliation
Pending finality

Payouts break
after “send”

I kept getting curious about the same payment plumbing problem from different angles: working near risk and compliance at American Express, building low-latency eFX routing at Clearpool, and trading notes with friends in fintech on how clean developer APIs hide messy settlement rails underneath.

Starting a cross-border transfer is easy; ending it cleanly is the hard part. One payout crosses fiat ramps, stablecoin settlement, custody checks, FX venues, and local rails like PIX or SPEI. When a downstream rail times out, naive callers either stall or risk double-paying on retry.

Nevin and I hacked together a small Rust and Postgres prototype around a single payment intent (POST /pay with currency, amount, and destination) to test how a deterministic state machine should behave when a local rail drops a connection mid-flight: polling idempotency keys before replaying, locking quotes, and writing a balanced double-entry ledger record.

Sub-wallets and policy gates

In the sandbox model, an account holds a root balance with scoped sub-wallets for automated callers or human operators. Before a state transition dispatches settlement, a small policy engine checks per-wallet limits, allowlisted destinations, and manual sign-off thresholds.

Because both the API caller and the operator console read the exact same intent state machine, a paused or timed-out transfer can be inspected and resumed without out-of-band reconciliation.

CallerIntent + policy

Currency, amount, destination, wallet permissions, and manual sign-off.

Lattice (Rust)Routing + state machine

Smart order routing, idempotency, timeout recovery, and ledger reconciliation.

Mocked partnersCustody + local rails

Simulated custody, screening, fiat ramps, and local bank payout webhooks.

Math around the router

While building the state machine, we also sketched three small calculators around the router: where fixed ramp overhead crosses variable basis-point fees, how splitting an operating balance between instant payout float and T-bill yield changes net fee drag, and how to sweep a larger FX order across multiple venue books by all-in price.