WPL Token

The WPLLockUp smart contract created to freeze tokens for a certain period of time. The duration of each freeze period is indicated in the PERIOD_TIME contract variable. And the payout percentage in each period of time is indicated in the PERIOD_PERCENT variable of the smart contract. According to the technical specification, 1/24 of the blocked tokens amount on user's account is unfrozen every 30 days.

The total number of investors whose tokens are locked in the smart contract is indicated in the countHolders variable. The total number of currently locked WPL ERC20 tokens is indicated in the lockupFounds variable. You'll get the total number of withdrawn unfrozen tokens from the smart contract by calling the withdrawFounds variable.

mapping(address => LockUpRecord) public lockup_record;    
//the period between token payments is 30 days
uint constant PERIOD_TIME = 30 days;
//the percentage that is paid during the period
uint constant PERIOD_PERCENT = 24;
//number of investors     
uint public countHolders = 0;
//number of lock tokens    
uint public lockupFounds = 0;
//number of tokens withdrawn    
uint public withdrawFounds = 0;   

You'll receive the balance of available for withdrawal tokens at that time by calling the getWithdrawalBalance option and entering the investor's address to it. The smart contract will automatically calculate the required amount.

function getWithdrawalBalance(address _target) public view returns(uint) {
        LockUpRecord storage lockupToken = lockup_record[_target];
        
        if (lockupToken.complete == true) {
            return 0;
        }

        uint timeLeft = block.timestamp - lockupToken.startTime;
        uint periodLeft = timeLeft / PERIOD_TIME;
        uint periodAmt = lockupToken.amount / PERIOD_PERCENT;
        uint availableWithdraw = (periodLeft * periodAmt) - lockupToken.withdrawSumm;
        uint totalWithdrawal = lockupToken.withdrawSumm + availableWithdraw;

        if (totalWithdrawal > lockupToken.amount) {
            return lockupToken.amount - lockupToken.withdrawSumm;
        }

        return (availableWithdraw);
    }

You'll automatically start the withdrawal of all the entire available balance of the WPL ERC20 token by calling the unlock option. You should launch this option only from the real investor's wallet to the which address the tokens were frozen.

function unlock() public {
        LockUpRecord storage lock = lockup_record[_msgSender()];
        require(msg.sender == lock.owner);
        require(lock.complete == false);
        //get balance available for withdrawal
        uint withdrawalBalance = getWithdrawalBalance(_msgSender());

        require(withdrawalBalance > 0, 'The balance available for withdrawal is 0');

        lock.withdrawSumm += withdrawalBalance;
        lock.lastPaymentTime = block.timestamp;

        if (lock.withdrawSumm <= lock.amount) {
            token.transfer(_msgSender(), withdrawalBalance);
            emit UnlockFounds(lock.owner, withdrawalBalance);
        }

        lockupFounds -= withdrawalBalance;
        withdrawFounds += withdrawalBalance;

        if (lock.withdrawSumm == lock.amount) {
            lock.complete = true;
            emit LockupComplete(_msgSender(), lock.amount);
        }
    }

Last updated