HQ20 / contracts

A set of reusable smart-contracts

Home Page:https://hq20-contracts.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix ERC20DividendableEth for supply changes.

alcueca opened this issue · comments

I've created a branch fix/erc20-dividends with line-by-line changes.

The formula that calculates the dividends per token will not be fair when the token supply changes. It needs to be:
dividendsPerToken = dividendsPerToken + dividendsToDistribute / token.totalSupply()

This is the spreadsheet I used to make sure what the formula should be.

dividendsPerToken is a fixed point number. pointMultiplier can be replaced by a dependency to Fixidity to be protected against overflows.

Please before changing the contract code the two tests specified in ERC20DividendableEth.test.ts and verify they don't pass.