Skip to content

Commit 90199cb

Browse files
authored
disallow creation of 0 supply dividend (#697)
1 parent 10c1d62 commit 90199cb

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

contracts/modules/Checkpoint/Dividend/ERC20/ERC20DividendCheckpoint.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
165165
require(_name != bytes32(0));
166166
uint256 dividendIndex = dividends.length;
167167
uint256 currentSupply = securityTokenInstance.totalSupplyAt(_checkpointId);
168-
require(currentSupply > 0, "Invalid supply");
169168
uint256 excludedSupply = 0;
170169
dividends.push(
171170
Dividend(
@@ -189,8 +188,8 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
189188
excludedSupply = excludedSupply.add(securityTokenInstance.balanceOfAt(_excluded[j], _checkpointId));
190189
dividends[dividendIndex].dividendExcluded[_excluded[j]] = true;
191190
}
192-
193-
dividends[dividendIndex].totalSupply = currentSupply.sub(excludedSupply);
191+
require(currentSupply > excludedSupply, "Invalid supply");
192+
dividends[dividendIndex].totalSupply = currentSupply - excludedSupply;
194193
dividendTokens[dividendIndex] = _token;
195194
_emitERC20DividendDepositedEvent(_checkpointId, _maturity, _expiry, _token, _amount, currentSupply, dividendIndex, _name);
196195
}

contracts/modules/Checkpoint/Dividend/Ether/EtherDividendCheckpoint.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
131131
require(_name[0] != bytes32(0));
132132
uint256 dividendIndex = dividends.length;
133133
uint256 currentSupply = ISecurityToken(securityToken).totalSupplyAt(_checkpointId);
134-
require(currentSupply > 0, "Invalid supply");
135134
uint256 excludedSupply = 0;
136135
dividends.push(
137136
Dividend(
@@ -155,7 +154,8 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
155154
excludedSupply = excludedSupply.add(ISecurityToken(securityToken).balanceOfAt(_excluded[j], _checkpointId));
156155
dividends[dividendIndex].dividendExcluded[_excluded[j]] = true;
157156
}
158-
dividends[dividendIndex].totalSupply = currentSupply.sub(excludedSupply);
157+
require(currentSupply > excludedSupply, "Invalid supply");
158+
dividends[dividendIndex].totalSupply = currentSupply - excludedSupply;
159159
/*solium-disable-next-line security/no-block-members*/
160160
emit EtherDividendDeposited(msg.sender, _checkpointId, _maturity, _expiry, msg.value, currentSupply, dividendIndex, _name);
161161
}

0 commit comments

Comments
 (0)