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: account summary to display both spot and leverage prices #2263

Merged
merged 13 commits into from
Sep 27, 2023
20 changes: 20 additions & 0 deletions proto/umee/leverage/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ service Query {
returns (QueryInspectResponse) {
option (google.api.http).get = "/umee/leverage/v1/inspect";
}

// InspectAccount runs the inspect query on a single address
rpc InspectAccount(QueryInspectAccount)
returns (QueryInspectAccountResponse) {
option (google.api.http).get = "/umee/leverage/v1/inspect-account";
}
}

// QueryParams defines the request structure for the Params gRPC service
Expand Down Expand Up @@ -366,13 +372,25 @@ message QueryInspect {
double ltv = 5;
}

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

// QueryInspectResponse defines the response structure for the Inspect gRPC service handler.
message QueryInspectResponse {
repeated InspectAccount borrowers = 1 [
(gogoproto.nullable) = false
];
}

// QueryInspectAccountResponse defines the response structure for the InspectAccount gRPC service handler.
message QueryInspectAccountResponse {
InspectAccount borrower = 1 [
(gogoproto.nullable) = false
];
}

// InspectAccount contains risk and balance info for a single account for the inspector query.
message InspectAccount {
// Address of a borrower
Expand All @@ -381,6 +399,8 @@ message InspectAccount {
RiskInfo analysis = 2;
// Collateral and borrowed tokens, denoted in human-readable symbol denom instead of ibc denom.
DecBalances position = 3;
// Info is a string which can be used to report additional information of any type
string info = 4;
}

// RiskInfo defines a borrower's account health without requiring sdk.Dec formatting.
Expand Down
224 changes: 224 additions & 0 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ paths:
description: >-
Borrowed contains all tokens the account has
borrowed, including interest owed.
info:
type: string
title: >-
Info is a string which can be used to report additional
information of any type
description: >-
InspectAccount contains risk and balance info for a single
account for the inspector query.
Expand Down Expand Up @@ -443,6 +448,129 @@ paths:
format: double
tags:
- Query
/umee/leverage/v1/inspect-account:
get:
summary: InspectAccount runs the inspect query on a single address
operationId: InspectAccount
responses:
'200':
description: A successful response.
schema:
type: object
properties:
borrower:
type: object
properties:
address:
type: string
title: Address of a borrower
analysis:
description: >-
USD totals of borrower's collateral, debt, and liquidation
threshold.
type: object
properties:
Borrowed:
type: number
format: double
description: Borrowed is account's borrowed value in USD.
Liquidation:
type: number
format: double
description: Liquidation is account's liquidation threshold in USD.
Value:
type: number
format: double
description: Value is account's collateral value in USD.
position:
description: >-
Collateral and borrowed tokens, denoted in human-readable
symbol denom instead of ibc denom.
type: object
properties:
collateral:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
DecCoin defines a token with a denomination and a
decimal amount.


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

signatures required by gogoproto.
description: >-
Collateral contains all uTokens the account has
collateralized. It has been converted from uTokens to
tokens.
borrowed:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
DecCoin defines a token with a denomination and a
decimal amount.


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

signatures required by gogoproto.
description: >-
Borrowed contains all tokens the account has borrowed,
including interest owed.
info:
type: string
title: >-
Info is a string which can be used to report additional
information of any type
description: >-
InspectAccount contains risk and balance info for a single
account for the inspector query.
description: >-
QueryInspectAccountResponse defines the response structure for the
InspectAccount 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/liquidation_targets:
get:
summary: >-
Expand Down Expand Up @@ -4404,6 +4532,11 @@ definitions:
description: >-
Borrowed contains all tokens the account has borrowed, including
interest owed.
info:
type: string
title: >-
Info is a string which can be used to report additional information of
any type
description: >-
InspectAccount contains risk and balance info for a single account for the
inspector query.
Expand Down Expand Up @@ -4624,6 +4757,92 @@ definitions:
description: >-
QueryBadDebtsResponse defines the response structure for the BedDebts gRPC
service handler.
umee.leverage.v1.QueryInspectAccountResponse:
type: object
properties:
borrower:
type: object
properties:
address:
type: string
title: Address of a borrower
analysis:
description: >-
USD totals of borrower's collateral, debt, and liquidation
threshold.
type: object
properties:
Borrowed:
type: number
format: double
description: Borrowed is account's borrowed value in USD.
Liquidation:
type: number
format: double
description: Liquidation is account's liquidation threshold in USD.
Value:
type: number
format: double
description: Value is account's collateral value in USD.
position:
description: >-
Collateral and borrowed tokens, denoted in human-readable symbol
denom instead of ibc denom.
type: object
properties:
collateral:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
DecCoin defines a token with a denomination and a decimal
amount.


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

signatures required by gogoproto.
description: >-
Collateral contains all uTokens the account has
collateralized. It has been converted from uTokens to tokens.
borrowed:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
DecCoin defines a token with a denomination and a decimal
amount.


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

signatures required by gogoproto.
description: >-
Borrowed contains all tokens the account has borrowed,
including interest owed.
info:
type: string
title: >-
Info is a string which can be used to report additional
information of any type
description: >-
InspectAccount contains risk and balance info for a single account for
the inspector query.
description: >-
QueryInspectAccountResponse defines the response structure for the
InspectAccount gRPC service handler.
umee.leverage.v1.QueryInspectResponse:
type: object
properties:
Expand Down Expand Up @@ -4702,6 +4921,11 @@ definitions:
description: >-
Borrowed contains all tokens the account has borrowed,
including interest owed.
info:
type: string
title: >-
Info is a string which can be used to report additional
information of any type
description: >-
InspectAccount contains risk and balance info for a single account
for the inspector query.
Expand Down
27 changes: 27 additions & 0 deletions x/leverage/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func GetQueryCmd() *cobra.Command {
QueryMaxWithdraw(),
QueryMaxBorrow(),
QueryInspect(),
QueryInspectAccount(),
)

return cmd
Expand Down Expand Up @@ -366,3 +367,29 @@ func QueryInspect() *cobra.Command {

return cmd
}

// QueryInspectAccount creates a Cobra command to inspect a single account.
func QueryInspectAccount() *cobra.Command {
cmd := &cobra.Command{
Use: "inspect-account [addr]",
Args: cobra.ExactArgs(1),
Short: "Inspect a single account",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryInspectAccount{
Address: args[0],
}
resp, err := queryClient.InspectAccount(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading
Loading