Skip to content

Commit 50fd775

Browse files
authored
Revert "Optimise GTM (#433)"
This reverts commit 42e4a78.
1 parent 42e4a78 commit 50fd775

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1449
-975
lines changed

CHANGELOG.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ All notable changes to this project will be documented in this file.
1313
* Added `getTokensSoldByTier` to return sold (not minted during finalisation) tokens in each tier to USDTSTO.
1414
* Removed individual mappings for tier data removed in UDSTSTO.
1515

16-
# GeneralTransferManager
17-
* Add an Offset that can be used to move all from & to dates forwards or backwards by a fixed offset.
18-
* Add `address[] public investors` to record a list of all addresses that have been added to the whitelist (`getInvestors`)
19-
* Fix for when `allowAllWhitelistIssuances` is FALSE
20-
* Make GTM a Proxy based implementation to reduce deployment gas costs
21-
2216
##Changed
2317
* `getAllModulesAndPermsFromTypes()` does not take securityToken address as a parameter anymore.
2418

contracts/modules/Checkpoint/DividendCheckpoint.sol

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
pragma solidity ^0.4.24;
99

1010
import "./ICheckpoint.sol";
11-
import "./DividendCheckpointStorage.sol";
1211
import "../Module.sol";
1312
import "../../interfaces/ISecurityToken.sol";
1413
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
@@ -18,9 +17,43 @@ import "openzeppelin-solidity/contracts/math/Math.sol";
1817
* @title Checkpoint module for issuing ether dividends
1918
* @dev abstract contract
2019
*/
21-
contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
20+
contract DividendCheckpoint is ICheckpoint, Module {
2221
using SafeMath for uint256;
2322

23+
uint256 public EXCLUDED_ADDRESS_LIMIT = 50;
24+
bytes32 public constant DISTRIBUTE = "DISTRIBUTE";
25+
bytes32 public constant MANAGE = "MANAGE";
26+
bytes32 public constant CHECKPOINT = "CHECKPOINT";
27+
28+
struct Dividend {
29+
uint256 checkpointId;
30+
uint256 created; // Time at which the dividend was created
31+
uint256 maturity; // Time after which dividend can be claimed - set to 0 to bypass
32+
uint256 expiry; // Time until which dividend can be claimed - after this time any remaining amount can be withdrawn by issuer -
33+
// set to very high value to bypass
34+
uint256 amount; // Dividend amount in WEI
35+
uint256 claimedAmount; // Amount of dividend claimed so far
36+
uint256 totalSupply; // Total supply at the associated checkpoint (avoids recalculating this)
37+
bool reclaimed; // True if expiry has passed and issuer has reclaimed remaining dividend
38+
uint256 dividendWithheld;
39+
uint256 dividendWithheldReclaimed;
40+
mapping (address => bool) claimed; // List of addresses which have claimed dividend
41+
mapping (address => bool) dividendExcluded; // List of addresses which cannot claim dividends
42+
bytes32 name; // Name/title - used for identification
43+
}
44+
45+
// List of all dividends
46+
Dividend[] public dividends;
47+
48+
// List of addresses which cannot claim dividends
49+
address[] public excluded;
50+
51+
// Mapping from address to withholding tax as a percentage * 10**16
52+
mapping (address => uint256) public withholdingTax;
53+
54+
// Total amount of ETH withheld per investor
55+
mapping (address => uint256) public investorWithheld;
56+
2457
event SetDefaultExcludedAddresses(address[] _excluded, uint256 _timestamp);
2558
event SetWithholding(address[] _investors, uint256[] _withholding, uint256 _timestamp);
2659
event SetWithholdingFixed(address[] _investors, uint256 _withholding, uint256 _timestamp);

contracts/modules/Checkpoint/DividendCheckpointStorage.sol

Lines changed: 0 additions & 43 deletions
This file was deleted.

contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
pragma solidity ^0.4.24;
22

33
import "./DividendCheckpoint.sol";
4-
import "./ERC20DividendCheckpointStorage.sol";
54
import "../../interfaces/IOwnable.sol";
65
import "../../interfaces/IERC20.sol";
76

87
/**
98
* @title Checkpoint module for issuing ERC20 dividends
109
*/
11-
contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendCheckpoint {
10+
contract ERC20DividendCheckpoint is DividendCheckpoint {
1211
using SafeMath for uint256;
1312

13+
// Mapping to token address for each dividend
14+
mapping (uint256 => address) public dividendTokens;
1415
event ERC20DividendDeposited(
1516
address indexed _depositor,
1617
uint256 _checkpointId,
@@ -67,8 +68,8 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
6768
address _token,
6869
uint256 _amount,
6970
bytes32 _name
70-
)
71-
external
71+
)
72+
external
7273
withPerm(MANAGE)
7374
{
7475
createDividendWithExclusions(_maturity, _expiry, _token, _amount, excluded, _name);
@@ -132,16 +133,16 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
132133
* @param _name Name/Title for identification
133134
*/
134135
function createDividendWithCheckpointAndExclusions(
135-
uint256 _maturity,
136-
uint256 _expiry,
137-
address _token,
138-
uint256 _amount,
139-
uint256 _checkpointId,
136+
uint256 _maturity,
137+
uint256 _expiry,
138+
address _token,
139+
uint256 _amount,
140+
uint256 _checkpointId,
140141
address[] _excluded,
141142
bytes32 _name
142-
)
143+
)
143144
public
144-
withPerm(MANAGE)
145+
withPerm(MANAGE)
145146
{
146147
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, _checkpointId, _excluded, _name);
147148
}
@@ -157,15 +158,15 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
157158
* @param _name Name/Title for identification
158159
*/
159160
function _createDividendWithCheckpointAndExclusions(
160-
uint256 _maturity,
161-
uint256 _expiry,
162-
address _token,
163-
uint256 _amount,
164-
uint256 _checkpointId,
161+
uint256 _maturity,
162+
uint256 _expiry,
163+
address _token,
164+
uint256 _amount,
165+
uint256 _checkpointId,
165166
address[] _excluded,
166167
bytes32 _name
167-
)
168-
internal
168+
)
169+
internal
169170
{
170171
ISecurityToken securityTokenInstance = ISecurityToken(securityToken);
171172
require(_excluded.length <= EXCLUDED_ADDRESS_LIMIT, "Too many addresses excluded");
@@ -209,7 +210,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
209210
}
210211

211212
/**
212-
* @notice Emits the ERC20DividendDeposited event.
213+
* @notice Emits the ERC20DividendDeposited event.
213214
* Seperated into a different function as a workaround for stack too deep error
214215
*/
215216
function _emitERC20DividendDepositedEvent(

contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
pragma solidity ^0.4.24;
22

3-
import "../../proxy/ERC20DividendCheckpointProxy.sol";
3+
import "./ERC20DividendCheckpoint.sol";
44
import "../ModuleFactory.sol";
55

66
/**
77
* @title Factory for deploying ERC20DividendCheckpoint module
88
*/
99
contract ERC20DividendCheckpointFactory is ModuleFactory {
1010

11-
address public logicContract;
12-
1311
/**
1412
* @notice Constructor
1513
* @param _polyAddress Address of the polytoken
1614
* @param _setupCost Setup cost of the module
1715
* @param _usageCost Usage cost of the module
1816
* @param _subscriptionCost Subscription cost of the module
1917
*/
20-
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _logicContract) public
18+
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
2119
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
2220
{
2321
version = "1.0.0";
@@ -26,7 +24,6 @@ contract ERC20DividendCheckpointFactory is ModuleFactory {
2624
description = "Create ERC20 dividends for token holders at a specific checkpoint";
2725
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
2826
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
29-
logicContract = _logicContract;
3027
}
3128

3229
/**
@@ -36,7 +33,7 @@ contract ERC20DividendCheckpointFactory is ModuleFactory {
3633
function deploy(bytes /* _data */) external returns(address) {
3734
if (setupCost > 0)
3835
require(polyToken.transferFrom(msg.sender, owner, setupCost), "insufficent allowance");
39-
address erc20DividendCheckpoint = new ERC20DividendCheckpointProxy(msg.sender, address(polyToken), logicContract);
36+
address erc20DividendCheckpoint = new ERC20DividendCheckpoint(msg.sender, address(polyToken));
4037
/*solium-disable-next-line security/no-block-members*/
4138
emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, setupCost, now);
4239
return erc20DividendCheckpoint;

contracts/modules/Checkpoint/ERC20DividendCheckpointStorage.sol

Lines changed: 0 additions & 11 deletions
This file was deleted.

contracts/modules/Checkpoint/EtherDividendCheckpoint.sol

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import "../../interfaces/IOwnable.sol";
88
*/
99
contract EtherDividendCheckpoint is DividendCheckpoint {
1010
using SafeMath for uint256;
11-
1211
event EtherDividendDeposited(
1312
address indexed _depositor,
1413
uint256 _checkpointId,
@@ -57,7 +56,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
5756
uint256 _expiry,
5857
uint256 _checkpointId,
5958
bytes32 _name
60-
)
59+
)
6160
external
6261
payable
6362
withPerm(MANAGE)
@@ -77,7 +76,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
7776
uint256 _expiry,
7877
address[] _excluded,
7978
bytes32 _name
80-
)
79+
)
8180
public
8281
payable
8382
withPerm(MANAGE)
@@ -95,10 +94,10 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
9594
* @param _name Name/title for identification
9695
*/
9796
function createDividendWithCheckpointAndExclusions(
98-
uint256 _maturity,
99-
uint256 _expiry,
100-
uint256 _checkpointId,
101-
address[] _excluded,
97+
uint256 _maturity,
98+
uint256 _expiry,
99+
uint256 _checkpointId,
100+
address[] _excluded,
102101
bytes32 _name
103102
)
104103
public
@@ -117,12 +116,12 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
117116
* @param _name Name/title for identification
118117
*/
119118
function _createDividendWithCheckpointAndExclusions(
120-
uint256 _maturity,
121-
uint256 _expiry,
122-
uint256 _checkpointId,
123-
address[] _excluded,
119+
uint256 _maturity,
120+
uint256 _expiry,
121+
uint256 _checkpointId,
122+
address[] _excluded,
124123
bytes32 _name
125-
)
124+
)
126125
internal
127126
{
128127
require(_excluded.length <= EXCLUDED_ADDRESS_LIMIT, "Too many addresses excluded");
@@ -170,7 +169,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
170169
*/
171170
function _payDividend(address _payee, Dividend storage _dividend, uint256 _dividendIndex) internal {
172171
(uint256 claim, uint256 withheld) = calculateDividend(_dividendIndex, _payee);
173-
_dividend.claimed[_payee] = true;
172+
_dividend.claimed[_payee] = true;
174173
uint256 claimAfterWithheld = claim.sub(withheld);
175174
if (claimAfterWithheld > 0) {
176175
/*solium-disable-next-line security/no-send*/

contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
pragma solidity ^0.4.24;
22

3-
import "../../proxy/EtherDividendCheckpointProxy.sol";
3+
import "./EtherDividendCheckpoint.sol";
44
import "../ModuleFactory.sol";
55

66
/**
77
* @title Factory for deploying EtherDividendCheckpoint module
88
*/
99
contract EtherDividendCheckpointFactory is ModuleFactory {
1010

11-
address public logicContract;
12-
1311
/**
1412
* @notice Constructor
1513
* @param _polyAddress Address of the polytoken
1614
* @param _setupCost Setup cost of the module
1715
* @param _usageCost Usage cost of the module
1816
* @param _subscriptionCost Subscription cost of the module
1917
*/
20-
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _logicContract) public
18+
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
2119
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
2220
{
2321
version = "1.0.0";
@@ -26,7 +24,6 @@ contract EtherDividendCheckpointFactory is ModuleFactory {
2624
description = "Create ETH dividends for token holders at a specific checkpoint";
2725
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
2826
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
29-
logicContract = _logicContract;
3027
}
3128

3229
/**
@@ -36,7 +33,7 @@ contract EtherDividendCheckpointFactory is ModuleFactory {
3633
function deploy(bytes /* _data */) external returns(address) {
3734
if(setupCost > 0)
3835
require(polyToken.transferFrom(msg.sender, owner, setupCost), "Insufficent allowance or balance");
39-
address ethDividendCheckpoint = new EtherDividendCheckpointProxy(msg.sender, address(polyToken), logicContract);
36+
address ethDividendCheckpoint = new EtherDividendCheckpoint(msg.sender, address(polyToken));
4037
/*solium-disable-next-line security/no-block-members*/
4138
emit GenerateModuleFromFactory(ethDividendCheckpoint, getName(), address(this), msg.sender, setupCost, now);
4239
return ethDividendCheckpoint;

0 commit comments

Comments
 (0)