04. Treasury and Institutional Finance
Transaction Truth, State Machines & Double-Entry Ledger
One authoritative reconciliation across payment intents, policy decisions, settlement outbox states, exact asset decimal precision, and balanced double-entry accounting—clearly separating simulated execution from on-chain finality.
Submission is never settled settlement
An HTTP
200 or 202 from /api/intents, /api/settlement/execute, or a transaction hash submission never counts as final settlement. An order only transitions to SETTLED after independent chain receipt/Transfer verification (or explicit simulated: true simulator completion using 0xsim_* refs).Canonical 16-stage lifecycle vs. runtime enforcement
FurlPay intentionally separates the Decision Machine (@furlpay/control-plane PaymentPhase) from the Execution Machine (SettlementLifecycleStatus) so “waiting on a human approver” can never be confused with “waiting on an on-chain block”:
| Conceptual Stage | Policy Decision (PaymentPhase) | Settlement Order State | Sandbox Equivalent & Guard |
|---|---|---|---|
| 1. Intent created & validated | Pre-decision | DRAFT | Quote + SHA-256 payloadHash compiled |
| 2. Policy & screening evaluated | AUTHORIZED / HOLD / DENIED | DRAFT -> REJECTED | Country/OFAC check (451) + x402 ceiling (403) |
| 3. Awaiting human approval | PENDING_APPROVAL / HOLD | PENDING_APPROVAL | pending_approval; EXECUTE refused without approvedAt |
| 4. Human / maker-checker approved | APPROVED | APPROVED | simulate-approval / WebAuthn passkey step-up |
| 5. Enqueued / signing requested | EXECUTING | EXECUTION_QUEUED | Cloud KMS transactionGuard validates destination & calldata |
| 6. Signed, submitted & confirming | EXECUTING | EXECUTING / RECONCILIATION_REQUIRED | Timeout stays non-terminal until chain receipt verified |
| 7. Confirmed & settled | SETTLED | SETTLED | settled (0xsim_* in sandbox; decoded Transfer log in prod) |
| 8. Terminal refusal / expiry / reversal | FAILED / DENIED / EXPIRED / REVERSED | FAILED / REJECTED / EXPIRED / CANCELLED / REVERSED | Timeout always resolves HOLD | DENY, never silent ALLOW |
Asset decimals, exact arithmetic & double-entry ledger
New money contracts forbid binary floats (float64/number). Amounts cross HTTP as decimal strings paired with exact integer base units:
- USDC / USDT / Sandbox USD:
6decimal places (1.00 USDC = 1_000_000nmicro-units viaparseDecimalUsdToMicros); conversion spread andplatformFeeBpsround deterministically in integerbigintmath. - Solana (SOL):
9decimals (lamports). EVM Native Gas (ETH/POL):18decimals (wei). - Balanced Ledger Invariant (
@furlpay/ledger): Every journal transaction requires>= 2postings withsum(debits) === sum(credits)in positive integer minor units. Postings are append-only; corrections post a single-use compensatingreverse()entry rather than mutating history. - Reconciliation: Unknown/timed-out settlement broadcasts route to
RECONCILIATION_REQUIREDrather than duplicate blind retries (Settlement Workspace).
Execution boundary transparency
| Capability | Status | Evidence |
|---|---|---|
| Non-custodial intent builders & on-chain verification | VERIFIED_PRODUCTION | /api/intents and /api/transactions/* construct caller-signed payloads without holding keys. |
| Pure control-plane FSM & double-entry ledger | AUDITED_LEDGER | Enforced across @furlpay/control-plane, @furlpay/ledger, and PostgreSQL trigger-protected audit tables. |
| Relayed institutional settlement worker | IMPLEMENTED_NOT_DEPLOYED | Sandbox simulation active; production execution fails closed (503 settlement_disarmed) until KMS signers & RPCs are armed. |
Related endpoints
| Method | Path | Description |
|---|---|---|
| POST | /api/intents | Validate and construct a canonical payment intent. |
| POST | /api/transactions/prepare | Prepare non-custodial wallet transaction parameters. |
| POST | /api/settlement/execute | Policy-driven settlement order creation, approval, and 202 outbox queueing (gated). |
| GET | /api/cron/reconcile | Scheduled internal reconciliation pass (INTERNAL_ONLY cron auth). |
| GET | /api/cron/settlement-worker | Scheduled transactional outbox drainer and recovery reconciler (INTERNAL_ONLY). |
Did this page help?
Edit this page on GitHub