-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: liquidation directly rewards base assets (#1118)
## Description Significant Change: - Instead of receiving uToken rewards on `MsgLiquidate`, liquidator receives equivalent base assets. Reasoning: We're about to add `MaxCollateralUtilization` which restricts `MsgWithdraw` at critical times, so `AvailableSupply` can be used for liquidation. But if liquidators receive their rewards as uTokens, then the `MsgWithdraw` restriction will apply to them just like any other user, and they will be unable to receive their base tokens. Switching to base assets received eliminates makes `MaxCollateralUtilization` work as intended, and also simplifies the `MsgLiquidate -> MsgWithdraw -> IBC (to sell reward)` liquidation workflow to just `MsgLiquidate -> IBC` --- API Breaking: - Reverts `MsgLiquidate`'s reward `sdk.Coin` field to reward_denom `string` Reasoning: That field was for rare cases where liquidators do not trust the umee `x/oracle` and want to put their own price floors. Such cases should be handled off-chain (just query prices) rather than adding a computation and required field for all users. See #828 --- closes: #898 closes: #828 relevant to #831 - because rounding up repayment and reward eliminates most "dust" liquidation remainders --- ### 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)) - [x] 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) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] 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)
- Loading branch information
Showing
23 changed files
with
818 additions
and
524 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// filterCoins returns the subset of an sdk.Coins that meet a given condition | ||
func (k Keeper) filterCoins(coins sdk.Coins, accept func(sdk.Coin) bool) sdk.Coins { | ||
filtered := sdk.Coins{} | ||
for _, c := range coins { | ||
if accept(c) { | ||
filtered = append(filtered, c) | ||
} | ||
} | ||
return filtered | ||
} | ||
|
||
// filterAcceptedCoins returns the subset of an sdk.Coins that are accepted, non-blacklisted tokens | ||
func (k Keeper) filterAcceptedCoins(ctx sdk.Context, coins sdk.Coins) sdk.Coins { | ||
return k.filterCoins( | ||
coins, | ||
func(c sdk.Coin) bool { | ||
return k.validateAcceptedAsset(ctx, c) == nil | ||
}, | ||
) | ||
} |
Oops, something went wrong.