Using the Orderbook

ALEX Orderbook is available at https://app.alexlab.co/orderbook.

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

Once user registration is complete, you can use our REST API (https://stxdx-api.alexlab.co/) to interact with the Orderbook.

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

For more details, please contract your ALEX representatives.

POST/v1/login
Body
payload*string
signature*string
Response
Request
const response = await fetch('/v1/login', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "payload": "text",
      "signature": "text"
    }),
});
const data = await response.json();

POST/v1/accounts:getByPrincipal
Body
principal*string
Response
Body
uid*string
principal*string
public_key*string
email*string
username*string
email_subscription_enabled*boolean
email_verified*boolean
Request
const response = await fetch('/v1/accounts:getByPrincipal', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "principal": "text"
    }),
});
const data = await response.json();
Response
{
  "uid": "text",
  "principal": "text",
  "public_key": "text",
  "email": "text",
  "username": "text",
  "email_subscription_enabled": false,
  "email_verified": false
}

GET/v1/accounts/{uid}
Authorization
Path parameters
uid*number
Response
Body
uid*string
principal*string
public_key*string
balances*array of UserBalanceDetail (object)
Request
const response = await fetch('/v1/accounts/{uid}', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer JWT"
    },
});
const data = await response.json();
Response
{
  "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/v1/accounts/pnl/{uid}/today
Authorization
Path parameters
uid*number
Response
  • See GetAccountPnlInfoResponse for details about pnl of today
Body
uid*string
today_pnl*string
today_pnl_percent*string
balances*array of AssetInfoDTO (object)
Request
const response = await fetch('/v1/accounts/pnl/{uid}/today', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer JWT"
    },
});
const data = await response.json();
Response
{
  "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/v1/assets
Response
Body
assetId*string
asset*string
Request
const response = await fetch('/v1/assets', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "assetId": "text",
  "asset": "text"
}

POST/v1/accounts/{uid}:updateSettings
Authorization
Path parameters
uid*number
Body
email*string
username*string
email_subscription_enabled*boolean
Response
Request
const response = await fetch('/v1/accounts/{uid}:updateSettings', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer JWT",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "email": "text",
      "username": "text",
      "email_subscription_enabled": false
    }),
});
const data = await response.json();

POST/v1/accounts/{uid}:sendVerificationEmail
Authorization
Path parameters
uid*number
Body
email*string
Response
Request
const response = await fetch('/v1/accounts/{uid}:sendVerificationEmail', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer JWT",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "email": "text"
    }),
});
const data = await response.json();

POST/v1/accounts/{uid}:verifyEmail
Path parameters
uid*number
Body
token*string
Response
Request
const response = await fetch('/v1/accounts/{uid}:verifyEmail', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "token": "text"
    }),
});
const data = await response.json();

GET/v1/accounts/{uid}/fund-history
Authorization
Path parameters
uid*number
Query parameters
Response
Body
history*array of BaseFundResponse (object)
Request
const response = await fetch('/v1/accounts/{uid}/fund-history', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer JWT"
    },
});
const data = await response.json();
Response
{
  "history": [
    {
      "asset_id": "text",
      "type": "deposit",
      "status": "pending",
      "amount": "text",
      "tx_id": "text",
      "created_at": "text"
    }
  ]
}

GET/v1/orders
Authorization
Query parameters
Response
Body
orders*array of BaseRenderOrderResponse (object)
Request
const response = await fetch('/v1/orders', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer JWT"
    },
});
const data = await response.json();
Response
{
  "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": false
    }
  ]
}

POST/v1/orders
Body
order*string
signature*string
Response
Body
market*enum
BTC-USDALEX-USDSTX-USDDB20-USDLONG-USDSHNT-USDPIZA-USDMAXI-USDINSC-USDMAJO-USDDEXM-USDATMT-USDBENG-USDCVLT-USDLBOW-USDMEME-USDNALS-USDNYTO-USDORDI-USDORDS-USDSBTC-USDโ‚ฟ-USDVMPX-USDOXBT-USDSATS-USDTARO-USDTRAC-USD10MM-USDXING-USDBANK-USDPEPE-USDZBIT-USDMOON-USDDRAC-USDLOVE-USDATLFG-USDDBIT-USDPASS-USDWZRD-USDMXRC-USDOHMS-USDJAKE-USDIGLI-USDORMM-USDLGER-USD
side*enum
buysell
price*string
risk*boolean
maker*string
size*string
type*enum
vanillafokioc
salt*string
timestamp*string
sender_fee*string
stop_price*string
expiration_height*string
Request
const response = await fetch('/v1/orders', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "order": "text",
      "signature": "text"
    }),
});
const data = await response.json();
Response
{
  "market": "BTC-USD",
  "side": "buy",
  "price": "text",
  "risk": false,
  "maker": "text",
  "size": "text",
  "type": "vanilla",
  "salt": "text",
  "timestamp": "text",
  "sender_fee": "text",
  "stop_price": "text",
  "expiration_height": "text"
}

POST/v1/orders:make
Body
market*enum
BTC-USDALEX-USDSTX-USDDB20-USDLONG-USDSHNT-USDPIZA-USDMAXI-USDINSC-USDMAJO-USDDEXM-USDATMT-USDBENG-USDCVLT-USDLBOW-USDMEME-USDNALS-USDNYTO-USDORDI-USDORDS-USDSBTC-USDโ‚ฟ-USDVMPX-USDOXBT-USDSATS-USDTARO-USDTRAC-USD10MM-USDXING-USDBANK-USDPEPE-USDZBIT-USDMOON-USDDRAC-USDLOVE-USDATLFG-USDDBIT-USDPASS-USDWZRD-USDMXRC-USDOHMS-USDJAKE-USDIGLI-USDORMM-USDLGER-USD
side*enum
buysell
price*string
risk*boolean
maker*string
size*string
type*enum
vanillafokioc
saltstring
stop_pricestring
timestampstring
sender_fee*string
expiration_height*string
Response
Body
type*string
expiration-height*string
maker-asset*string
maker-asset-data*string
maximum-fill*string
sender*string
sender-fee*string
taker-asset*string
taker-asset-data*string
maker*string
salt*string
timestamp*string
stop*string
risk*boolean
Request
const response = await fetch('/v1/orders:make', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "market": "BTC-USD",
      "side": "buy",
      "price": "text",
      "risk": false,
      "maker": "text",
      "size": "text",
      "type": "vanilla",
      "sender_fee": "text",
      "expiration_height": "text"
    }),
});
const data = await response.json();
Response
{
  "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": false
}

GET/v1/orderbook/{market}
Path parameters
market*string
Response
Body
bids*array of OrderBookPriceSize (object)
asks*array of OrderBookPriceSize (object)
Request
const response = await fetch('/v1/orderbook/{market}', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "bids": [
    {
      "price": "text",
      "size": "text"
    }
  ],
  "asks": [
    {
      "price": "text",
      "size": "text"
    }
  ]
}

GET/v1/orders/{order_hash}
Authorization
Path parameters
order_hash*string
Response
Body
order*BaseRenderOrderResponse (object)
Request
const response = await fetch('/v1/orders/{order_hash}', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer JWT"
    },
});
const data = await response.json();
Response
{
  "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": false
  }
}

POST/v1/orders/{order_hash}:cancel
Authorization
Path parameters
order_hash*string
Response
Body
order*BaseRenderOrderResponse (object)
Request
const response = await fetch('/v1/orders/{order_hash}:cancel', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer JWT"
    },
});
const data = await response.json();
Response
{
  "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": false
  }
}

POST/v1/orders:cancel_all
Authorization
Body
marketenum
BTC-USDALEX-USDSTX-USDDB20-USDLONG-USDSHNT-USDPIZA-USDMAXI-USDINSC-USDMAJO-USDDEXM-USDATMT-USDBENG-USDCVLT-USDLBOW-USDMEME-USDNALS-USDNYTO-USDORDI-USDORDS-USDSBTC-USDโ‚ฟ-USDVMPX-USDOXBT-USDSATS-USDTARO-USDTRAC-USD10MM-USDXING-USDBANK-USDPEPE-USDZBIT-USDMOON-USDDRAC-USDLOVE-USDATLFG-USDDBIT-USDPASS-USDWZRD-USDMXRC-USDOHMS-USDJAKE-USDIGLI-USDORMM-USDLGER-USD
Response
Body
orders*array of string
Request
const response = await fetch('/v1/orders:cancel_all', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer JWT",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({}),
});
const data = await response.json();
Response
{
  "orders": [
    "text"
  ]
}

GET/v1/orderbook:tickers
Query parameters
Response
Body
tickers*array of OrderBookTickerDTO (object)
Request
const response = await fetch('/v1/orderbook:tickers', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "tickers": [
    {
      "market": "BTC-USD",
      "bid": "text",
      "bid_size": "text",
      "ask": "text",
      "ask_size": "text"
    }
  ]
}

GET/v1/fills
Authorization
Query parameters
Response
Body
fills*array of OrderFillDTO (object)
Request
const response = await fetch('/v1/fills', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer JWT"
    },
});
const data = await response.json();
Response
{
  "fills": [
    {
      "id": 0,
      "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": 0
    }
  ]
}

GET/v1/orderbook/{market}:fills
Path parameters
market*string
Response
Body
fills*array of OrderFillDTO (object)
Request
const response = await fetch('/v1/orderbook/{market}:fills', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "fills": [
    {
      "id": 0,
      "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": 0
    }
  ]
}

GET/v1/orderbook/{market}:trades
Path parameters
market*string
Response
Body
trades*array of MarketTrade (object)
Request
const response = await fetch('/v1/orderbook/{market}:trades', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "trades": [
    {
      "timestamp": 0,
      "price": "text",
      "size": "text",
      "left_hash": "text",
      "left_maker": 0,
      "left_side": "buy",
      "right_hash": "text",
      "right_maker": 0,
      "right_side": "buy"
    }
  ]
}

GET/v1/orderbook/{market}:trading-view
Path parameters
market*string
Query parameters
Response
Body
metadata*TradingViewDataMetadata (object)
series*array of array of string

['range_start', 'open', 'high', 'low', 'close', 'volume']

Request
const response = await fetch('/v1/orderbook/{market}:trading-view', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "metadata": {
    "market": "BTC-USD",
    "resolution": 0,
    "lastUpdate": 0,
    "nextTime": 0,
    "timezone": "text",
    "columns": [
      "text"
    ]
  },
  "series": [
    [
      "text"
    ]
  ]
}

GET/v1/orderbook:overview
Response
Body
market*enum
BTC-USDALEX-USDSTX-USDDB20-USDLONG-USDSHNT-USDPIZA-USDMAXI-USDINSC-USDMAJO-USDDEXM-USDATMT-USDBENG-USDCVLT-USDLBOW-USDMEME-USDNALS-USDNYTO-USDORDI-USDORDS-USDSBTC-USDโ‚ฟ-USDVMPX-USDOXBT-USDSATS-USDTARO-USDTRAC-USD10MM-USDXING-USDBANK-USDPEPE-USDZBIT-USDMOON-USDDRAC-USDLOVE-USDATLFG-USDDBIT-USDPASS-USDWZRD-USDMXRC-USDOHMS-USDJAKE-USDIGLI-USDORMM-USDLGER-USD
ticker*OrderBookTickerDTO (object)
price*string
last_price*string
price_24h_change*string
price_24h_change_percent*string
lowest_price*string
highest_price*string
volume_24h*string
amount_24h*string
Request
const response = await fetch('/v1/orderbook:overview', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
[
  {
    "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/v1/orderbook/{market}:overview
Path parameters
market*string
Response
Body
market*enum
BTC-USDALEX-USDSTX-USDDB20-USDLONG-USDSHNT-USDPIZA-USDMAXI-USDINSC-USDMAJO-USDDEXM-USDATMT-USDBENG-USDCVLT-USDLBOW-USDMEME-USDNALS-USDNYTO-USDORDI-USDORDS-USDSBTC-USDโ‚ฟ-USDVMPX-USDOXBT-USDSATS-USDTARO-USDTRAC-USD10MM-USDXING-USDBANK-USDPEPE-USDZBIT-USDMOON-USDDRAC-USDLOVE-USDATLFG-USDDBIT-USDPASS-USDWZRD-USDMXRC-USDOHMS-USDJAKE-USDIGLI-USDORMM-USDLGER-USD
ticker*OrderBookTickerDTO (object)
price*string
last_price*string
price_24h_change*string
price_24h_change_percent*string
lowest_price*string
highest_price*string
volume_24h*string
amount_24h*string
Request
const response = await fetch('/v1/orderbook/{market}:overview', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "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"
}

Last updated