Stage: Confirm Deposit & Failure Handling
This phase follows the submission of a trade and the user's deposit of funds into a Vault on the source asset-chain. Here, Multi-Party Computation (MPC) nodes validate the trade before it continues. The MPC's key roles include:
Verifying the deposit amount and source addresses match the trade data.
Validating pre-signatures for both settlement and refund paths.
Ensuring data and signatures are consistent and untampered.
Scenarios
✅ Successful Deposit Match
If the MPC confirms the deposits match expectations, confirmDeposit is called, moving the trade to SELECT_PMM.
❌ Failure or Timeout
If there's a mismatch, the trade is marked Failure, halting progress. After scriptTimeout, MPC triggers a refund of the user's funds.
✅ Valid Deposit: confirmDeposit()
Function: confirmDeposit(bytes32 tradeId, bytes memory signature, bytes[] memory depositFromList) external
Requirements:
Called via the
Routercontract by an authorized MPC Node.Validates trade is at
CONFIRM_DEPOSITstage.Uses EIP-712 for signature verification.
Transition trade to
SELECT_PMMupon validation.
Event: Emits DepositConfirmed, indicating progression to SELECT_PMM.
❌ Invalid Deposit or Error: report()
Function: report(bytes32 tradeId, bytes calldata msgError, bytes calldata signature) external
Requirements:
Called via the
Routercontract by an authorized MPC Node.Trade should not be finalized as
COMPLETED,FAILURE, orREFUNDED.Invalid deposits trigger halt and a
FailureReportedevent.
⚠️ Key Aspects to Report Failure
Mismatch with
amountIn.Invalid pre-signatures.
Tampered data in
scriptInfo.
Event: FailureReported, providing transparency on failed trades.
Queryable Trade Data
✅ On Successful Deposit Confirmation
Get Trade Stage:
getCurrentStage(bytes32 tradeId)- Returns the stage (e.g.,SELECT_PMM).Get Deposit Address List:
getDepositAddressList(bytes32 tradeId)- Lists addresses that deposited into the Vault.
❌ On Invalid Deposit or Timeout
Get Trade Stage:
getCurrentStage(bytes32 tradeId)- Returns the stage (e.g.,FAILURE).Get Failure Details:
getFailureInfo(bytes32 tradeId)- Provides error metadata, including stage and failure reason.
Last updated
