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: additional leverage queries #617

Merged
merged 15 commits into from
Mar 7, 2022
Merged

feat: additional leverage queries #617

merged 15 commits into from
Mar 7, 2022

Conversation

toteki
Copy link
Member

@toteki toteki commented Mar 7, 2022

Description

  • TokenMarketSize (base tokens), which is the total lent by all lenders
  • Lent Amount (base tokens) for a single lender, in one or all denoms
  • Borrowed Value (USD) for a single borrower, in one or all denoms
  • Lent Value (USD) for a single lender, in one or all denoms

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...

  • included the correct type prefix in the PR title
  • added appropriate labels to the PR
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers 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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@@ -23,7 +23,7 @@ func (k Keeper) TokenPrice(ctx sdk.Context, denom string) (sdk.Dec, error) {

price, err := k.oracleKeeper.GetExchangeRateBase(ctx, denom)
if err != nil {
return sdk.ZeroDec(), err
return sdk.ZeroDec(), sdkerrors.Wrap(err, "oracle")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find myself having to use the rule "denom in error message is capitalized, so the error must be coming from oracle" a lot.

It will be better to prefix this one error return with a label since it's the only place where leverage calls an oracle function.

@toteki
Copy link
Member Author

toteki commented Mar 7, 2022

Just need spec/03_queries.go, and client/tests/suite.go and then ready to merge

edit: leaving out grpc_query_test.go since the other queries don't use it yet - they're covered by the cli tests

@alexanderbez
Copy link
Contributor

Let's not forget the CLI command handlers too. No need to add a boat load of tests for them, but lets at least have the CLI handlers 👍

@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2022

Codecov Report

Merging #617 (11c2409) into main (6b2a099) will decrease coverage by 0.36%.
The diff coverage is 45.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #617      +/-   ##
==========================================
- Coverage   48.45%   48.08%   -0.37%     
==========================================
  Files          63       64       +1     
  Lines        7940     8801     +861     
==========================================
+ Hits         3847     4232     +385     
- Misses       3835     4311     +476     
  Partials      258      258              
Impacted Files Coverage Δ
x/leverage/client/cli/query.go 0.00% <0.00%> (ø)
x/leverage/keeper/exchange_rate.go 61.81% <0.00%> (-17.26%) ⬇️
x/leverage/keeper/grpc_query.go 7.33% <0.00%> (-3.38%) ⬇️
x/leverage/keeper/keeper.go 47.80% <ø> (ø)
x/leverage/keeper/loaned.go 0.00% <0.00%> (ø)
x/leverage/keeper/oracle.go 68.42% <0.00%> (ø)
x/leverage/simulation/operations.go 91.69% <ø> (ø)
x/leverage/types/query.pb.gw.go 0.00% <0.00%> (ø)
x/leverage/client/tests/suite.go 100.00% <100.00%> (ø)

@toteki toteki marked this pull request as ready for review March 7, 2022 19:32
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
x/leverage/client/cli/query.go Outdated Show resolved Hide resolved
@alexanderbez alexanderbez merged commit c0935d0 into main Mar 7, 2022
@alexanderbez alexanderbez deleted the adam/queries branch March 7, 2022 21:48
mergify bot pushed a commit that referenced this pull request Mar 7, 2022
alexanderbez pushed a commit that referenced this pull request Mar 7, 2022
(cherry picked from commit c0935d0)

Co-authored-by: Adam Moser <63419657+toteki@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants