Skip to content

Commit

Permalink
feat: add timestamp when getting orderbook
Browse files Browse the repository at this point in the history
Closes: #21
  • Loading branch information
sourabhxyz committed Mar 6, 2024
1 parent b2aa2e7 commit a956602
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ instance Swagger.ToSchema OrderInfo where
declareNamedSchema =
Swagger.genericDeclareNamedSchema Swagger.defaultSchemaOptions {Swagger.fieldLabelModifier = dropAndCamelToSnake @OrderInfoPrefix}

-- TODO: Show id instead?
data OrderBookInfo = OrderBookInfo
{ obiMarketPairId !OrderAssetPair,
obiTimestamp !GYTime,
obiBids ![OrderInfo],
obiAsks ![OrderInfo]
}
Expand All @@ -163,7 +163,6 @@ instance Swagger.ToSchema OrderBookInfo where
declareNamedSchema =
Swagger.genericDeclareNamedSchema Swagger.defaultSchemaOptions {Swagger.fieldLabelModifier = dropAndCamelToSnake @OrderResPrefix}

-- TODO: Give timestamp for /orders
-- TODO: Rename it to `OrdersAPI`.

type DEXPartialOrderAPI =
Expand Down Expand Up @@ -261,7 +260,7 @@ handleOrders ∷ Ctx → OrderAssetPair → Maybe GYAddressBech32 → IO OrderBo
handleOrders ctx@Ctx {..} orderAssetPair mownAddress = do
logInfo ctx "Fetching order(s)."
let porefs = dexPORefs ctxDexInfo
-- this timestamp
gytime getCurrentGYTime
os runQuery ctx $ partialOrders porefs
let os' =
Map.filter
Expand All @@ -286,6 +285,7 @@ handleOrders ctx@Ctx {..} orderAssetPair mownAddress = do
pure $
OrderBookInfo
{ obiMarketPairId = orderAssetPair,
obiTimestamp = gytime,
obiAsks = asks,
obiBids = bids
}
7 changes: 7 additions & 0 deletions web/swagger/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,17 @@
},
"market_pair_id": {
"$ref": "#/definitions/OrderAssetPair"
},
"timestamp": {
"description": "This is the posix time in ISO8601 format.",
"example": "1970-01-01T00:00:00Z",
"format": "ISO8601",
"type": "string"
}
},
"required": [
"market_pair_id",
"timestamp",
"bids",
"asks"
],
Expand Down

0 comments on commit a956602

Please sign in to comment.