Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix!: allow safe leverage operations during partial oracle outages (backport #1821) #1828

Merged
merged 3 commits into from
Feb 15, 2023

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 15, 2023

This is an automatic backport of pull request #1821 done by Mergify.
Cherry-pick of 87b9ed4 has failed:

On branch mergify/bp/release/v4.1.x/pr-1821
Your branch is up to date with 'origin/release/v4.1.x'.

You are currently cherry-picking commit 87b9ed4.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   CHANGELOG.md
	modified:   x/leverage/client/tests/tests.go
	modified:   x/leverage/keeper/borrows.go
	modified:   x/leverage/keeper/collateral.go
	new file:   x/leverage/keeper/errors.go
	new file:   x/leverage/keeper/errors_test.go
	modified:   x/leverage/keeper/grpc_query.go
	modified:   x/leverage/keeper/grpc_query_test.go
	modified:   x/leverage/keeper/iter.go
	modified:   x/leverage/keeper/keeper.go
	modified:   x/leverage/keeper/limits.go
	modified:   x/leverage/keeper/liquidate.go
	modified:   x/leverage/keeper/msg_server.go
	modified:   x/leverage/keeper/oracle.go
	modified:   x/leverage/keeper/oracle_test.go
	new file:   x/leverage/keeper/outage_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   proto/umee/leverage/v1/query.proto
	both modified:   swagger/swagger.yaml
	both modified:   x/leverage/types/query.pb.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

…1821)

## Description

This one does a lot of things:
- Allows `account_summary` to work during price outages, treating all unknown prices as zero.
  - In such cases, supplied value and other fields will appear lower than it really is, since some assets were skipped
  - Liquidation threshold will be null when it can't be computed, since there's no safe way to do that with missing prices
- `borrow_limit` in queries as well as messages is computed using only collateral with known prices
  - If the portion of your collateral with known prices is enough to cover a borrow, then it still works.
  - Same for withdraw and decollateralize
- `MaxWithdraw` and `MaxBorrow` (both queries and messages) now function with missing collateral prices, respecting the borrow limit policy above. The queries return zero on missing borrow prices, or a missing price for the specific token being asked for.
- `liquidation_targets` query skips addresses where liquidation threshold cannot be computed, instead of returning an error for the whole query
- `MsgLiquidate` will be able to function with some missing prices on the target's borrowed assets, if their other borrows are  high enough to still put them above their liquidation threshold

API Breaking:
- `liquidation_threshold` field in `account_summary` field can now be null

---

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

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] added appropriate labels to the PR
- [x] targeted the correct branch (see [PR Targeting](https://github.com/umee-network/umee/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [x] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] 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)

(cherry picked from commit 87b9ed4)

# Conflicts:
#	proto/umee/leverage/v1/query.proto
#	swagger/swagger.yaml
#	x/leverage/types/query.pb.go
@mergify mergify bot requested review from a team as code owners February 15, 2023 22:32
@mergify mergify bot added the conflicts label Feb 15, 2023
@toteki toteki merged commit 43253fe into release/v4.1.x Feb 15, 2023
@toteki toteki deleted the mergify/bp/release/v4.1.x/pr-1821 branch February 15, 2023 23:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant