duality-labs/hapi-indexer

Create tick liquidity endpoint

Closed this issue · 0 comments

dib542 commented

to achieve efficient data fetching for the liquidity endpoints:

Example format:

{
  "structure": {
    "height": "blockHeight",
    "reserves": [
      ["relativeTickIndex","reserves"]
    ]
  },
  "data": {
    "height": 12345,
    "reserves": [
      [-10000,1.23e12],
      [1,2.34e23],
      [10,3.45e34],
    ]
  }
}

Note: block height could be read from Grpc-Metadata-X-Cosmos-Block-Height server response header, just ensure that the correct CORS header is set so that the web app can read those headers.

This endpoint should have long polling enabled:

  • a request should send its last know height (or 0)
  • if the server detects that the current chain height:
    • is new to the requester: it can send back the data immediately
    • is equal or less than to the requester's known height: it can wait until the chain progresses before sending back the new data and new height (or the request times out ~25 seconds?)
    • is behind the requester by a significant amount: maybe send a 400 Bad Request (because its an unexpected request)