Make fee conversion rounding explicit (always round up)#238
Conversation
WalkthroughThe change updates Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Hey @OneNov0209 |
Thanks for the review. I’ve updated the implementation to make the rounding policy explicit (always round up) and added a changelog entry under UNRELEASED -> Fixed. This keeps the behavior deterministic and avoids any possibility of fee underpayment while staying consistent and simple. Let me know if you prefer a different rounding policy. |
Clarified ERC20 fee conversion rounding behavior.
|
Done, I've added the changelog entry and pushed it on top of this PR. Thanks! |
|
Thanks mate. I already create ticket on discord |
Description
This PR makes the ERC20 fee conversion rounding behavior explicit and conservative.
Previously, the code used:
RoundInt() uses bankers rounding, which can round up or down depending on the value.
For fee calculation paths, this can theoretically allow very small underpayment in edge cases.
This PR changes the logic to always round up:
This guarantees that:
The economic difference is negligible (at most 1 unit of smallest denomination), but this removes ambiguity and makes the policy clear.
Related discussion: #227