-
Notifications
You must be signed in to change notification settings - Fork 3
/
LockedPoolz.sol
63 lines (58 loc) · 1.87 KB
/
LockedPoolz.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./LockedManageable.sol";
contract LockedPoolz is LockedManageable {
constructor() {
Index = 0;
}
modifier isTokenValid(address _Token) {
require(isTokenWhiteListed(_Token), "Need Valid ERC20 Token"); //check if _Token is ERC20
_;
}
function SplitPool(
uint256 _PoolId,
uint256 _NewAmount,
address _NewOwner
) internal returns (uint256) {
Pool storage pool = AllPoolz[_PoolId];
require(pool.StartAmount >= _NewAmount, "Not Enough Amount Balance");
uint256 poolAmount = pool.StartAmount - _NewAmount;
pool.StartAmount = poolAmount;
uint256 poolId = CreatePool(
pool.Token,
pool.StartTime,
pool.FinishTime,
_NewAmount,
_NewOwner
);
emit PoolSplit(_PoolId, poolId, _NewAmount, _NewOwner);
return poolId;
}
//create a new pool
function CreatePool(
address _Token, // token to lock address
uint256 _StartTime, // Until what time the pool will Start
uint256 _FinishTime, // Until what time the pool will end
uint256 _StartAmount, //Total amount of the tokens to sell in the pool
address _Owner // Who the tokens belong to
) internal isTokenValid(_Token) returns (uint256) {
require(
_StartTime <= _FinishTime,
"StartTime is greater than FinishTime"
);
//register the pool
AllPoolz[Index] = Pool(_StartTime, _FinishTime, _StartAmount, 0, _Owner, _Token);
MyPoolz[_Owner].push(Index);
emit NewPoolCreated(
Index,
_Token,
_StartTime,
_FinishTime,
_StartAmount,
_Owner
);
uint256 poolId = Index;
Index++;
return poolId;
}
}