Stage: Confirm Settlement & Failure Handling
Following a confirmed payment through confirmPayment(), the trade moves to the CONFIRM_SETTLEMENT phase. In this stage, the MPC is tasked with settling the trade by releasing funds to the designated PMM on the source chain. Upon executing the release transaction, the MPC calls confirmSettlement(), submits the releaseTxId, and transitions the trade to the COMPLETED stage.
If issues arise, such as network failures, and if the user has claimed a refund, the MPC must call the report() function, marking the trade as FAILURE and stopping further progress. Here are the core responsibilities of the MPC at this stage:
Release Funds: Initiates settlement by sending funds to the PMM.
Confirm Settlement: Calls
confirmSettlement().Report Failures: Uses
report()to log a failure if necessary.
⚠️ Important: Reporting a failure means the MPC is held accountable for compensating the PMM’s loss.
Possible Scenarios
✅ Successful Settlement
MPC releases funds to the PMM.
Confirms settlement with
confirmSettlement(), usingreleaseTxId.Trade reaches the
COMPLETEDstage.SettlementConfirmedevent logs the final transaction.Trade is final and unmodifiable.
❌ Settlement Failure
If incapable of settling, possibly due to a network issue, and a refund is claimed, MPC reports via
report().Trade is marked
FAILURE.FailureReportedevent is logged for transparency.Audit records detail the failed transaction.
Functions
On Successful Settlement: confirmSettlement()
confirmSettlement()Permissioned Execution: Only through the
Routercontract by an authorizedMPC Node.Stage Validation: Trade must be in
CONFIRM_SETTLEMENT.Signature Validation: Ensures signer validity using EIP-712.
State Transition: Updates trade to
COMPLETED, recordsreleaseTxId.Event Emission: Emits
SettlementConfirmed.
On Unexpected Incidents: report()
report()Permissioned Execution: Via
Router, authorizedMPC Node.Constraints: Trade must not be final (not
COMPLETED,FAILURE, orREFUNDED).Reasons for Failure:
Chain-level or MPC issues.
User refund claimed.
Signature Verification: Uses EIP-712 for authenticity.
State Transition: Logs failure reason, marks trade as
FAILURE.Event Emission: Emits
FailureReported.
Queryable Trade Data
After settlement, regardless if the trade is COMPLETED or FAILURE, public view functions are available:
On Successful Settlement
Get Trade Stage:
Get Trade Finalization:
On Unexpected Incidents
Get Trade Stage:
Get Failure Details:
Last updated
