Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from The-Poolz/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
PoolzAdmin authored Dec 30, 2020
2 parents 386ea3b + 1694085 commit e895a73
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 58 deletions.
2 changes: 1 addition & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

ganache-cli --gasLimit 6721975 2> /dev/null 1> /dev/null &
ganache-cli --gasLimit 7721975 2> /dev/null 1> /dev/null &
sleep 5 # to make sure ganache-cli is up and running before compiling
rm -rf build
truffle compile
Expand Down
1 change: 1 addition & 0 deletions contracts/Invest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ contract Invest is PoolsData {
{
require(_PoolId < poolsCount, "Wrong pool id, InvestETH fail");
require(pools[_PoolId].Maincoin == address(0x0), "Pool is not for ETH");
require(msg.value >= MinETHInvest && msg.value <= MaxETHInvest, "Investment amount not valid");
uint256 ThisInvestor = NewInvestor(msg.sender, msg.value, _PoolId);
uint256 Tokens = CalcTokens(_PoolId, msg.value, msg.sender);
if (pools[_PoolId].IsLocked) {
Expand Down
19 changes: 14 additions & 5 deletions contracts/Manageable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ contract Manageable is ETHHelper {
Fee = 20; // *10000
MinDuration = 0; //need to set
PoolPrice = 0; // Price for create a pool
MaxDuration = 60*60*24*30*6; // half year
MaxDuration = 60 * 60 * 24 * 30 * 6; // half year
MinETHInvest = 10000; // for percent calc
MaxETHInvest = 100 * 10**18; // 100 eth per wallet
}

mapping(address => uint256) FeeMap;
Expand All @@ -18,6 +20,16 @@ contract Manageable is ETHHelper {
uint256 internal MinDuration; //the minimum duration of a pool, in seconds
uint256 internal MaxDuration; //the maximum duration of a pool from the creation, in seconds
uint256 internal PoolPrice;
uint256 internal MinETHInvest;
uint256 internal MaxETHInvest;

function SetMinETHInvest(uint256 _MinETHInvest) public onlyOwner {
MinETHInvest = _MinETHInvest;
}

function SetMaxETHInvest(uint256 _MaxETHInvest) public onlyOwner {
MaxETHInvest = _MaxETHInvest;
}

function GetMinDuration() public view returns (uint256) {
return MinDuration;
Expand All @@ -39,10 +51,7 @@ contract Manageable is ETHHelper {
return PoolPrice;
}

function SetPoolPrice(uint256 _PoolPrice)
public
onlyOwner
{
function SetPoolPrice(uint256 _PoolPrice) public onlyOwner {
PoolPrice = _PoolPrice;
}

Expand Down
63 changes: 42 additions & 21 deletions contracts/ThePoolz.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,70 @@ contract ThePoolz is InvestorData {
uint256 internal StartInvestor;
uint256 internal StartProjectOwner;


function SetStartForWork(uint256 _StartInvestor, uint256 _StartProjectOwner)
public
onlyOwner
{
StartInvestor = _StartInvestor;
StartProjectOwner = _StartProjectOwner;
}

function GetMinWorkInvestor() public view returns (uint256) {
return MinWorkInvestor;
}

function SetMinWorkInvestor(uint256 _MinWorkInvestor) public onlyOwner {
MinWorkInvestor = _MinWorkInvestor;
}

function GetMinWorkProjectOwner() public view returns (uint256) {
return MinWorkProjectOwner;
}

function SetMinWorkProjectOwner(uint256 _MinWorkProjectOwner) public onlyOwner {
function SetMinWorkProjectOwner(uint256 _MinWorkProjectOwner)
public
onlyOwner
{
MinWorkProjectOwner = _MinWorkProjectOwner;
}

//will revert if less then parameters
function SafeWork() external returns (uint256, uint256) {
require(CanWork(),"Need more then minimal work count");
require(CanWork(), "Need more then minimal work count");
return DoWork();
}

function CanWork() public view returns(bool) {
function CanWork() public view returns (bool) {
uint256 inv;
uint256 pro;
(inv,pro) = CountWork();
(inv, pro) = CountWork();
return (inv > MinWorkInvestor || pro > MinWorkProjectOwner);
}

function DoWork() public returns (uint256, uint256) {
uint256 pro = WorkForProjectOwner();
uint256 inv = WorkForInvestors();
return (inv,pro);
uint256 inv = WorkForInvestors();
return (inv, pro);
}

function CountWork() public view returns(uint256, uint256)
{
function CountWork() public view returns (uint256, uint256) {
uint256 temp_investor_count = 0;
uint256 temp_projectowner_count = 0;
for (uint256 Investorindex = StartInvestor; Investorindex < TotalInvestors; Investorindex++) {
if(IsReadyWithdrawInvestment(Investorindex)) temp_investor_count++;
for (
uint256 Investorindex = StartInvestor;
Investorindex < TotalInvestors;
Investorindex++
) {
if (IsReadyWithdrawInvestment(Investorindex)) temp_investor_count++;
}
for (
uint256 POindex = StartProjectOwner;
POindex < poolsCount;
POindex++
) {
if (IsReadyWithdrawLeftOvers(POindex)) temp_projectowner_count++;
}
for (uint256 POindex = StartProjectOwner; POindex < poolsCount; POindex++) {
if (IsReadyWithdrawLeftOvers(POindex) ) temp_projectowner_count++;
}
return (temp_investor_count,temp_projectowner_count);
return (temp_investor_count, temp_projectowner_count);
}

function WorkForInvestors() internal returns (uint256) {
Expand All @@ -73,14 +91,14 @@ contract ThePoolz is InvestorData {
if (WithdrawInvestment(index)) WorkDone++;
}
SetInvestorStart();
emit InvestorsWork(StartInvestor,WorkDone);
emit InvestorsWork(StartInvestor, WorkDone);
return WorkDone;
}

function SetInvestorStart() internal {
for (uint256 index = StartInvestor; index < TotalInvestors; index++) {
if (GetPoolStatus(Investors[index].Poolid) == PoolStatus.Close)
StartInvestor = index;
StartInvestor = index;
else return;
}
}
Expand All @@ -90,13 +108,16 @@ contract ThePoolz is InvestorData {
bool FixStart = true;
for (uint256 index = StartProjectOwner; index < poolsCount; index++) {
if (WithdrawLeftOvers(index)) WorkDone++;
if (FixStart && (pools[index].TookLeftOvers || pools[index].Lefttokens == 0)) {
if (
FixStart &&
(pools[index].TookLeftOvers || pools[index].Lefttokens == 0)
) {
StartProjectOwner = index;
} else {
FixStart = false;
FixStart = false;
}
}
emit ProjectOwnerWork(StartProjectOwner,WorkDone);
emit ProjectOwnerWork(StartProjectOwner, WorkDone);
return WorkDone;
}
}
58 changes: 29 additions & 29 deletions contracts/TokenList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";

contract TokenList is Pausable {

bool public IsTokenFilterOn;
uint256 public NumberOfTokens;
mapping (address=>bool) private _IsAllowed;
mapping (uint256 => address) private _Tokens;

constructor () public {
NumberOfTokens=0;
IsTokenFilterOn = false; //true on prod
}
function SwapTokenFilter() public onlyOwner {
IsTokenFilterOn=!IsTokenFilterOn;
}

function AddToken(address _address) public onlyOwner {
require(!_IsAllowed[_address], "This Token in List");
_IsAllowed[_address] = true;
_Tokens[NumberOfTokens] = _address;
NumberOfTokens++;
bool public IsTokenFilterOn;
uint256 public NumberOfTokens;
mapping(address => bool) private _IsAllowed;
mapping(uint256 => address) private _Tokens;

constructor() public {
NumberOfTokens = 0;
IsTokenFilterOn = false; //true on prod
}

function SwapTokenFilter() public onlyOwner {
IsTokenFilterOn = !IsTokenFilterOn;
}

function AddToken(address _address) public onlyOwner {
require(!_IsAllowed[_address], "This Token in List");
_IsAllowed[_address] = true;
_Tokens[NumberOfTokens] = _address;
NumberOfTokens++;
}

function RemoveToken(address _address) public onlyOwner {
require(_IsAllowed[_address], "This Token not in List");
_IsAllowed[_address] = false;
}

function IsValidToken(address _address) public view returns (bool) {
return !IsTokenFilterOn || _IsAllowed[_address];
}
}
function RemoveToken(address _address) public onlyOwner {
require(_IsAllowed[_address], "This Token not in List");
_IsAllowed[_address] = false;
}

function IsValidToken(address _address) public view returns(bool) {
return !IsTokenFilterOn || _IsAllowed[_address];
}

}
2 changes: 1 addition & 1 deletion coverage.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*" // Match any network id
network_id: "*", // Match any network id
gas: 7721974
},
rinkeby: {
host: "localhost", // Connect to geth on the specified
Expand Down

0 comments on commit e895a73

Please sign in to comment.