|
| 1 | +--- |
| 2 | +title: "Atomic Exchange" |
| 3 | +description: Enable atomic asset exchanges between parties with XvP Settlement |
| 4 | +--- |
| 5 | + |
| 6 | +import { Callout } from "fumadocs-ui/components/callout"; |
| 7 | + |
| 8 | +## SettleMint XvP Settlement |
| 9 | + |
| 10 | +The XvP (Anything-versus-Payment) Settlement module enables atomic, trustless |
| 11 | +exchanges of digital assets between parties. This feature provides a secure |
| 12 | +mechanism for executing delivery-versus-payment (DvP), payment-versus-payment |
| 13 | +(PvP), or any asset-versus-asset exchange in a single, indivisible transaction. |
| 14 | + |
| 15 | +## What is XvP Settlement? |
| 16 | + |
| 17 | +XvP Settlement is a smart contract-based solution that ensures all parties in a |
| 18 | +transaction either receive their expected assets simultaneously or the |
| 19 | +transaction does not execute at all. This eliminates counterparty risk and |
| 20 | +settlement failures common in traditional exchanges. |
| 21 | + |
| 22 | +### Key benefits |
| 23 | + |
| 24 | +- **Atomic execution**: All transfers succeed or fail together, eliminating |
| 25 | + partial settlement risk |
| 26 | +- **Trustless operation**: No need for intermediaries or escrow services |
| 27 | +- **Programmable settlement**: Configure expiration dates and auto-execution |
| 28 | + parameters |
| 29 | +- **Multi-party capability**: Support for complex settlement flows involving |
| 30 | + multiple assets and participants |
| 31 | + |
| 32 | +## Creating an XvP Settlement |
| 33 | + |
| 34 | +To create a new XvP Settlement, navigate to the XvP Settlement section and click |
| 35 | +"Create New Settlement." The creation interface allows you to configure: |
| 36 | + |
| 37 | +1. **Settlement party**: The counterparty wallet address for the exchange |
| 38 | +2. **Assets**: Select the assets and amounts you wish to exchange |
| 39 | +3. **Expiry date**: The date after which the settlement cannot be executed |
| 40 | +4. **Auto-execute**: Toggle to automatically execute the settlement upon final |
| 41 | + approval |
| 42 | + |
| 43 | +<Callout type="info"> |
| 44 | + While the underlying smart contract supports complex multi-party flows, the |
| 45 | + current UI implements a simplified version allowing for exchanges between two |
| 46 | + parties. |
| 47 | +</Callout> |
| 48 | + |
| 49 | +Once configured, submit the transaction to deploy a new XvP Settlement contract. |
| 50 | +The newly created settlement will appear in your settlement list for monitoring. |
| 51 | + |
| 52 | +## Approving an XvP Settlement |
| 53 | + |
| 54 | +When you're involved in an XvP Settlement (either as initiator or counterparty), |
| 55 | +you'll need to approve it before execution. The approval process includes: |
| 56 | + |
| 57 | +1. **Review settlement details**: Verify the assets, amounts, and expiry date |
| 58 | +2. **Grant asset allowances**: Approve the settlement contract to transfer your |
| 59 | + assets |
| 60 | +3. **Submit approval**: Confirm your participation in the settlement |
| 61 | + |
| 62 | +When you approve a settlement, two transactions occur: |
| 63 | + |
| 64 | +- First, you grant the XvP contract allowance to transfer the specified assets |
| 65 | + from your wallet |
| 66 | +- Second, you mark your approval on the settlement contract itself |
| 67 | + |
| 68 | +Once all involved parties have approved the settlement, it becomes eligible for |
| 69 | +execution. |
| 70 | + |
| 71 | +## Executing an XvP Settlement |
| 72 | + |
| 73 | +The execution phase is where the XvP Settlement demonstrates its value. During |
| 74 | +execution: |
| 75 | + |
| 76 | +1. The contract verifies all required approvals are in place |
| 77 | +2. It checks that the settlement hasn't expired or been cancelled |
| 78 | +3. It atomically transfers all assets between parties in a single transaction |
| 79 | + |
| 80 | +If auto-execution is enabled during creation, the settlement will automatically |
| 81 | +execute when the final party approves it. In this case, the last approver pays |
| 82 | +the gas fees for the execution transaction. |
| 83 | + |
| 84 | +<Callout type="warning"> |
| 85 | + If auto-execution is disabled, the settlement requires manual execution after |
| 86 | + approvals. Any wallet can execute by paying the gas fees. |
| 87 | +</Callout> |
| 88 | + |
| 89 | +## Cancelling an XvP Settlement |
| 90 | + |
| 91 | +Any involved party can cancel an XvP Settlement before it has been executed. |
| 92 | +This provides a safety mechanism if: |
| 93 | + |
| 94 | +- Settlement parameters were incorrectly configured |
| 95 | +- Market conditions change before settlement execution |
| 96 | +- One party needs to withdraw from the agreement |
| 97 | +- The settlement is no longer needed |
| 98 | + |
| 99 | +Once a settlement is cancelled, it cannot be reactivated or executed. |
| 100 | + |
| 101 | +## Settlement states |
| 102 | + |
| 103 | +An XvP Settlement can exist in one of several states: |
| 104 | + |
| 105 | +- **Pending**: Created but not yet fully approved by all parties |
| 106 | +- **Ready**: Fully approved and ready for execution |
| 107 | +- **Executed**: Successfully completed, with all assets transferred |
| 108 | +- **Expired**: Past the cutoff date and no longer executable |
| 109 | +- **Cancelled**: Explicitly cancelled by an involved party |
| 110 | + |
| 111 | +These states help track the lifecycle of each settlement and provide clarity on |
| 112 | +its current status. |
| 113 | + |
| 114 | +## Technical implementation |
| 115 | + |
| 116 | +The XvP Settlement is powered by a secure smart contract that follows best |
| 117 | +practices for atomic exchanges. The contract: |
| 118 | + |
| 119 | +- Utilizes OpenZeppelin's security libraries |
| 120 | +- Implements reentrancy protection |
| 121 | +- Supports meta-transactions for gasless operations |
| 122 | +- Includes comprehensive error handling |
| 123 | +- Emits events for all key actions for auditability |
| 124 | + |
| 125 | +Each settlement contract maintains its own state and manages the asset flows |
| 126 | +between parties, ensuring settlement integrity and security. |
0 commit comments