Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(token registry): proto max collateral share #1096

Merged
merged 22 commits into from
Jul 5, 2022

Conversation

robert-zaremba
Copy link
Member

@robert-zaremba robert-zaremba commented Jul 4, 2022

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

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • 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 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)

@robert-zaremba robert-zaremba requested a review from a team as a code owner July 4, 2022 21:39
@robert-zaremba robert-zaremba changed the title Robert/proto max collateral supply feat(token factory): proto max collateral supply Jul 4, 2022
@robert-zaremba robert-zaremba changed the title feat(token factory): proto max collateral supply feat(token registry): proto max collateral supply Jul 4, 2022
@robert-zaremba robert-zaremba requested a review from a team as a code owner July 4, 2022 21:41
@robert-zaremba robert-zaremba force-pushed the robert/proto-max-collateral-supply branch from 518c105 to 063768a Compare July 4, 2022 21:48
@toteki
Copy link
Member

toteki commented Jul 4, 2022

For clarity, what is an example of this in use?

Option 1 - If I'm understanding correctly:

MaxCollateralSupply(tokenA) = 20%

Each time collateral of token A is added to the system, the total USD value of all collateral
in the system is calculated. If the total USD value of all token A collateral in the system
would exceed 20% of the first value, `MsgAddCollateral` fails.

There might also be restrictions on `MsgRemoveCollateral` of token B, if removing
token B would cause token A to exceed 20% of system collateral value.

Option 2 - if I'm misunderstanding the wording, this was another possibility

MaxCollateralSupply(tokenA) = 20%

If the total supply of token A is 1000, then only 200 can be used as collateral until more
is supplied.

Am I correct in assuming this proposal is the first option?

@robert-zaremba
Copy link
Member Author

For clarity, what is an example of this in use?

I will add ADR update once this will get merged with a proper example. Option 1 is the valid one - see the linked issue - it has more details.

There might also be restrictions on MsgRemoveCollateral of token B, if removing token B would cause token A to exceed 20% of system collateral value.

This is a good and valid point. The restriction will only hold when adding a collateral.

@toteki
Copy link
Member

toteki commented Jul 4, 2022

We might also solicit naming advice for this parameter in discussion tomorrow.

MaxCollateralSupply on its own suggests a limit to the amount of collateral itself, rather than a "ratio" or "share" of the total market.

@robert-zaremba
Copy link
Member Author

MaxCollateralSupply on its own suggests a limit to the amount of collateral itself, rather than a "ratio" or "share" of the total market.

How about MaxCollateralSupplyRatio? Feel free to propose other names.

@toteki
Copy link
Member

toteki commented Jul 5, 2022

MaxCollateralSupply (wrong meaning)
MaxCollateralMarketShare? (too long)
MaxCollateralShare?

@robert-zaremba
Copy link
Member Author

Renamed to MaxCollateralShare

x/leverage/types/token.go Outdated Show resolved Hide resolved
@toteki toteki added this to the Calypso milestone Jul 5, 2022
Copy link
Member

@toteki toteki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a little housekeeping (see commits) - approving now.

@toteki toteki changed the title feat(token registry): proto max collateral supply feat(token registry): proto max collateral share Jul 5, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #1096 (e6dbc18) into main (7d45ca6) will increase coverage by 0.27%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1096      +/-   ##
==========================================
+ Coverage   43.55%   43.82%   +0.27%     
==========================================
  Files          65       65              
  Lines        8390     8393       +3     
==========================================
+ Hits         3654     3678      +24     
+ Misses       4486     4472      -14     
+ Partials      250      243       -7     
Impacted Files Coverage Δ
x/leverage/types/token.go 72.58% <100.00%> (+36.98%) ⬆️

@mergify mergify bot merged commit 616a686 into main Jul 5, 2022
@mergify mergify bot deleted the robert/proto-max-collateral-supply branch July 5, 2022 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants