tunnl
  • Introduction
  • Roadmap
  • Orderbook Exchange
    • Getting Started
    • Userflow
    • UI/UX
    • Matching Engine and Orderbook
    • On-Chain Execution
    • Margin and Shorts
    • Oracles
    • Decentralized Leverage
    • Liquidations
    • Interest and Lending Rate
    • Fees
    • Token Details
  • Aggregated USDC
  • Aggregated Swaps
    • Getting Started
    • Fees
  • MPC Vaults
  • TUN Token
    • Profit Share and Buy Back
    • Token Allocations
    • Token Emissions
    • Governance
Powered by GitBook
On this page
  • Spot Trades
  • Margin Trades
  1. Orderbook Exchange

Userflow

PreviousGetting StartedNextUI/UX

Last updated 2 months ago

Spot Trades

  • User deposits funds into the exchange

  • User places market, limit, or stop-loss orders using the front-end

  • The front-end verifies user balances are sufficient for the trade

  • The order details are passed to the off-chain

  • The matching engine runs a second verifcation of user balances

  • If a limit order is not matched it is placed into the orderbook as a maker order

  • If the order is matched, it will prompt the taker to approve the transaction using their wallet provider

  • Once approved, the order is sent to the exchange contract where it checks a verification signature for order detail authenticity provided by a verfier.

  • The exchange contract places the pending trade details into "Pending Orders"

  • The exchange contract reviews the order details and verifies for a third time that the user balances are sufficient for the trade and executes the trade between the users

Margin Trades

Margin trades are processed in the same manner as above, but takes into consideration different factors such as "Total Portfolio Value", "Initial Margin Requirements", and "Maintenance Margin Requirements" as outlined further in the section.

Please note that with this architecture, only takers are responsible for gas fees. Users do not need to pay gas fees for any order that goes into the book.

UI
matching engine/orderbook
Margin and Shorts