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 Router contract.

  • Caller must be an authorized Solver.

Trade Stage Validation

  • Stage & Trade ID: Ensure the trade is in the SUBMIT stage 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 Management contract.

  • MPC Key: Ensure mpcAssetPubkey is 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 refundPresign for MPC validation.

  • EVM/Solana: Pre-signature must be empty, and refundAddress must match the one in tradeData.

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 TradeInfoSubmitted event 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