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

V0.3.7 patch21 extra tests around demurrage #70

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

benjaminbollen
Copy link
Member

still significant bug in ERC20 Inflationary

  1. there was additional logic to absorb conversion errors between demurrage and inflationary format, but that implementation itself had a bug. It SHOULD have been of the form
- Extend numerical precision
- do the computation
- trash the extra Least Significant Bits we added

but instead it was wrongly implemented as

- Extend the numerical precision
- do the computation to convert to inflationary format
- don't yet trash the extra least significant bits

then on unwrapping

- do the computation to convert back
- trash the extra bits

this actually caused the extra bits to pollute the other bits more, introducing a bigger inaccuracy than without this extra complexity.

In hindsight the obvious insight is that GAMMA and BETA have a fixed precision, so multiplying by them keeps the same amount of accurate bits, regardless of shifting the bit registry, so the whole exercise just complicated the code and costs extra gas.

So it is removed.

  1. also removed some extra dead / redundant code in demurrage

* @param _balance Demurraged balance to calculate the inflationary balance of
* @param _dayUpdated The day the balance was last updated
*/
function _calculateInflationaryBalance(uint256 _balance, uint256 _dayUpdated) internal pure returns (uint256) {
Copy link
Member Author

Choose a reason for hiding this comment

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

duplicates of public convertDemurrageToInflationaryValue

@cducrest
Copy link

Looks fine

@benjaminbollen benjaminbollen merged commit 1337093 into develop Oct 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants