Coinsult

Request your audit at coinsult.net

Advanced Manual
Smart Contract Audit

July 25, 2022

Audit requested by

PowerLabs

0x2a5f446f8b6A819BC3f1715156a4ddaC3b7eaf50

PowerLabs / Security Audit

Table of Contents

1. Audit Summary

1.1 Audit scope

1.2 Tokenomics

1.3 Source Code

2. Disclaimer

3. Global Overview

3.1 Informational issues

3.2 Low-risk issues

3.3 Medium-risk issues

3.4 High-risk issues

4. Vulnerabilities Findings

5. Contract Privileges

5.1 Maximum Fee Limit Check

5.2 Contract Pausability Check

5.3 Max Transaction Amount Check

5.4 Exclude From Fees Check

5.5 Ability to Mint Check

5.6 Ability to Blacklist Check

5.7 Owner Privileges Check

6. Notes

6.1 Notes by Coinsult

6.2 Notes by PowerLabs

7. Contract Snapshot

8. Website Review

9. Certificate of Proof

PowerLabs / Security Audit

Audit Summary

Audit Scope

Project Name

PowerLabs

Blockchain

Binance Smart Chain

Smart Contract Language

Solidity

Contract Address

0x2a5f446f8b6A819BC3f1715156a4ddaC3b7eaf50

Audit Method

Static Analysis, Manual Review

Date of Audit

25 July 2022

This audit report has been prepared by Coinsult’s experts at the request of the client. In this audit, the results of the static analysis and the manual code review will be presented. The purpose of the audit is to see if the functions work as intended, and to identify potential security issues within the smart contract.

The information in this report should be used to understand the risks associated with the smart contract. This report can be used as a guide for the development team on how the contract could possibly be improved by remediating the issues that were identified.

PowerLabs / Security Audit

Tokenomics

Rank Address Quantity (Token) Percentage
1 Powerlabs: Deployer 1,000,000,000 100.0000%

Source Code

Coinsult was comissioned by PowerLabs to perform an audit based on the following code:
https://bscscan.com/address/0x2a5f446f8b6a819bc3f1715156a4ddac3b7eaf50#code

PowerLabs / Security Audit

Disclaimer

This audit report has been prepared by Coinsult’s experts at the request of the client. In this audit, the results of the static analysis and the manual code review will be presented. The purpose of the audit is to see if the functions work as intended, and to identify potential security issues within the smart contract.

The information in this report should be used to understand the risks associated with the smart contract. This report can be used as a guide for the development team on how the contract could possibly be improved by remediating the issues that were identified.

Coinsult is not responsible if a project turns out to be a scam, rug-pull or honeypot. We only provide a detailed analysis for your own research.

Coinsult is not responsible for any financial losses. Nothing in this contract audit is financial advice, please do your own research.

The information provided in this audit is for informational purposes only and should not be considered investment advice. Coinsult does not endorse, recommend, support or suggest to invest in any project. 

Coinsult can not be held responsible for when a project turns out to be a rug-pull, honeypot or scam.

PowerLabs / Security Audit

Global Overview

Manual Code Review

In this audit report we will highlight the following issues:

Vulnerability Level

Total

Pending

Acknowledged

Resolved

0

0

0

0

7

0

0

0

0

0

0

0

0

0

0

0

Privilege Overview

Coinsult checked the following privileges:

Contract Privilege

Description

Owner can mint?

Owner can blacklist?

Owner can set fees > 25%?

Owner can exclude from fees?

Owner can pause trading?

Owner can set Max TX amount?

More owner priviliges are listed later in the report.

PowerLabs / Security Audit

Contract contains Reentrancy vulnerabilities

Additional information: This combination increases risk of malicious intent. While it may be justified by some complex mechanics (e.g. rebase, reflections, buyback). 

More information: Slither

				
					function _transfer(
		address from,
		address to,
		uint256 amount
		) internal override {
			require(from != address(0), "ERC20: transfer from the zero address");
			require(to != address(0), "ERC20: transfer to the zero address");

			if(amount == 0) {
				super._transfer(from, to, 0);
				return;
			}

			bool isBuyFromLp = automatedMarketMakerPairs[from];
			bool isSelltoLp = automatedMarketMakerPairs[to];
			bool _isInLaunch = this.isInLaunch();

			uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp  ? _tradingPausedTimestamp : _getNow();

			if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) {
				require(isTradingEnabled, "Powerlabs: Trading is currently disabled.");
				require(!_isBlocked[to], "Powerlabs: Account is blocked");
				require(!_isBlocked[from], "Powerlabs: Account is blocked");
				if (_isInLaunch && currentTimestamp.sub(_launchStartTimestamp)  60, "Powerlabs: Cannot buy more than once per min in first 5min of launch");
				}
				if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) {
					require(amount <= maxTxAmount, "Powerlabs: Buy amount exceeds the maxTxBuyAmount.");
				}
				if (!_isExcludedFromMaxWalletLimit[to]) {
					require(balanceOf(to).add(amount) = minimumTokensBeforeSwap;

			if (
				isTradingEnabled &&
				canSwap &&
				!_swapping &&
				_totalFee > 0 &&
				automatedMarketMakerPairs[to] &&
				from != liquidityWallet && to != liquidityWallet &&
				from != marketingWallet && to != marketingWallet &&
				from != devWallet && to != devWallet && 
				from != buyBackWallet && to != buyBackWallet && 
				from != stakingAddress && to != stakingAddress
			) {
				_swapping = true;
				_swapAndLiquify();
				_swapping = false;
			}

			bool takeFee = !_swapping && isTradingEnabled;

			if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
				takeFee = false;
			}
			if (takeFee) {
				uint256 fee = amount.mul(_totalFee).div(100);
				amount = amount.sub(fee);
				super._transfer(from, address(this), fee);
			}

			if (_isInLaunch && currentTimestamp.sub(_launchStartTimestamp)  60) {
					_buyTimesInLaunch[to] = currentTimestamp;
				}
			}

			super._transfer(from, to, amount);

			_mintOnBlockEmission();

			try dividendTracker.setBalance(payable(from), balanceOf(from)) {} catch {}
			try dividendTracker.setBalance(payable(to), balanceOf(to)) {} catch {}

			if(!_swapping) {
				uint256 gas = gasForProcessing;
				try dividendTracker.process(gas) returns (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) {
					emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, true, gas, tx.origin);
				}
				catch {}
			}
	}
				
			

Recommendation

Apply the check-effects-interactions pattern.

Exploit scenario

				
					    function withdrawBalance(){
        // send userBalance[msg.sender] Ether to msg.sender
        // if mgs.sender is a contract, it will call its fallback function
        if( ! (msg.sender.call.value(userBalance[msg.sender])() ) ){
            throw;
        }
        userBalance[msg.sender] = 0;
    }
				
			
Bob uses the re-entrancy bug to call withdrawBalance two times, and withdraw more than its initial deposit to the contract.

PowerLabs / Security Audit

Avoid relying on block.timestamp

block.timestamp can be manipulated by miners.

				
					function blockAccount(address account) public onlyOwner {
		uint256 currentTimestamp = _getNow();
		require(!_isBlocked[account], "Powerlabs: Account is already blocked");
		if (_isLaunched) {
			require(currentTimestamp.sub(_launchStartTimestamp) < _blockedTimeLimit, "Powerlabs: Time to block accounts has expired");
		}
		_isBlocked[account] = true;
		emit BlockedAccountChange(account, true);
	}
				
			

Recommendation

Do not use block.timestampnow or blockhash as a source of randomness

Exploit scenario

				
					contract Game {

    uint reward_determining_number;

    function guessing() external{
      reward_determining_number = uint256(block.blockhash(10000)) % 10;
    }
}
				
			

Eve is a miner. Eve calls guessing and re-orders the block containing the transaction. As a result, Eve wins the game.

PowerLabs / Security Audit

Too many digits

Literals with many digits are difficult to read and review.

				
					constructor() DividendPayingToken("Powerlabs_Dividend_Tracker", "Powerlabs_Dividend_Tracker") {
		claimWait = 3600;
		minimumTokenBalanceForDividends = 200000000 * (10**18);
	}
				
			

Recommendation

Exploit scenario

				
					contract MyContract{
    uint 1_ether = 10000000000000000000; 
}
				
			

While 1_ether looks like 1 ether, it is 10 ether. As a result, it’s likely to be used incorrectly.

PowerLabs / Security Audit

No zero address validation for some functions

Detect missing zero address validation.

				
					function activateMintOnBlockEmission(address _mintAddress, uint256 _mintAmount) public onlyOwner {
	    require(!mintOnBlockEmission, "Powerlabs: Mint is already set activate");
	    mintAddress = _mintAddress;
		mintAmount = _mintAmount;
		_blockTracker = block.number;
	    mintOnBlockEmission = true;
	}
				
			

Recommendation

Check that the new address is not zero.

Exploit scenario

				
					contract C {

  modifier onlyAdmin {
    if (msg.sender != owner) throw;
    _;
  }

  function updateOwner(address newOwner) onlyAdmin external {
    owner = newOwner;
  }
}
				
			

Bob calls updateOwner without specifying the newOwner, soBob loses ownership of the contract.

PowerLabs / Security Audit

Functions that send Ether to arbitrary destinations

Unprotected call to a function sending Ether to an arbitrary address.

				
					function _swapAndLiquify() private {
		uint256 contractBalance = balanceOf(address(this));
		uint256 initialBNBBalance = address(this).balance;

		uint256 amountToLiquify = contractBalance.mul(_liquidityFee).div(_totalFee).div(2);
		uint256 amountForStaking = contractBalance.mul(_stakingFee).div(_totalFee);
		uint256 amountToSwap = contractBalance.sub((amountToLiquify.add(amountForStaking)));

		_swapTokensForBNB(amountToSwap);

		uint256 bnbBalanceAfterSwap = address(this).balance.sub(initialBNBBalance);
		uint256 totalBNBFee = _totalFee.sub(_liquidityFee.div(2));
		uint256 amountBNBLiquidity = bnbBalanceAfterSwap.mul(_liquidityFee).div(totalBNBFee).div(2);
		uint256 amountBNBMarketing = bnbBalanceAfterSwap.mul(_marketingFee).div(totalBNBFee);
		uint256 amountBNBBuyBack = bnbBalanceAfterSwap.mul(_buyBackFee).div(totalBNBFee);
		uint256 amountBNBDev = bnbBalanceAfterSwap.mul(_devFee).div(totalBNBFee);
		uint256 amountBNBHolders = bnbBalanceAfterSwap.sub((amountBNBLiquidity.add(amountBNBMarketing).add(amountBNBBuyBack).add(amountBNBDev)));

		payable(marketingWallet).transfer(amountBNBMarketing);
		payable(buyBackWallet).transfer(amountBNBBuyBack);
		payable(devWallet).transfer(amountBNBDev);
		
		if (amountToLiquify > 0) {
			_addLiquidity(amountToLiquify, amountBNBLiquidity);
			emit SwapAndLiquify(amountToSwap, amountBNBLiquidity, amountToLiquify);
		}

		(bool stakingSuccess) = IERC20(address(this)).transfer(address(stakingAddress), amountForStaking);
		if(stakingSuccess) {
			emit StakingTokensSent(amountForStaking);
		}
	
		(bool dividendSuccess,) = address(dividendTracker).call{value: amountBNBHolders}("");
		if(dividendSuccess) {
			emit DividendsSent(amountBNBHolders);
		}
	}
				
			

Recommendation

Ensure that an arbitrary user cannot withdraw unauthorized funds.

Exploit scenario

				
					contract ArbitrarySend{
    address destination;
    function setDestination(){
        destination = msg.sender;
    }

    function withdraw() public{
        destination.transfer(this.balance);
    }
}
				
			

Bob calls setDestination and withdraw. As a result he withdraws the contract’s balance.

PowerLabs / Security Audit

Missing events arithmetic

Detect missing events for critical arithmetic parameters.

				
					function activateMintOnBlockEmission(address _mintAddress, uint256 _mintAmount) public onlyOwner {
	    require(!mintOnBlockEmission, "Powerlabs: Mint is already set activate");
	    mintAddress = _mintAddress;
		mintAmount = _mintAmount;
		_blockTracker = block.number;
	    mintOnBlockEmission = true;
	}
				
			

Recommendation

Emit an event for critical parameter changes.

Exploit scenario

				
					contract C {

  modifier onlyAdmin {
    if (msg.sender != owner) throw;
    _;
  }

  function updateOwner(address newOwner) onlyAdmin external {
    owner = newOwner;
  }
}
				
			

updateOwner() has no event, so it is difficult to track off-chain changes in the buy price.

PowerLabs / Security Audit

Redundant Statements

Detect the usage of redundant statements that have no effect.

				
					function _msgData() internal view virtual returns (bytes calldata) {
		this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
		return msg.data;
	}
				
			

Recommendation

Remove redundant statements if they congest code but offer no value.

Exploit scenario

				
					contract RedundantStatementsContract {

    constructor() public {
        uint; // Elementary Type Name
        bool; // Elementary Type Name
        RedundantStatementsContract; // Identifier
    }

    function test() public returns (uint) {
        uint; // Elementary Type Name
        assert; // Identifier
        test; // Identifier
        return 777;
    }
}
				
			

Each commented line references types/identifiers, but performs no action with them, so no code will be generated for such statements and they can be removed.

PowerLabs / Security Audit

Contract Privileges

Maximum Fee Limit Check

Coinsult tests if the owner of the smart contract can set the transfer, buy or sell fee to 25% or more. It is bad practice to set the fees to 25% or more, because owners can prevent healthy trading or even stop trading when the fees are set too high. 

Type of fee

Description

Transfer fee

Buy fee

Sell fee

Type of fee

Description

Max transfer fee

Max buy fee

Max sell fee

PowerLabs / Security Audit

Contract Pausability Check

Coinsult tests if the owner of the smart contract has the ability to pause the contract. If this is the case, users can no longer interact with the smart contract; users can no longer trade the token.

Privilege Check

Description

Can owner pause the contract?

PowerLabs / Security Audit

Max Transaction Amount Check

Coinsult tests if the owner of the smart contract can set the maximum amount of a transaction. If the transaction exceeds this limit, the transaction will revert. Owners could prevent normal transactions to take place if they abuse this function.

Privilege Check

Description

Can owner set max tx amount?

PowerLabs / Security Audit

Exclude From Fees Check

Coinsult tests if the owner of the smart contract can exclude addresses from paying tax fees. If the owner of the smart contract can exclude from fees, they could set high tax fees and exclude themselves from fees and benefit from 0% trading fees. However, some smart contracts require this function to exclude routers, dex, cex or other contracts / wallets from fees.

Privilege Check

Description

Can owner exclude from fees?

PowerLabs / Security Audit

Ability To Mint Check

Coinsult tests if the owner of the smart contract can mint new tokens. If the contract contains a mint function, we refer to the token’s total supply as non-fixed, allowing the token owner to “mint” more tokens whenever they want.

A mint function in the smart contract allows minting tokens at a later stage. A method to disable minting can also be added to stop the minting process irreversibly.

Minting tokens is done by sending a transaction that creates new tokens inside of the token smart contract. With the help of the smart contract function, an unlimited number of tokens can be created without spending additional energy or money.

Privilege Check

Description

Can owner mint?

PowerLabs / Security Audit

Ability To Blacklist Check

Coinsult tests if the owner of the smart contract can blacklist accounts from interacting with the smart contract. Blacklisting methods allow the contract owner to enter wallet addresses which are not allowed to interact with the smart contract. 

This method can be abused by token owners to prevent certain / all holders from trading the token. However, blacklists might be good for tokens that want to rule out certain addresses from interacting with a smart contract.

Privilege Check

Description

Can owner blacklist?

PowerLabs / Security Audit

Other Owner Privileges Check

Coinsult lists all important contract methods which the owner can interact with.

⚠ Owner can activate trading for certain addresses even if trading is disabled

⚠ Owner can cancel launch

⚠ Owner can exclude addresses from dividend

⚠ Owner can exclude addresses from max transaction limit

⚠ Owner can exclude addresses from max wallet limit

⚠ Owner is able to deactivate and activate mint on block emmision

PowerLabs / Security Audit

Notes

Notes by PowerLabs

“Powerlabs has a mint function in case we move to our dex with the same token where we would need to mint tokens as rewards and burn them to keep them deflationary.

At this moment we do not mint any tokens, all are preminted before presale. And we have plans to change that. It is entirely possible to use a 2 token structure for our dex with a new reward token for LP farmers.”

“Owner can cancel launch is a fail safe for if the launch didnt go right
Owner can exclude from dividends when the treasury become big enough you can exclude it from fees
Owner can exclude from max transaction is for the staking and farming contracts to hold the token amount that they do since it is a large percent of supply
same answer for max wallet limit
Minting function is for the dex purpose later on down in the road map but we plan on not using it unless needed
when we do pary time hours taxes go up on sell because buy in taxes are lowed to prevent mass dumping
pause trading is a function all contract should have incase of migration the ability to disable trading prevent people from buying old contract and getting rekt
activate trading for specific addresses is for adding the liquidity to the contract before launch and allowing token to be sent to presalers prior to launch”

Notes by Coinsult

✅ No notes provided by Coinsult

PowerLabs / Security Audit

Contract Snapshot

This is how the constructor of the contract looked at the time of auditing the smart contract.

				
					contract Powerlabs is Ownable, ERC20 {
	using SafeMath for uint256;

	IUniswapV2Router02 public uniswapV2Router;
	address public immutable uniswapV2Pair;

	string private constant _name = "Powerlabs";
	string private constant _symbol = "PWL";
	uint8 private constant _decimals = 9;

	PowerlabsDividendTracker public dividendTracker;
	
	bool public isTradingEnabled;
	uint256 private _tradingPausedTimestamp;

	// initialSupply
	uint256 constant initialSupply = 1000000000 * (10**9);
				
			

PowerLabs / Security Audit

Website Review

Coinsult checks the website completely manually and looks for visual, technical and textual errors. We also look at the security, speed and accessibility of the website. In short, a complete check to see if the website meets the current standard of the web development industry. 

Type of check

Description

Mobile friendly?

Contains jQuery errors?

Is SSL secured?

Contains spelling errors?

PowerLabs / Security Audit

Certificate of Proof

PowerLabs

Audited by Coinsult.net

Date: 25 July 2022

Coinsult

coinsult.net

End of report
Smart Contract Audit

Request your smart contract audit / KYC

t.me/coinsult_tg