Integration Flow
Order and wallet saga
Buy, sell, and redemption state transitions across OpenPoly and operator systems.
Order and wallet saga
Money flow and trade flow are coordinated saga, not one DB transaction.
Buy-side flow
- user requests quote
- OpenPoly computes quote with current FX and fees
- user submits order
- OpenPoly creates order record
- OpenPoly debits operator wallet
- if debit succeeds -> OpenPoly executes AMM trade
- OpenPoly commits final order state
- OpenPoly emits webhook event
Sell or redemption flow
- OpenPoly computes credits-equivalent proceeds
- OpenPoly computes external payout amount
- OpenPoly settles internal state
- OpenPoly credits operator wallet
- OpenPoly emits success or failure webhook event
Common order statuses
queuedprocessingoperator_debit_pendingoperator_debitedoperator_credit_pendingprocessedfailedcompensation_pendingcompensatedmanual_review
Failure handling
Debit failed
- order ->
failed - no AMM trade
- failure webhook emitted
Debit unknown
- order ->
manual_review - no AMM trade until resolved
- operator lookup and human follow-up required
Credit failed or unknown
- payout-side record can move to
manual_review - do not blindly re-credit with new idempotency key
- confirm remote state through lookup first
Manual review rule
manual_review means automatic path stopped because final wallet state or business completion is not safe to assume.
Typical triggers:
- wallet result
unknown - compensation needed
- payout-side credit failed after internal state advanced
Compensation
If debit succeeded but downstream completion failed, OpenPoly may require reversal or compensation flow. That is why order lifecycle includes:
compensation_pendingcompensated
Operator guidance
- track every mutation by
idempotency_key - use lookup endpoint before any retry after timeout
- treat
manual_reviewas operational incident, not user-facing success
