Orderbook

In order to indicate current pricing for Native APIs and aggregators, you have to provide price levels endpoint that will return price levels of all the supported pairs in a specified chain. Native will call the endpoint every second on every supported network to get the latest price levels. The endpoint provided must adhere to the following format:

Orderbook Endpoint

GET <market_maker_base_url>/orderbook

Params

NameDescription

chainId

Chain ID of the network. In integer. eg: 1 for Ethereum, 56 for BSC.

Example

<market_maker_base_url>/orderbook?chainId=1

Response

You need to provide a response in the following format:

Type: Array of order pairs

NameDescription

base_symbol

The symbol of the token you are buying or selling.

base_address

The address of the token you are buying or selling.

quote_symbol

The symbol of the token that will exchanged for the base token.

quote_address

The address of the token that will exchanged for the base token.

levels

This is an array of tuples in the format of [[int, int]]. The value at index 0 is the amount of tokens and the value at index 1 is the price you are willing to transact at.

side

"ask" or "bid". Indicates whether you are buying or selling the base token.

minimum_in_base

The minimum amount of base tokens that you are willing to transact.

Example response:

[
    {
        "base_symbol": "USDT",
        "base_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "quote_symbol": "AAVE",
        "quote_address": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
        "levels": [
            [
                278.6807021305324,
                0.016506345666681244
            ],
            [
                2883.2639932781804,
                0.0165090675397643
            ],
            // ... more price levels
        ],
        "side": "ask",
        "minimum_in_base": 0.0001
    },
    {
        "base_symbol": "AAVE",
        "base_address": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
        "quote_symbol": "USDT",
        "quote_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "levels": [
            [
                4.6,
                60.58276133272444
            ],
            [
                47.6,
                60.572772968029
            ],
            // ... more price levels
        ],
        "side": "bid",
        "minimum_in_base": 0.0001
    }
    // ... more token pairs
]

Note that the price levels need to be returned in a non-cumulative manner. For example, for the following price levels of WETH-USDT pair:

[
    [0.001, 1600],
    [1,1610],
    [2,1612]
]

if someone wanted to trade 3 WETH for USDT, the price would be: 0.001 * 1600 + 1 * 1610 + 1.999 * 1612 = 4833.988

Note: Native server is hosted in Singapore region and we require all the market makers to give response to all the endpoints in under 1 second.

Last updated