Migrating to V2

V2 Migration Guide


Starting with V2, the markets endpoint is paginated, which introduces a change to the way markets are retrieved using the SDK.

A line of code like this:

const zrxWethMarket = rr.markets.get('ZRX-WETH');

would become:

const zrxWethMarket = await rr.markets.getAsync('ZRX-WETH');

Because the markets are retrieved asynchronously, they are returned by the underlying cache asynchronously, too. You can also populate the underlying cache with a specific page or markets or the nextpage, like so:

// Get a specific page with a specific result count.
const page = 5;
const perPage = 25;
await rr.markets.getPageAsync(page, perPage); // Returns the resulting page of markets and caches them.
// Populate the next page of markets (each page consists of 100 markets).
await rr.markets.getNextPageAsync(); // Returns the resulting page of markets and caches them too.

In the markets initialization step of the SDK setup, the ZRX/WETH market is explicitly retrieved, along with the first page of 100 markets. In simple use-cases, you shouldn't have to worry about other changes in our feed and trade APIs, the SDK is already updated to handle the new schemas and endpoints seamlessly.

SDK Gotchas

Previously, the markets and tokens properties of an SDK instance were derived from a TypeScript implementation of ES6 Map which included a size() method to return the number of entries in the cache. The tokens property is now a plain ES6 map, which uses a size property as opposed to a method getter. So lines of code like the following:

const numTokens = rr.tokens.size();
const numMarkets = rr.markets.size();

would be rewritten as:

const numTokens = rr.tokens.size;
const numMarkets = rr.markets.size;

The markets property shares the above change, but note that markets is not a plain ES6 map, rather a custom collection object with very similar features. It shares all the same methods and properties as ES6 map excluding get and set methods. It's also iterable, so you can use it in a for... of... block!

Feed API

Listing Markets

Our markets endpoint is now more modular, breaking out the market's base, ticker, history, and stats. You can specify which parts of a market you'd like in the response with the include query parameter.

An example request might look like the following:

curl https://api.radarrelay.com/v2/markets?include=base,ticker,stats,history
# OR
curl https://api.radarrelay.com/v2/markets/ZRX-WETH?include=base,ticker,stats,history

By default, only the market's base is returned in the response.

Feed API Gotchas

  • Our pagination middleware limits requests to 100 items per page. The affected endpoints are /markets and markets/{marketId}/fills.

  • The per_page query parameter is now perPage. The old nomenclature will no longer work.

Trade API

The schema of order objects has changed significantly within the Trade API, be sure to familiarize yourself with the updated SignedOrder and RadarSignedOrder interfaces.

Trade API Gotchas

  • The salt property of an order is expected to be a Unix timestamp.

  • The signature property is simplified to be a hex string encoded.

  • makerTokenAmount and takerTokenAmount become makerAssetAmount and takerAssetAmountrespectively.

Standard Relayer API (SRA)

Check out the 0x Standard Relayer API README and the 0x protocol 2.0.0 specification for information regarding changes to the SRA.