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 MarketSummary query #894

Merged
merged 5 commits into from
May 13, 2022
Merged

feat: add MarketSummary query #894

merged 5 commits into from
May 13, 2022

Conversation

toteki
Copy link
Member

@toteki toteki commented May 11, 2022

Description

Adds a query which groups a set of queries the frontend often executes together.

Needs discussion:

  • Does frontend exchange_rate requested in client #434 refer to asset's USD price (x/oracle query) or its uToken exchange rate (x/leverage query)? Currently returns both.
  • To avoid mixing usd totals and token totals in the query response, would it be acceptable to return token market size (e.g. 5M ATOM instead of usd market size (e.g. 100M USD)? Frontend would then multiple by oracle price.

closes: #893


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)

@toteki toteki requested a review from a team as a code owner May 11, 2022 23:33
@codecov-commenter
Copy link

codecov-commenter commented May 11, 2022

Codecov Report

Merging #894 (4746ae1) into main (d919765) will decrease coverage by 0.04%.
The diff coverage is 1.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #894      +/-   ##
==========================================
- Coverage   51.08%   51.04%   -0.05%     
==========================================
  Files          64       64              
  Lines        9425     9431       +6     
==========================================
- Hits         4815     4814       -1     
- Misses       4365     4372       +7     
  Partials      245      245              
Impacted Files Coverage Δ
x/leverage/types/query.pb.gw.go 0.00% <0.00%> (ø)
x/oracle/types/query.pb.gw.go 0.00% <ø> (ø)
x/leverage/keeper/grpc_query.go 5.55% <2.77%> (-0.77%) ⬇️

Comment on lines +376 to +377
string oracle_price = 3
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = true];
Copy link
Member Author

Choose a reason for hiding this comment

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

Note how nullable is true here - if oracle is down, this field will be null but the query will work.

Comment on lines +384 to +385
string market_size = 7
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
Copy link
Member Author

Choose a reason for hiding this comment

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

Note market_size (tokens) not market_size_usd here. See discussion question in PR description

@EbrahimElbagory
Copy link
Contributor

EbrahimElbagory commented May 12, 2022

Does frontend exchange_rate requested in https://github.com/umee-network/umee-v1-client/issues/434 refer to asset's USD price (x/oracle query) or its uToken exchange rate (x/leverage query)? Currently returns both.

This is the assets USD price (double check with core dev)

To avoid mixing usd totals and token totals in the query response, would it be acceptable to return token market size (e.g. 5M ATOM instead of usd market size (e.g. 100M USD)? Frontend would then multiple by oracle price

Yes wont make any difference on the front end.

@RafilxTenfen
Copy link
Contributor

The oracle price for Atom at the moment is "9.4345...." but the returned amount is oracle_price": "0.000009631755656363",
image

I am doing something wrong?

@toteki
Copy link
Member Author

toteki commented May 12, 2022

It's correct - the 10^6 difference is between uatom and ATOM because exponent = 6

@toteki toteki merged commit 0ecf33c into main May 13, 2022
@toteki toteki deleted the adam/893 branch May 13, 2022 03:15
mergify bot pushed a commit that referenced this pull request May 13, 2022
* feat: add MarketSummary query

(cherry picked from commit 0ecf33c)

# Conflicts:
#	x/leverage/types/query.pb.go
#	x/leverage/types/query.pb.gw.go
toteki added a commit that referenced this pull request May 13, 2022
* feat: add MarketSummary query (#894)

* feat: add MarketSummary query

(cherry picked from commit 0ecf33c)

# Conflicts:
#	x/leverage/types/query.pb.go
#	x/leverage/types/query.pb.gw.go

* proto gen

Co-authored-by: toteki <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.

x/leverage: frontend summary query
5 participants