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: Add error field in market summary #1799

Merged
merged 8 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 proto/umee/leverage/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ message QueryMarketSummaryResponse {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = true
];
string errors = 20;
}

// QueryAccountBalances defines the request structure for the AccountBalances gRPC service handler.
Expand Down
4 changes: 4 additions & 0 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ paths:
price is used if required medians is zero. Price is nil when
the oracle is down or insufficient historic medians are
available.
errors:
type: string
description: >-
QueryMarketSummaryResponse defines the response structure for the
MarketSummary gRPC service handler.
Expand Down Expand Up @@ -2229,6 +2231,8 @@ definitions:
the leverage registry. Current price is used if required medians is
zero. Price is nil when the oracle is down or insufficient historic
medians are available.
errors:
type: string
description: >-
QueryMarketSummaryResponse defines the response structure for the
MarketSummary gRPC service handler.
Expand Down
10 changes: 8 additions & 2 deletions x/leverage/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,17 @@ func (q Querier) MarketSummary(
}

// Oracle prices in response will be nil if it is unavailable
if oraclePrice, _, oracleErr := q.Keeper.TokenPrice(ctx, req.Denom, types.PriceModeSpot); oracleErr == nil {
oraclePrice, _, oracleErr := q.Keeper.TokenPrice(ctx, req.Denom, types.PriceModeSpot)
if oracleErr == nil {
resp.OraclePrice = &oraclePrice
} else {
resp.Errors += oracleErr.Error()
}
if historicPrice, _, historicErr := q.Keeper.TokenPrice(ctx, req.Denom, types.PriceModeHistoric); historicErr == nil {
historicPrice, _, historicErr := q.Keeper.TokenPrice(ctx, req.Denom, types.PriceModeHistoric)
if historicErr == nil {
resp.OracleHistoricPrice = &historicPrice
} else {
resp.Errors += historicErr.Error()
}

return &resp, nil
Expand Down
Loading