diff --git a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol index 6dfc7ef68..c01e6ec14 100644 --- a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol @@ -124,9 +124,6 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { uint256 dividendIndex = dividends.length; uint256 currentSupply = ISecurityToken(securityToken).totalSupplyAt(_checkpointId); uint256 excludedSupply = 0; - for (uint256 i = 0; i < _excluded.length; i++) { - excludedSupply = excludedSupply.add(ISecurityToken(securityToken).balanceOfAt(_excluded[i], _checkpointId)); - } dividends.push( Dividend( _checkpointId, @@ -135,16 +132,18 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { _expiry, _amount, 0, - currentSupply.sub(excludedSupply), + 0, false, 0, 0, _name ) ); - for (uint256 j = 0; j < _excluded.length; j++) { - dividends[dividends.length - 1].dividendExcluded[_excluded[j]] = true; + for (uint256 i = 0; i < _excluded.length; i++) { + excludedSupply = excludedSupply.add(ISecurityToken(securityToken).balanceOfAt(_excluded[i], _checkpointId)); + dividends[dividends.length - 1].dividendExcluded[_excluded[i]] = true; } + dividends[dividends.length - 1].totalSupply = currentSupply.sub(excludedSupply); dividendTokens[dividendIndex] = _token; _emitERC20DividendDepositedEvent(_checkpointId, _maturity, _expiry, _token, _amount, currentSupply, dividendIndex, _name); } diff --git a/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol b/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol index 2c4349589..11b0c31d3 100644 --- a/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol @@ -106,9 +106,6 @@ contract EtherDividendCheckpoint is DividendCheckpoint { uint256 dividendIndex = dividends.length; uint256 currentSupply = ISecurityToken(securityToken).totalSupplyAt(_checkpointId); uint256 excludedSupply = 0; - for (uint256 i = 0; i < _excluded.length; i++) { - excludedSupply = excludedSupply.add(ISecurityToken(securityToken).balanceOfAt(_excluded[i], _checkpointId)); - } dividends.push( Dividend( _checkpointId, @@ -117,16 +114,18 @@ contract EtherDividendCheckpoint is DividendCheckpoint { _expiry, msg.value, 0, - currentSupply.sub(excludedSupply), + 0, false, 0, 0, _name ) ); - for (uint256 j = 0; j < _excluded.length; j++) { - dividends[dividends.length - 1].dividendExcluded[_excluded[j]] = true; + for (uint256 i = 0; i < _excluded.length; i++) { + excludedSupply = excludedSupply.add(ISecurityToken(securityToken).balanceOfAt(_excluded[i], _checkpointId)); + dividends[dividends.length - 1].dividendExcluded[_excluded[i]] = true; } + dividends[dividends.length -1].totalSupply = currentSupply.sub(excludedSupply); emit EtherDividendDeposited(msg.sender, _checkpointId, now, _maturity, _expiry, msg.value, currentSupply, dividendIndex, _name); }