$yieldfabric-ai>

Atomic Swaps

Execute bilateral trades with atomic settlement guarantees

01

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

02

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 }
        ]
      }
    }
  }'
03

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 } }"
  }'
04

Swap Lifecycle

StepActionDescription
1Create ObligationsBuild obligation structures (can be self-referential)
2Accept ObligationsLock the structures ready for exchange
3Create SwapInitiator proposes swap with obligations and expected payment
4Complete SwapCounterparty executes swap by providing payment
5Atomic SettlementBoth transfers happen simultaneously or not at all
05

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

06

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)
See complete workflow example →
07

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"
    }
  }'