Mach 2
  • Getting Started
    • What is Mach?
    • Mach 2
      • Optimistic Settlement
      • Intents
      • Order Matching
      • Stables & RWAs
    • Trade Lifecycle
  • Navigation
    • Users
      • FAQ
    • Market Makers
  • Protocol
    • Overview
      • Cross-Chain Swap
      • Challenge Process
    • CCTP
    • LayerZero
    • API
      • Integration
    • Staging
    • Deployed Contracts
    • Supported Assets
    • Security
  • Whitepaper
  • Audits
  • Github
Powered by GitBook
On this page
  • Flow of Funds
  • Step 1: User Signs the Trade
  • Step 2: Market Maker Matches the Trade
  • Step 3: Market Maker Proposes and Executes the Match
  • Step 4: Market Maker Finalized Trade - Funds are Settled
  • Trade Lifecycle
  1. Getting Started

Trade Lifecycle

PreviousStables & RWAsNextUsers

Last updated 12 months ago

Flow of Funds

Step 1: User Signs the Trade

The user calls the placetrade function which signs permission for the user's limit order on the source chain.

Step 2: Market Maker Matches the Trade

The market maker calls placetrade with inverse inputs, to match the user's limit order with an equal and opposite order.

Step 3: Market Maker Proposes and Executes the Match

The market maker calls proposematch and executematch on both chains. These functions link the user's order with the market maker's inverse order, preparing both sides for finalization.

Step 4: Market Maker Finalized Trade - Funds are Settled

The market maker calls finalizetrade only on the source chain. This completes the trade, transferring the tokens between the user and the market maker parties and settles the transactions.

Trade Lifecycle

  1. Alice places an order seeking to convert 100 units of Asset Y into Asset X.

  2. Bob places an order to trade 100 units of Asset X for 100 units of Asset Y.

  3. If Assets X and Y are on a different blockchains, the orders are passed to the destination blockchain via layer0

    1. Otherwise, the matching occurs locally.

  4. Every 5 minutes, orders are paired.

    1. If there is a taker order from X to Y, this is paired with Alice’s order

    2. If there is no taker order but there is a maker order, Alice is paired with the market maker.

    3. The maker has 15 minutes to fund Alice’s trade. If the maker fails to fund Alice’s trade, they forfeit their collateral and lose their position in the queue.

  5. Once matched, the smart contracts confirm that both sides are funded, authorizing the release of funds on the opposing chain.