feat: add total collateral function and query#1094
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1094 +/- ##
==========================================
- Coverage 43.72% 43.54% -0.18%
==========================================
Files 65 65
Lines 8298 8336 +38
==========================================
+ Hits 3628 3630 +2
- Misses 4421 4456 +35
- Partials 249 250 +1
|
| func (k Keeper) GetTotalCollateral(ctx sdk.Context, denom string) sdk.Int { | ||
| if !k.IsAcceptedUToken(ctx, denom) { | ||
| // non-uTokens cannot be collateral | ||
| return sdk.ZeroInt() |
There was a problem hiding this comment.
shouldn't we return error?
There was a problem hiding this comment.
That is an option, yes.
The current approach follows the other getters, in that they return zero when queried for the borrowed/reserved/etc amount of something that doesn't exist or wouldn't be valid input for a setter.
Compare to querying the borrowed amount of an invalid denom (or unregistered Token, or a uToken denom) - it will simply return zero. Actually trying to borrow the same denom returns an error though.
There was a problem hiding this comment.
OK, then let's update the function docs please.
There was a problem hiding this comment.
lmk if the current godoc looks good
// GetTotalCollateral returns an sdk.Coin representing how much of a given uToken
// the x/leverage module account currently holds as collateral. Non-uTokens and invalid
// assets return zero.Co-authored-by: Robert Zaremba <robert@zaremba.ch>
robert-zaremba
left a comment
There was a problem hiding this comment.
utACK. Pending the function doc update
| func (k Keeper) GetTotalCollateral(ctx sdk.Context, denom string) sdk.Int { | ||
| if !k.IsAcceptedUToken(ctx, denom) { | ||
| // non-uTokens cannot be collateral | ||
| return sdk.ZeroInt() |
There was a problem hiding this comment.
OK, then let's update the function docs please.
Adds
GetTotalCollateral(denom)and an associated grpc query.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!to the type prefix if API or client breaking changeCHANGELOG.mdReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...