Userflow

Spot Trades

  • User deposits funds into the exchange contract

  • User places market or limit orders using the front-end UI

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

  • The order details are passed to the off-chain matching engine/orderbook

  • 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

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

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

  • The exchange contract pings the oracle for it to confirm that the trade does in fact exist in the orderbook

  • The oracle returns with verification which allows the order to move from "Pending Orders" and execute

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 Margin and Shorts 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.

Last updated