Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: MaxBorrow query and modify MaxWithdraw to return all denoms #1683

Merged
merged 12 commits into from
Jan 5, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1588](https://github.com/umee-network/umee/pull/1588) Historacle proto.
- [1653](https://github.com/umee-network/umee/pull/1653) Incentive Msg Server interface implementation.
- [1654](https://github.com/umee-network/umee/pull/1654) Leverage historacle integration.
- [1683](https://github.com/umee-network/umee/pull/1683) Add MaxBorrow, AllMaxBorrow, AllMaxWithdraw queries.

## [v3.3.0](https://github.com/umee-network/umee/releases/tag/v3.3.0) - 2022-12-20

Expand Down
64 changes: 64 additions & 0 deletions proto/umee/leverage/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ service Query {
returns (QueryMaxWithdrawResponse) {
option (google.api.http).get = "/umee/leverage/v1/max_withdraw";
}

// MaxBorrow queries the maximum amount of a given token an address can borrow.
rpc MaxBorrow(QueryMaxBorrow)
returns (QueryMaxBorrowResponse) {
option (google.api.http).get = "/umee/leverage/v1/max_borrow";
}

// AllMaxWithdraw queries the maximum amount of all tokens an address can withdraw.
rpc AllMaxWithdraw(QueryAllMaxWithdraw)
returns (QueryAllMaxWithdrawResponse) {
option (google.api.http).get = "/umee/leverage/v1/all_max_withdraw";
}
toteki marked this conversation as resolved.
Show resolved Hide resolved

// AllMaxBorrow queries the maximum amount of all tokens an address can borrow.
rpc AllMaxBorrow(QueryAllMaxBorrow)
returns (QueryAllMaxBorrowResponse) {
option (google.api.http).get = "/umee/leverage/v1/all_max_borrow";
}
toteki marked this conversation as resolved.
Show resolved Hide resolved
}

// QueryParams defines the request structure for the Params gRPC service
Expand Down Expand Up @@ -271,3 +289,49 @@ message QueryMaxWithdrawResponse {
// Tokens is the equivalent of max uTokens converted to base tokens
cosmos.base.v1beta1.Coin tokens = 2 [(gogoproto.nullable) = false];
}

// QueryMaxBorrow defines the request structure for the MaxBorrow gRPC service handler.
message QueryMaxBorrow {
string address = 1;
// denom is the base token denom to borrow
string denom = 2;
toteki marked this conversation as resolved.
Show resolved Hide resolved
}

// QueryMaxBorrowResponse defines the response structure for the MaxBorrow gRPC service handler.
message QueryMaxBorrowResponse {
// Tokens is the maximum amount of tokens that can be borrowed
cosmos.base.v1beta1.Coin tokens = 1 [(gogoproto.nullable) = false];
toteki marked this conversation as resolved.
Show resolved Hide resolved
}

// QueryAllMaxWithdraw defines the request structure for the AllMaxWithdraw gRPC service handler.
message QueryAllMaxWithdraw {
string address = 1;
}

// QueryAllMaxWithdrawResponse defines the response structure for the MaxAllWithdraw gRPC service handler.
message QueryAllMaxWithdrawResponse {
// uTokens is the maximum amount of uTokens that can be withdrawn
repeated cosmos.base.v1beta1.Coin uTokens = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// Tokens is the equivalent of max uTokens converted to base tokens
repeated cosmos.base.v1beta1.Coin tokens = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// QueryAllMaxBorrow defines the request structure for the AllMaxBorrow gRPC service handler.
message QueryAllMaxBorrow {
string address = 1;
}

// QueryAllMaxBorrowResponse defines the response structure for the AllMaxBorrow gRPC service handler.
message QueryAllMaxBorrowResponse {
// Tokens is the maximum amount of tokens that can be borrowed
repeated cosmos.base.v1beta1.Coin tokens = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
285 changes: 285 additions & 0 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,150 @@ paths:
type: string
tags:
- Query
/umee/leverage/v1/all_max_borrow:
get:
summary: >-
AllMaxBorrow queries the maximum amount of all tokens an address can
borrow.
operationId: AllMaxBorrow
responses:
'200':
description: A successful response.
schema:
type: object
properties:
tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
title: Tokens is the maximum amount of tokens that can be borrowed
description: >-
QueryAllMaxBorrowResponse defines the response structure for the
AllMaxBorrow gRPC service handler.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: address
in: query
required: false
type: string
tags:
- Query
/umee/leverage/v1/all_max_withdraw:
get:
summary: >-
AllMaxWithdraw queries the maximum amount of all tokens an address can
withdraw.
operationId: AllMaxWithdraw
responses:
'200':
description: A successful response.
schema:
type: object
properties:
uTokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
title: uTokens is the maximum amount of uTokens that can be withdrawn
tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
title: >-
Tokens is the equivalent of max uTokens converted to base
tokens
description: >-
QueryAllMaxWithdrawResponse defines the response structure for the
MaxAllWithdraw gRPC service handler.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: address
in: query
required: false
type: string
tags:
- Query
/umee/leverage/v1/bad_debts:
get:
summary: >-
Expand Down Expand Up @@ -471,6 +615,71 @@ paths:
type: string
tags:
- Query
/umee/leverage/v1/max_borrow:
get:
summary: >-
MaxBorrow queries the maximum amount of a given token an address can
borrow.
operationId: MaxBorrow
responses:
'200':
description: A successful response.
schema:
type: object
properties:
tokens:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
title: Tokens is the maximum amount of tokens that can be borrowed
description: >-
QueryMaxBorrowResponse defines the response structure for the
MaxBorrow gRPC service handler.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: address
in: query
required: false
type: string
- name: denom
description: denom is the base token denom to borrow.
in: query
required: false
type: string
tags:
- Query
/umee/leverage/v1/max_withdraw:
get:
summary: >-
Expand Down Expand Up @@ -1928,6 +2137,63 @@ definitions:
description: >-
QueryAccountSummaryResponse defines the response structure for the
AccountSummary gRPC service handler.
umee.leverage.v1.QueryAllMaxBorrowResponse:
type: object
properties:
tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
title: Tokens is the maximum amount of tokens that can be borrowed
description: >-
QueryAllMaxBorrowResponse defines the response structure for the
AllMaxBorrow gRPC service handler.
umee.leverage.v1.QueryAllMaxWithdrawResponse:
type: object
properties:
uTokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
title: uTokens is the maximum amount of uTokens that can be withdrawn
tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
title: Tokens is the equivalent of max uTokens converted to base tokens
description: >-
QueryAllMaxWithdrawResponse defines the response structure for the
MaxAllWithdraw gRPC service handler.
umee.leverage.v1.QueryBadDebtsResponse:
type: object
properties:
Expand Down Expand Up @@ -2102,6 +2368,25 @@ definitions:
description: >-
QueryMarketSummaryResponse defines the response structure for the
MarketSummary gRPC service handler.
umee.leverage.v1.QueryMaxBorrowResponse:
type: object
properties:
tokens:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
title: Tokens is the maximum amount of tokens that can be borrowed
description: >-
QueryMaxBorrowResponse defines the response structure for the MaxBorrow
gRPC service handler.
umee.leverage.v1.QueryMaxWithdrawResponse:
type: object
properties:
Expand Down
Loading