AlcorDocs

On-chain Data

Reading spot markets and orders straight from the DEX contract tables.

Markets and orders can be read directly from the DEX contract with any node API, without Alcor's servers. The table layouts are described in Contract tables.

The DEX contract per chain:

ChainDEX contract
WAXalcordexmain
EOSeostokensdex
Teloseostokensdex
XPRalcor

Markets

Markets are stored in the markets table, with the contract itself as scope.

cleos -u https://wax.greymass.com get table alcordexmain alcordexmain markets
import { JsonRpc } from 'eosjs'

const rpc = new JsonRpc('https://wax.greymass.com', { fetch })

const { rows } = await rpc.get_table_rows({
  code: 'alcordexmain',   // DEX contract
  scope: 'alcordexmain',  // same as the contract
  table: 'markets',
  limit: 1000,
})
{
  "rows": [
    {
      "id": 0,
      "base_token": { "sym": "8,WAX", "contract": "eosio.token" },
      "quote_token": { "sym": "4,PGL", "contract": "prospectorsw" },
      "min_buy": "0.00000100 WAX",
      "min_sell": "0.0001 PGL",
      "frozen": 0,
      "fee": 0
    }
  ],
  "more": true
}

The contract names the sides the other way round from the API: its base_token is the API's target (the token prices are quoted in) and its quote_token is the API's base.

FieldDescription
idMarket id: the scope of the market's order tables, and the market_id of the API tickers
base_tokenTarget token: the token prices are quoted in
quote_tokenBase token: the token being traded
min_buySmallest buy order
min_sellSmallest sell order
frozen1 when trading is frozen
feeMarket fee in hundredths of a percent

Orders

Orders are stored in the buyorder and sellorder tables, with the market id as scope.

cleos -u https://wax.greymass.com get table alcordexmain 26 buyorder -l 2
const { rows } = await rpc.get_table_rows({
  code: 'alcordexmain',
  scope: 26,             // market id
  table: 'buyorder',     // or 'sellorder'
  key_type: 'i128',
  index_position: 2,     // secondary index: sorted by price
  limit: 1000,
})
{
  "rows": [
    {
      "id": 28,
      "account": "pxawpxawpxaw",
      "bid": "10.00000000 WAX",
      "ask": "1999.9560 TLM",
      "unit_price": "500012",
      "timestamp": 1603653505
    }
  ],
  "more": true,
  "next_key": "558"
}
FieldDescription
idOrder id, used to cancel the order
accountOrder owner
bidWhat the order offers
askWhat the order wants in return
unit_pricePrice as an integer: the price in target per base multiplied by 10^8
timestampOrder creation time, unix seconds

On this page