Skip to content

Commit

Permalink
Merge pull request #338 from cosmosquad-labs/fix-order-book-response
Browse files Browse the repository at this point in the history
refactor!: refactor `MakeOrderBookResponse`
  • Loading branch information
dongsam authored Jul 18, 2022
2 parents 7c1f522 + 079dfa6 commit 0251d7d
Show file tree
Hide file tree
Showing 19 changed files with 834 additions and 583 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Client Breaking Changes

* (x/liquidity) [\#338](https://github.com/cosmosquad-labs/squad/pull/338) Refactor `OrderBooks` query:
* `tick_precisions` field has been removed from `QueryOrderBooksRequest`
* `tick_precision` field has been removed from `OrderBookResponse` and `price_unit` has been added instead
* The order between `sells` and `buys` has been changed

### CLI Breaking Changes

* (x/liquidity) [\#338](https://github.com/cosmosquad-labs/squad/pull/338) Refactor `order-books` query cmd:
* `[tick-precisions]` argument has been removed: `order-books [pair-ids]`
* Response structure has been changed

## v2.0.0

### Client Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

44 changes: 16 additions & 28 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24228,10 +24228,9 @@ paths:
items:
type: object
properties:
tick_precision:
type: integer
format: int64
buys:
price_unit:
type: string
sells:
type: array
items:
type: object
Expand All @@ -24242,7 +24241,7 @@ paths:
type: string
pool_order_amount:
type: string
sells:
buys:
type: array
items:
type: object
Expand Down Expand Up @@ -24287,14 +24286,6 @@ paths:
type: string
format: uint64
collectionFormat: multi
- name: tick_precisions
in: query
required: false
type: array
items:
type: integer
format: int64
collectionFormat: multi
- name: num_ticks
in: query
required: false
Expand Down Expand Up @@ -45252,10 +45243,9 @@ definitions:
items:
type: object
properties:
tick_precision:
type: integer
format: int64
buys:
price_unit:
type: string
sells:
type: array
items:
type: object
Expand All @@ -45266,7 +45256,7 @@ definitions:
type: string
pool_order_amount:
type: string
sells:
buys:
type: array
items:
type: object
Expand All @@ -45280,10 +45270,9 @@ definitions:
squad.liquidity.v1beta1.OrderBookResponse:
type: object
properties:
tick_precision:
type: integer
format: int64
buys:
price_unit:
type: string
sells:
type: array
items:
type: object
Expand All @@ -45294,7 +45283,7 @@ definitions:
type: string
pool_order_amount:
type: string
sells:
buys:
type: array
items:
type: object
Expand Down Expand Up @@ -45786,10 +45775,9 @@ definitions:
items:
type: object
properties:
tick_precision:
type: integer
format: int64
buys:
price_unit:
type: string
sells:
type: array
items:
type: object
Expand All @@ -45800,7 +45788,7 @@ definitions:
type: string
pool_order_amount:
type: string
sells:
buys:
type: array
items:
type: object
Expand Down
152 changes: 108 additions & 44 deletions docs/api/liquidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ Example Request

<!-- markdown-link-check-disable -->
```bash
http://localhost:1317/squad/liquidity/v1beta1/order_books?pair_ids=1&tick_precisions=3&num_ticks=10
http://localhost:1317/squad/liquidity/v1beta1/order_books?pair_ids=1&num_ticks=5
```

Example Response
Expand All @@ -631,111 +631,175 @@ Example Response
"pairs": [
{
"pair_id": "1",
"base_price": "1.181500000000000000",
"base_price": "1.180000000000000000",
"order_books": [
{
"tick_precision": 3,
"buys": [
"price_unit": "0.000100000000000000",
"sells": [
{
"price": "1.181000000000000000",
"user_order_amount": "138",
"price": "1.180500000000000000",
"user_order_amount": "64712",
"pool_order_amount": "0"
},
{
"price": "1.180400000000000000",
"user_order_amount": "19985",
"pool_order_amount": "0"
},
{
"price": "1.180300000000000000",
"user_order_amount": "64725",
"pool_order_amount": "0"
},
{
"price": "1.180200000000000000",
"user_order_amount": "19993",
"pool_order_amount": "0"
},
{
"price": "1.180100000000000000",
"user_order_amount": "64738",
"pool_order_amount": "0"
}
],
"buys": [
{
"price": "1.180000000000000000",
"user_order_amount": "485",
"user_order_amount": "20000",
"pool_order_amount": "0"
},
{
"price": "1.179000000000000000",
"user_order_amount": "312",
"price": "1.179900000000000000",
"user_order_amount": "64752",
"pool_order_amount": "0"
},
{
"price": "1.178000000000000000",
"user_order_amount": "450",
"price": "1.179800000000000000",
"user_order_amount": "20009",
"pool_order_amount": "0"
},
{
"price": "1.177000000000000000",
"user_order_amount": "313",
"price": "1.179700000000000000",
"user_order_amount": "64765",
"pool_order_amount": "0"
},
{
"price": "1.176000000000000000",
"user_order_amount": "488",
"price": "1.179600000000000000",
"user_order_amount": "20017",
"pool_order_amount": "0"
}
]
},
{
"price_unit": "0.001000000000000000",
"sells": [
{
"price": "1.185000000000000000",
"user_order_amount": "421298",
"pool_order_amount": "0"
},
{
"price": "1.175000000000000000",
"user_order_amount": "313",
"price": "1.184000000000000000",
"user_order_amount": "421830",
"pool_order_amount": "0"
},
{
"price": "1.174000000000000000",
"user_order_amount": "453",
"price": "1.183000000000000000",
"user_order_amount": "422365",
"pool_order_amount": "0"
},
{
"price": "1.173000000000000000",
"user_order_amount": "314",
"price": "1.182000000000000000",
"user_order_amount": "422901",
"pool_order_amount": "0"
},
{
"price": "1.172000000000000000",
"user_order_amount": "490",
"price": "1.181000000000000000",
"user_order_amount": "423440",
"pool_order_amount": "0"
}
],
"sells": [
"buys": [
{
"price": "1.191000000000000000",
"user_order_amount": "449",
"price": "1.180000000000000000",
"user_order_amount": "20000",
"pool_order_amount": "0"
},
{
"price": "1.190000000000000000",
"user_order_amount": "309",
"price": "1.179000000000000000",
"user_order_amount": "424020",
"pool_order_amount": "0"
},
{
"price": "1.189000000000000000",
"user_order_amount": "477",
"price": "1.178000000000000000",
"user_order_amount": "424558",
"pool_order_amount": "0"
},
{
"price": "1.188000000000000000",
"user_order_amount": "310",
"price": "1.177000000000000000",
"user_order_amount": "425099",
"pool_order_amount": "0"
},
{
"price": "1.187000000000000000",
"user_order_amount": "450",
"price": "1.176000000000000000",
"user_order_amount": "425640",
"pool_order_amount": "0"
}
]
},
{
"price_unit": "0.010000000000000000",
"sells": [
{
"price": "1.230000000000000000",
"user_order_amount": "3763074",
"pool_order_amount": "0"
},
{
"price": "1.186000000000000000",
"user_order_amount": "311",
"price": "1.220000000000000000",
"user_order_amount": "4377452",
"pool_order_amount": "0"
},
{
"price": "1.185000000000000000",
"user_order_amount": "482",
"price": "1.210000000000000000",
"user_order_amount": "4106019",
"pool_order_amount": "0"
},
{
"price": "1.184000000000000000",
"user_order_amount": "311",
"price": "1.200000000000000000",
"user_order_amount": "4157434",
"pool_order_amount": "0"
},
{
"price": "1.183000000000000000",
"user_order_amount": "451",
"price": "1.190000000000000000",
"user_order_amount": "4210331",
"pool_order_amount": "0"
}
],
"buys": [
{
"price": "1.180000000000000000",
"user_order_amount": "20000",
"pool_order_amount": "0"
},
{
"price": "1.182000000000000000",
"user_order_amount": "172",
"price": "1.170000000000000000",
"user_order_amount": "4329993",
"pool_order_amount": "0"
},
{
"price": "1.160000000000000000",
"user_order_amount": "4320112",
"pool_order_amount": "0"
},
{
"price": "1.150000000000000000",
"user_order_amount": "4111940",
"pool_order_amount": "0"
},
{
"price": "1.140000000000000000",
"user_order_amount": "4430076",
"pool_order_amount": "0"
}
]
Expand Down
4 changes: 3 additions & 1 deletion docs/cli/liquidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,9 @@ order-books [pair-ids] [tick-precisions]
Example

```bash
squad order-books 1 3,4 --num-ticks=10
squad order-books 1 --num-ticks=10

squad order-books 1,2,3
```


12 changes: 6 additions & 6 deletions proto/squad/liquidity/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ message QueryOrdersByOrdererRequest {

// QueryOrderBooksRequest is request type for the Query/OrderBooks RPC method.
message QueryOrderBooksRequest {
repeated uint64 pair_ids = 1;
repeated uint32 tick_precisions = 2;
uint32 num_ticks = 3;
repeated uint64 pair_ids = 1;
uint32 num_ticks = 2;
}

// QueryOrderBooksResponse is response type for Query/OrderBooks RPC method.
Expand Down Expand Up @@ -298,9 +297,10 @@ message OrderBookPairResponse {
}

message OrderBookResponse {
uint32 tick_precision = 1;
repeated OrderBookTickResponse buys = 2 [(gogoproto.nullable) = false];
repeated OrderBookTickResponse sells = 3 [(gogoproto.nullable) = false];
string price_unit = 1
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
repeated OrderBookTickResponse sells = 2 [(gogoproto.nullable) = false];
repeated OrderBookTickResponse buys = 3 [(gogoproto.nullable) = false];
}

message OrderBookTickResponse {
Expand Down
Loading

0 comments on commit 0251d7d

Please sign in to comment.