-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #422 from PolymathNetwork/Vesting-Escrow-Wallet
Vesting escrow wallet
- Loading branch information
Showing
10 changed files
with
2,028 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../../Pausable.sol"; | ||
import "../Module.sol"; | ||
|
||
/** | ||
* @title Interface to be implemented by all Wallet modules | ||
* @dev abstract contract | ||
*/ | ||
contract IWallet is Module, Pausable { | ||
|
||
function unpause() public onlyOwner { | ||
super._unpause(); | ||
} | ||
|
||
function pause() public onlyOwner { | ||
super._pause(); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../../proxy/VestingEscrowWalletProxy.sol"; | ||
import "../../interfaces/IBoot.sol"; | ||
import "../ModuleFactory.sol"; | ||
import "../../libraries/Util.sol"; | ||
|
||
/** | ||
* @title Factory for deploying VestingEscrowWallet module | ||
*/ | ||
contract VestingEscrowWalletFactory is ModuleFactory { | ||
|
||
address public logicContract; | ||
/** | ||
* @notice Constructor | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _logicContract) public | ||
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) | ||
{ | ||
require(_logicContract != address(0), "Invalid address"); | ||
version = "1.0.0"; | ||
name = "VestingEscrowWallet"; | ||
title = "Vesting Escrow Wallet"; | ||
description = "Manage vesting schedules to employees / affiliates"; | ||
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
logicContract = _logicContract; | ||
} | ||
|
||
/** | ||
* @notice Used to launch the Module with the help of factory | ||
* _data Data used for the intialization of the module factory variables | ||
* @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 due to insufficent Allowance provided"); | ||
} | ||
VestingEscrowWalletProxy vestingEscrowWallet = new VestingEscrowWalletProxy(msg.sender, address(polyToken), logicContract); | ||
//Checks that _data is valid (not calling anything it shouldn't) | ||
require(Util.getSig(_data) == IBoot(vestingEscrowWallet).getInitFunction(), "Invalid data"); | ||
/*solium-disable-next-line security/no-low-level-calls*/ | ||
require(address(vestingEscrowWallet).call(_data), "Unsuccessfull call"); | ||
/*solium-disable-next-line security/no-block-members*/ | ||
emit GenerateModuleFromFactory(address(vestingEscrowWallet), getName(), address(this), msg.sender, setupCost, now); | ||
return address(vestingEscrowWallet); | ||
} | ||
|
||
/** | ||
* @notice Type of the Module factory | ||
*/ | ||
function getTypes() external view returns(uint8[]) { | ||
uint8[] memory res = new uint8[](1); | ||
res[0] = 6; | ||
return res; | ||
} | ||
|
||
/** | ||
* @notice Returns the instructions associated with the module | ||
*/ | ||
function getInstructions() external view returns(string) { | ||
/*solium-disable-next-line max-len*/ | ||
return "Issuer can deposit tokens to the contract and create the vesting schedule for the given address (Affiliate/Employee). These address can withdraw tokens according to there vesting schedule."; | ||
} | ||
|
||
/** | ||
* @notice Get the tags related to the module factory | ||
*/ | ||
function getTags() external view returns(bytes32[]) { | ||
bytes32[] memory availableTags = new bytes32[](2); | ||
availableTags[0] = "Vested"; | ||
availableTags[1] = "Escrow Wallet"; | ||
return availableTags; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
/** | ||
* @title Wallet for core vesting escrow functionality | ||
*/ | ||
contract VestingEscrowWalletStorage { | ||
|
||
struct Schedule { | ||
// Name of the template | ||
bytes32 templateName; | ||
// Tokens that were already claimed | ||
uint256 claimedTokens; | ||
// Start time of the schedule | ||
uint256 startTime; | ||
} | ||
|
||
struct Template { | ||
// Total amount of tokens | ||
uint256 numberOfTokens; | ||
// Schedule duration (How long the schedule will last) | ||
uint256 duration; | ||
// Schedule frequency (It is a cliff time period) | ||
uint256 frequency; | ||
// Index of the template in an array template names | ||
uint256 index; | ||
} | ||
|
||
// Number of tokens that are hold by the `this` contract but are unassigned to any schedule | ||
uint256 public unassignedTokens; | ||
// Address of the Treasury wallet. All of the unassigned token will transfer to that address. | ||
address public treasuryWallet; | ||
// List of all beneficiaries who have the schedules running/completed/created | ||
address[] public beneficiaries; | ||
// Flag whether beneficiary has been already added or not | ||
mapping(address => bool) internal beneficiaryAdded; | ||
|
||
// Holds schedules array corresponds to the affiliate/employee address | ||
mapping(address => Schedule[]) public schedules; | ||
// Holds template names array corresponds to the affiliate/employee address | ||
mapping(address => bytes32[]) internal userToTemplates; | ||
// Mapping use to store the indexes for different template names for a user. | ||
// affiliate/employee address => template name => index | ||
mapping(address => mapping(bytes32 => uint256)) internal userToTemplateIndex; | ||
// Holds affiliate/employee addresses coressponds to the template name | ||
mapping(bytes32 => address[]) internal templateToUsers; | ||
// Mapping use to store the indexes for different users for a template. | ||
// template name => affiliate/employee address => index | ||
mapping(bytes32 => mapping(address => uint256)) internal templateToUserIndex; | ||
// Store the template details corresponds to the template name | ||
mapping(bytes32 => Template) templates; | ||
|
||
// List of all template names | ||
bytes32[] public templateNames; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../modules/Wallet/VestingEscrowWalletStorage.sol"; | ||
import "./OwnedProxy.sol"; | ||
import "../Pausable.sol"; | ||
import "../modules/ModuleStorage.sol"; | ||
/** | ||
* @title Escrow wallet module for vesting functionality | ||
*/ | ||
contract VestingEscrowWalletProxy is VestingEscrowWalletStorage, ModuleStorage, Pausable, OwnedProxy { | ||
/** | ||
* @notice Constructor | ||
* @param _securityToken Address of the security token | ||
* @param _polyAddress Address of the polytoken | ||
* @param _implementation representing the address of the new implementation to be set | ||
*/ | ||
constructor (address _securityToken, address _polyAddress, address _implementation) | ||
public | ||
ModuleStorage(_securityToken, _polyAddress) | ||
{ | ||
require( | ||
_implementation != address(0), | ||
"Implementation address should not be 0x" | ||
); | ||
__implementation = _implementation; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.