Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ All notable changes to this project will be documented in this file.
* Added `getTokensSoldByTier` to return sold (not minted during finalisation) tokens in each tier to USDTSTO.
* Removed individual mappings for tier data removed in UDSTSTO.

# GeneralTransferManager
* Add an Offset that can be used to move all from & to dates forwards or backwards by a fixed offset.
* Add `address[] public investors` to record a list of all addresses that have been added to the whitelist (`getInvestors`)
* Fix for when `allowAllWhitelistIssuances` is FALSE
* Make GTM a Proxy based implementation to reduce deployment gas costs

##Changed
* `getAllModulesAndPermsFromTypes()` does not take securityToken address as a parameter anymore.

Expand Down
37 changes: 35 additions & 2 deletions contracts/modules/Checkpoint/DividendCheckpoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
pragma solidity ^0.4.24;

import "./ICheckpoint.sol";
import "./DividendCheckpointStorage.sol";
import "../Module.sol";
import "../../interfaces/ISecurityToken.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
Expand All @@ -18,9 +17,43 @@ import "openzeppelin-solidity/contracts/math/Math.sol";
* @title Checkpoint module for issuing ether dividends
* @dev abstract contract
*/
contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
contract DividendCheckpoint is ICheckpoint, Module {
using SafeMath for uint256;

uint256 public EXCLUDED_ADDRESS_LIMIT = 50;
bytes32 public constant DISTRIBUTE = "DISTRIBUTE";
bytes32 public constant MANAGE = "MANAGE";
bytes32 public constant CHECKPOINT = "CHECKPOINT";

struct Dividend {
uint256 checkpointId;
uint256 created; // Time at which the dividend was created
uint256 maturity; // Time after which dividend can be claimed - set to 0 to bypass
uint256 expiry; // Time until which dividend can be claimed - after this time any remaining amount can be withdrawn by issuer -
// set to very high value to bypass
uint256 amount; // Dividend amount in WEI
uint256 claimedAmount; // Amount of dividend claimed so far
uint256 totalSupply; // Total supply at the associated checkpoint (avoids recalculating this)
bool reclaimed; // True if expiry has passed and issuer has reclaimed remaining dividend
uint256 dividendWithheld;
uint256 dividendWithheldReclaimed;
mapping (address => bool) claimed; // List of addresses which have claimed dividend
mapping (address => bool) dividendExcluded; // List of addresses which cannot claim dividends
bytes32 name; // Name/title - used for identification
}

// List of all dividends
Dividend[] public dividends;

// List of addresses which cannot claim dividends
address[] public excluded;

// Mapping from address to withholding tax as a percentage * 10**16
mapping (address => uint256) public withholdingTax;

// Total amount of ETH withheld per investor
mapping (address => uint256) public investorWithheld;

event SetDefaultExcludedAddresses(address[] _excluded, uint256 _timestamp);
event SetWithholding(address[] _investors, uint256[] _withholding, uint256 _timestamp);
event SetWithholdingFixed(address[] _investors, uint256 _withholding, uint256 _timestamp);
Expand Down
43 changes: 0 additions & 43 deletions contracts/modules/Checkpoint/DividendCheckpointStorage.sol

This file was deleted.

39 changes: 20 additions & 19 deletions contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
pragma solidity ^0.4.24;

import "./DividendCheckpoint.sol";
import "./ERC20DividendCheckpointStorage.sol";
import "../../interfaces/IOwnable.sol";
import "../../interfaces/IERC20.sol";

/**
* @title Checkpoint module for issuing ERC20 dividends
*/
contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendCheckpoint {
contract ERC20DividendCheckpoint is DividendCheckpoint {
using SafeMath for uint256;

// Mapping to token address for each dividend
mapping (uint256 => address) public dividendTokens;
event ERC20DividendDeposited(
address indexed _depositor,
uint256 _checkpointId,
Expand Down Expand Up @@ -67,8 +68,8 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
address _token,
uint256 _amount,
bytes32 _name
)
external
)
external
withPerm(MANAGE)
{
createDividendWithExclusions(_maturity, _expiry, _token, _amount, excluded, _name);
Expand Down Expand Up @@ -132,16 +133,16 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
* @param _name Name/Title for identification
*/
function createDividendWithCheckpointAndExclusions(
uint256 _maturity,
uint256 _expiry,
address _token,
uint256 _amount,
uint256 _checkpointId,
uint256 _maturity,
uint256 _expiry,
address _token,
uint256 _amount,
uint256 _checkpointId,
address[] _excluded,
bytes32 _name
)
)
public
withPerm(MANAGE)
withPerm(MANAGE)
{
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, _checkpointId, _excluded, _name);
}
Expand All @@ -157,15 +158,15 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
* @param _name Name/Title for identification
*/
function _createDividendWithCheckpointAndExclusions(
uint256 _maturity,
uint256 _expiry,
address _token,
uint256 _amount,
uint256 _checkpointId,
uint256 _maturity,
uint256 _expiry,
address _token,
uint256 _amount,
uint256 _checkpointId,
address[] _excluded,
bytes32 _name
)
internal
)
internal
{
ISecurityToken securityTokenInstance = ISecurityToken(securityToken);
require(_excluded.length <= EXCLUDED_ADDRESS_LIMIT, "Too many addresses excluded");
Expand Down Expand Up @@ -209,7 +210,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
}

/**
* @notice Emits the ERC20DividendDeposited event.
* @notice Emits the ERC20DividendDeposited event.
* Seperated into a different function as a workaround for stack too deep error
*/
function _emitERC20DividendDepositedEvent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
pragma solidity ^0.4.24;

import "../../proxy/ERC20DividendCheckpointProxy.sol";
import "./ERC20DividendCheckpoint.sol";
import "../ModuleFactory.sol";

/**
* @title Factory for deploying ERC20DividendCheckpoint module
*/
contract ERC20DividendCheckpointFactory is ModuleFactory {

address public logicContract;

/**
* @notice Constructor
* @param _polyAddress Address of the polytoken
* @param _setupCost Setup cost of the module
* @param _usageCost Usage cost of the module
* @param _subscriptionCost Subscription cost of the module
*/
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _logicContract) public
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
{
version = "1.0.0";
Expand All @@ -26,7 +24,6 @@ contract ERC20DividendCheckpointFactory is ModuleFactory {
description = "Create ERC20 dividends for token holders at a specific checkpoint";
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
logicContract = _logicContract;
}

/**
Expand All @@ -36,7 +33,7 @@ contract ERC20DividendCheckpointFactory is ModuleFactory {
function deploy(bytes /* _data */) external returns(address) {
if (setupCost > 0)
require(polyToken.transferFrom(msg.sender, owner, setupCost), "insufficent allowance");
address erc20DividendCheckpoint = new ERC20DividendCheckpointProxy(msg.sender, address(polyToken), logicContract);
address erc20DividendCheckpoint = new ERC20DividendCheckpoint(msg.sender, address(polyToken));
/*solium-disable-next-line security/no-block-members*/
emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, setupCost, now);
return erc20DividendCheckpoint;
Expand Down
11 changes: 0 additions & 11 deletions contracts/modules/Checkpoint/ERC20DividendCheckpointStorage.sol

This file was deleted.

25 changes: 12 additions & 13 deletions contracts/modules/Checkpoint/EtherDividendCheckpoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "../../interfaces/IOwnable.sol";
*/
contract EtherDividendCheckpoint is DividendCheckpoint {
using SafeMath for uint256;

event EtherDividendDeposited(
address indexed _depositor,
uint256 _checkpointId,
Expand Down Expand Up @@ -57,7 +56,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
uint256 _expiry,
uint256 _checkpointId,
bytes32 _name
)
)
external
payable
withPerm(MANAGE)
Expand All @@ -77,7 +76,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
uint256 _expiry,
address[] _excluded,
bytes32 _name
)
)
public
payable
withPerm(MANAGE)
Expand All @@ -95,10 +94,10 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
* @param _name Name/title for identification
*/
function createDividendWithCheckpointAndExclusions(
uint256 _maturity,
uint256 _expiry,
uint256 _checkpointId,
address[] _excluded,
uint256 _maturity,
uint256 _expiry,
uint256 _checkpointId,
address[] _excluded,
bytes32 _name
)
public
Expand All @@ -117,12 +116,12 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
* @param _name Name/title for identification
*/
function _createDividendWithCheckpointAndExclusions(
uint256 _maturity,
uint256 _expiry,
uint256 _checkpointId,
address[] _excluded,
uint256 _maturity,
uint256 _expiry,
uint256 _checkpointId,
address[] _excluded,
bytes32 _name
)
)
internal
{
require(_excluded.length <= EXCLUDED_ADDRESS_LIMIT, "Too many addresses excluded");
Expand Down Expand Up @@ -170,7 +169,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
*/
function _payDividend(address _payee, Dividend storage _dividend, uint256 _dividendIndex) internal {
(uint256 claim, uint256 withheld) = calculateDividend(_dividendIndex, _payee);
_dividend.claimed[_payee] = true;
_dividend.claimed[_payee] = true;
uint256 claimAfterWithheld = claim.sub(withheld);
if (claimAfterWithheld > 0) {
/*solium-disable-next-line security/no-send*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
pragma solidity ^0.4.24;

import "../../proxy/EtherDividendCheckpointProxy.sol";
import "./EtherDividendCheckpoint.sol";
import "../ModuleFactory.sol";

/**
* @title Factory for deploying EtherDividendCheckpoint module
*/
contract EtherDividendCheckpointFactory is ModuleFactory {

address public logicContract;

/**
* @notice Constructor
* @param _polyAddress Address of the polytoken
* @param _setupCost Setup cost of the module
* @param _usageCost Usage cost of the module
* @param _subscriptionCost Subscription cost of the module
*/
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _logicContract) public
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
{
version = "1.0.0";
Expand All @@ -26,7 +24,6 @@ contract EtherDividendCheckpointFactory is ModuleFactory {
description = "Create ETH dividends for token holders at a specific checkpoint";
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
logicContract = _logicContract;
}

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