-
Notifications
You must be signed in to change notification settings - Fork 170
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!: convert LiquidationIncentive from Dec to uint32 #1149
Conversation
NOTE: I didn't update all the tests and CLI. Let's have initial review before moving it further. |
Another thing to consider is the size of small decimal numbers. Is basis points too precise or per-mile will need good enough? |
Percent should be okay in my opinion, but it might help to have the extra precision in case it's needed. Make sure we're capable of handling values like |
I have added a new type for package: |
I will add MaxBorrowRate to this PR to cover two examples and have better taste of how this will work. |
I've added |
Changing everything from |
These are not parameters to the messages. Except the general gov param update, for which we don't have any additional interface yet. |
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.
utack 👍 just has to pass e2e
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.
Let's do these params all at once, and without the custom math types at first (so uint32 only in proto)
Why? I don't see the reason why not using the custom type. Custom type gives us more control in fact and provides the essence of the solution. |
) | ||
|
||
const ( | ||
// UTokenPrefix defines the uToken denomination prefix for all uToken types. | ||
UTokenPrefix = "u/" | ||
UTokenPrefix = "u/" | ||
maxBorrowRateLimit = bpmath.ONE * 10_000 |
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.
This limit isn't necessary to hard code
@@ -432,7 +433,7 @@ func (k Keeper) LiquidateBorrow( | |||
} | |||
|
|||
// apply liquidation incentive | |||
reward.Amount = reward.Amount.ToDec().Mul(sdk.OneDec().Add(liquidationIncentive)).TruncateInt() | |||
reward.Amount = bpmath.Mul(reward.Amount, liquidationIncentive).Add(reward.Amount) |
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.
This is the only use of Mul
(or Quo
) I could find in the current diff
Interestingly enough, the original line had to be removed in my liquidation PR #1118 , because even the small sdk.Dec
early rounding was contributing to dust issues. Now liquidation incentive is multiplied to a Dec without rounding back to Int.
I think it is possible to avoid 4-precision Mul
and Quo
altogether
Preferences:
I did the merge conflict cleanup on this, so it should be ready after that. We can merge it before #1118 if you're worried about merge conflicts. edit: Oh, but we need to fix tests here too |
I can also handle conflicts here if #1118 merges first - as far as I know it's being blocked not because it has problems but just to keep this one first. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@@ -115,9 +115,9 @@ func IntegrationTestNetworkConfig() network.Config { | |||
LiquidationThreshold: sdk.MustNewDecFromStr("0.05"), | |||
BaseBorrowRate: sdk.MustNewDecFromStr("0.02"), | |||
KinkBorrowRate: sdk.MustNewDecFromStr("0.2"), | |||
MaxBorrowRate: sdk.MustNewDecFromStr("1.5"), | |||
MaxBorrowRate: 1_5000, |
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.
for bigger numbers we can use _
to separate "decimal". Note: we can't write 0_100
(for 0.1), because go would interpret it in octal notation.
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
Following discussion about using fixed point integers to represent small decimal values (percentage, basis points), this PR demonstrates how we can do it without adding more complexity.
See #1107 for discussion and motivation.
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...