Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
toteki committed Mar 17, 2022
1 parent e2fc828 commit a5e1f15
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions x/leverage/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,23 @@ func (q Querier) CollateralValue(
return nil, err
}

var tokens sdk.Coins
var uTokens sdk.Coins

if len(req.Denom) == 0 {
tokens = q.Keeper.GetBorrowerCollateral(ctx, lender)
uTokens = q.Keeper.GetBorrowerCollateral(ctx, lender)
} else {
if !q.Keeper.IsAcceptedUToken(ctx, req.Denom) {
return nil, status.Error(codes.InvalidArgument, "not accepted uToken denom")
}

collateral := q.Keeper.GetCollateralAmount(ctx, lender, req.Denom)

tokens = sdk.NewCoins(collateral)
uTokens = sdk.NewCoins(collateral)
}

tokens, err := q.Keeper.ExchangeUTokens(ctx, uTokens)
if err != nil {
return nil, err
}

value, err := q.Keeper.TotalTokenValue(ctx, tokens)
Expand Down

0 comments on commit a5e1f15

Please sign in to comment.