Smart contract for secure storage of ERC20 tokens.
npm install
truffle run coverage
truffle dashboard
truffle migrate --f 1 --to 1 --network dashboard
Problem: Admin has set the payment price for creating a pool, but it is necessary that certain addresses don't pay.
Solution: Create a whitelist of addresses that don't pay and integrate it with Locked-pools.
- The default whitelist address is zero
- We can set only contract that implements IWhiteList interface.
function setWhiteListAddress(address _address) external;
Testnet tx: link
Locked-pools can uses three manual whitelists. One of them is a whitelist for tokens that are exempt from paying fees.
function setTokenFeeWhiteListId(uint256 _id) external;
Testnet tx: link
If someone is trying to lock tokens that damage the contract, we can create a whitelist of tokens that can only be used to create a locked pool.
function setTokenFilterWhiteListId(uint256 _id) external;
Testnet tx: link
Setting a whitelist ID for users who are exempt from paying fees.
function setUserWhiteListId(uint256 _id) external;
Testnet tx: link
There is a restriction on the implementation of mass locked pools.
// by default, the maximum transaction limit is 400
function setMaxTransactionLimit(uint256 _newLimit) external;
Testnet tx: link
// by default the token filter is disabled
function swapTokenFilter() external;
Testnet tx: link
After using PoolTransfer, a new locked-pool of tokens is created based on the previous one, but with a new owner.
function PoolTransfer(uint256 _PoolId, address _NewOwner)
external;
Testnet tx: link
When you splitting a pool, it creates a new pool with splitted amount, in the original pool, the amount is reduced by the amount of the new pool.
function SplitPoolAmount(
uint256 _PoolId,
uint256 _NewAmount,
address _NewOwner
) external returns(uint256)
Testnet tx: link
Using the ApproveAllowance function, we can allocate an amount for non-owner addresses to split the pool.
function ApproveAllowance(
uint256 _PoolId,
uint256 _Amount,
address _Spender
) external;
Testnet tx: link
ATTENTION! The number of locked tokens must be approved by the contract of the token before use.
CreateNewPool() function allows us to create a new pool for locking tokens. If it is needed you have to pay some fee for creation.
function CreateNewPool(
address _Token, // Token address to lock
uint256 _StartTime, // Until what time a pool will start
uint256 _FinishTime, // Until what time a pool will end
uint256 _StartAmount, // Total amount of the tokens to sell in a pool
address _Owner // Token owner
) external payable;
Testnet tx: link
ATTENTION! The number of locked tokens must be approved by the contract of the token before use.
CreateMassPool() function allows us to create an array of pools for locking tokens.
function CreateMassPools(
address _Token,
uint256[] calldata _StartTime,
uint256[] calldata _FinishTime,
uint256[] calldata _StartAmount,
address[] calldata _Owner
) external payable;
Testnet tx: link
ATTENTION! The number of locked tokens must be approved by the contract of the token before use.
function CreatePoolsWrtTime(
address _Token,
uint256[] calldata _StartTime,
uint256[] calldata _FinishTime,
uint256[] calldata _StartAmount,
address[] calldata _Owner
) external payable
Testnet tx: link
Find pool IDs by specifying token addresses.
function GetMyPoolsIdByToken(address[] memory _tokens)
public
view
returns (uint256[] memory);
Each element of the Pool array will return:
uint256 StartTime, uint256 FinishTime, uint256 StartAmount, uint256 DebitedAmount, address Owner, address Token
function GetPoolsData(uint256[] memory _ids)
public
view
returns (Pool[] memory)
If _tokenAddress
returns true, we don't need to pay to create the pool.
function isTokenWithoutFee(address _tokenAddress) public view returns(bool);
If false is returned, the token cannot be used in a locked pool.
function isTokenWhiteListed(address _tokenAddress) public view returns(bool);
Returns true if _UserAddress
have allocation in WhiteList.
function isUserWithoutFee(address _UserAddress) public view returns(bool);
There is a way how to get a pool data.
function AllPoolz(uint256 _id)
public
view
returns (
uint256, // StartTime
uint256, // FinishTime
uint256, // StartAmount
uint256, // DebitedAmount
address, // Owner
address // Token
);
The function returns an array of all your pools IDs.
function GetAllMyPoolsId() public view returns (uint256[] memory);
Returns only your pools with a balance.
function GetMyPoolsId() public view returns (uint256[] memory);
The WithdrawToken() function allows you to withdraw tokens if the pool is over, provided they are still in the pool.
function WithdrawToken(uint256 _PoolId) external returns (bool);
Testnet tx: link
See how many tokens can be unlocked in a pool.
function getWithdrawableAmount(uint256 _PoolId) public view returns(uint256)
When splitting a pool, the existing allowance for a user in the pool will be reduced by the specified amount.
function SplitPoolAmountFrom(
uint256 _PoolId,
uint256 _Amount,
address _Address
) external returns(uint256);
Testnet tx: link
There is a way how to get a pool allowance.
function Allowance(uint256 _PoolId, address _Address) public view returns(uint256);
The-Poolz Contracts is released under the MIT License.