Git Product home page Git Product logo

locked-pools's Introduction

Locked Deal V2

Build Status codecov CodeFactor

Smart contract for secure storage of ERC20 tokens.

Navigation

Installation

npm install

Testing

truffle run coverage

Deploy

truffle dashboard
truffle migrate --f 1 --to 1 --network dashboard

Admin settings

Whitelist address

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

Non-paid token

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

Security token filter

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

User without fee

Setting a whitelist ID for users who are exempt from paying fees.

    function setUserWhiteListId(uint256 _id) external;

Testnet tx: link

Max transaction limit

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

Enable/Disable token filter

    // by default the token filter is disabled
    function swapTokenFilter() external;

Testnet tx: link

Pool owner settings

Transfer of ownership of locked tokens

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

Splitting a pool amount

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

Approving an allowance

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

User settings

Creating a new pool

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

Creating an array of pools

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

Creating an array of pools with respect to finish time

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

Getting my pools' ids by a token

Find pool IDs by specifying token addresses.

    function GetMyPoolsIdByToken(address[] memory _tokens)
        public
        view
        returns (uint256[] memory);

Getting a pools' data

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)

Is Token without fee

If _tokenAddress returns true, we don't need to pay to create the pool.

    function isTokenWithoutFee(address _tokenAddress) public view returns(bool);

Check token validation

If false is returned, the token cannot be used in a locked pool.

    function isTokenWhiteListed(address _tokenAddress) public view returns(bool);

Does the user have to pay a commission?

Returns true if _UserAddress have allocation in WhiteList.

    function isUserWithoutFee(address _UserAddress) public view returns(bool);

Gettting a pool data

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

Getting all my pools' ids

The function returns an array of all your pools IDs.

    function GetAllMyPoolsId() public view returns (uint256[] memory);

Getting my pools ids

Returns only your pools with a balance.

    function GetMyPoolsId() public view returns (uint256[] memory);

Withdrawing a token

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

Getting a withdrawable amount

See how many tokens can be unlocked in a pool.

    function getWithdrawableAmount(uint256 _PoolId) public view returns(uint256)

Splitting a pool amount from already an existing pool's allowance for a user.

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

Getting allowance

There is a way how to get a pool allowance.

    function Allowance(uint256 _PoolId, address _Address) public view returns(uint256);

License

The-Poolz Contracts is released under the MIT License.

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.