Stage: Trade Initialization
The trade is initialized when a user deposits funds into the designated Vault on the source asset-chain network (such as Bitcoin, EVM-compatible networks, or Solana). At this point, deposit confirmation is not required. A Solver submits the trade via the Router contract while awaiting deposit confirmation.
Trade Submission Function
submitTrade(
bytes32 tradeId,
TradeData calldata tradeData,
Affiliate calldata affiliateInfo,
SettlementPresign[] calldata settlementPresigns,
RefundPresign calldata refundPresign
) external;Permissioned Execution
Must be initiated through the
Routercontract.Caller must be an authorized
Solver.
Trade Stage Validation
Stage & Trade ID: Ensure the trade is in the
SUBMITstage with a matching tradeId derived from session-specific inputs.Timeout: Verify that the trade has not expired (
scriptTimeout).Whitelisting: Both source/destination chains and tokens must be whitelisted via the
Managementcontract.MPC Key: Ensure
mpcAssetPubkeyis active and not expired.PMM Check: All participating PMMs must be registered in the Management contract.
Affiliate Fee: Total affiliate fees must not exceed protocol-defined limits.
Refund Presign
Bitcoin: Requires a valid
refundPresignfor MPC validation.EVM/Solana: Pre-signature must be empty, and
refundAddressmust match the one intradeData.
Settlement Presigns
User-submitted signatures stored, but not verified at this stage. Verification occurs at
CONFIRM_DEPOSIT.
Fee Calculation
EVM/Solana: Protocol and affiliate fees are computed when submitted.
Bitcoin: Protocol fee is deferred to PMM selection.
Fee details (pFeeAmount and aFeeAmount) are calculated based on the trade amount and rates.
Trade State Transition
Trade progresses to
CONFIRM_DEPOSIT.Records trade details, pre-signatures, and fee amounts on-chain.
Event Emission
Emits
TradeInfoSubmittedevent providing crucial trade details. This signals the MPC to begin subsequent processing.
Queryable Trade Data
Once submitted, the following trade information is publicly queryable:
Get Trade Stage:
getCurrentStage(bytes32 tradeId) external view returns (uint256);Get Trade Data:
getTradeData(bytes32 tradeId) external view returns (TradeData memory);Get Settlement Presigns:
getSettlementPresigns(bytes32 tradeId) external view returns (SettlementPresign[] memory);Get Refund Presign:
getRefundPresigns(bytes32 tradeId) external view returns (RefundPresign memory);Get Affiliate Info:
getAffiliateInfo(bytes32 tradeId) external view returns (Affiliate memory);
Last updated
