diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index 2a2d2b3072..136bf72eb0 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -19,7 +19,7 @@ import { fetchAsync } from '@0x/utils'; import * as _ from 'lodash'; import * as queryString from 'query-string'; -import { Client, HttpRequestOptions, HttpRequestType } from './types'; +import { HttpRequestOptions, HttpRequestType } from './types'; import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers'; const TRAILING_SLASHES_REGEX = /\/+$/; @@ -28,7 +28,7 @@ const TRAILING_SLASHES_REGEX = /\/+$/; * This class includes all the functionality related to interacting with a set of HTTP endpoints * that implement the standard relayer API v2 */ -export class HttpClient implements Client { +export class HttpClient { private readonly _apiEndpointUrl: string; /** * Format parameters to be appended to http requests into query string form diff --git a/packages/connect/src/index.ts b/packages/connect/src/index.ts index f319d63cb2..517678bd52 100644 --- a/packages/connect/src/index.ts +++ b/packages/connect/src/index.ts @@ -1,6 +1,6 @@ export { HttpClient } from './http_client'; export { ordersChannelFactory } from './orders_channel_factory'; -export { Client, OrdersChannel, OrdersChannelHandler } from './types'; +export { OrdersChannel, OrdersChannelHandler } from './types'; export { APIOrder, AssetPairsRequestOpts, diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts index 08a4506ac4..5e990de9e7 100644 --- a/packages/connect/src/types.ts +++ b/packages/connect/src/types.ts @@ -1,30 +1,4 @@ -import { - APIOrder, - AssetPairsItem, - AssetPairsRequestOpts, - FeeRecipientsResponse, - OrderbookRequest, - OrderbookResponse, - OrderConfigRequest, - OrderConfigResponse, - OrdersChannelSubscriptionOpts, - OrdersRequestOpts, - PagedRequestOpts, - PaginatedCollection, - SignedOrder, -} from '@0x/types'; - -export interface Client { - getAssetPairsAsync: ( - requestOpts?: AssetPairsRequestOpts & PagedRequestOpts, - ) => Promise>; - getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise>; - getOrderAsync: (orderHash: string) => Promise; - getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise; - getOrderConfigAsync: (request: OrderConfigRequest) => Promise; - getFeeRecipientsAsync: (requestOpts?: PagedRequestOpts) => Promise; - submitOrderAsync: (signedOrder: SignedOrder) => Promise; -} +import { APIOrder, OrdersChannelSubscriptionOpts } from '@0x/types'; export interface OrdersChannel { subscribe: (subscriptionOpts: OrdersChannelSubscriptionOpts) => void; diff --git a/packages/connect/test/fixtures/standard_relayer_api/order_config.json b/packages/connect/test/fixtures/standard_relayer_api/order_config.json index 39da91e6d7..ad2c2cd827 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/order_config.json +++ b/packages/connect/test/fixtures/standard_relayer_api/order_config.json @@ -2,5 +2,7 @@ "senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32", "feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da", "makerFee": "100000000000000", - "takerFee": "200000000000000" + "takerFee": "200000000000000", + "makerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d", + "takerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d" } diff --git a/packages/connect/test/fixtures/standard_relayer_api/order_config.ts b/packages/connect/test/fixtures/standard_relayer_api/order_config.ts index 2290c39c0b..94dcde71f8 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/order_config.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/order_config.ts @@ -7,4 +7,6 @@ export const orderConfigResponse: OrderConfigResponse = { feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', makerFee: new BigNumber('100000000000000'), takerFee: new BigNumber('200000000000000'), + makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', }; diff --git a/packages/json-schemas/schemas/eip712_domain_schema.json b/packages/json-schemas/schemas/eip712_domain_schema.json index 3b6c9ef1e3..268254fff3 100644 --- a/packages/json-schemas/schemas/eip712_domain_schema.json +++ b/packages/json-schemas/schemas/eip712_domain_schema.json @@ -1,10 +1,18 @@ { "id": "/eip712DomainSchema", "properties": { - "name": { "type": "string" }, - "version": { "type": "version" }, - "chainId": { "type": "number" }, - "verifyingContractAddress": { "$ref": "/addressSchema" } + "name": { + "type": "string" + }, + "version": { + "type": "version" + }, + "chainId": { + "type": "number" + }, + "verifyingContract": { + "$ref": "/addressSchema" + } }, "required": [ "chainId", diff --git a/packages/json-schemas/schemas/orders_request_opts_schema.json b/packages/json-schemas/schemas/orders_request_opts_schema.json index 4c1b9b4e98..05f486930d 100644 --- a/packages/json-schemas/schemas/orders_request_opts_schema.json +++ b/packages/json-schemas/schemas/orders_request_opts_schema.json @@ -2,18 +2,50 @@ "id": "/OrdersRequestOptsSchema", "type": "object", "properties": { - "makerAssetProxyId": { "$ref": "/hexSchema" }, - "takerAssetProxyId": { "$ref": "/hexSchema" }, - "makerAssetAddress": { "$ref": "/addressSchema" }, - "takerAssetAddress": { "$ref": "/addressSchema" }, - "exchangeAddress": { "$ref": "/addressSchema" }, - "senderAddress": { "$ref": "/addressSchema" }, - "makerAssetData": { "$ref": "/hexSchema" }, - "takerAssetData": { "$ref": "/hexSchema" }, - "traderAssetData": { "$ref": "/hexSchema" }, - "makerAddress": { "$ref": "/addressSchema" }, - "takerAddress": { "$ref": "/addressSchema" }, - "traderAddress": { "$ref": "/addressSchema" }, - "feeRecipientAddress": { "$ref": "/addressSchema" } + "makerAssetProxyId": { + "$ref": "/hexSchema" + }, + "takerAssetProxyId": { + "$ref": "/hexSchema" + }, + "makerAssetAddress": { + "$ref": "/addressSchema" + }, + "takerAssetAddress": { + "$ref": "/addressSchema" + }, + "exchangeAddress": { + "$ref": "/addressSchema" + }, + "senderAddress": { + "$ref": "/addressSchema" + }, + "makerAssetData": { + "$ref": "/hexSchema" + }, + "takerAssetData": { + "$ref": "/hexSchema" + }, + "traderAssetData": { + "$ref": "/hexSchema" + }, + "makerFeeAssetData": { + "$ref": "/hexSchema" + }, + "takerFeeAssetData": { + "$ref": "/hexSchema" + }, + "makerAddress": { + "$ref": "/addressSchema" + }, + "takerAddress": { + "$ref": "/addressSchema" + }, + "traderAddress": { + "$ref": "/addressSchema" + }, + "feeRecipientAddress": { + "$ref": "/addressSchema" + } } } diff --git a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json index 8193861e12..3d060a7631 100644 --- a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json +++ b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json @@ -2,10 +2,31 @@ "id": "/relayerApiOrderConfigResponseSchema", "type": "object", "properties": { - "makerFee": { "$ref": "/wholeNumberSchema" }, - "takerFee": { "$ref": "/wholeNumberSchema" }, - "feeRecipientAddress": { "$ref": "/addressSchema" }, - "senderAddress": { "$ref": "/addressSchema" } + "makerFee": { + "$ref": "/wholeNumberSchema" + }, + "takerFee": { + "$ref": "/wholeNumberSchema" + }, + "feeRecipientAddress": { + "$ref": "/addressSchema" + }, + "senderAddress": { + "$ref": "/addressSchema" + }, + "makerFeeAssetData": { + "$ref": "/hexSchema" + }, + "takerFeeAssetData": { + "$ref": "/hexSchema" + } }, - "required": ["makerFee", "takerFee", "feeRecipientAddress", "senderAddress"] + "required": [ + "makerFee", + "takerFee", + "feeRecipientAddress", + "senderAddress", + "makerFeeAssetData", + "takerFeeAssetData" + ] } diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.json b/packages/json-schemas/schemas/relayer_api_orders_schema.json index 84e75cd045..a8c970e718 100644 --- a/packages/json-schemas/schemas/relayer_api_orders_schema.json +++ b/packages/json-schemas/schemas/relayer_api_orders_schema.json @@ -1,5 +1,7 @@ { "id": "/relayerApiOrdersSchema", "type": "array", - "items": { "$ref": "/relayerApiOrderSchema" } + "items": { + "$ref": "/relayerApiOrderSchema" + } } diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 855777a390..6c3aa4f379 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -478,6 +478,8 @@ describe('Schema', () => { takerFee: '30000000000000000', feeRecipientAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', senderAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', }, ]; validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema); diff --git a/packages/sra-spec/.discharge.json b/packages/sra-spec/.discharge.json index 80ede84f36..8985f07e87 100644 --- a/packages/sra-spec/.discharge.json +++ b/packages/sra-spec/.discharge.json @@ -1,6 +1,6 @@ { - "domain": "sra-spec", - "build_command": "yarn build-json", + "domain": "sra3-spec", + "build_command": "yarn build", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/sra-spec/public/index.html b/packages/sra-spec/public/index.html index 5271b50c68..e334c6749c 100644 --- a/packages/sra-spec/public/index.html +++ b/packages/sra-spec/public/index.html @@ -1,24 +1,27 @@ - - 0x Standard Relayer API - - - - - + + + + + - - - - - - + + + + + + + + diff --git a/packages/sra-spec/src/api.ts b/packages/sra-spec/src/api.ts index 37a6677816..fdfb9548b5 100644 --- a/packages/sra-spec/src/api.ts +++ b/packages/sra-spec/src/api.ts @@ -9,7 +9,7 @@ import { generateResponses } from './responses'; export const api: OpenApiSpec = { openapi: '3.0.0', info: { - version: '2.0.0', + version: '3.0.0', title: 'Standard Relayer REST API', description: md.introduction, license: { @@ -18,7 +18,7 @@ export const api: OpenApiSpec = { }, }, paths: { - '/v2/asset_pairs': { + '/v3/asset_pairs': { get: { description: 'Retrieves a list of available asset pairs and the information required to trade them (in any order). Setting only `assetDataA` or `assetDataB` returns pairs filtered by that asset only.', @@ -53,7 +53,7 @@ export const api: OpenApiSpec = { ), }, }, - '/v2/orders': { + '/v3/orders': { get: { description: 'Retrieves a list of orders given query parameters. This endpoint should be [paginated](#section/Pagination). For querying an entire orderbook snapshot, the [orderbook endpoint](#operation/getOrderbook) is recommended. If both makerAssetData and takerAssetData are specified, returned orders will be sorted by price determined by (takerTokenAmount/makerTokenAmount) in ascending order. By default, orders returned by this endpoint are unsorted.', @@ -99,7 +99,7 @@ export const api: OpenApiSpec = { { name: 'exchangeAddress', in: 'query', - description: `Same as exchangeAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as exchangeAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/addressSchema', @@ -108,7 +108,7 @@ export const api: OpenApiSpec = { { name: 'senderAddress', in: 'query', - description: `Same as senderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as senderAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/addressSchema', @@ -117,7 +117,7 @@ export const api: OpenApiSpec = { { name: 'makerAssetData', in: 'query', - description: `Same as makerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as makerAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/hexSchema', @@ -126,7 +126,7 @@ export const api: OpenApiSpec = { { name: 'takerAssetData', in: 'query', - description: `Same as takerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as takerAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/hexSchema', @@ -135,7 +135,7 @@ export const api: OpenApiSpec = { { name: 'traderAssetData', in: 'query', - description: `Same as traderAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as traderAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/hexSchema', @@ -144,7 +144,7 @@ export const api: OpenApiSpec = { { name: 'makerAddress', in: 'query', - description: `Same as makerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as makerAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/addressSchema', @@ -153,7 +153,7 @@ export const api: OpenApiSpec = { { name: 'takerAddress', in: 'query', - description: `Same as takerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as takerAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/addressSchema', @@ -162,7 +162,7 @@ export const api: OpenApiSpec = { { name: 'traderAddress', in: 'query', - description: `Same as traderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as traderAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/addressSchema', @@ -171,12 +171,30 @@ export const api: OpenApiSpec = { { name: 'feeRecipientAddress', in: 'query', - description: `Same as feeRecipientAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`, + description: `Same as feeRecipientAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, example: '0xe41d2489571d322189246dafa5ebde1f4699f498', schema: { $ref: '#/components/schemas/addressSchema', }, }, + { + name: 'makerFeeAssetData', + in: 'query', + description: `Same as makerFeeAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, + example: '0xe41d2489571d322189246dafa5ebde1f4699f498', + schema: { + $ref: '#/components/schemas/hexSchema', + }, + }, + { + name: 'takerFeeAssetData', + in: 'query', + description: `Same as takerFeeAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`, + example: '0xe41d2489571d322189246dafa5ebde1f4699f498', + schema: { + $ref: '#/components/schemas/hexSchema', + }, + }, ], true, ), @@ -187,7 +205,7 @@ export const api: OpenApiSpec = { ), }, }, - '/v2/order/{orderHash}': { + '/v3/order/{orderHash}': { get: { description: 'Retrieves the 0x order with meta info that is associated with the hash.', operationId: 'getOrder', @@ -212,7 +230,7 @@ export const api: OpenApiSpec = { ), }, }, - '/v2/orderbook': { + '/v3/orderbook': { get: { description: `Retrieves the orderbook for a given asset pair. This endpoint should be [paginated](#section/Pagination). Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by _taker fee price_ which is defined as the **takerFee** divided by **takerTokenAmount**. After _taker fee price_, orders are to be sorted by expiration in ascending order. The way pagination works for this endpoint is that the **page** and **perPage** query params apply to both \`bids\` and \`asks\` collections, and if \`page\` * \`perPage\` > \`total\` for a certain collection, the \`records\` for that collection should just be empty. `, operationId: 'getOrderbook', @@ -248,9 +266,9 @@ export const api: OpenApiSpec = { ), }, }, - '/v2/order_config': { + '/v3/order_config': { post: { - description: `Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: \`senderAddress\`, \`feeRecipientAddress\`, \`makerFee\`, \`takerFee\`. `, + description: `Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: \`senderAddress\`, \`feeRecipientAddress\`, \`makerFee\`, \`takerFee\`, \`makerFeeAssetData\`, \`takerFeeAssetData\`. `, operationId: 'getOrderConfig', parameters: generateParameters([], false), requestBody: { @@ -272,7 +290,7 @@ export const api: OpenApiSpec = { ), }, }, - '/v2/fee_recipients': { + '/v3/fee_recipients': { get: { description: `Retrieves a collection of all fee recipient addresses for a relayer. This endpoint should be [paginated](#section/Pagination).`, operationId: 'getFeeRecipients', @@ -284,7 +302,7 @@ export const api: OpenApiSpec = { ), }, }, - '/v2/order': { + '/v3/order': { post: { description: `Submit a signed order to the relayer.`, operationId: 'postOrder', diff --git a/packages/sra-spec/src/examples/relayerApiOrder.ts b/packages/sra-spec/src/examples/relayerApiOrder.ts index e3ae66dc35..a2851943b2 100644 --- a/packages/sra-spec/src/examples/relayerApiOrder.ts +++ b/packages/sra-spec/src/examples/relayerApiOrder.ts @@ -13,8 +13,11 @@ export const relayerApiOrder = { makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', takerAssetData: '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', + makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', + chainId: 1, }, metaData: {}, }; diff --git a/packages/sra-spec/src/examples/relayerApiOrderConfigResponse.ts b/packages/sra-spec/src/examples/relayerApiOrderConfigResponse.ts index a3c531c0a2..ec43c9f05a 100644 --- a/packages/sra-spec/src/examples/relayerApiOrderConfigResponse.ts +++ b/packages/sra-spec/src/examples/relayerApiOrderConfigResponse.ts @@ -3,4 +3,6 @@ export const relayerApiOrderConfigResponse = { feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', makerFee: '100000000000000', takerFee: '200000000000000', + makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', }; diff --git a/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts b/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts index 7f07726498..ab9825cdbd 100644 --- a/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts +++ b/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts @@ -19,8 +19,11 @@ export const relayerApiOrderbookResponse = { makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', takerAssetData: '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', + makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', + chainId: 1, }, metaData: {}, }, @@ -48,6 +51,7 @@ export const relayerApiOrderbookResponse = { takerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891', + chainId: 1, }, metaData: {}, }, diff --git a/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts b/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts index eb66b8e81f..d5f64d6215 100644 --- a/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts +++ b/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts @@ -18,8 +18,11 @@ export const relayerApiOrdersResponse = { makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', takerAssetData: '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', + makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', + chainId: 1, }, metaData: {}, }, diff --git a/packages/sra-spec/src/examples/signedOrder.ts b/packages/sra-spec/src/examples/signedOrder.ts index 8513c398fd..c901da2909 100644 --- a/packages/sra-spec/src/examples/signedOrder.ts +++ b/packages/sra-spec/src/examples/signedOrder.ts @@ -12,6 +12,9 @@ export const signedOrder = { makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', takerAssetData: '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', + makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', + chainId: 1, }; diff --git a/packages/sra-spec/src/md/introduction.md b/packages/sra-spec/src/md/introduction.md index 2ab7786eef..f851f200dc 100644 --- a/packages/sra-spec/src/md/introduction.md +++ b/packages/sra-spec/src/md/introduction.md @@ -25,21 +25,21 @@ const validatorResult: ValidatorResult = validator.validate(tokenPairsResponse, Requests that return potentially large collections should respond to the **?page** and **?perPage** parameters. For example: ```bash -$ curl https://api.example-relayer.com/v2/asset_pairs?page=3&perPage=20 +$ curl https://api.example-relayer.com/v3/asset_pairs?page=3&perPage=20 ``` Page numbering should be 1-indexed, not 0-indexed. If a query provides an unreasonable (ie. too high) `perPage` value, the response can return a validation error as specified in the [errors section](#section/Errors). If the query specifies a `page` that does not exist (ie. there are not enough `records`), the response should just return an empty `records` array. All endpoints that are paginated should return a `total`, `page`, `perPage` and a `records` value in the top level of the collection. The value of `total` should be the total number of records for a given query, whereas `records` should be an array representing the response to the query for that page. `page` and `perPage`, are the same values that were specified in the request. See the note in [miscellaneous](#section/Misc.) about formatting `snake_case` vs. `lowerCamelCase`. -These requests include the [`/v2/asset_pairs`](#operation/getAssetPairs), [`/v2/orders`](#operation/getOrders), [`/v2/fee_recipients`](#operation/getFeeRecipients) and [`/v2/orderbook`](#operation/getOrderbook) endpoints. +These requests include the [`/v3/asset_pairs`](#operation/getAssetPairs), [`/v3/orders`](#operation/getOrders), [`/v3/fee_recipients`](#operation/getFeeRecipients) and [`/v3/orderbook`](#operation/getOrderbook) endpoints. # Network Id All requests should be able to specify a **?networkId** query param for all supported networks. For example: ```bash -$ curl https://api.example-relayer.com/v2/asset_pairs?networkId=1 +$ curl https://api.example-relayer.com/v3/asset_pairs?networkId=1 ``` If the query param is not provided, it should default to **1** (mainnet). @@ -75,7 +75,7 @@ A [Link Header](https://tools.ietf.org/html/rfc5988) can be included in a respon For example: ```bash -Link: ; rel="next", +Link: ; rel="next", ; rel="last" ``` @@ -103,7 +103,7 @@ Rate limit guidance for clients can be optionally returned in the response heade For example: ```bash -$ curl -i https://api.example-relayer.com/v2/asset_pairs +$ curl -i https://api.example-relayer.com/v3/asset_pairs HTTP/1.1 200 OK Date: Mon, 20 Oct 2017 12:30:06 GMT Status: 200 OK @@ -169,7 +169,7 @@ Validation error codes: # Asset Data Encoding -As we now support multiple [token transfer proxies](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxy), the identifier of which proxy to use for the token transfer must be encoded, along with the token information. Each proxy in 0x v2 has a unique identifier. If you're using 0x.js there will be helper methods for this encoding and decoding. +As we now support multiple [token transfer proxies](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#assetproxy), the identifier of which proxy to use for the token transfer must be encoded, along with the token information. Each proxy in 0x v3 has a unique identifier. If you're using 0x.js there will be helper methods for this encoding and decoding. The identifier for the Proxy uses a similar scheme to [ABI function selectors](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#function-selector). @@ -194,11 +194,11 @@ Encoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc740 0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063 ``` -For more information see [the Asset Proxy](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#erc20proxy) section of the v2 spec and the [Ethereum ABI Spec](https://solidity.readthedocs.io/en/develop/abi-spec.html). +For more information see [the Asset Proxy](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#erc20proxy) section of the v3 spec and the [Ethereum ABI Spec](https://solidity.readthedocs.io/en/develop/abi-spec.html). # Meta Data in Order Responses -In v2 of the standard relayer API we added the `metaData` field. It is meant to provide a standard place for relayers to put optional, custom or non-standard fields that may of interest to the consumer of the API. +In v3 of the standard relayer API we added the `metaData` field. It is meant to provide a standard place for relayers to put optional, custom or non-standard fields that may of interest to the consumer of the API. A good example of such a field is `remainingTakerAssetAmount`, which is a convenience field that communicates how much of a 0x order is potentially left to be filled. Unlike the other fields in a 0x order, it is not guaranteed to be correct as it is derived from whatever mechanism the implementer (ie. the relayer) is using. While convenient for prototyping and low stakes situations, we recommend validating the value of the field by checking the state of the blockchain yourself. diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 3e53788e0b..4d385fd8e4 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -429,6 +429,8 @@ export interface OrdersRequestOpts { senderAddress?: string; makerAssetData?: string; takerAssetData?: string; + makerFeeAssetData?: string; + takerFeeAssetData?: string; makerAddress?: string; takerAddress?: string; traderAddress?: string; @@ -468,6 +470,8 @@ export interface OrderConfigResponse { takerFee: BigNumber; feeRecipientAddress: string; senderAddress: string; + makerFeeAssetData: string; + takerFeeAssetData: string; } export type FeeRecipientsResponse = PaginatedCollection;