Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
78ce59c
WIP
adamdossa Oct 4, 2018
1178731
More WIP
adamdossa Oct 4, 2018
dfe78fc
Use a public function
adamdossa Oct 4, 2018
0cf16c5
Comment out to
adamdossa Oct 4, 2018
2834840
Wip
adamdossa Oct 9, 2018
e2dc1e5
Add some test cases and fix
adamdossa Oct 9, 2018
54b9929
Fix ordering.
adamdossa Oct 9, 2018
3c97e8a
More test cases
adamdossa Oct 9, 2018
a03f27d
Add natspec commitments
adamdossa Oct 9, 2018
e5e94c1
Merge branch 'development-1.5.0' into sample_modules
adamdossa Oct 9, 2018
1bdfb39
Remove some revert messages
adamdossa Oct 9, 2018
c3a6e1f
Follow best practice for function modifiers
adamdossa Oct 9, 2018
d8eb699
Change timing in test cases
adamdossa Oct 10, 2018
395e998
Merge branch 'development-1.5.0' into sample_modules
SatyamSB Oct 10, 2018
7e7b9bb
use the createInstance helper
SatyamSB Oct 10, 2018
27161db
Merge branch 'development-1.5.0' into sample_modules
adamdossa Oct 12, 2018
d0ba4e6
Merge branch 'development-1.5.0' into sample_modules
adamdossa Oct 25, 2018
761a42f
Merge branch 'development-1.5.0' into sample_modules
pabloruiz55 Oct 25, 2018
07d5ecc
Merge branch 'development-1.5.0' into sample_modules
adamdossa Oct 25, 2018
be0cd01
Merge remote-tracking branch 'origin/sample_modules' into sample_modules
adamdossa Oct 25, 2018
709c564
Move modules
adamdossa Oct 25, 2018
3335162
Merge branch 'development-1.5.0' into sample_modules
adamdossa Oct 25, 2018
61c8bd2
Remove unused library
adamdossa Oct 25, 2018
98b273d
updated solCover to skip experimental contracts
pabloruiz55 Oct 25, 2018
e8dbe31
Add test for removeSchedule
adamdossa Oct 25, 2018
147d6c5
reverting solCover skip on experimental folder
pabloruiz55 Oct 25, 2018
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
2 changes: 1 addition & 1 deletion contracts/mocks/MockBurnFactory.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.24;

import "./MockRedemptionManager.sol";
import "../modules/Burn/TrackedRedemptionFactory.sol";
import "../modules/Experimental/Burn/TrackedRedemptionFactory.sol";

/**
* @title Mock Contract Not fit for production environment
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/MockRedemptionManager.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pragma solidity ^0.4.24;

import "../modules/Burn/TrackedRedemption.sol";
import "../modules/Experimental/Burn/TrackedRedemption.sol";

/**
* @title Burn module for burning tokens and keeping track of burnt amounts
*/
contract MockRedemptionManager is TrackedRedemption {

mapping (address => uint256) tokenToRedeem;

event RedeemedTokenByOwner(address _investor, address _byWhoom, uint256 _value, uint256 _timestamp);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.24;

import "./IBurn.sol";
import "../Module.sol";
import "../../interfaces/ISecurityToken.sol";
import "../../Burn/IBurn.sol";
import "../../Module.sol";
import "../../../interfaces/ISecurityToken.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
Expand Down Expand Up @@ -41,7 +41,7 @@ contract TrackedRedemption is IBurn, Module {
redeemedTokens[msg.sender] = redeemedTokens[msg.sender].add(_value);
emit Redeemed(msg.sender, _value, now);
}

/**
* @notice Returns the permissions flag that are associated with CountTransferManager
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.24;

import "./TrackedRedemption.sol";
import "../ModuleFactory.sol";
import "../../ModuleFactory.sol";

/**
* @title Factory for deploying GeneralTransferManager module
Expand Down
155 changes: 155 additions & 0 deletions contracts/modules/Experimental/Mixed/ScheduledCheckpoint.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
pragma solidity ^0.4.24;

import "./../../Checkpoint/ICheckpoint.sol";
import "../../TransferManager/ITransferManager.sol";
import "../../../interfaces/ISecurityToken.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
* @title Burn module for burning tokens and keeping track of burnt amounts
*/
contract ScheduledCheckpoint is ICheckpoint, ITransferManager {
using SafeMath for uint256;

struct Schedule {
bytes32 name;
uint256 startTime;
uint256 nextTime;
uint256 interval;
uint256 index;
uint256[] checkpointIds;
uint256[] timestamps;
uint256[] periods;
}

bytes32[] public names;

mapping (bytes32 => Schedule) public schedules;

event AddSchedule(bytes32 _name, uint256 _startTime, uint256 _interval, uint256 _timestamp);
event RemoveSchedule(bytes32 _name, uint256 _timestamp);

/**
* @notice Constructor
* @param _securityToken Address of the security token
* @param _polyAddress Address of the polytoken
*/
constructor (address _securityToken, address _polyAddress) public
Module(_securityToken, _polyAddress)
{
}

/**
* @notice This function returns the signature of configure function
*/
function getInitFunction() public pure returns (bytes4) {
return bytes4(0);
}

/**
* @notice adds a new schedule for checkpoints
* @param _name name of the new schedule (must be unused)
* @param _startTime start time of the schedule (first checkpoint)
* @param _interval interval at which checkpoints should be created
*/
function addSchedule(bytes32 _name, uint256 _startTime, uint256 _interval) external onlyOwner {
require(_startTime > now, "Start time must be in the future");
require(schedules[_name].name == bytes32(0), "Name already in use");
schedules[_name].name = _name;
schedules[_name].startTime = _startTime;
schedules[_name].nextTime = _startTime;
schedules[_name].interval = _interval;
schedules[_name].index = names.length;
names.push(_name);
emit AddSchedule(_name, _startTime, _interval, now);
}

/**
* @notice removes a schedule for checkpoints
* @param _name name of the schedule to be removed
*/
function removeSchedule(bytes32 _name) external onlyOwner {
require(schedules[_name].name == _name, "Name does not exist");
uint256 index = schedules[_name].index;
names[index] = names[names.length - 1];
names.length--;
if (index != names.length) {
schedules[names[index]].index = index;
}
delete schedules[_name];
emit RemoveSchedule(_name, now);
}


/**
* @notice Used to create checkpoints that correctly reflect balances
* @param _isTransfer whether or not an actual transfer is occuring
* @return always returns Result.NA
*/
function verifyTransfer(address /* _from */, address /* _to */, uint256 /* _amount */, bytes /* _data */, bool _isTransfer) public returns(Result) {
require(_isTransfer == false || msg.sender == securityToken, "Sender is not owner");
if (paused || !_isTransfer) {
return Result.NA;
}
_updateAll();
return Result.NA;
}

/**
* @notice gets schedule details
* @param _name name of the schedule
*/
function getSchedule(bytes32 _name) view external returns(bytes32, uint256, uint256, uint256, uint256[], uint256[], uint256[]) {
return (
schedules[_name].name,
schedules[_name].startTime,
schedules[_name].nextTime,
schedules[_name].interval,
schedules[_name].checkpointIds,
schedules[_name].timestamps,
schedules[_name].periods
);
}

/**
* @notice manually triggers update outside of transfer request for named schedule (can be used to reduce user gas costs)
* @param _name name of the schedule
*/
function update(bytes32 _name) external onlyOwner {
_update(_name);
}

function _update(bytes32 _name) internal {
Schedule storage schedule = schedules[_name];
if (schedule.nextTime <= now) {
uint256 checkpointId = ISecurityToken(securityToken).createCheckpoint();
uint256 periods = now.sub(schedule.nextTime).div(schedule.interval).add(1);
schedule.timestamps.push(schedule.nextTime);
schedule.nextTime = periods.mul(schedule.interval).add(schedule.nextTime);
schedule.checkpointIds.push(checkpointId);
schedule.periods.push(periods);
}
}

/**
* @notice manually triggers update outside of transfer request for all schedules (can be used to reduce user gas costs)
*/
function updateAll() onlyOwner external {
_updateAll();
}

function _updateAll() internal {
uint256 i;
for (i = 0; i < names.length; i++) {
_update(names[i]);
}
}

/**
* @notice Return the permissions flag that are associated with CountTransferManager
*/
function getPermissions() view external returns(bytes32[]) {
bytes32[] memory allPermissions = new bytes32[](0);
return allPermissions;
}
}
102 changes: 102 additions & 0 deletions contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
pragma solidity ^0.4.24;

import "./ScheduledCheckpoint.sol";
import "../../ModuleFactory.sol";

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

/**
* @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) public
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
{
version = "1.0.0";
name = "ScheduledCheckpoint";
title = "Schedule Checkpoints";
description = "Allows you to schedule checkpoints in the future";
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0));
}

/**
* @notice used to launch the Module with the help of factory
* @return address Contract address of the Module
*/
function deploy(bytes /* _data */) external returns(address) {
if(setupCost > 0)
require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided");
address scheduledCheckpoint = new ScheduledCheckpoint(msg.sender, address(polyToken));
emit GenerateModuleFromFactory(scheduledCheckpoint, getName(), address(this), msg.sender, setupCost, now);
return scheduledCheckpoint;
}

/**
* @notice Type of the Module factory
*/
function getTypes() external view returns(uint8[]) {
uint8[] memory res = new uint8[](2);
res[0] = 4;
res[1] = 2;
return res;
}

/**
* @notice Get the name of the Module
*/
function getName() public view returns(bytes32) {
return name;
}

/**
* @notice Get the description of the Module
*/
function getDescription() external view returns(string) {
return description;
}

/**
* @notice Get the title of the Module
*/
function getTitle() external view returns(string) {
return title;
}

/**
* @notice Get the version of the Module
*/
function getVersion() external view returns(string) {
return version;
}

/**
* @notice Get the setup cost of the module
*/
function getSetupCost() external view returns (uint256) {
return setupCost;
}

/**
* @notice Get the Instructions that helped to used the module
*/
function getInstructions() external view returns(string) {
return "Schedule a series of future checkpoints by specifying a start time and interval of each checkpoint";
}

/**
* @notice Get the tags related to the module factory
*/
function getTags() external view returns(bytes32[]) {
bytes32[] memory availableTags = new bytes32[](2);
availableTags[0] = "Scheduled";
availableTags[1] = "Checkpoint";
return availableTags;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.4.24;
import "./ITransferManager.sol";

import "./../../TransferManager/ITransferManager.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
Expand Down Expand Up @@ -317,4 +318,4 @@ contract SingleTradeVolumeRestrictionTM is ITransferManager {
allPermissions[0] = ADMIN;
return allPermissions;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pragma solidity ^0.4.24;

import "./../ModuleFactory.sol";
import "./../../ModuleFactory.sol";
import "./SingleTradeVolumeRestrictionTM.sol";
import "../../libraries/Util.sol";
import "../../../libraries/Util.sol";

/**
* @title Factory for deploying SingleTradeVolumeRestrictionManager
*/
Expand Down
Loading