Brine's Docupaper
AboutTrade
  • ABOUT
    • πŸ“’Brine Docupaper
    • πŸͺ™Tokenomics
  • πŸ—žοΈBrine Bytes
    • 🧡October Edition
  • TECH
    • πŸ‘©β€πŸ’»Tech Docupaper
      • 🏨High level architecture
      • πŸ€”Starkware logic
      • 🌊Transactional flow
        • Off-chain accounts
        • The deposit flow
        • The withdrawal flow
        • The trade flow
        • The transfer flow
        • Full withdrawal
    • πŸ”ŒAPI Documentation
      • πŸ˜‹Getting started
        • Test connectivity
      • πŸ“ˆMarket
        • 24hr Tickers Price
        • K-line/Candlestick data
        • Orderbook
        • Recent trades
      • ↔️Trading
        • Create order
        • Get order
        • List orders
        • Cancel order
        • List trades
      • πŸ”Account
        • Login
        • Profile Information
        • Balance details
        • Profit and loss details
      • 🌏Web-socket stream
        • πŸ—οΈPrivate web-socket connection
        • πŸ‘₯Public websocket connection
      • ✨Internal Transfer
        • Create Internal Transfer
        • Get Internal Transfer
        • Check User Existence
        • List Internal Transfers
      • πŸ§ͺSDK Reference
        • NodeJS SDK
  • FOR USERS
    • πŸ“’User Docuguide
      • πŸ’»Web App
        • Sign up through Metamask
        • Sign up through Wallet Connect
        • Place a Market Order Trade
        • Place a Limit Order Trade
        • Refer Brine to a Friend
        • Deposit with Metamask
        • Withdraw to Metamask
  • LEGAL
    • ‼️Disclaimer
Powered by GitBook
On this page

Was this helpful?

  1. TECH
  2. Tech Docupaper

High level architecture

Tech Docupaper ( Part I ): Covers an overview of high level architecture of Brine.

PreviousTech DocupaperNextStarkware logic

Last updated 1 year ago

Was this helpful?

Brine Key

A public and private key that is generated via a static signature of the user’s ethereum address.

Cairo

Cairo is A STARK-based Turing-complete language for writing provable programs on blockchain.

SHARP

A shared proving service for Cairo programs. It receives proof requests from different applications and outputs proofs to attest to the validity of Cairo executions. The output proof can be shared among multiple proof requests.

STARK VERIFIER

An on-chain component that receives a state update validity proof and verifies that the proof is valid.

Brine has 2 components.

1. Off-Chain

a) Stores wallet based data b) Stores current state of orders & trades c) Creates batches for transactions d) Sends state updates to the L2 scalability engines

2. On-Chain

a) Holds the state commitments and the system assets b) Management of accounts on-chain (All balance instructions arrive as L1 transactions) c) Responsible for enforcing the validity of state transitions

  • All the transactions including deposits/orders/trades/withdrawals/transfers/stake requests are aggregated and stored on an off-chain state system managed by Brine (Brine at no point has access to the keys of the users). All transactions before being submitted are signed by the user's Brine private key. The transactions are matched via our internal engine and is sent to a Cairo based batching service which sends the batches to SHARP*.

*SHARP on programmed intervals sends the STARK proof to the STARK VERIFIER for verification. The service then sends an on-chain state update transaction to the Brine Contract in L1, which will be accepted only if the verifier finds the proof valid.

User Journey

Brine has 2 components.

  1. Once there are enough confirmation, funds are transferred to the Brine wallet.

  2. Whenever user creates an order, the user signs the order with his Brine Key* with all the necessary parameters.

  3. Brine upon finding a suitable matching order, matches the order and the same is then sent to the batching processor.

  4. As explained above the batch processor sends the batches to SHARP which then sends it to the STARK verifier for verification and is finally pushed to L1 as a state update updating the balances of contract wallets.

  5. Withdrawal can be made by a user directly via the smart contract or by sending a request to Brine which allows the user to withdraw the funds with reduced gas fee.

User deposits funds by interacting with the contract:

πŸ‘©β€πŸ’»
🏨
https://goerli.etherscan.io/address/0x87eB0b1B5958c7fD034966925Ea026ad8Bf3d6dD
A visual representaion of high level architecture of Brine