ALEXGO
  • ๐Ÿ˜€What is ALEX?
  • ๐Ÿ“ˆAutomated Market Making
    • Our Design
  • ๐Ÿง™โ€โ™€๏ธBitcoin Oracle
    • What is the Bitcoin Oracle
  • ๐ŸฉธXLink
    • XLink
  • ๐Ÿš…Orderbook
    • What is the Orderbook?
    • Understanding the Orderbook
  • ๐Ÿš€Launchpad
    • What is the Launchpad
  • ๐Ÿ“šWhitepaper
    • Automated Market Making of Trading Pool
    • Automated Market Making of Yield Token Pool
    • Automated Market Making of Collateral Rebalancing Pool
    • Dive Into Collateral Rebalancing Pool!
  • ๐ŸŽฎDevelopers
    • Networks
      • Mainnet
      • Testnet
    • Protocol Contracts
      • amm-pool-v2-01.clar
      • amm-registry-v2-01.clar
      • amm-vault-v2-01.clar
      • farming-campaign-v2-02.clar
    • REST API
Powered by GitBook
On this page
  1. Orderbook

Using the Orderbook

Last updated 7 months ago

ALEX Orderbook is available at .

Register with the Orderbook

Users register with the Orderbook and deploy their own wallet to which they make deposits and withdrawals.

At the registration, users provide their public keys so the Orderbook can verify their signed orders.

Place buy / sell orders gas-free

Users can place buy / sell orders of any tokens supported by the Orderbook without paying transaction fees. They can cancel orders any time. Orderbook ensures that the user wallet balance is sufficient.

All orders are signed by the originating users and the orders are validated with the usersโ€™ public keys before settlement.

Orders are matched and confirmed

Order Matching Engine continuously matches buy and sell orders. Matched orders are sent to Exchange Contract.

Orders are settled in aggregate

Exchange Contract validates the matched orders, aggregate them and settle in a single transaction. It updates the order fill, which is then used by Order Matching Engine to optimise the order matching.

REST API

For more details, please contract your ALEX representatives.

Once user registration is complete, you can use our REST API () to interact with the Orderbook.

For example, uses our API to automate grid trading on the Orderbook.

๐Ÿš…
https://app.alexlab.co/orderbook
https://stxdx-api.alexlab.co/
b20-trading-bot
get
Authorizations
Path parameters
uidnumberRequired
Responses
200Success
application/json
404Error
get
GET /v1/accounts/{uid} HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
{
  "uid": "text",
  "principal": "text",
  "public_key": "text",
  "balances": [
    {
      "asset_name": "text",
      "asset_id": "text",
      "balance": "text",
      "available": "text",
      "incoming": "text",
      "locked": "text",
      "pending_withdraw": "text"
    }
  ]
}
get
Authorizations
Path parameters
uidnumberRequired
Responses
200
* See `GetAccountPnlInfoResponse` for details about pnl of today
application/json
404Error
get
GET /v1/accounts/pnl/{uid}/today HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
{
  "uid": "text",
  "today_pnl": "text",
  "today_pnl_percent": "text",
  "balances": [
    {
      "assetName": "text",
      "assetId": "text",
      "initialBalance": "text",
      "startBlockHeight": "text",
      "netTransfer": "text",
      "deposit": "text",
      "balance": "text"
    }
  ]
}
get
Responses
200Success
application/json
get
GET /v1/assets HTTP/1.1
Host: 
Accept: */*
200Success
{
  "assetId": "text",
  "asset": "text"
}
get
Authorizations
Path parameters
uidnumberRequired
Query parameters
limitnumberOptional
beforenumberOptional
  • return funds before or equal the timestamp, equals to where created_at <= before
    • format as number of milliseconds elapsed since January 1, 1970 00:00:00 UTC
afternumberOptional
  • return funds after the timestamp, equals to where created_at > after
    • format as number of milliseconds elapsed since January 1, 1970 00:00:00 UTC
Responses
200Success
application/json
get
GET /v1/accounts/{uid}/fund-history HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
200Success
{
  "history": [
    {
      "asset_id": "text",
      "type": "deposit",
      "status": "pending",
      "amount": "text",
      "tx_id": "text",
      "created_at": "text"
    }
  ]
}
get
Authorizations
Query parameters
statusstring ยท enumOptionalPossible values:
marketstring ยท enumOptionalPossible values:
sidestring ยท enumOptionalPossible values:
limitnumberOptional
beforenumberOptional
  • return orders before or equal the timestamp, equals to where created_at <= before
  • format as number of milliseconds elapsed since January 1, 1970 00:00:00 UTC
afternumberOptional
  • return orders after the timestamp, equals to where created_at > after
  • format as number of milliseconds elapsed since January 1, 1970 00:00:00 UTC
Responses
200Success
application/json
get
GET /v1/orders HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
200Success
{
  "orders": [
    {
      "type": "vanilla",
      "order_hash": "text",
      "maker": "text",
      "created_at": "text",
      "status": "matching",
      "salt": "text",
      "side": "buy",
      "size": "text",
      "remaining_size": "text",
      "price": "text",
      "market": "BTC-USD",
      "sender_fee": "text",
      "taker_asset_data": "text",
      "maker_asset_data": "text",
      "taker_asset": "text",
      "maker_asset": "text",
      "maximum_fill": "text",
      "unsettle_filled": "text",
      "filled": "text",
      "avg_settled_price": "text",
      "expiration_height": "text",
      "stop_price": "text",
      "risk": true
    }
  ]
}
get
Path parameters
marketstringRequired
Responses
200Success
application/json
get
GET /v1/orderbook/{market} HTTP/1.1
Host: 
Accept: */*
200Success
{
  "bids": [
    {
      "price": "text",
      "size": "text"
    }
  ],
  "asks": [
    {
      "price": "text",
      "size": "text"
    }
  ]
}
get
Authorizations
Path parameters
order_hashstringRequired
Responses
200Success
application/json
get
GET /v1/orders/{order_hash} HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
200Success
{
  "order": {
    "type": "vanilla",
    "order_hash": "text",
    "maker": "text",
    "created_at": "text",
    "status": "matching",
    "salt": "text",
    "side": "buy",
    "size": "text",
    "remaining_size": "text",
    "price": "text",
    "market": "BTC-USD",
    "sender_fee": "text",
    "taker_asset_data": "text",
    "maker_asset_data": "text",
    "taker_asset": "text",
    "maker_asset": "text",
    "maximum_fill": "text",
    "unsettle_filled": "text",
    "filled": "text",
    "avg_settled_price": "text",
    "expiration_height": "text",
    "stop_price": "text",
    "risk": true
  }
}
post
Authorizations
Path parameters
order_hashstringRequired
Responses
200Success
application/json
post
POST /v1/orders/{order_hash}:cancel HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
200Success
{
  "order": {
    "type": "vanilla",
    "order_hash": "text",
    "maker": "text",
    "created_at": "text",
    "status": "matching",
    "salt": "text",
    "side": "buy",
    "size": "text",
    "remaining_size": "text",
    "price": "text",
    "market": "BTC-USD",
    "sender_fee": "text",
    "taker_asset_data": "text",
    "maker_asset_data": "text",
    "taker_asset": "text",
    "maker_asset": "text",
    "maximum_fill": "text",
    "unsettle_filled": "text",
    "filled": "text",
    "avg_settled_price": "text",
    "expiration_height": "text",
    "stop_price": "text",
    "risk": true
  }
}
get
Query parameters
marketsstring[]Optional
Responses
200Success
application/json
get
GET /v1/orderbook:tickers HTTP/1.1
Host: 
Accept: */*
200Success
{
  "tickers": [
    {
      "market": "BTC-USD",
      "bid": "text",
      "bid_size": "text",
      "ask": "text",
      "ask_size": "text"
    }
  ]
}
get
Authorizations
Query parameters
marketstringOptional

market

Responses
200Success
application/json
get
GET /v1/fills HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
200Success
{
  "fills": [
    {
      "id": 1,
      "tx_id": "text",
      "status": "matched",
      "sender_fee": "text",
      "maker": "text",
      "maker_asset": "text",
      "market": "BTC-USD",
      "side": "buy",
      "type": "vanilla",
      "price": "text",
      "fill_fixed": "text",
      "size": "text",
      "created_at": 1
    }
  ]
}
get
Path parameters
marketstringRequired
Responses
200Success
application/json
get
GET /v1/orderbook/{market}:fills HTTP/1.1
Host: 
Accept: */*
200Success
{
  "fills": [
    {
      "id": 1,
      "tx_id": "text",
      "status": "matched",
      "sender_fee": "text",
      "maker": "text",
      "maker_asset": "text",
      "market": "BTC-USD",
      "side": "buy",
      "type": "vanilla",
      "price": "text",
      "fill_fixed": "text",
      "size": "text",
      "created_at": 1
    }
  ]
}
get
Path parameters
marketstringRequired
Responses
200Success
application/json
get
GET /v1/orderbook/{market}:trades HTTP/1.1
Host: 
Accept: */*
200Success
{
  "trades": [
    {
      "timestamp": 1,
      "price": "text",
      "size": "text",
      "left_hash": "text",
      "left_maker": 1,
      "left_side": "buy",
      "right_hash": "text",
      "right_maker": 1,
      "right_side": "buy"
    }
  ]
}
get
Path parameters
marketstringRequired
Query parameters
resolutionnumberRequired

resolution in minutes, must be positive number

countbacknumberOptional

if set, the from parameter will be ignored

fromnumberOptional

UNIX timestamp before to, required if countback is not provided

tostringRequired

UNIX timestamp in the past aligned with resolution or now

Responses
200Success
application/json
get
GET /v1/orderbook/{market}:trading-view?resolution=1&to=text HTTP/1.1
Host: 
Accept: */*
200Success
{
  "metadata": {
    "market": "BTC-USD",
    "resolution": 1,
    "lastUpdate": 1,
    "nextTime": 1,
    "timezone": "text",
    "columns": [
      "text"
    ]
  },
  "series": [
    [
      "text"
    ]
  ]
}
get
Responses
200Success
application/json
get
GET /v1/orderbook:overview HTTP/1.1
Host: 
Accept: */*
200Success
[
  {
    "market": "BTC-USD",
    "ticker": {
      "market": "BTC-USD",
      "bid": "text",
      "bid_size": "text",
      "ask": "text",
      "ask_size": "text"
    },
    "price": "text",
    "last_price": "text",
    "price_24h_change": "text",
    "price_24h_change_percent": "text",
    "lowest_price": "text",
    "highest_price": "text",
    "volume_24h": "text",
    "amount_24h": "text"
  }
]
get
Path parameters
marketstringRequired
Responses
200Success
application/json
get
GET /v1/orderbook/{market}:overview HTTP/1.1
Host: 
Accept: */*
200Success
{
  "market": "BTC-USD",
  "ticker": {
    "market": "BTC-USD",
    "bid": "text",
    "bid_size": "text",
    "ask": "text",
    "ask_size": "text"
  },
  "price": "text",
  "last_price": "text",
  "price_24h_change": "text",
  "price_24h_change_percent": "text",
  "lowest_price": "text",
  "highest_price": "text",
  "volume_24h": "text",
  "amount_24h": "text"
}
  • Register with the Orderbook
  • Place buy / sell orders gas-free
  • Orders are matched and confirmed
  • Orders are settled in aggregate
  • REST API
  • POST/v1/login
  • POST/v1/accounts:getByPrincipal
  • GET/v1/accounts/{uid}
  • GET/v1/accounts/pnl/{uid}/today
  • GET/v1/assets
  • POST/v1/accounts/{uid}:updateSettings
  • POST/v1/accounts/{uid}:sendVerificationEmail
  • POST/v1/accounts/{uid}:verifyEmail
  • GET/v1/accounts/{uid}/fund-history
  • GET/v1/orders
  • POST/v1/orders
  • POST/v1/orders:make
  • GET/v1/orderbook/{market}
  • GET/v1/orders/{order_hash}
  • POST/v1/orders/{order_hash}:cancel
  • POST/v1/orders:cancel_all
  • GET/v1/orderbook:tickers
  • GET/v1/fills
  • GET/v1/orderbook/{market}:fills
  • GET/v1/orderbook/{market}:trades
  • GET/v1/orderbook/{market}:trading-view
  • GET/v1/orderbook:overview
  • GET/v1/orderbook/{market}:overview
post
Body
payloadstringRequired
signaturestringRequired
Responses
201Success
post
POST /v1/login HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 37

{
  "payload": "text",
  "signature": "text"
}
201Success

No content

post
Body
principalstringRequired
Responses
200Success
application/json
404Error
post
POST /v1/accounts:getByPrincipal HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 20

{
  "principal": "text"
}
{
  "uid": "text",
  "principal": "text",
  "public_key": "text",
  "email": "text",
  "username": "text",
  "email_subscription_enabled": true,
  "email_verified": true
}
post
Authorizations
Path parameters
uidnumberRequired
Body
emailstringRequired
usernamestringRequired
email_subscription_enabledbooleanRequired
Responses
409Error
post
POST /v1/accounts/{uid}:updateSettings HTTP/1.1
Host: 
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 68

{
  "email": "text",
  "username": "text",
  "email_subscription_enabled": true
}
409Error

No content

post
Authorizations
Path parameters
uidnumberRequired
Body
emailstringRequired
Responses
404Error
post
POST /v1/accounts/{uid}:sendVerificationEmail HTTP/1.1
Host: 
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 16

{
  "email": "text"
}
404Error

No content

post
Path parameters
uidnumberRequired
Body
tokenstringRequired
Responses
201Success
post
POST /v1/accounts/{uid}:verifyEmail HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 16

{
  "token": "text"
}
201Success

No content

post
Body
orderstringRequired
signaturestringRequired
Responses
200Success
application/json
post
POST /v1/orders HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 35

{
  "order": "text",
  "signature": "text"
}
200Success
{
  "market": "BTC-USD",
  "side": "buy",
  "price": "text",
  "risk": true,
  "maker": "text",
  "size": "text",
  "type": "vanilla",
  "salt": "text",
  "timestamp": "text",
  "sender_fee": "text",
  "stop_price": "text",
  "expiration_height": "text"
}
post
Body
marketstring ยท enumRequiredPossible values:
sidestring ยท enumRequiredPossible values:
pricestringRequired
riskbooleanRequired
makerstringRequired
sizestringRequired
typestring ยท enumRequiredPossible values:
saltstringOptional
stop_pricestringOptional
timestampstringOptional
sender_feestringRequired
expiration_heightstringRequired
Responses
200Success
application/json
post
POST /v1/orders:make HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 206

{
  "market": "BTC-USD",
  "side": "buy",
  "price": "text",
  "risk": true,
  "maker": "text",
  "size": "text",
  "type": "vanilla",
  "salt": "text",
  "stop_price": "text",
  "timestamp": "text",
  "sender_fee": "text",
  "expiration_height": "text"
}
200Success
{
  "type": "text",
  "expiration-height": "text",
  "maker-asset": "text",
  "maker-asset-data": "text",
  "maximum-fill": "text",
  "sender": "text",
  "sender-fee": "text",
  "taker-asset": "text",
  "taker-asset-data": "text",
  "maker": "text",
  "salt": "text",
  "timestamp": "text",
  "stop": "text",
  "risk": true
}
post
Authorizations
Body
marketstring ยท enumOptionalPossible values:
Responses
200Success
application/json
post
POST /v1/orders:cancel_all HTTP/1.1
Host: 
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 20

{
  "market": "BTC-USD"
}
200Success
{
  "orders": [
    "text"
  ]
}