Skip to content

Commit

Permalink
feat(token registry): proto max collateral share (#1096)
Browse files Browse the repository at this point in the history
## Description

ref: #1095

---

### 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
- [ ] 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
robert-zaremba authored Jul 5, 2022
1 parent 7d45ca6 commit 616a686
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 237 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [913](https://github.com/umee-network/umee/pull/913) Changed update registry gov proposal to add and update tokens, but never delete them.
- [918](https://github.com/umee-network/umee/pull/918) Add MarketSummary query to CLI.
- [1068](https://github.com/umee-network/umee/pull/1068) Add a cache layer for token registry.
- [1096](https://github.com/umee-network/umee/pull/1096) Add `max_collateral_share` to the x/leverage token registry.
- [1094](https://github.com/umee-network/umee/pull/1094) Added TotalCollateral query.
- [1099](https://github.com/umee-network/umee/pull/1099) Added TotalBorrowed query.

Expand Down
9 changes: 9 additions & 0 deletions proto/umee/leverage/v1/leverage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,13 @@ message Token {
// and enable_msg_borrow set to false. Such tokens can be safely removed from the
// oracle and price feeder as well.
bool blacklist = 14;

// Maximum collateral share specifies how much of the
// system's overall collateral be provided by a single token.
// Value is a percent; allowed values are in [0, 100] range.
// 100 means that the token has no restriction. 10 means maximum 10% of total
// collateral value can provided by this token.
uint32 max_collateral_share = 15 [
(gogoproto.moretags) = "yaml:\"max_collateral_share\""
];
}
1 change: 1 addition & 0 deletions x/leverage/spec/02_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ type Token struct {
EnableMsgSupply bool
EnableMsgBorrow bool
Blacklist bool
MaxCollateralShare uint32
}
```
143 changes: 94 additions & 49 deletions x/leverage/types/leverage.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions x/leverage/types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (t Token) Validate() error {
}
}

if t.MaxCollateralShare > 100 {
return sdkerrors.ErrInvalidRequest.Wrap("Token.MaxCollateralShare must be in [0; 100] range")
}

return nil
}

Expand Down
Loading

0 comments on commit 616a686

Please sign in to comment.