Trading architecture

This section describes Spin's trading architecture i.e. modules involved in perpetuals trading.

Spin's trading modules

Margin Vault is an on-chain wallet that works according to the smart contract logic. To trade on Spin, users need to deposit funds to the margin vault that stores users' funds safely, while the smart contract defines the amount of funds the user can transfer depending on their balance and current positions.
Risk Engine is a module that runs pre-trade checking and order settlement.
All information about the user activity is kept in the smart contract that calculates traders' metrics such as required collateral, uPnL, margin ratio, etc.
  1. 1.
    User deposits USDC to the margin account
2. User enters a position for 1 BTC-PERP
3. User closes the position