NAV
Im token logo imToken API Documentation DApp-SDK Tokenlon-Onboarding Tokenlon-MMSK Tokenlon-MMProxy Tokenlon-JSSDK Tokenlon-Open-API
typescript
  • Introduction
  • Installation
  • Preparation
  • Interfaces for Market-Makers
  • Configuration
  • Market maker interface prechecks
  • Initialization
  • Data flow
  • Public API provided by MMSK
  • English

    Introduction

    Tokenlon-MMSK is a tool to start Node http service for market making. The service is deployed on the market maker side. It is an intermediate proxy that connects the imToken Server and the market maker service. MMSK stands for Market Maker Service Kit, which is used to reduce the cost of communication at both ends.

    Installation

    Download the latest release here.

    To be sure that the file hasn’t been tampered with, we suggest the market maker checks the downloaded zip file’s sha256 checksum, for example via: shasum -a 256 /path/to/file

    After the check and un-zip is completed, enter the tokenlon-mmsk root directory, and execute:

    yarn or npm install

    Preparation

    1. The market maker needs to prepare a wallet for signature, the marketMakerSigner
    2. Contact imToken and provide the marketMakerSigner wallet address to imToken. Now, imToken will deploy a marketMakerProxyContract and provide the contract address to the market maker.
    3. Contact imToken for environment parameters such as EXCHANGE_URL, WEBSOCKET_URL
    4. Deposit tokens to the marketMakerProxyContract

    Interfaces for Market-Makers

    The market maker needs to implement following 5 Tokenlon-MMSK interfaces:

    1. The pairs interface asks market maker for authorized trading currency pairs
    2. The indicativePrice interface asks market maker to provide a reference price for a specific trading currency pair
    3. The price interface asks the market maker quoting prices for a specific trading amount
    4. The deal interface: Once the quote confirmed by the users, the imToken Server will push an order to the tokenlon-mmsk, and tokenlon-mmsk then notifies the market maker via the deal interface
    5. The exception interface: Once the order has some exception situation, the imToken Server will push an exception order to the tokenlon-mmsk, and tokenlon-mmsk then notifies the market maker via the exception interface

    Using Zerorpc approach

    example

    import * as zerorpc from 'zerorpc'
    
    const server = new zerorpc.Server({
      pairs(params, reply) {
        reply(null, {
          result: true,
          pairs: ['SNT/ETH', 'KNC/ETH', 'ETH/DAI'],
        })
      },
      indicativePrice(params, reply) {
        reply(null, {
          result: true,
          exchangeable: true,
          minAmount: 0.002,
          maxAmount: 100,
          price: 0.00032,
        })
      },
      price(params, reply) {
        reply(null, {
          result: true,
          exchangeable: true,
          minAmount: 0.002,
          maxAmount: 100,
          quoteId: '234dsfasd-sdfasdf-sdfasf'
        })
      },
      deal(params, replay) {
        reply(null, {
          result: true
        })
      },
      exception(params, replay) {
        reply(null, {
          result: true
        })
      },
    
    })
    server.bind('tcp://0.0.0.0:4242')
    

    For further details, refer to:zerorpc

    pairs interface

    Invoke

    import * as zerorpc from 'zerorpc'
    
    const client = new zerorpc.Client()
    client.connect('tcp://127.0.0.1:4242')
    
    client.invoke('pairs', undefined, (error, res, more) => {
        console.log(res)
    })
    

    Response

    {
      "result": true,
      "pairs": [
        "SNT/ETH",
        "OMG/ETH",
        "ETH/DAI"
      ]
    }
    
    // Return
    {
      "result": false,
      "message": "Exception"
    }
    

    Parameter

    none

    return

    Returned in normal conditions
    Name Type Description
    result Boolean whether normal return
    pairs Array pair string array
    Returned in other circumstances
    Name Type Description
    result Boolean whether normal return
    message String possible error information

    indicativePrice interface

    Invoke

    import * as zerorpc from 'zerorpc'
    
    const client = new zerorpc.Client()
    client.connect('tcp://127.0.0.1:4242')
    
    client.invoke('indicativePrice', {
      base: 'SNT',
      quote: 'ETH',
      side: 'SELL',
      amount: 50,
    }, (error, res, more) => {
        console.log(res)
    })
    
    client.invoke('indicativePrice', {
      base: 'SNT',
      quote: 'ETH',
      side: 'SELL',
      amount: 1000,
    }, (error, res, more) => {
        console.log(res)
    })
    

    Response

    // Returned in normal conditions
    {
      "result": true,
      "exchangeable": true,
      "price": 0.00017508,
      "minAmount": 0.002,
      "maxAmount": 100,
    }
    
    // Returned in other circumstances
    {
      "result": false,
      "exchangeable": false,
      "minAmount": 0.002,
      "maxAmount": 100,
      "message": "insufficient balance"
    }
    

    Parameter

    Name Type Mandatory Description
    base String YES base symbol
    quote String YES quote symbol
    side String YES 'BUY' or 'SELL'
    amount Number NO BUY or SELL base amount

    return

    Returned in normal conditions
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    price Number
    Returned in other circumstances
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    message String possible error information

    price interface

    Invoke

    import * as zerorpc from 'zerorpc'
    
    const client = new zerorpc.Client()
    client.connect('tcp://127.0.0.1:4242')
    
    client.invoke('price', {
      base: 'SNT',
      quote: 'ETH',
      side: 'SELL',
      amount: 50,
      uniqId: 'dfasfsdf',
    }, (error, res, more) => {
        console.log(res)
    })
    
    client.invoke('price', {
      base: 'SNT',
      quote: 'ETH',
      side: 'SELL',
      amount: 1000,
      uniqId: 'dfasfsdf',
    }, (error, res, more) => {
        console.log(res)
    })
    

    Response

    // Returned in normal conditions
    {
      "result": true,
      "exchangeable": true,
      "price": 0.00017508,
      "minAmount": 0.0002,
      "maxAmount": 100,
      "quoteId": "asfadsf-dsfsdf-ggsd-qwe-rgjty",
    }
    
    // Returned in other circumstances
    {
      "result": false,
      "exchangeable": false,
      "minAmount": 0.0002,
      "maxAmount": 100,
      "message": "insufficient balance"
    }
    

    Parameter

    Name Type Mandatory Description
    base String YES base symbol
    quote String YES quote symbol
    side String YES 'BUY' or 'SELL'
    amount Number YES BUY or SELL base amount
    uniqId String YES Identifies each unique user

    return

    Returned in normal conditions
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    price Number
    quoteId String A unique value used to track the final order of the quotation and the transaction status.
    Returned in other circumstances
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    message String possible error information

    deal interface

    Invoke

    import * as zerorpc from 'zerorpc'
    
    const client = new zerorpc.Client()
    client.connect('tcp://127.0.0.1:4242')
    
    client.invoke('deal', {
      makerToken: 'SNT',
      takerToken: 'ETH',
      makerTokenAmount: 1000,
      takerTokenAmount: 1,
      quoteId: '234dsfasd-sdfasdf-sdfasf',
      timestamp: 1231234324,
    }, (error, res, more) => {
        console.log(res)
    })
    

    Response

    {
      "result": true
    }
    

    Parameter

    Name Type Mandatory Description
    makerToken String YES token symbol
    takerToken String YES token symbol
    makerTokenAmount Number YES maker token's amount
    takerTokenAmount Number YES taker token's amount
    quoteId String YES quoteId from price interface
    timestamp Number YES

    return

    Name Type Description
    result Boolean We suggest you just return true, If you return false,imToken will always retry to send this notification to you, and it maybe repeat your hedge.

    exception interface

    Invoke

    import * as zerorpc from 'zerorpc'
    
    const client = new zerorpc.Client()
    client.connect('tcp://127.0.0.1:4242')
    
    client.invoke('exception', {
      makerToken: 'SNT',
      takerToken: 'ETH',
      makerTokenAmount: 1000,
      takerTokenAmount: 1,
      quoteId: '234dsfasd-sdfasdf-sdfasf',
      timestamp: 1231234324,
      type: 'FAILED',
    }, (error, res, more) => {
        console.log(res)
    })
    

    Response

    {
      "result": true
    }
    

    Parameter

    Name Type Mandatory Description
    makerToken String YES token symbol
    takerToken String YES token symbol
    makerTokenAmount Number YES maker token's amount
    takerTokenAmount Number YES taker token's amount
    quoteId String YES quoteId from price interface
    type String YES 'FAILED' means that order failed; 'TIMEOUT' means that order timeout(also failed too);'DELAY' means that order is executed but imToken didn't notify MM by deal API
    timestamp Number YES

    return

    Name Type Description
    result Boolean We suggest you just return true, If you return false,imToken will always retry to send this notification to you, and it maybe repeat your processing.

    Using HTTP approach

    pairs interface

    Request

    curl 'HTTP_SERVER_ENDPOINT/pairs'
    

    Response

    // Returned in normal conditions
    {
      "result": true,
      "pairs": [
        "SNT/ETH",
        "OMG/ETH",
        "DAI/ETH"
      ]
    }
    
    // Returned in other circumstances
    {
      "result": false,
      "message": "Exception"
    }
    

    Request address: HTTP_SERVER_ENDPOINT/pairs

    Parameter

    GET

    return

    none

    request return

    Returned in normal conditions
    Name Type Description
    result Boolean whether normal return
    pairs Array pair string array
    Returned in other circumstances
    Name Type Description
    result Boolean whether normal return
    message String possible error information

    indicativePrice interface

    Request

    curl 'HTTP_SERVER_ENDPOINT/indicativePrice?base=SNT&quote=OMG&amount=30&side=BUY'
    

    Response

    // Returned in normal conditions
    {
      "result": true,
      "exchangeable": true,
      "price": 0.00017508,
      "minAmount": 0.0002,
      "maxAmount": 100
    }
    
    // Returned in other circumstances
    {
      "result": false,
      "exchangeable": false,
      "minAmount": 0.0002,
      "maxAmount": 100,
      "message": "insufficient balance"
    }
    

    Request URL: HTTP_SERVER_ENDPOINT/indicativePrice

    Request return

    GET

    Request parameters

    Name Type Mandatory Description
    base String YES base symbol
    quote String YES quote symbol
    side String YES 'BUY' or 'SELL'
    amount Number NO BUY or SELL base amount

    Request return

    Returned in normal conditions
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    price Number
    Returned in other circumstances
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    message String possible error information

    price interface

    Request

    curl 'HTTP_SERVER_ENDPOINT/price?base=SNT&quote=OMG&amount=30&side=BUY&uniqId=dfdsfjsidf'
    

    Response

    // Returned in normal conditions
    {
      "result": true,
      "exchangeable": true,
      "price": 0.00017508,
      "minAmount": 0.0002,
      "maxAmount": 100,
      "quoteId": "asfadsf-dsfsdf-ggsd-qwe-rgjty"
    }
    
    // Returned in other circumstances
    {
      "result": false,
      "exchangeable": false,
      "minAmount": 0.0002,
      "maxAmount": 100,
      "message": "insufficient balance"
    }
    

    Request URL: HTTP_SERVER_ENDPOINT/price

    Request return

    GET

    Request parameters

    Name Type Mandatory Description
    base String YES base symbol
    quote String YES quote symbol
    side String YES 'BUY' or 'SELL'
    amount Number YES BUY or SELL base amount
    uniqId String YES Identifies each unique user

    Request return

    Returned in normal conditions
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    price Number
    quoteId String A unique value used to track the final order of the quotation and the transaction status.
    Returned in other circumstances
    Name Type Description
    result Boolean whether normal return
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    message String possible error information

    deal interface

    Request

    curl -X POST \
      HTTP_SERVER_ENDPOINT/deal \
      -H 'Content-Type: application/json' \
      -H 'cache-control: no-cache' \
      -d '{"makerToken": "SNT","takerToken":"OMG","makerTokenAmount":30,"takerTokenAmount":0.1,"quoteId":"234dsfasd-sdfasdf-sdfasf","timestamp":1231234324}'
    

    Response

    {
      "result": true
    }
    

    Request address: HTTP_SERVER_ENDPOINT/deal

    Request return

    POST

    Request parameters

    Name Type Mandatory Description
    makerToken String YES token symbol
    takerToken String YES token symbol
    makerTokenAmount Number YES maker token's amount
    takerTokenAmount Number YES taker token's amount
    quoteId String YES quoteId from price interface
    timestamp Number YES

    Request return

    Name Type Description
    result Boolean We suggest you just return true, If you return false,imToken will always retry to send this notification to you, and it maybe repeat your hedge.

    exception interface

    Request

    curl -X POST \
      HTTP_SERVER_ENDPOINT/exception \
      -H 'Content-Type: application/json' \
      -H 'cache-control: no-cache' \
      -d '{"makerToken": "SNT","takerToken":"OMG","makerTokenAmount":30,"takerTokenAmount":0.1,"quoteId":"234dsfasd-sdfasdf-sdfasf","timestamp":1231234324,"type":"FAILED"}'
    

    Response

    {
      "result": true
    }
    

    Parameter

    Name Type Mandatory Description
    makerToken String YES token symbol
    takerToken String YES token symbol
    makerTokenAmount Number YES maker token's amount
    takerTokenAmount Number YES taker token's amount
    quoteId String YES quoteId from price interface
    type String YES 'FAILED' means that order failed; 'TIMEOUT' means that order timeout(also failed too);'DELAY' means that order is executed but imToken didn't notify MM by deal API
    timestamp Number YES

    return

    Name Type Description
    result Boolean We suggest you just return true, **If you return false,imToken will always retry to send this notification to you, and it maybe repeat your processing.

    Configuration

    Market makers can customize the configuration parameters of mmConf.js in the app directory of tokenlon-mmsk project.

    EXCHANGE_URL

    Contact bd@consenlabs.com to establish a partnership with imToken.

    WEBSOCKET_URL

    Contact bd@consenlabs.com to establish a partnership with imToken.

    PROVIDER_URL

    const PROVIDER_URL = 'https://kovan.infura.io/v3/xxxxxx'
    const PROVIDER_URL = ['https://kovan.infura.io/v3/xxxxxx1', 'https://kovan.infura.io/v3/xxxxxx2', 'https://kovan.infura.io/v3/xxxxxx3']
    
    // mainnet
    const PROVIDER_URL = 'https://mainnet.infura.io/v3/xxxxxx'
    const PROVIDER_URL = ['https://mainnet.infura.io/v3/xxxxxx1', 'https://mainnet.infura.io/v3/xxxxxx2', 'https://mainnet.infura.io/v3/xxxxxx3']
    

    PROVIDER_URL support string, array configuration

    market maker can register infura to get provider url

    MMSK_SERVER_PORT

    TOKENLON-MMSK service port. The default value is 80.

    WALLET_ADDRESS

    marketMakerSigner address (the wallet address used for signing).

    wallet private key configuration

    marketMakerSigner private key

    The key can be used in two ways: Private key mode, keystore mode.

    keystore mode

    keystore mode

    // the environment variable configured by the operation and maintenance - keystore storage location
    const keystorePath = process.env.KEYSTORE_PATH
    // read keystore
    const keystoreStr = fs.readFileSync(keystorePath).toString()
    const keystore = JSON.parse(keystoreStr)
    const USE_KEYSTORE = true
    const WALLET_KEYSTORE = keystore
    

    Under this mode, only the wallet keystore is stored on the server, and the administrator needs to enter a password to get the corresponding private key. The specific way is to set the USE_KEYSTORE parameter to true and use WALLET_KEYSTORE. The WALLET_PRIVATE_KEY doesn’t need to be passed.

    Now Tokenlon-MMSK will prompt for the password of the keystore at the command line.

    pure private key mode

    private key mode

    const WALLET_PRIVATE_KEY = 'your marketMakerSigner private key'
    

    Set USE_KEYSTORE to false or not pass, use WALLET_PRIVATE_KEY, don't pass WALLET_KEYSTORE.

    Market maker interface address configuration

    zerorpc mode

    const USE_ZERORPC = true
    const ZERORPC_SERVER_ENDPOINT = 'your zerorpc addr and port' // like tcp:127.0.0.1:4242
    

    http mode

    const USE_ZERORPC = false
    const HTTP_SERVER_ENDPOINT = 'your http server endpoint' // like https://xxx.xxx.com
    

    The market maker interface can be provided via zerorpc or http mode.

    1. When using HTTP to provide pairsindicativePricepricedealexception set USE_ZERORPC to false, don't pass ZERORPC_SERVER_ENDPOINT.
    2. When using zerorpc to provide pairsindicativePricepricedealexception set, USE_ZERORPC to true, don't pass HTTP_SERVER_ENDPOINT.

    Market maker interface prechecks

    mmConf.js for private key mode and http interface configuration

    module.exports = {
      EXCHANGE_URL,
      WEBSOCKET_URL,
      PROVIDER_URL, // like ['https://mainnet.infura.io']
      MMSK_SERVER_PORT: 80, // default is 80,
    
      WALLET_ADDRESS,
      WALLET_PRIVATE_KEY,
    
      USE_ZERORPC: false,
      HTTP_SERVER_ENDPOINT: 'https://abc.abc.com',
    })
    

    mmConf.js for keystore and zerorpc configuration

    import * as fs from 'fs'
    
    // environment variable configuration - keystore storage location
    const keystorePath = process.env.KEYSTORE_PATH
    // Read keystore
    const keystoreStr = fs.readFileSync(keystorePath).toString()
    const keystore = JSON.parse(keystoreStr)
    
    module.exports = {
      EXCHANGE_URL,
      WEBSOCKET_URL,
      PROVIDER_URL, // like ['https://mainnet.infura.io']
      MMSK_SERVER_PORT: 80, // default is 80,
    
      WALLET_ADDRESS,
      USE_KEYSTORE: true,
      WALLET_KEYSTORE: keystore,
    
      USE_ZERORPC: true,
      ZERORPC_SERVER_ENDPOINT: 'tcp:127.0.0.1:4242',
    }
    

    Use interface checks: yarn run check or npm run check

    This method can be used to detect the implementation of the interface and check whether there are related problems. For example, the:

    1. interface returns does not conform to the standard
    2. interface returns an error

    And others.

    Initialization

    mmConf.js interface for private key and zerorpc configuration

    module.exports = {
      EXCHANGE_URL,
      WEBSOCKET_URL,
      PROVIDER_URL, // like ['https://mainnet.infura.io']
      MMSK_SERVER_PORT: 80, // default is 80,
    
      WALLET_ADDRESS,
      WALLET_PRIVATE_KEY,
    
      USE_ZERORPC: true,
      ZERORPC_SERVER_ENDPOINT: 'tcp:127.0.0.1:4242',
    })
    

    mmConf.js for keystore and http configuration

    import * as fs from 'fs'
    
    // environment variable configuration environment variable - keystore storage location
    const keystorePath = process.env.KEYSTORE_PATH
    // Read keystore
    const keystoreStr = fs.readFileSync(keystorePath).toString()
    const keystore = JSON.parse(keystoreStr)
    
    module.exports = {
      EXCHANGE_URL,
      WEBSOCKET_URL,
      PROVIDER_URL, // like ['https://mainnet.infura.io']
      MMSK_SERVER_PORT: 80, // default is 80,
    
      WALLET_ADDRESS,
      USE_KEYSTORE: true,
      WALLET_KEYSTORE: keystore,
    
      USE_ZERORPC: false,
      HTTP_SERVER_ENDPOINT: 'https://xxx.xxx.com',
    }
    

    Run: yarn start or npm run start

    For service deployment, market makers needs to provide an external network access (IP or domain name). Mode), and give that external network access address (IP or domain name) to imToken.

    Data flow

    tokenlon-flow-en

    Public API provided by MMSK

    tokenlon-mmsk also provides following public APIs to marker makers.

    getSupportedTokenList

    example

    {
      "result": true,
      "tokens": [
        {
          "symbol": "ETH",
          "opposites": [
            "MANA",
            "SNT",
          ]
        },
        {
          "symbol": "MANA",
          "opposites": [
            "ETH"
          ]
        },
        {
          "symbol": "SNT",
          "opposites": [
            "ETH"
          ]
        }
      ]
    }
    

    imToken will return the tokens supported by the market maker and imToken through this interface, through the pairs interface of the market maker and the getTokenList interface of imToken Server.

    Request mode

    GET

    Request parameter

    None

    request return

    Name Type Description
    result Boolean Whether Returned in normal conditions
    tokens Array token item array

    getRate

    example

    {
      "result": true,
      "exchangeable": true,
      "minAmount": 0.0002,
      "maxAmount": 100,
      "rate": 124.28
    }
    

    imToken Server will continuously poll the getRate interface of the requesting market maker mmsk Server to provide the best quotation to the user. This interface is only a simple derivative of the market maker's indicativePrice interface.

    Request mode

    GET

    Request parameters

    Name Type Mandatory description
    base String YES base symbol
    quote String YES quote symbol
    side String YES 'BUY' or 'SELL'
    amount Number NO BUY or SELL base amount

    request return

    Returned in normal conditions

    Name Type description
    result Boolean Whether Returned in normal conditions
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    rate Number

    Returned in other circumstances

    Name Type Description
    result Boolean Whether Returned in normal conditions
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    message String error message

    newOrder

    example

    {
      "result": true,
      "rate": 0.00002,
      "exchangeable": true,
      "minAmount": 0.0002,
      "maxAmount": 100,
      "order": {
        "makerAddress": "0xb6025914f4e631d458f4668cc232d1e38ddbd569",
        "makerAssetAmount": "1000000000000000000000",
        "makerAssetData": "0xf47261b0000000000000000000000000744d70fdbe2ba4cf95131626614a1763df805b9e",
        "makerFee": "0",
        "takerAddress": "0x08053129c3967f4a496958aac5a1e8e6df6c7652",
        "takerAssetAmount": "23324453240000000000",
        "takerAssetData": "0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "takerFee": "0",
        "senderAddress": "0x8f19bf4b5dfae80c1e3f91bd33f3bbc37326d5e7",
        "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
        "expirationTimeSeconds": "1539498614",
        "exchangeAddress": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa",
        "salt": "59572482685924225672407231424301404205239289582722616080644908172098386763718",
        "makerWalletSignature": "0x1b66353b9b6cff19d5acbdf275d55e988c2a077c6c6074bcf49705e09b7efd3a61212821ff244b96623fa5181507da0b796a6693b1d511e9355a83c4c06ac88a66fba2ff8436171ddd3653cd2ca1c5595046144d7f04",
        "quoteId": "TD-190109-173025-NqGaWun",
        "feeFactor": 10
      }
    }
    

    When the user clicks quote request button in the imToken app, they will get the order for the corresponding price. The imToken server polls the newOrder interface of each market maker’s mmsk server to provide the order with the best quote prices to the user.

    Request mode

    GET

    Request parameters

    Name Type Mandatory description
    base String YES base symbol
    quote String YES quote symbol
    side String YES 'BUY' or 'SELL'
    userAddr String YES user's address
    amount Number YES BUY or SELL base amount
    uniqId String YES represents the user's unique Id

    request return

    Returned in normal conditions

    Name Type description
    result Boolean Whether Returned in normal conditions
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    rate Number This order's rate
    order Object 0x's maker signed order

    Returned in other circumstances

    Name Type Description
    result Boolean Whether Returned in normal conditions
    exchangeable Boolean Whether is tradable
    minAmount Number The minimum amount that base token can be traded
    maxAmount Number The maximum amount that base token can be traded
    message String error message

    dealOrder

    example

    {
      makerToken: 'SNT',
      takerToken: 'ETH',
      makerTokenAmount: 1000,
      takerTokenAmount: 1,
      quoteId: '234dsfasd-sdfasdf-sdfasf',
      timestamp: 1231234324,
    }
    

    Request mode

    POST

    Request parameters

    Name Type Mandatory Description
    makerToken String YES token symbol
    takerToken String YES token symbol
    makerTokenAmount Number YES maker token's amount
    takerTokenAmount Number YES taker token's amount
    quoteId String YES quoteId from price interface
    timestamp Number YES

    request return

    Returned in normal conditions

    Name Type description
    result true

    Returned in other circumstances

    Name Type Description
    result false
    message String error message

    exceptionOrder

    example

    {
      makerToken: 'SNT',
      takerToken: 'ETH',
      makerTokenAmount: 1000,
      takerTokenAmount: 1,
      quoteId: '234dsfasd-sdfasdf-sdfasf',
      timestamp: 1231234324,
      type: 'FAILED',
    }
    

    Request parameters

    POST

    Request parameters

    Name Type Mandatory Description
    makerToken String YES token symbol
    takerToken String YES token symbol
    makerTokenAmount Number YES maker token's amount
    takerTokenAmount Number YES taker token's amount
    quoteId String YES quoteId from price interface
    type String YES 'FAILED' 代表这笔订单失败;'TIMEOUT' 代表这笔订单超时失败;'DELAY' 代表这笔订单成交了,但是没有通过 deal 通知做市商,此种情况也属于异常情况
    timestamp Number YES

    request return

    Returned in normal conditions

    Name Type description
    result true

    Returned in other circumstances

    Name Type Description
    result false
    message String error message

    version

    Request mode

    GET

    request return

    Name Type description
    result true
    version String The version of MMSK

    getBalance

    example

    {
      "result": true,
      "balance": 0.13371396
    }
    

    Market maker can get marketMakerProxyContract contract’s corresponding token balance through this interface.

    Request mode

    GET

    Request parameters

    Name Type Mandatory description
    token String YES token symbol

    request return

    Name Type description
    result Boolean Whether Returned in normal conditions
    balance Number the token's balance

    getBalances

    example

    {
      "result": true,
      "balances": [
        {
          "symbol": "ETH",
          "balance": 0.13371396
        },
        {
          "symbol": "ZRX",
          "balance": 0
        },
        {
          "symbol": "DAI",
          "balance": 5.78464455
        },
        {
          "symbol": "KNC",
          "balance": 49.99451026
        },
        {
          "symbol": "MKR",
          "balance": 0
        },
        {
          "symbol": "OMG",
          "balance": 0
        },
        {
          "symbol": "SNT",
          "balance": 0
        },
        {
          "symbol": "MANA",
          "balance": 0
        }
      ]
    }
    

    Same as getBalance, but can get multiple balances. The market maker can get token balances of multiple marketMakerProxyContract contract through this interface.

    Request mode

    GET

    Request parameters

    request return

    Name Type description
    result Boolean Whether Returned in normal conditions
    balances Array balance item array

    getOrdersHistory

    example

    {
      "result": true,
      "orders": [
        {
          "makerToken": "SNT",
          "takerToken": "ETH",
          "makerTokenAmount": 1000,
          "takerTokenAmount": 1,
          "quoteId": "234dsfasd-sdfasdf-sdfasf",
          "status": "success",
          "txHash": "0x953e9641811865e2a5da0bcfbee1c0da2f88e252efb9e782e60730ac0e730807",
          "timestamp": 1549349662
        }
      ]
    }
    

    The Market Maker can get the order of all transactions through this interface.

    Request mode

    GET

    Request parameters

    Name Type Mandatory description
    page Number YES
    perpage Number YES per page

    request return

    Name Type description
    result Boolean Whether Returned in normal conditions
    orders Array See the example

    getOrderState

    example

    {
      "result": true,
      "order": {
        "makerToken": "SNT",
        "takerToken": "ETH",
        "makerTokenAmount": 1000,
        "takerTokenAmount": 1,
        "quoteId": "234dsfasd-sdfasdf-sdfasf",
        "status": "success",
        "txHash": "0x953e9641811865e2a5da0bcfbee1c0da2f88e252efb9e782e60730ac0e730807",
        "timestamp": 1549349662
      }
    }
    

    The Market Maker can get the order status of each transaction by quoteId through this interface.

    Request mode

    GET

    Request parameters

    Name Type Mandatory description
    quoteId String YES a unique value final order for tracking the offer, and if transaction

    request return

    Name Type description
    result Boolean Whether Returned in normal conditions
    order Object See the example

    Appendix:order status

    corresponding status to an order can be:

    status description
    unbroadcast Order has not been forwarded by the service to the chain
    pending Transaction is in mempool, waiting to be mined
    success Successfully submitted on chain
    failed Failure of on-chain transaction
    timeout Timeout of transaction on chain
    invalid Order is invalid
    abandoned Order isn't be used