feat: Add DirectLiquidationFee and uToken liquidation option#1222
Merged
mergify[bot] merged 42 commits intomainfrom Aug 10, 2022
Merged
feat: Add DirectLiquidationFee and uToken liquidation option#1222mergify[bot] merged 42 commits intomainfrom
mergify[bot] merged 42 commits intomainfrom
Conversation
toteki
commented
Aug 7, 2022
toteki
commented
Aug 8, 2022
toteki
commented
Aug 8, 2022
toteki
commented
Aug 8, 2022
toteki
commented
Aug 8, 2022
Contributor
Author
There was a problem hiding this comment.
Adds proto for DirectLiquidationFee as well as actually implementing the behavior.
Misc additions:
- Moved token <-> uToken denom functions to
typespackage. Previously there were similar functions in bothtypesandkeeper. - Improved operations tests in simulation package and fixed a hidden bug (fees making messages fail if the random generator hit certain values, due to some transactions not using
CoinsSpentInMsg)
Codecov Report
@@ Coverage Diff @@
## main #1222 +/- ##
==========================================
- Coverage 51.20% 50.97% -0.24%
==========================================
Files 67 67
Lines 6657 6772 +115
==========================================
+ Hits 3409 3452 +43
- Misses 3008 3077 +69
- Partials 240 243 +3
|
adamewozniak
approved these changes
Aug 10, 2022
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
| if err != nil { | ||
| return err | ||
| } | ||
| return k.setBorrow(ctx, borrowAddr, k.GetBorrow(ctx, borrowAddr, repay.Denom).Sub(repay)) |
Contributor
There was a problem hiding this comment.
if result is zero (old_borrow - repay) then we should close the position and remove the record.
Contributor
Author
There was a problem hiding this comment.
setBorrow (or technically setAdjustedBorrow which it uses internally) clears the record whenever something would be set to zero
| // If there are not enough uTokens in balance, Withdraw will attempt to withdraw uToken collateral | ||
| // to make up the difference (as long as borrow limit allows). If the uToken denom is invalid or | ||
| // balances are insufficient to withdraw the full amount requested, returns an error. | ||
| func (k Keeper) Withdraw(ctx sdk.Context, supplierAddr sdk.AccAddress, uToken sdk.Coin) error { |
Contributor
There was a problem hiding this comment.
+1 for renaming to uToken
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
DirectLiquidationFeeas well as actually implementing the behavior.Misc additions:
typespackage. Previously there were similar functions in bothtypesandkeeper.CoinsSpentInMsg)closes: #1158
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...