From 3771df728c2dfcdeeb3fc49cd27ef864f2e94316 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 7 Aug 2018 16:24:31 -0700 Subject: Add GET OrderBook endpoint --- packages/sra-api/src/api.ts | 36 +++++++++++++++ packages/sra-api/src/examples/index.ts | 2 + .../src/examples/relayerApiOrderBookResponse.ts | 54 ++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 packages/sra-api/src/examples/relayerApiOrderBookResponse.ts diff --git a/packages/sra-api/src/api.ts b/packages/sra-api/src/api.ts index 2cc15b297..5289a31f3 100644 --- a/packages/sra-api/src/api.ts +++ b/packages/sra-api/src/api.ts @@ -205,6 +205,42 @@ export const api: OpenApiSpec = { ), }, }, + '/v2/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 **per_page** query params apply to both \`bids\` and \`asks\` collections, and if \`page\` * \`per_page\` > \`total\` for a certain collection, the \`records\` for that collection should just be empty. `, + operationId: 'getOrderBook', + parameters: generateParameters( + [ + { + name: 'baseAssetData', + in: 'query', + description: `assetData (makerAssetData or takerAssetData) designated as the base currency in the [currency pair calculation](https://en.wikipedia.org/wiki/Currency_pair) of price.`, + required: true, + example: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + schema: { + $ref: '#/components/schemas/hexSchema', + }, + }, + { + name: 'quoteAssetData', + in: 'query', + description: `assetData (makerAssetData or takerAssetData) designated as the quote currency in the currency pair calculation of price (required).`, + required: true, + example: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + schema: { + $ref: '#/components/schemas/hexSchema', + }, + }, + ], + true, + ), + responses: generateResponses( + 'relayerApiOrderBookResponseSchema', + examples.relayerApiOrderBookResponse, + `The sorted order book for the specified asset pair.`, + ), + }, + }, }, components: { schemas: openApiSchemas, diff --git a/packages/sra-api/src/examples/index.ts b/packages/sra-api/src/examples/index.ts index d99c0469b..51d979fe4 100644 --- a/packages/sra-api/src/examples/index.ts +++ b/packages/sra-api/src/examples/index.ts @@ -1,11 +1,13 @@ import { validationError } from './errors'; import { relayerApiAssetDataPairsResponse } from './relayerApiAssetDataPairsResponse'; import { relayerApiOrder } from './relayerApiOrder'; +import { relayerApiOrderBookResponse } from './relayerApiOrderBookResponse'; import { relayerApiOrdersResponse } from './relayerApiOrdersResponse'; export const examples = { validationError, relayerApiAssetDataPairsResponse, relayerApiOrder, + relayerApiOrderBookResponse, relayerApiOrdersResponse, }; diff --git a/packages/sra-api/src/examples/relayerApiOrderBookResponse.ts b/packages/sra-api/src/examples/relayerApiOrderBookResponse.ts new file mode 100644 index 000000000..4e1e7a8eb --- /dev/null +++ b/packages/sra-api/src/examples/relayerApiOrderBookResponse.ts @@ -0,0 +1,54 @@ +export const relayerApiOrderBookResponse = { + bids: { + total: 325, + page: 2, + perPage: 100, + records: [ + { + order: { + makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b', + takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', + feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', + senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', + makerAssetAmount: '10000000000000000', + takerAssetAmount: '20000000000000000', + makerFee: '100000000000000', + takerFee: '200000000000000', + expirationTimeSeconds: '1532560590', + salt: '1532559225', + makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', + exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', + signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', + }, + metaData: {}, + }, + ], + }, + asks: { + total: 500, + page: 2, + perPage: 100, + records: [ + { + order: { + makerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', + takerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b', + feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', + senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', + makerAssetAmount: '20000000000000000', + takerAssetAmount: '10000000000000000', + makerFee: '200000000000000', + takerFee: '100000000000000', + expirationTimeSeconds: '1532560590', + salt: '1532559225', + makerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', + takerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', + signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891', + }, + metaData: {}, + }, + ], + }, +}; -- cgit
Commit message (Expand)AuthorAgeFilesLines
* - Update to 1.8sunpoet2013-11-032-3/+3
* - Install official UGENE documentation (PDF)danfe2013-11-013-3/+21
* - Update to version 1.12.3danfe2013-10-318-79/+325
* Update to version 36.3.6dpawel2013-10-305-93/+114
* Update to libmpc version 1.0.1 which brings the following fixes:gerald2013-10-2612-5/+12
* - Remove manual creation and removal of share/applications, as it's now in th...amdmi32013-10-223-4/+0
* Deprecated some ports broken for more than 6 monthbapt2013-10-181-0/+3
* - Switch to build with lang/ruby19tabthorpe2013-10-111-1/+1
* Update BioCocoa to the latest release.theraven2013-10-093-75/+68
* - Update to 0.5.1wen2013-10-043-4/+4
* - Update to 1.7sunpoet2013-10-043-12/+12
* biology/avida: add <unistd.h>, <typoinfo> for modern compilersmarino2013-10-022-0/+20
* - Remove NO_STAGE as these have been tested to be safebdrewery2013-09-252-2/+0
* Use value of BOINC_CLIENT_HOME in pkg-messagerene2013-09-242-2/+3
* - Add stagedir supportrene2013-09-241-12/+17
* Respect 'make check-sanity' for this port too.rene2013-09-241-2/+1
* Fix NO_STAGE attributionbapt2013-09-231-1/+1
* Add NO_STAGE all over the place in preparation for the staging support (cat: ...bapt2013-09-20