Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

/v2/orderbook: Pagination defaults to page 0. SRA spec defines page 1. #31

Closed
laurengarcia opened this issue Jan 17, 2019 · 4 comments · Fixed by #39
Closed

/v2/orderbook: Pagination defaults to page 0. SRA spec defines page 1. #31

laurengarcia opened this issue Jan 17, 2019 · 4 comments · Fixed by #39
Labels
bug 🪲 Something isn't working

Comments

@laurengarcia
Copy link

@dekz - Found another one:

When I hit local Launch Kit (.ts version) endpoint via curl /v2/orderbook it is properly returning bids and asks.

But when i use the 0x Connect client for the exact same query it doesn't return the actual records with the rest of the response. Records field is always empty in the response:

client.getOrderbookAsync(
  { "baseAssetData": baseAssetData,
    "quoteAssetData": quoteAssetData
  })
  .then(
    (r) => console.log(r),
    (e) => console.log(e)
  )

// query returns empty records:
{ bids: { total: 0, page: 1, perPage: 10, records: [] },
  asks: { total: 5, page: 1, perPage: 10, records: [] } }

Here's what the curl response for same exact query looks like, seems correct:

curl 'http://localhost:3000/v2/orderbook?baseAssetData=0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa&quoteAssetData=0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c'
{"bids":{"total":0,"page":0,"perPage":20,"records":[]},"asks":{"total":5,"page":0,"perPage":20,"records":[{"metaData":{},"order":{"signature":"0x1baf04b260c29cad9c6bb8812ea4c61a2681fadd578be000d2e770697d76d90fc811a301d55a161613920bbdeb64798157654b5adc2634f0a1f0579f67c62c04bd02","senderAddress":"0x0000000000000000000000000000000000000000","makerAddress":"0x063aaf1fbbf0238f1cb571a5e9a6d91304798887","takerAddress":"0x0000000000000000000000000000000000000000","makerFee":"0","takerFee":"0","makerAssetAmount":"1000000000000000000","takerAssetAmount":"50000000000000","makerAssetData":"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa","takerAssetData":"0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c","salt":"26834400093700189474277646721932965984745061693386137028316104425807600698868","exchangeAddress":"0x35dd2932454449b14cee11a94d3674a936d5d7b2","feeRecipientAddress":"0x0000000000000000000000000000000000000000","expirationTimeSeconds":"1547675321658"}},{"metaData":{},"order":{"signature":"0x1cfe8e9d8a323049babeaa413e507905f2f2a1e8f1e399fa7457db0ab67218024c069d8e82c89cfb519bbd92f1878da527f16c82dda55ed2d05fc2bb8806e922f802","senderAddress":"0x0000000000000000000000000000000000000000","makerAddress":"0x063aaf1fbbf0238f1cb571a5e9a6d91304798887","takerAddress":"0x0000000000000000000000000000000000000000","makerFee":"0","takerFee":"0","makerAssetAmount":"2000000000000000000","takerAssetAmount":"20000000000000","makerAssetData":"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa","takerAssetData":"0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c","salt":"23021941304080017233667145501165113484278445408483391664784942613403220214467","exchangeAddress":"0x35dd2932454449b14cee11a94d3674a936d5d7b2","feeRecipientAddress":"0x0000000000000000000000000000000000000000","expirationTimeSeconds":"1547681622628"}},{"metaData":{},"order":{"signature":"0x1b462e392e6008295fa29adb32d68427b7835969eca098942a585422682793f1ed67ad7f5caaa281b4852dd7e9c3acffb8fe123bb36ae62adf4cce71f9e5cef7b402","senderAddress":"0x0000000000000000000000000000000000000000","makerAddress":"0xb78f09d705dedaca26dc99e9ee7d789be7b38fcc","takerAddress":"0x0000000000000000000000000000000000000000","makerFee":"0","takerFee":"0","makerAssetAmount":"1000000000000000000","takerAssetAmount":"10000000000000","makerAssetData":"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa","takerAssetData":"0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c","salt":"57718887633272621300663749607971996856877233498333220590130402684590306265495","exchangeAddress":"0x35dd2932454449b14cee11a94d3674a936d5d7b2","feeRecipientAddress":"0x0000000000000000000000000000000000000000","expirationTimeSeconds":"1547684162302"}},{"metaData":{},"order":{"signature":"0x1b34607ea85f31174ec2b6f3c0813c8890144f1e26b57cf75719dff889a930ccf270ec6f397e074643d8ad28f86000325adb1656574d0b78f2e559ac9f9e06f31102","senderAddress":"0x0000000000000000000000000000000000000000","makerAddress":"0xb78f09d705dedaca26dc99e9ee7d789be7b38fcc","takerAddress":"0x0000000000000000000000000000000000000000","makerFee":"0","takerFee":"0","makerAssetAmount":"1000000000000000000","takerAssetAmount":"17000000000000","makerAssetData":"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa","takerAssetData":"0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c","salt":"90216706402638628412782469223982886692502260413125767364808989292368542931132","exchangeAddress":"0x35dd2932454449b14cee11a94d3674a936d5d7b2","feeRecipientAddress":"0x0000000000000000000000000000000000000000","expirationTimeSeconds":"1547687884512"}},{"metaData":{},"order":{"signature":"0x1bff4d0aa4ef7657c6c2df7bd959340a0259657a27aeb616fb8d6bca04d94cc8ce3165ddb083c820f1059e2eb39ea8f3bf1d76060458e513ceb3623347c287d0b902","senderAddress":"0x0000000000000000000000000000000000000000","makerAddress":"0x063aaf1fbbf0238f1cb571a5e9a6d91304798887","takerAddress":"0x0000000000000000000000000000000000000000","makerFee":"0","takerFee":"0","makerAssetAmount":"1000000000000000000","takerAssetAmount":"13000000000000","makerAssetData":"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa","takerAssetData":"0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c","salt":"62855717622068651739943073684441414449311622915772187888148272159221902181113","exchangeAddress":"0x35dd2932454449b14cee11a94d3674a936d5d7b2","feeRecipientAddress":"0x0000000000000000000000000000000000000000","expirationTimeSeconds":"1547688659771"}}]}}
@laurengarcia
Copy link
Author

.. and Thanks :)

@dekz
Copy link
Member

dekz commented Jan 17, 2019

@laurengarcia this one I can't reproduce. Seems like your response is returning page 1 some how and not page 0 in the 0x Connect response. But the curl returns page 0 since no pagination params are given. Are you using any RequestOpts in the call to getOrderbookAsync (second parameter)?

import { HttpClient } from '@0x/connect';

const client = new HttpClient('http://localhost:3000/v2');
const baseAssetData = '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa';
const quoteAssetData = '0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c';
client.getOrderbookAsync(
    { "baseAssetData": baseAssetData,
      "quoteAssetData": quoteAssetData
    })
    .then(
      (r) => console.log(JSON.stringify(r, null, 2)),
      (e) => console.log(e)
    )

With the response:

{
  "bids": {
    "total": 0,
    "page": 0,
    "perPage": 20,
    "records": []
  },
  "asks": {
    "total": 2,
    "page": 0,
    "perPage": 20,
    "records": [
      {
        "metaData": {},
        "order": {
          "signature": "0x1b2217d8efad41909d1f759f64bd2a471639e3d17340ed736bb33ace4641e8f2097ff3d6c1f7dbc51d28e323e0becbe410808be125c0b9f15b8ef4b7c1f5b4a27c02",
          "senderAddress": "0x0000000000000000000000000000000000000000",
          "makerAddress": "0x5409ed021d9299bf6814279a6a1411a7e866a631",
          "takerAddress": "0x0000000000000000000000000000000000000000",
          "makerFee": "0",
          "takerFee": "0",
          "makerAssetAmount": "100000000000000000000000",
          "takerAssetAmount": "100000000000000000000",
          "makerAssetData": "0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa",
          "takerAssetData": "0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c",
          "salt": "4997075760802117905243536649051906104008891540108681218169938513821289690431",
          "exchangeAddress": "0x35dd2932454449b14cee11a94d3674a936d5d7b2",
          "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
          "expirationTimeSeconds": "1646079500783"
        }
      },
      {
        "metaData": {},
        "order": {
          "signature": "0x1cb5245d5c90a2561502d6a9f01002ac476ca51a324f3e4b26870f41ca24d3a7e54d01c59083977b92e0534642378186ee173bb33d8dbb16d03ac60fb7db962a6a02",
          "senderAddress": "0x0000000000000000000000000000000000000000",
          "makerAddress": "0x5409ed021d9299bf6814279a6a1411a7e866a631",
          "takerAddress": "0x0000000000000000000000000000000000000000",
          "makerFee": "0",
          "takerFee": "0",
          "makerAssetAmount": "100000000000000000000",
          "takerAssetAmount": "100000000000000000",
          "makerAssetData": "0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa",
          "takerAssetData": "0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c",
          "salt": "48421664369936352591469907962264571897462657488340054914166087266166526899713",
          "exchangeAddress": "0x35dd2932454449b14cee11a94d3674a936d5d7b2",
          "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
          "expirationTimeSeconds": "1547623505418"
        }
      }
    ]
  }
}

Matching the curl output:

curl 'http://localhost:3000/v2/orderbook?baseAssetData=0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa&quoteAssetData=0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1941  100  1941    0     0  25873      0 --:--:-- --:--:-- --:--:-- 26229
{
  "bids": {
    "total": 0,
    "page": 0,
    "perPage": 20,
    "records": []
  },
  "asks": {
    "total": 2,
    "page": 0,
    "perPage": 20,
    "records": [
      {
        "metaData": {},
        "order": {
          "signature": "0x1b2217d8efad41909d1f759f64bd2a471639e3d17340ed736bb33ace4641e8f2097ff3d6c1f7dbc51d28e323e0becbe410808be125c0b9f15b8ef4b7c1f5b4a27c02",
          "senderAddress": "0x0000000000000000000000000000000000000000",
          "makerAddress": "0x5409ed021d9299bf6814279a6a1411a7e866a631",
          "takerAddress": "0x0000000000000000000000000000000000000000",
          "makerFee": "0",
          "takerFee": "0",
          "makerAssetAmount": "100000000000000000000000",
          "takerAssetAmount": "100000000000000000000",
          "makerAssetData": "0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa",
          "takerAssetData": "0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c",
          "salt": "4997075760802117905243536649051906104008891540108681218169938513821289690431",
          "exchangeAddress": "0x35dd2932454449b14cee11a94d3674a936d5d7b2",
          "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
          "expirationTimeSeconds": "1646079500783"
        }
      },
      {
        "metaData": {},
        "order": {
          "signature": "0x1cb5245d5c90a2561502d6a9f01002ac476ca51a324f3e4b26870f41ca24d3a7e54d01c59083977b92e0534642378186ee173bb33d8dbb16d03ac60fb7db962a6a02",
          "senderAddress": "0x0000000000000000000000000000000000000000",
          "makerAddress": "0x5409ed021d9299bf6814279a6a1411a7e866a631",
          "takerAddress": "0x0000000000000000000000000000000000000000",
          "makerFee": "0",
          "takerFee": "0",
          "makerAssetAmount": "100000000000000000000",
          "takerAssetAmount": "100000000000000000",
          "makerAssetData": "0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa",
          "takerAssetData": "0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c",
          "salt": "48421664369936352591469907962264571897462657488340054914166087266166526899713",
          "exchangeAddress": "0x35dd2932454449b14cee11a94d3674a936d5d7b2",
          "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
          "expirationTimeSeconds": "1547623505418"
        }
      }
    ]
  }
}

@laurengarcia
Copy link
Author

My bad! Was indeed passing in pagination params and didn't realize that page param is zero indexed (was requesting page 1). The reason I thought this was because I was looking at the SRA documentation, which says that the default page param is 1.

http://sra-spec.s3-website-us-east-1.amazonaws.com/#operation/getOrderbook

image

@dekz
Copy link
Member

dekz commented Jan 20, 2019

Yeah I agree, 0 indexed pagination is non-standard.

@dekz dekz changed the title /v2/orderbook: Empty records field when queried via 0x Connect /v2/orderbook: Pagination defaults to page 0. SRA spec defines page 1. Jan 20, 2019
@dekz dekz added the bug 🪲 Something isn't working label Jan 20, 2019
@dekz dekz closed this as completed in #39 Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants