Next week, Version 2 of the 0x Exchange is scheduled to go to the Ethereum mainnet. We outlined the new supported features from 0x v2 a few posts ago, including the addition of support for ERC721 Tokens, which we announced earlier this week.
The new features of 0x v2 have necessitated some changes to the Standard Relayer API (SRA). Until now, OpenRelay’s support of 0x v2 was implemented with an early draft of the SRA, but today we are announcing full support for the finalized Version 2 of the HTTP SRA. This means that OpenRelay is compatible with the 0x v2 tools such as 0x.js and 0x Connect.
Our ingest process still follows the same flow as outlined in our post about Ingesting 27 million orders, but has been updated to support the new order format, as well as ERC721 tokens.
In Version 2 of the SRA, relayers are given a space to provide additional metadata with respect to orders. OpenRelay adds these additional, non-standard metadata fields:
hash: The keccak256 hash of the 0x order. This can be calculated from the order, but depending on what tools you are using, it may be handy to have it provided by the API.
feeRate: The taker fee per unit of the taker token. This can also be calculated from the order, but having it handy may help you decide which orders offer the best price.
status: This is OpenRelay’s status numeric code for the order. The possible status codes are:
- 0 — Open — The order is open and available to be filled.
- 1 — Filled — The order has been filled.
- 2 — Unfunded — The maker either lacks the maker token or the fee token required to complete this order. Unfunded orders may be partially fillable based on the maker’s available assets, but are removed from the order book and search APIs, and are no longer tracked by OpenRelay for further updates.
- 3 — Cancelled — The order has been cancelled, either through a direct order cancellation, or through a call to cancelUpTo.
Note that there is no special status for expired; expired orders are identified based on their timestamp. Additionally, the /v2/orders and /v2/orderbook endpoints only list orders with a status of 0 (open). The only endpoint that will return orders with other statuses is the /v2/order/[HASH] endpoint.
takerAssetAmountRemaining: The number of remaining base units of the taker asset. Any partial fills can decrease this number after it is served by OpenRelay, so we advise checking the block chain for current values before submitting an order to be filled. This value is intended primarily for initial filtering, to weed out orders that may not have enough remaining tokens to be worth filling.
We are working on updates to OpenRelay’s documentation, but as we currently compy with the Standard Relayer API, community-driven tools should work out of the box.
One behavior of the SRA that may seem strange for the next few days is that the
search endpoints all take a
networkId query parameter, which the SRA notes
must default to 1. If the user specifies an unsupported network, the SRA
prescribes an error to raise. Until Version 2 launches on mainnet, the SRA’s default
network is also an unsupported network, and thus OpenRelay will return the
prescribed error. To use the SRA on Kovan, add
networkId=42 to your query
string. We plan to add mainnet support as soon as the 0x project team publishes
addresses for the mainnet contracts.
The 0x Project team has indicated that they plan to disable the 0x v1 exchange contract in December. We intend to continue supporting the v0 API endpoints through that time. If the 0x Project team changes their plans with respect to disabling the v1 exchange, we will support the corresponding endpoints at least through the end of the year.
Note that even once 0x v2 is on mainnet, OpenRelay’s /v0/ endpoints and /v2/ endpoints will return separate sets of orders.
Future API Updates
Currently we only support the HTTP implementation of the Standard Relayer API. We hope to support the websockets implementation by the end of the year. We are also exploring ways to enhance our support for ERC721 tokens, to make the additional metadata about ERC721 tokens more accessible.