Prerequisites
- Authenticated with M2M token (Authentication)
- A DvP settlement template
- Both parties have wallet addresses on a supported chain
- You know the maturity date for the repo
Flow overview
A repo consists of two linked settlements:- Opening: You create a
repo_opensettlement with amaturity_atdate - Closing: KeyStone auto-creates a
repo_closesettlement when maturity arrives
Step 1: Create the opening settlement
Create a settlement withsettlement_category: "repo_open" and a maturity_at timestamp.
timeout_at controls when the opening settlement times out if not completed.
maturity_at controls when the closing settlement is created after the opening finalizes.
These are independent - maturity_at should be after timeout_at.Step 2: Confirm counterparty (cross-platform only)
If this is a cross-platform repo, the counterparty platform must confirm their participation. See Cross-Platform Settlements for the confirmation flow. For single-platform repos, skip to Step 3.Step 3: Compliance screening
The engine automatically screens all parties through LSEG World-Check (entity) and CipherOwl (wallet). This happens without any action on your part. If a party is flagged, the settlement pauses. Submit a compliance decision to continue:Step 4: Escrow deposits
Once compliance clears, the engine registers the settlement on the escrow smart contract. Both parties deposit their assets on-chain:- Seller deposits bond tokens to the escrow contract
- Buyer deposits USDC to the escrow contract
You do not need to notify KeyStone when deposits are made. On-chain monitoring detects them automatically.
Step 5: Atomic swap executes
When all deposits are confirmed, the escrow contract executes the atomic swap:- Bond tokens transfer to the buyer’s wallet
- USDC transfers to the seller’s wallet
SETTLED to FINALIZED.
Step 6: Await maturity
The opening settlement is now complete. KeyStone monitors thematurity_at timestamp. When maturity arrives, the system automatically creates the closing settlement.
You can monitor the opening settlement to check its status:
Triggering maturity early (admin only)
Administrators can trigger maturity before the scheduled date:Step 7: Closing settlement auto-created
At maturity, KeyStone creates arepo_close settlement with:
- Reversed legs (buyer returns bonds, seller returns USDC)
- The same parties and template
parent_settlement_idpointing to the opening settlement
Step 8: Closing settlement completes
The closing settlement follows the same Steps 3-5 as the opening:- Compliance screening
- Escrow deposits (buyer deposits bonds, seller deposits USDC)
- Atomic swap (bonds return to seller, USDC returns to buyer)
- Settlement finalizes
settlement.state.finalized for the closing settlement.
Step 9: Query related settlements
At any point, you can query all settlements linked to a repo:Error scenarios
| Scenario | Result |
|---|---|
| Opening compliance rejection | Opening settlement rolls back. No closing settlement is created. |
| Opening deposit timeout | Opening settlement times out. Deposits returned. No closing created. |
| Closing compliance rejection | Closing settlement rolls back. Opening remains finalized. |
| Closing deposit timeout | Closing settlement times out. Deposits returned. Manual resolution needed. |
| Maturity worker downtime | Worker catches up on next run. Closing settlement created when worker resumes. |
Webhooks
Subscribe to settlement state events to track both opening and closing legs. Thesettlement_category field in webhook payloads lets you distinguish between them: