Git Product home page Git Product logo

locked-pools's People

Contributors

ashwinarora avatar dmytropodelnik avatar lomet avatar poolzadmin avatar youstillalive avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

locked-pools's Issues

refactor

maybe: we can make a new pool for the new user, and make the amount 0
or we need to make sure the allowance is reset.

function TransferPoolOwnership(
uint256 _PoolId,
address _NewOwner
) external isPoolValid(_PoolId) isPoolOwner(_PoolId) notZeroAddress(_NewOwner) {
Pool storage pool = AllPoolz[_PoolId];
pool.Owner = _NewOwner;
uint256[] storage array = MyPoolz[msg.sender];
for(uint i=0 ; i<array.length ; i++){
if(array[i] == _PoolId){
array[i] = array[array.length - 1];
array.pop();
}
}
MyPoolz[_NewOwner].push(_PoolId);
emit PoolOwnershipTransfered(_PoolId, _NewOwner, msg.sender);
}

split creation

Lets slit the Creating to other file

function CreateNewPool(
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
) external payable notZeroAddress(_Owner) returns(uint256) {
TransferInToken(_Token, msg.sender, _StartAmount);
if(WhiteList_Address != address(0) && !(isUserWithoutFee(msg.sender) || isTokenWithoutFee(_Token))){
PayFee(Fee);
}
CreatePool(_Token, _StartTime, _FinishTime, _StartAmount, _Owner);
}
function CreateMassPools(
address _Token,
uint256[] calldata _StartTime,
uint256[] calldata _FinishTime,
uint256[] calldata _StartAmount,
address[] calldata _Owner
) external payable
isGreaterThanZero(_Owner.length)
isBelowLimit(_Owner.length)
{
require(_Owner.length == _FinishTime.length, "Date Array Invalid");
require(_StartTime.length == _FinishTime.length, "Date Array Invalid");
require(_Owner.length == _StartAmount.length, "Amount Array Invalid");
TransferInToken(_Token, msg.sender, Array.getArraySum(_StartAmount));
if(WhiteList_Address != address(0) && !(isUserWithoutFee(msg.sender) || isTokenWithoutFee(_Token))){
PayFee(Fee * _Owner.length);
}
uint256 firstPoolId = Index;
for(uint i=0 ; i < _Owner.length; i++){
CreatePool(_Token, _StartTime[i], _FinishTime[i], _StartAmount[i], _Owner[i]);
}
uint256 lastPoolId = Index - 1;
emit MassPoolsCreated(firstPoolId, lastPoolId);
}
// create pools with respect to finish time
function CreatePoolsWrtTime(
address _Token,
uint256[] calldata _StartTime,
uint256[] calldata _FinishTime,
uint256[] calldata _StartAmount,
address[] calldata _Owner
) external payable
isGreaterThanZero(_StartTime.length)
isBelowLimit(_Owner.length * _FinishTime.length)
{
require(_Owner.length == _StartAmount.length, "Amount Array Invalid");
require(_FinishTime.length == _StartTime.length, "Date Array Invalid");
TransferInToken(_Token, msg.sender, Array.getArraySum(_StartAmount) * _FinishTime.length);
uint256 firstPoolId = Index;
if(WhiteList_Address != address(0) && !(isUserWithoutFee(msg.sender) || isTokenWithoutFee(_Token))){
PayFee(Fee * _Owner.length * _FinishTime.length);
}
for(uint i=0 ; i < _FinishTime.length ; i++){
for(uint j=0 ; j < _Owner.length ; j++){
CreatePool(_Token, _StartTime[i], _FinishTime[i], _StartAmount[j], _Owner[j]);
}
}
uint256 lastPoolId = Index - 1;
emit MassPoolsCreated(firstPoolId, lastPoolId);
}
}

file names

let's find better file names (and the locations of the functions.)

Add readme

Please list all the commands and how to use them by category (admin, pool owner, user).

update event model

we need the owner to be part of the topic:
image
like in the transfer / allow
image

Update Readme

  • add description to all functions
  • change TransferPoolOwnership to PoolTransfer description, testnet event

withdraw every second.

This is a Version update for a locked deal, in this version we will perform:

  1. 0% unlock before the first-timer
  2. 100% after the second-timer
  3. 50% in the middle, and so on... calculate by the second

public variables

update visibility of variables.

mapping(uint256 => Pool) AllPoolz;
mapping(address => uint256[]) MyPoolz;
uint256 internal Index;

After that, we could potentially remove the GetPoolData(uint256 _id) and GetAllMyPoolsId functions, because the state of the visible variable automatically creates getter methods.

create filter whitelist

Potential problem:
Using the CreateNewPool function could potentially lead to a hack. When we pass a fake token that overwrites the transfer logic or other functions.

Solution:
If Token is bad for our contract we can create a whitelist of tokens that can be only used to create a pool. This feature is disabled by default.

Add new get my pools ids

add a new view function that can get an input list of addresses, that will return only pools id that the token address is matching.

this will help the front to faster fetch all id's for a specific token

remove GetPoolAllowance function

We already have a public Allowance variable that returns the allocation amount.
Allowance function signature: Allowance(uint256 _PoolId, address _Address) public view returns(uint256)

add `GetMyPoolDataByToken)`

GetMyPoolDataByToken will looks like:

GetMyPoolDataByToken(address[] memory _tokens) 
{
 return GetPoolsData(GetMyPoolsIdByToken(_tokens));
}

Payment

  • add payment system - price per lock and.
  • free price list (using whitelist contract)- this address, don't pay.

add new view function

It will take an array of Id's and return all the data

function GetPoolData(uint256 _id)
public
view
isPoolValid(_id)
returns (
uint256,
uint256,
uint256,
uint256,
address,
address
)
{
Pool storage pool = AllPoolz[_id];
require(
pool.Owner == msg.sender || pool.Allowance[msg.sender] > 0,
"Private Information"
);
return (
pool.StartTime,
pool.FinishTime,
pool.StartAmount,
pool.DebitedAmount,
pool.Owner,
pool.Token
);
}

extract to helper

this function can be used as libery

function KeepNElementsInArray(uint256[] memory _arr, uint256 _n)
internal
pure
returns (uint256[] memory)
{
require(_arr.length >= _n,"can't cut more then got");
uint256[] memory activeIds = new uint256[](_n);
for (uint256 i = 0; i < _n; i++) {
activeIds[i] = _arr[i];
}
return activeIds;
}

split logic

in current version, splitting after withdraw can lose tokens

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;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.