Coinsult

Request your audit at coinsult.net

Advanced Manual
Smart Contract Audit

May 9, 2022

Audit requested by

F8 Dao

0x54fdd659ef83708c6dfd460fb309113db688a9df

F8 Dao / 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 F8 Dao

7. Contract Snapshot

8. Website Review

9. Certificate of Proof

F8 Dao / Security Audit

Audit Summary

Audit Scope

Project Name

F8 Dao

Blockchain

Binance Smart Chain

Smart Contract Language

Solidity

Contract Address

0x54fdd659ef83708c6dfd460fb309113db688a9df

Audit Method

Static Analysis, Manual Review

Date of Audit

9 May 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.

F8 Dao / Security Audit

Tokenomics

Source Code

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

F8 Dao / 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.

F8 Dao / 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

6

0

0

0

3

0

0

0

0

0

0

0

F8 Dao / Security Audit

Avoid relying on block.timestamp

block.timestamp can be manipulated by miners.

				
					        if(player.lastWithdrawTime.add(WITHDRAW_INTERVAL) >= block.timestamp) {
            refReward = 0;
        }
				
			

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.

F8 Dao / Security Audit

Too many digits

Literals with many digits are difficult to read and review.

				
					            if(totalInvestValue >= 10000 && player.refsCount >= 13 && _getTeamValidMemberCount(_player) >= 500 && getTeamMemberL2Count(_player) >= 2) {
                level = 3;
            } else if (totalInvestValue >= 2000 && player.refsCount >= 8 && _getTeamValidMemberCount(_player) >= 200 && getTeamMemberL1Count(_player) >= 2) {
                level = 2;
            } else if (totalInvestValue >= 1000 && player.refsCount >= 5 && _getTeamValidMemberCount(_player) >= 50) {
                level = 1;
            }
				
			

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.

F8 Dao / Security Audit

Missing events arithmetic

Detect missing events for critical arithmetic parameters.

				
					    function activation(address _ref) payable external {

        require(players[_ref].active, "Warning: ref must be activated.");
        require(block.timestamp >= START_TIME, "Warning: Activity not started.");
        require(_ref != _msgSender(), "Warning: Referal can't refer to itself.");
        require(!players[_msgSender()].active, "Warning: You have been activated.");

        Player storage player = players[_msgSender()];

        if (!player.active) {
            player.active = true;
            playersCount += 1;
            
            player.referrer = payable(_ref);
            players[_ref].refsCount += 1;
            players[_ref].refsList.push(_msgSender());
        }

        activationList[_msgSender()] = _ref;
        activations.push(_msgSender());

        _updateReferrerCount(player.referrer);
        _payTax();
    }
				
			

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.

F8 Dao / Security Audit

Conformance to Solidity naming conventions

Allow _ at the beginning of the mixed_case match for private variables and unused parameters.

				
					contract Cards {
    
    uint256[4] internal CARD = [0, 1, 2, 3];
    uint256[4] internal CARD_VALUES = [100, 500, 2000, 5000];
    uint256[4] internal CARD_PROFITS = [10, 12, 15, 18];
    
    uint256[5] internal CARD_ALL_REWARDS_PERCENTS = [20, 15, 10, 8, 6];
    uint256[5][1] internal CARD_REWARDS_PERCENTS;
    
    constructor() {
        CARD_REWARDS_PERCENTS[0] = CARD_ALL_REWARDS_PERCENTS;
    }

}
				
			

Recommendation

Follow the Solidity naming convention.

Rule exceptions

  • Allow constant variable name/symbol/decimals to be lowercase (ERC20).
  • Allow _ at the beginning of the mixed_case match for private variables and unused parameters.

F8 Dao / Security Audit

Redundant Statements

Detect the usage of redundant statements that have no effect.

				
					    struct Player{
        bool active;
        address payable referrer;
        Holding[] holdings;
        uint256 refsCount;
        address[] refsList;
        uint256 referralReward;
        uint256[4] accumulatives;
        uint256 lastWithdrawTime;
        uint256 teamCount;
        address[] teamList;
        uint256 playerTotalValue;
        uint256 playerWithdrawAmount;
        uint256 teamPerformance;
        uint256 teamProfit;
        uint256 lastSellTime;
        uint256 maxDailyWithdrawnRewardAmount;
        uint256 dailyWithdrawnRewardAmount;
        
    }
				
			

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.

F8 Dao / Security Audit

Costly operations inside a loop

Costly operations inside a loop might waste gas, so optimizations are justified. 

				
					    function buyCard(uint256 _card) payable external nonReentrant {
        
        require(players[_msgSender()].active, "Warning: You have not activated.");
        require(_card < CARD_TYPES_COUNT, "Warning: Invalid card number.");

        Player storage player = players[_msgSender()];
        
        uint256 price = getCurrentPirce(CARD_VALUES[_card]);

        holdingsCounter += 1;

        player.holdings.push(
            Holding({
                id: holdingsCounter,
                cardType: _card,
                cardValue: CARD_VALUES[_card],
                cardProfit: CARD_PROFITS[_card],
                buyTime: block.timestamp,
                buyPrice: price,
                profitCap: ((price * PROFIT_CAP) / 100),
                cumulativeWithdrawal: 0,
                lastWithdrawnTime: block.timestamp
            })
        );
        
        _updateReferrerProfit(player.referrer, price);
        _updateReferrerPerformance(player.referrer, price);

        player.accumulatives[_card] += price;
        player.playerTotalValue += price;
        player.maxDailyWithdrawnRewardAmount += price;
        totalSaleValue += price;
        
        token.safeTransferFrom(_msgSender(), address(this), price);
        emit Buy(holdingsCounter, _msgSender(), _card, price);

        _payTax();
    }
				
			

Recommendation

Use a local variable to hold the loop computation result.

Exploit scenario

				
					contract CostlyOperationsInLoop{

    function bad() external{
        for (uint i=0; i < loop_count; i++){
            state_variable++;
        }
    }

    function good() external{
      uint local_variable = state_variable;
      for (uint i=0; i < loop_count; i++){
        local_variable++;
      }
      state_variable = local_variable;
    }
}
				
			

Incrementing state_variable in a loop incurs a lot of gas because of expensive SSTOREs, which might lead to an out-of-gas.

Requirements about TRX, on the BSC + Spelling error
				
					    function sellCard(uint256 holdingIndex) payable external {
        
        require(players[_msgSender()].active, "Warning: You have not activated.");
        Player storage player = players[_msgSender()];
        
        require(player.lastSellTime.add(SELL_INTERVAL) &lt; block.timestamp, &quot;Warning: Sell time interval error.&quot;);
        require(holdingIndex = holding.buyPrice, "Warning: TRX not enought.");
        
        if (holdingIndex &lt; (player.holdings.length - 1)) {
            player.holdings[holdingIndex] = player.holdings[(player.holdings.length - 1)];
        }
        
        player.holdings.pop();
        
        player.lastSellTime = block.timestamp;
        player.playerWithdrawAmount += price;
        player.maxDailyWithdrawnRewardAmount -= price;
        totalWithdrawAmount += price;
        
        token.safeTransfer(_msgSender(), price);
        emit Sell(_msgSender(), holding.cardType, price);

        _payTax();
    }
				
			

Recommendation

Revise the contract to avoid blind copy issues from another chain. Also remove spelling errors like ‘enought’.
Spelling error
				
					    function serProfitCap(uint256 _amount) external onlyOperator {
        PROFIT_CAP = _amount;
    }
				
			

Recommendation

serProfitCap -> setProfitCap
Potential Spelling error
				
					contract UincornCard is Context, Ownable, Cards {
    
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    struct Holding {
        uint256 id;
        uint256 cardType;
        uint256 cardValue;
        uint256 cardProfit;
        uint256 buyTime;
        uint256 buyPrice;
        uint256 profitCap;
        uint256 cumulativeWithdrawal;
        uint256 lastWithdrawnTime;
    }
    
				
			

Recommendation

UincornCard or UnicornCard?

F8 Dao / Security Audit

Other Owner Privileges Check

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

F8 Dao / Security Audit

Notes

Notes by F8 Dao

No notes provided by the team.

Notes by Coinsult

✅ No notes provided by Coinsult

F8 Dao / Security Audit

Contract Snapshot

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

				
					contract UincornCard is Context, Ownable, Cards {
    
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    struct Holding {
        uint256 id;
        uint256 cardType;
        uint256 cardValue;
        uint256 cardProfit;
        uint256 buyTime;
        uint256 buyPrice;
        uint256 profitCap;
        uint256 cumulativeWithdrawal;
        uint256 lastWithdrawnTime;
    }
 
				
			

F8 Dao / 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?

F8 Dao / Security Audit

Certificate of Proof

F8 Dao

Audited by Coinsult.net

Date: 9 May 2022

Coinsult

coinsult.net

End of report
Smart Contract Audit

Request your smart contract audit / KYC

t.me/coinsult_tg