Atomic Swaps
Execute bilateral trades with atomic settlement guarantees
What are Atomic Swaps?
Atomic swaps enable bilateral trades where both parties exchange assets or obligations simultaneously. The swap either completes entirely or fails - no partial execution possible.
✓ Atomic Settlement
Both parties exchange simultaneously or transaction fails
✓ No Counterparty Risk
Smart contract enforced execution
✓ Complex Structures
Exchange multiple obligations at once
✓ Immutable Records
Full audit trail on-chain
Create Atomic Swap
Create a swap offering your obligations in exchange for payment:
curl -X POST https://pay.yieldfabric.com/graphql \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation($counterpartyExpectedPayments: InitialPaymentsInput) { createSwap(input: { swapId: \"123456789\", counterparty: \"counterpart@yieldfabric.com\", deadline: \"2025-11-10\", initiatorObligationIds: [\"CONTRACT-OBLIGATION-1\", \"CONTRACT-OBLIGATION-2\"], counterpartyExpectedPayments: $counterpartyExpectedPayments }) { success swapId } }",
"variables": {
"counterpartyExpectedPayments": {
"denomination": "aud-token-asset",
"amount": "100",
"payments": [
{ "oracleAddress": null, "oracleOwner": null, "oracleKeySender": "0", "oracleValueSenderSecret": "0", "oracleKeyRecipient": "0", "oracleValueRecipientSecret": "0", "unlockSender": null, "unlockReceiver": null }
]
}
}
}'Complete Swap
As the counterparty, complete the swap by providing the required payment:
curl -X POST https://pay.yieldfabric.com/graphql \
-H "Authorization: Bearer $COUNTERPART_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation { completeSwap(input: { swapId: \"123456789\" }) { success message swapId } }"
}'Swap Lifecycle
| Step | Action | Description |
|---|---|---|
| 1 | Create Obligations | Build obligation structures (can be self-referential) |
| 2 | Accept Obligations | Lock the structures ready for exchange |
| 3 | Create Swap | Initiator proposes swap with obligations and expected payment |
| 4 | Complete Swap | Counterparty executes swap by providing payment |
| 5 | Atomic Settlement | Both transfers happen simultaneously or not at all |
Use Cases
Securitization
Sell future payment rights for immediate liquidity
Debt Trading
Transfer loan obligations between parties
Structured Finance
Package composite obligation bundles
Liquidity Provision
Exchange obligations for cash
Example: Annuity Securitization
Scenario: Issuer creates future payment obligations (105 AUD over time) and atomically swaps them for immediate payment (100 AUD upfront).
Issuer:
- • Receives: 100 AUD immediately (liquidity)
- • Owes: 105 AUD over time (as obligor)
Counterparty:
- • Pays: 100 AUD upfront
- • Receives: 105 AUD over time (5% yield)
Query Swaps
Get all swaps for your account:
curl -X POST https://pay.yieldfabric.com/graphql \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "query GetSwaps($entityId: ID!) { swapFlow { coreSwaps { byEntityId(entityId: $entityId) { id swapId status deadline parties { entity { name } role } initiatorObligationIds } } } }",
"variables": {
"entityId": "your-entity-id"
}
}'