You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test case 1: Transfers of dividend carrying tokens also transfer the dividends.
Supply: 100 tokens, User 1 has 40, User 2 has 60.
Distribute 10 ether.
User 2 claims dividends. He's got 6 ether now.
User 1 transfers 6 tokens to user 2.
User 2 claims dividends again. He's got 6.6 ether now.
Test case 2: Transfers of non dividend carrying tokens don't transfer any dividends.
Supply: 100 tokens, User 1 has 40, User 2 has 60.
Distribute 10 ether.
User 1 claims dividends.
User 1 transfers 6 tokens to user 2.
User 2 claims dividends again. He's got 6 ether now.
Fix the issues with the supply first, please.
A
mapping(address => uint) public dividendsPerTokenAdjustment
is required to keep track of imbalances when transferring tokens with owning dividends.In a transfer:
transferWeight = trasnferAmount / recipientBalance
(Fixed point)dividendsPerTokenDifferential = lastDividendsPerToken[sender]-lastDividendsPerToken[receiver]
dividendsPerTokenAdjustment[account] = dividendsPerTokenAdjustment[account] + dividendsPerTokenDifferential * transferWeight
When calculating dividends owed:
owedDividendsPerToken = dividendsPerToken - lastDividendsPerToken[account] + dividendsPerTokenAdjustment[account]
When claiming dividends:
dividendsPerTokenAdjustment[account] = 0
The text was updated successfully, but these errors were encountered: