-
Notifications
You must be signed in to change notification settings - Fork 193
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(vpool): Add check for maximum leverage for open positions #793
Conversation
x/perp/keeper/msg_server_test.go
Outdated
app.VpoolKeeper.CreatePool( | ||
ctx, | ||
common.PairBTCStable, | ||
sdk.OneDec(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) would be nice to add argument comments for the other parameters too.
x/vpool/types/gov.go
Outdated
@@ -66,5 +66,13 @@ func (m *CreatePoolProposal) ValidateBasic() error { | |||
return fmt.Errorf("maintenance margin ratio ratio must be 0 <= ratio <= 1") | |||
} | |||
|
|||
if m.MaxLeverage.LT(sdk.OneDec()) { | |||
return fmt.Errorf("Max leverage must be >= 1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be possible for users to open positions with < 1 leverage? They would essentially be opening an over-collateralized position because they maybe think the asset will fluctuate a lot in the short term, but long term will move in their position favorably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave that as a behavior, i think it causes no harm to let the user open those positions
Can you check the integration tests? They seem to have failed for this PR. |
Fix #781
tasks: