Overview
High-level overview of action flow

Introduction

This guide will provide more information on interactions with Orderly.
Four main flows for building a DEX on top of Orderly Network are:
  • Connect & Register
    • Allow users to create an account with Orderly Network, and also create access keys for users to interact with the smart contract and the matching engine
  • Deposit & Withdrawal
    • Allow users to deposit and withdraw assets to/from the Orderly Asset Manager contract.
  • Trading
    • Allow users to view their balances and to place, edit, cancel, and view orders
  • Market Data
    • Allow the DEX to show market data information including the order book and charts

Architecture

Orderly 1.0 Architecture

Smart Contract (Asset Manager)

The asset manager contract is the main Smart Contract of Orderly network which acts as a custodial account to provide the best user experience possible for an on-chain exchange with it's low fees, fast trade execution, and deep liquidity.The contract stores the following information:
  • NEAR Account ↔︎ Orderly / Trading Key mappings
  • Balance of each account in Orderly
  • Whitelist of permitted assets for the contract
  • Whitelist of permitted trading pairs
The contract has the following usages:
  • Allows users to create an account - i.e. bind their NEAR account_id with specific Orderly trading keys
  • Allows users to deposit whitelisted assets to their Orderly account
  • Allow users to withdraw their assets from their Orderly account
  • Settles executed trades by updating balances of all users on-chain after receiving trade executions

Off-Chain Engine

Currently, the Matching Engine (Orderbook) is off-chain and the smart contract is used as a settlement layer, to offer market-leading trade execution with low latency and minimal fees.The Off-Chain Engine has the following functionalities:
  • Order service
  • Matching engine
  • Trade upload management (uploads executed trades back up to the smart contract)
  • Deposit/Withdrawal management

Connect & Register

In order to register an account and connect a wallet, a user needs two key pairs: Orderly Key Pair (ed25519), also known as Access Key, and Trading Key Pair (secp256k1). Orderly Access Key Pair is generated by the wallet and more information can be found here. Trading keys can be generated by the front-end using this library. Please refer to Authentication for more information on Authentication via WebSocket and RESTful APIs.

Deposit & Withdrawal

Deposit flow
Withdrawal flow
Users have to transfer their funds into the Orderly smart contract, known as an Asset Manager, which acts as a custodial account in order to trade. Deposits and withdrawals are initiated through a smart contract. More details can be found on the smart contract API page.

Trading

Trade flow
User trading data can be retrieved via various RESTful and Websocket APIs. Users can also manage orders via REST APIs. More details can be found on the off-chain engine API page.

Market Data

Market data retrieval flow
Market data can be connected via various RESTful and Websocket APIs. More details can be found on the off-chain engine API page.
Some of the market data, such as listed token pairs and listed tokens, can be retrieved through Smart Contract APIs and Off-Chain APIs.
This guide is a WIP. If you have any suggestions or questions please contact us by email
Copy link
On this page
Introduction
Architecture
Smart Contract (Asset Manager)
Off-Chain Engine
Connect & Register
Deposit & Withdrawal
Trading
Market Data