Concepts
Settlement
Atomic two-step settlement engine guaranteeing simultaneous fund transfer.
Settlement is the atomic heart of SplitPay. In a single blockchain transaction, client funds are transferred into the contract and disbursed to each member in the exact proportions configured.
Atomic Settlement Mechanism
Atomicity means all-or-nothing: either all recipients receive their funds and all distribution receipts are persisted, or the entire transaction reverts and no tokens change hands.
Settlement Engine Steps
- Payer Authorization:
payment.payer.require_auth()ensures only the designated payer (or authorized signer) can release funds. - Total BPS Validation: Re-validates that total member shares equal exactly 10,000 BPS at the moment of settlement.
- Integer Split Calculation: Multiplies gross amount by member BPS and divides by 10,000, adding remainder to member 0.
- Token Inflow: Invokes
token::Client::transferfrom payer to contract address. - Token Outflows: Dispatches transfers from contract address to each member address.
- Receipt Storage: Stores individual
Distributionstructs in persistent contract storage. - Event Publication: Emits
payment_settledanddistribution_createdevents.
Reversion & Failure Handling
If the payer lacks sufficient balance or asset trustlines, or if any transfer fails, the Soroban runtime halts execution and rolls back all ledger footprint changes. Funds are never lost or partially stuck inside the contract.