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: inspect query warns on failing addresses #2341

Merged
merged 6 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

- [2299](https://github.com/umee-network/umee/pull/2299) Upgrade Cosmos SDK to v0.47.
- [2301](https://github.com/umee-network/umee/pull/2301) use gov/v1 MinInitialDepositRatio and set it to 0.1.
- [2341](https://github.com/umee-network/umee/pull/2341) inspect query also returns a list of accounts whose positions could not be calculated
toteki marked this conversation as resolved.
Show resolved Hide resolved

### Breaking Changes

Expand Down
2 changes: 2 additions & 0 deletions proto/umee/leverage/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ message QueryInspectResponse {
repeated InspectAccount borrowers = 1 [
(gogoproto.nullable) = false
];
// Failures is a list of addresses for which the position calculation failed.
repeated string failures = 2;
toteki marked this conversation as resolved.
Show resolved Hide resolved
toteki marked this conversation as resolved.
Show resolved Hide resolved
}

// QueryInspectAccountResponse defines the response structure for the InspectAccount gRPC service handler.
Expand Down
14 changes: 14 additions & 0 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ paths:
description: >-
InspectAccount contains risk and balance info for a single
account for the inspector query.
failures:
type: array
items:
type: string
description: >-
Failures is a list of addresses for which the position
calculation failed.
description: >-
QueryInspectResponse defines the response structure for the
Inspect gRPC service handler.
Expand Down Expand Up @@ -5079,6 +5086,13 @@ definitions:
description: >-
InspectAccount contains risk and balance info for a single account
for the inspector query.
failures:
type: array
items:
type: string
description: >-
Failures is a list of addresses for which the position calculation
failed.
description: >-
QueryInspectResponse defines the response structure for the Inspect gRPC
service handler.
Expand Down
5 changes: 4 additions & 1 deletion x/leverage/keeper/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func (q Querier) Inspect(
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
failures := []string{}

// This query is also disabled by default as a safety measure. Enable with liquidator queries.
if !q.Keeper.liquidatorQueryEnabled {
Expand Down Expand Up @@ -73,6 +74,8 @@ func (q Querier) Inspect(
borrowedValue = position.BorrowedValue()
collateralValue = position.CollateralValue()
liquidationThreshold = position.Limit()
} else {
failures = append(failures, addr.String())
}

borrowed := k.GetBorrowerBorrows(ctx, addr)
Expand Down Expand Up @@ -120,7 +123,7 @@ func (q Querier) Inspect(
for _, b := range borrowers {
sortedBorrowers = append(sortedBorrowers, *b)
}
return &types.QueryInspectResponse{Borrowers: sortedBorrowers}, nil
return &types.QueryInspectResponse{Borrowers: sortedBorrowers, Failures: failures}, nil
toteki marked this conversation as resolved.
Show resolved Hide resolved
}

// Separated from grpc_query.go
Expand Down
Loading
Loading