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: recent price mode support #2267

Merged
merged 22 commits into from
Oct 3, 2023
Merged

feat: recent price mode support #2267

merged 22 commits into from
Oct 3, 2023

Conversation

toteki
Copy link
Member

@toteki toteki commented Sep 27, 2023

Adjust account summary query to display leverage logic prices (considering the more cautious of spot and historic generally) but allow expired prices.

Leverage transactions, and transaction-simulating queries like max borrow, reject expired prices.

Hard-codes max price age (for now) at 3 minutes for transactions' sake. Compare to current 30 second price voting window, but 3 hour historic median period

@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Merging #2267 (e8727b6) into main (7f05ad4) will decrease coverage by 4.96%.
Report is 251 commits behind head on main.
The diff coverage is 83.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2267      +/-   ##
==========================================
- Coverage   75.38%   70.43%   -4.96%     
==========================================
  Files         100      171      +71     
  Lines        8025    12892    +4867     
==========================================
+ Hits         6050     9081    +3031     
- Misses       1589     3208    +1619     
- Partials      386      603     +217     
Files Coverage Δ
ante/ante.go 66.66% <100.00%> (+18.45%) ⬆️
ante/fee.go 80.00% <100.00%> (+1.64%) ⬆️
ante/spam_prevention.go 75.92% <ø> (ø)
app/inflation/inflation.go 100.00% <100.00%> (ø)
util/coin/utoken.go 100.00% <100.00%> (ø)
x/incentive/client/tests/suite.go 100.00% <100.00%> (ø)
x/incentive/client/tests/tests.go 100.00% <100.00%> (ø)
x/incentive/codec.go 47.82% <ø> (+9.89%) ⬆️
x/incentive/genesis.go 92.48% <100.00%> (+79.14%) ⬆️
x/incentive/keeper/bond.go 92.50% <ø> (ø)
... and 49 more

... and 90 files with indirect coverage changes

@toteki toteki marked this pull request as ready for review September 28, 2023 17:04
@toteki toteki requested a review from a team as a code owner September 28, 2023 17:04
x/leverage/keeper/oracle.go Outdated Show resolved Hide resolved
x/leverage/keeper/oracle.go Outdated Show resolved Hide resolved
x/leverage/keeper/oracle.go Outdated Show resolved Hide resolved
x/leverage/types/oracle.go Show resolved Hide resolved
@gsk967
Copy link
Collaborator

gsk967 commented Oct 1, 2023

@adam can you check why we are clearning exg_rates if we clear exg_rates then we will get unknown denom error in GetExchangeRate function, so resolve this we need keep the old prices

@robert-zaremba WDYT about this ?

We are getting this results after stopping the price-feeder but have to get old results instead of unknown denom error,

We need to use old price instead of showing error

http://localhost:1316/umee/leverage/v1/market_summary?denom=uumee
{
  "symbol_denom": "UMEE",
  "exponent": 6,
  "oracle_price": null,
  "uToken_exchange_rate": "1.000000005967583058",
  "supply_APY": "0.000454358176141041",
  "borrow_APY": "0.051000989990100099",
  "supplied": "100000",
  "reserved": "0",
  "collateral": "100000",
  "borrowed": "1001",
  "liquidity": "99000",
  "maximum_borrow": "90000",
  "maximum_collateral": "100000",
  "minimum_liquidity": "10000",
  "uToken_supply": "100000",
  "available_borrow": "88999",
  "available_withdraw": "89000",
  "available_collateralize": "0",
  "oracle_historic_price": null,
  "errors": "oracle: UMEE: unknown denomoracle: UMEE: unknown denom"
}

and same with account_summary req also , is has to use old price instead of null calculations

http://localhost:1316/umee/leverage/v1/account_summary?address=umee1y6xz2ggfc0pcsmyjlekh0j9pxh6hk87ymc9due

{
  "supplied_value": "0.000000000000000000",
  "collateral_value": "0.000000000000000000",
  "borrowed_value": "0.000000000000000000",
  "borrow_limit": null,
  "liquidation_threshold": null,
  "spot_supplied_value": "0.000000000000000000",
  "spot_collateral_value": "0.000000000000000000",
  "spot_borrowed_value": "0.000000000000000000"
}

Copy link
Collaborator

@gsk967 gsk967 left a comment

Choose a reason for hiding this comment

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

@adam Please check my comments
I am per-approving this pr
you can remove https://github.com/umee-network/umee/blob/adam/recent/x/oracle/abci.go#L57 this line in next your pr

Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

  • I think mode.AllowsExpired() doesn't make sense
  • we should stop using deprecated features in a new code (errors.Register)

x/leverage/keeper/oracle.go Show resolved Hide resolved
x/leverage/types/errors.go Show resolved Hide resolved
@robert-zaremba
Copy link
Member

Yes @gsk967 , prices should NOT be cleared. I thought you already did it ;)
Could you or @toteki make sure this done? It's required for beta1

@toteki toteki requested a review from a team as a code owner October 1, 2023 11:44
@toteki toteki added this pull request to the merge queue Oct 2, 2023
@toteki toteki removed this pull request from the merge queue due to a manual request Oct 2, 2023
@toteki toteki enabled auto-merge October 2, 2023 15:13
@toteki toteki added this pull request to the merge queue Oct 2, 2023
@toteki toteki removed this pull request from the merge queue due to a manual request Oct 2, 2023
@toteki toteki added this pull request to the merge queue Oct 2, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 2, 2023
@robert-zaremba robert-zaremba added this pull request to the merge queue Oct 2, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 3, 2023
@toteki toteki added the skip-e2e-test Skip the e2e tests label Oct 3, 2023
@toteki toteki enabled auto-merge October 3, 2023 02:18
@toteki toteki added this pull request to the merge queue Oct 3, 2023
Merged via the queue into main with commit 33624ed Oct 3, 2023
40 checks passed
@toteki toteki deleted the adam/recent branch October 3, 2023 02:20
facundomedica pushed a commit that referenced this pull request Oct 30, 2023
* price mode support

* cl#

* fix tests

* change query behavior

* update test

* add emulated price outage to mock oracle

* test++

* test++

* adjust price behavior for account summary query

* message behavior tests

* lint

* comment

* market summary uses price mdoe query

* fix oracle behavior (stop clearing prices)

* tests++

* tests++

* warning++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-e2e-test Skip the e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants