Coinsult

Request your audit at coinsult.net

Advanced Manual
Smart Contract Audit

April 26, 2022

Audit requested by

Marvel Finance

Not deployed yet

Marvel Finance / 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 Marvel Finance

7. Contract Snapshot

8. Website Review

9. Certificate of Proof

Marvel Finance / Security Audit

Audit Summary

Audit Scope

Project Name

Marvel Finance

Blockchain

Binance Smart Chain

Smart Contract Language

Solidity

Contract Address

Not deployed yet

Audit Method

Static Analysis, Manual Review

Date of Audit

26 April 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.

Marvel Finance / Security Audit

Tokenomics

Source Code

Coinsult was comissioned by Marvel Finance to perform an audit based on the following code:

Note: This project uses openzeppelin imports. While we do check the full contract for vulnerabilities at the time of the audit, we can not ensure the correctness of these imported modules.

Marvel Finance / 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.

Marvel Finance / 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

0

0

0

0

0

0

0

0

Marvel Finance / Security Audit

Avoid relying on block.timestamp

block.timestamp can be manipulated by miners.

				
					        if (_amount > 0) {
            stakedTime[msg.sender] = block.timestamp;
            uint256 balanceBefore = stakedToken.balanceOf(address(this));
            stakedToken.safeTransferFrom(
                address(msg.sender),
                address(this),
                _amount
            );
            uint256 balanceAfter = stakedToken.balanceOf(address(this));
            _amount = balanceAfter.sub(balanceBefore);
            user.amount = user.amount.add(_amount);
        }
				
			

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.

Marvel Finance / Security Audit

Too many digits

Literals with many digits are difficult to read and review.

				
					        require(
            newValue >= 200000 && newValue <= 1000000,
            "gasForProcessing must be between 200,000 and 500,000"
        );
				
			

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.

Marvel Finance / Security Audit

Functions that send Ether to arbitrary destinations

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

				
					    function safeTransferReferral(
        IERC20 _rewardToken,
        uint256 _gas,
        address _account,
        uint256 _amount
    ) internal returns (uint256) {
        uint256 iterations = 0;
        uint256 gasUsed = 0;
        uint256 gasLeft = gasleft();
        while (gasUsed  newGasLeft) {
                gasUsed = gasUsed.add(gasLeft.sub(newGasLeft));
            }
            gasLeft = newGasLeft;
        }
        return _amount;
    }
				
			

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.

Marvel Finance / Security Audit

Missing events arithmetic

Detect missing events for critical arithmetic parameters.

				
					    function setReferralRewardPercent(uint256 _tier, uint256 _percent)
        external
        onlyOwner
    {
        referralTotalFeePercent = referralTotalFeePercent
            .sub(referralRewardPercent[_tier])
            .add(_percent);
        referralRewardPercent[_tier] = _percent;
    }
				
			

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.

Marvel Finance / Security Audit

Conformance to Solidity naming conventions

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

				
					uint256 public PRECISION_FACTOR;
				
			

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.

Marvel Finance / Security Audit

Redundant Statements

Detect the usage of redundant statements that have no effect.

				
					    // The address of the smart chef factory
    address public SMART_CHEF_FACTORY;

    // Whether a limit is set for users
    bool public hasUserLimit;

    // Accrued token per share
    uint256 public accTokenPerShare;

    // The block number when CAKE mining ends.
    uint256 public bonusEndBlock;

    // The block number when CAKE mining starts.
    uint256 public startBlock;

    // The block number of the last pool update
    uint256 public lastRewardBlock;

    // The pool limit (0 if none)
    uint256 public poolLimitPerUser;

    // CAKE tokens created per block.
    uint256 public rewardPerBlock;

    // The reward token
    IERC20 public rewardToken;

    // The staked token
    IERC20 public stakedToken;
				
			

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.

Marvel Finance / Security Audit

Other Owner Privileges Check

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

⚠ Owner can set referral fee for each tier without a limit

 function setReferralRewardPercent(uint256 _tier, uint256 _percent)
external
onlyOwner
{
referralTotalFeePercent = referralTotalFeePercent
.sub(referralRewardPercent[_tier])
.add(_percent);
referralRewardPercent[_tier] = _percent;
}

⚠ Owner can emergency withdraw rewards

 /*
* @notice Stop rewards
* @dev Only callable by owner. Needs to be for emergency.
*/
function emergencyRewardWithdraw(uint256 _amount) external onlyOwner {
rewardToken.safeTransfer(address(msg.sender), _amount);
}

⚠ Owner can update pool limit per user

/*
* @notice Update pool limit per user
* @dev Only callable by owner.
* @param _hasUserLimit: whether the limit remains forced
* @param _poolLimitPerUser: new pool limit per user
*/
function updatePoolLimitPerUser(
bool _hasUserLimit,
uint256 _poolLimitPerUser
) external onlyOwner {
require(hasUserLimit, "Must be set");
if (_hasUserLimit) {
require(
_poolLimitPerUser > poolLimitPerUser,
"New limit must be higher"
);
poolLimitPerUser = _poolLimitPerUser;
} else {
hasUserLimit = _hasUserLimit;
poolLimitPerUser = 0;
}
emit NewPoolLimit(poolLimitPerUser);
}

Marvel Finance / Security Audit

Notes

Notes by Marvel Finance

No notes provided by the team.

Notes by Coinsult

✅ No notes provided by Coinsult

Marvel Finance / Security Audit

Contract Snapshot

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

				
					contract SmartChefInitializable is
    SmartReferral,
    StakedTokenLock,
    ReentrancyGuard,
    Initializable
{
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    // The address of the smart chef factory
    address public SMART_CHEF_FACTORY;

    // Whether a limit is set for users
    bool public hasUserLimit;

    // Accrued token per share
    uint256 public accTokenPerShare;

    // The block number when CAKE mining ends.
    uint256 public bonusEndBlock;

    // The block number when CAKE mining starts.
    uint256 public startBlock;

    // The block number of the last pool update
    uint256 public lastRewardBlock;

    // The pool limit (0 if none)
    uint256 public poolLimitPerUser;

    // CAKE tokens created per block.
    uint256 public rewardPerBlock;

    // The reward token
    IERC20 public rewardToken;

    // The staked token
    IERC20 public stakedToken;

    mapping(address => ExtraTokenInfo) public extraRewardTokenInfos;
    address[] private extraRewardTokens;

    // Info of each user that stakes tokens (stakedToken)
    mapping(address => UserInfo) public userInfo;

    struct ExtraTokenInfo {
        uint256 tid;
        IERC20 rewardToken;
        uint256 assignRate;
        bool enable;
    }
				
			

Marvel Finance / 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?

Marvel Finance / Security Audit

Certificate of Proof

Marvel Finance

Audited by Coinsult.net

Date: 26 April 2022

Coinsult

coinsult.net

End of report
Smart Contract Audit

Request your smart contract audit / KYC

t.me/coinsult_tg