Skip to content

Commit

Permalink
feat: Add DirectLiquidationFee and uToken liquidation option (#1222)
Browse files Browse the repository at this point in the history
## Description

- Adds proto for `DirectLiquidationFee` as well as actually implementing the behavior.

Misc additions:

- Moved token <-> uToken denom functions to `types` package. Previously there were similar functions in both `types` and `keeper`.
- 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`)

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

- [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
toteki committed Aug 10, 2022
1 parent af0793b commit 8277b19
Show file tree
Hide file tree
Showing 33 changed files with 814 additions and 762 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1140](https://github.com/umee-network/umee/pull/1140) Rename MarketSize query to TotalSuppliedValue, and TokenMarketSize to TotalSupplied.
- [1188](https://github.com/umee-network/umee/pull/1188) Remove all individual queries which duplicate market_summary fields.
- [1199](https://github.com/umee-network/umee/pull/1199) Move all queries which require address input (e.g. `supplied`, `collateral_value`, `borrow_limit`) into aggregate queries `acccount_summary` or `account_balances`.
- [1222](https://github.com/umee-network/umee/pull/1222) Add leverage parameter DirectLiquidationFee.

### Features

Expand All @@ -79,6 +80,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1203](https://github.com/umee-network/umee/pull/1203) Add Swagger docs.
- [1212](https://github.com/umee-network/umee/pull/1212) Add `util/checkers` utility package providing common check / validation functions.
- [1220](https://github.com/umee-network/umee/pull/1220) Submit oracle prevotes / vote txs via the CLI.
- [1222](https://github.com/umee-network/umee/pull/1222) Liquidation reward_denom can now be either token or uToken.

### Improvements

Expand Down
8 changes: 8 additions & 0 deletions proto/umee/leverage/v1/leverage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ message Params {
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"small_liquidation_size\""
];
// Direct Liquidation Fee is the reduction in liquidation incentive experienced
// by liquidators who choose to receive base assets instead of uTokens as
// liquidation rewards.
string direct_liquidation_fee = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"direct_liquidation_fee\""
];
}

// Token defines a token, along with its metadata and parameters, in the Umee
Expand Down
7 changes: 4 additions & 3 deletions proto/umee/leverage/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ message MsgLiquidate {
// Repayment is the maximum amount of base tokens that the liquidator is willing
// to repay.
cosmos.base.v1beta1.Coin repayment = 3 [(gogoproto.nullable) = false];
// RewardDenom is the base token denom that the liquidator is willing to accept
// as a liquidation reward. The uToken equivalent of any base token rewards
// will be taken from the borrower's collateral.
// RewardDenom is the denom that the liquidator will receive as a liquidation reward.
// If it is a uToken, the liquidator will receive uTokens from the borrower's
// collateral. If it is a base token, the uTokens will be redeemed directly at
// a reduced Liquidation Incentive, and the liquidator will receive base tokens.
string reward_denom = 4;
}

Expand Down
Loading

0 comments on commit 8277b19

Please sign in to comment.