Prerequisites
- Authenticated with M2M token (Authentication)
- A DvP settlement template
Flow overview
Step 1: Create the settlement
Provide party details and legs inline in the settlement instruction.state: "INSTRUCTED" and the engine begins processing immediately.
Step 2: Compliance screening
The engine automatically screens all parties through LSEG World-Check (entity) and CipherOwl (wallet). In ~95% of cases, this completes automatically and the settlement advances toCOMPLIANCE_CLEARED.
If a party is flagged, the settlement pauses. Submit a compliance decision to continue:
Step 3: Escrow registration and deposits
Once compliance clears, the engine registers the settlement on the escrow smart contract and waits for deposits. Both parties deposit their assets to the escrow contract address on-chain. KeyStone detects deposits in real-time via Alchemy webhooks.You don’t need to notify KeyStone when deposits are made. On-chain monitoring detects them automatically.
Step 4: Execution and finalization
When all deposits are confirmed:- The escrow contract executes the atomic swap
- Tokens go to the buyer’s wallet, USDC goes to the seller’s wallet
- Settlement transitions to
SETTLED, thenFINALIZED - Your webhook endpoint receives
settlement.state.finalized
Monitoring
Track the settlement via polling or webhooks:Error scenarios
| Scenario | Result |
|---|---|
| Compliance rejection | Settlement -> ROLLED_BACK |
| Deposit timeout | Settlement -> TIMED_OUT, deposits returned |
| Execution failure | Settlement -> ROLLED_BACK, deposits returned |
| Network error during deposit check | Engine retries on next webhook/poller cycle |