Leviathan

Smart Contract Audit Report

Audit Summary

Leviathan Audit Report Leviathan is a new BEP-20 token with an elastic supply that performs automatic liquidity adds.

For this audit, we reviewed the Leviathan contract provided to us by the project team.

Audit Findings

Please ensure trust in the team prior to investing as they have substantial control in the ecosystem.
Date: March 28th, 2022.

Finding #1 - Leviathan - Informational

Description: The shouldRebase function is not enforced in the contract. As a result, the rebaseFrequency and nextRebase variables serve no real purpose.
Recommendation: The shouldRebase function, rebaseFrequency and nextRebase state variables should be removed to reduce contract size and deployment costs.

Finding #2 - Leviathan - Informational

Description: Several functions are declared public, but are never called internally.
shouldRebase, updateBlacklist, addMinter, removeMinter, rescueToken
Recommendation: These functions should be declared external for additional gas savings on each call.

Finding #3 - Leviathan - Informational

Description: The DEAD and ZERO state variables can never be modified, but are not declared constant.
Recommendation: These state variables should be declared constant for additional gas savings on each call.

Contract Overview

  • The initial supply is set to 100 billion tokens and will be minted to the team's Treasury wallet upon deployment.
  • The maximum supply of is 340,282,366,920,938,463,463,374,607,431,768,211,455 tokens.
  • The contract utilizes a Minter role. The assigned addresses can mint any number of tokens up to the maximum supply to any address at any time.
  • The contract utilizes a Rebase Executor role. The assigned address can trigger a manual rebase; this serves as a frictionless token redistribution which automatically adds tokens for all token holders proportionally at the time of each total supply change.
  • The number of tokens added is dependent on the current total supply, and the ratio between the "reward yield" and the "reward yield denominator"; this ratio defaults to ~0.042% of the current total supply.
  • The rebase function calls sync() on the Pancakeswap Pair contract to prevent theft-of-liquidity attacks that have occurred with other rebase tokens.
  • No burn functions are present though the circulating supply can be decreased by sending tokens to the 0x..dead address.
  • There was no token allocation for our team to analyze as the contract has yet to be deployed to the Mainnet.

  • There is a Liquidity fee, Treasury fee, and RFV fee on all transfers via Pancakeswap where neither the sender nor the recipient is excluded from fees.
  • The contract charges an additional fee on all sell transactions via Pancakeswap.
  • The fees charged during transfers are stored in the contract address. The tokens are swapped for BNB for the purpose of funding Pancakeswap liquidity when the following conditions are met:
    • The automatic liquidity add functionality is enabled by the team.
    • The threshold number of tokens in the contract address (determined by the owner) has been reached.
    • The contract is not currently performing an automatic liquidity add.
    • The caller is not initiating a buy transaction via Pancakeswap.
  • If the Liquidity during the swap is greater than the target value set by the team, no liquidity will be added. Otherwise, the Liquidity fee is used for an automatic Liquidity-add.
  • Liquidity-adds are automatically performed by selling the tokens collected as fees, pairing the received BNB with the token, and adding it as liquidity to the BNB pair.
  • The LP tokens received through this process are sent to the Liquidity wallet controlled by the team. We recommend that the team lock these newly acquired LP tokens.
  • The tokens collected from the Treasury fee and RFV fee are swapped for BNB and sent to the team's Treasury wallet and RFV wallet respectively.
  • The contract utilizes SafeMath libraries to prevent any overflows/underflows.
Ownership Controls:
  • The owner can manually trigger a positive or negative rebase at any time.
  • The owner can set total transfer fees to any value, up to 25%, at any time.
  • The owner can set the additional fee on sell transactions to any value at any time.
  • The owner can exclude accounts from transfer fees.
  • The owner can update the rebase frequency and update the next rebase timestamp at any time.
  • The owner can update the reward yield and the reward yield denominator to any values at any time.
  • The owner can enable/disable automatic liquidity adds at any time.
  • The owner can update the threshold number of tokens that triggers an automatic liquidity add to any value at any time.
  • The owner can add/remove accounts from the Minter role and Rebase Executor roles at any time.
  • The owner can airdrop any number of tokens to any addresses at any time.
  • The owner can blacklist accounts from being able to participate in transfers.
  • The owner can update the Pair address to any address at any time.
  • The owner can update the team's Liquidity wallet, Treasury wallet, and RFV wallet to any addresses at any time.
  • The owner can withdraw any BNB or tokens from the contract at any time.
  • The owner can manually sync the LP Pair contract at any time.

Audit Results

Vulnerability CategoryNotesResult
Arbitrary Jump/Storage WriteN/APASS
Centralization of Control
  • The LP tokens generated through automatic liquidity adds are sent to the team's Liquidity wallet.
  • The Minter role addresses can mint any number of tokens up to the maximum supply.
  • The owner can set the additional fee on sell transactions to any percentage.
  • The owner can manually trigger a positive or negative rebase.
  • The owner can manually add/remove accounts from the transfer blacklist.
  • The owner can withdraw any tokens and BNB from the contract.
WARNING
Compiler IssuesN/APASS
Delegate Call to Untrusted ContractN/APASS
Dependence on Predictable VariablesN/APASS
Ether/Token TheftN/APASS
Flash LoansN/APASS
Front RunningN/APASS
Improper EventsN/APASS
Improper Authorization SchemeN/APASS
Integer Over/UnderflowN/APASS
Logical IssuesN/APASS
Oracle IssuesN/APASS
Outdated Compiler VersionN/APASS
Race ConditionsN/APASS
ReentrancyN/APASS
Signature IssuesN/APASS
Unbounded LoopsN/APASS
Unused CodeN/APASS
Overall Contract Safety PASS

Inheritance Chart

Smart Contract Audit - Inheritance

Function Graph

Smart Contract Audit - Graph

Functions Overview


 ($) = payable function
 # = non-constant function
 
 Int = Internal
 Ext = External
 Pub = Public

 + [Lib] SafeMathInt 
    - [Int] mul
    - [Int] div
    - [Int] sub
    - [Int] add
    - [Int] abs

 + [Int] IERC20 
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Ext] allowance
    - [Ext] transfer #
    - [Ext] approve #
    - [Ext] transferFrom #

 + [Lib] SafeMath 
    - [Int] add
    - [Int] sub
    - [Int] sub
    - [Int] mul
    - [Int] div
    - [Int] div
    - [Int] mod

 + [Int] InterfaceLP 
    - [Ext] sync #

 + [Lib] Roles 
    - [Int] add #
    - [Int] remove #
    - [Int] has

 +  MinterRole 
    - [Pub]  #
    - [Pub] isMinter
    - [Pub] renounceMinter #
    - [Int] _addMinter #
    - [Int] _removeMinter #

 +  ERC20Detailed (IERC20)
    - [Pub]  #
    - [Pub] name
    - [Pub] symbol
    - [Pub] decimals

 + [Int] IDEXRouter 
    - [Ext] factory
    - [Ext] WETH
    - [Ext] addLiquidity #
    - [Ext] addLiquidityETH ($)
    - [Ext] swapExactTokensForTokensSupportingFeeOnTransferTokens #
    - [Ext] swapExactETHForTokensSupportingFeeOnTransferTokens ($)
    - [Ext] swapExactTokensForETHSupportingFeeOnTransferTokens #

 + [Int] IDEXFactory 
    - [Ext] createPair #

 +  Ownable 
    - [Pub]  #
    - [Pub] owner
    - [Pub] isOwner
    - [Pub] renounceOwnership #
       - modifiers: onlyOwner
    - [Pub] transferOwnership #
       - modifiers: onlyOwner
    - [Int] _transferOwnership #

 +  Leviathan (ERC20Detailed, Ownable, MinterRole)
    - [Pub]  #
       - modifiers: ERC20Detailed
    - [Ext] setNextRebase #
       - modifiers: onlyOwner
    - [Ext] setRewardYield #
       - modifiers: onlyOwner
    - [Ext] setRebaseFrequency #
       - modifiers: onlyOwner
    - [Pub] shouldRebase
    - [Pub] updateBlacklist #
       - modifiers: onlyOwner
    - [Ext] rebase #
       - modifiers: onlyOwner
    - [Ext] executorRebase #
       - modifiers: isExecutor,initialDistributionLock
    - [Prv] coreRebase #
    - [Ext] totalSupply
    - [Ext] transfer #
       - modifiers: validRecipient,initialDistributionLock
    - [Ext] setLP #
       - modifiers: onlyOwner
    - [Ext] allowance
    - [Ext] balanceOf
    - [Int] _basicTransfer #
    - [Int] _transferFrom #
    - [Ext] transferFrom #
       - modifiers: validRecipient
    - [Int] swapBack #
       - modifiers: swapping
    - [Int] takeFee #
    - [Ext] decreaseAllowance #
       - modifiers: initialDistributionLock
    - [Ext] increaseAllowance #
       - modifiers: initialDistributionLock
    - [Ext] approve #
       - modifiers: initialDistributionLock
    - [Ext] checkFeeExempt
    - [Ext] setInitialDistributionFinished #
       - modifiers: onlyOwner
    - [Ext] enableTransfer #
       - modifiers: onlyOwner
    - [Ext] setFeeExempt #
       - modifiers: onlyOwner
    - [Int] shouldTakeFee
    - [Ext] mint #
       - modifiers: onlyMinter
    - [Ext] setSwapBackSettings #
       - modifiers: onlyOwner
    - [Int] shouldSwapBack
    - [Pub] getCirculatingSupply
    - [Ext] setTargetLiquidity #
       - modifiers: onlyOwner
    - [Pub] addMinter #
       - modifiers: onlyOwner
    - [Pub] removeMinter #
       - modifiers: onlyOwner
    - [Ext] isNotInSwap
    - [Ext] sendPresale #
       - modifiers: onlyOwner
    - [Ext] checkSwapThreshold
    - [Ext] manualSync #
    - [Ext] setFeeReceivers #
       - modifiers: onlyOwner
    - [Ext] setRebaseExecutor #
       - modifiers: onlyOwner
    - [Ext] setFees #
       - modifiers: onlyOwner
    - [Ext] clearStuckBalance #
       - modifiers: onlyOwner
    - [Pub] rescueToken #
       - modifiers: onlyOwner
    - [Prv] transferToAddressETH #
    - [Pub] getLiquidityBacking
    - [Pub] isOverLiquified
    - [Ext]  ($)

About SourceHat

SourceHat has quickly grown to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1800+ solidity smart contract audits covering all major project types and protocols, securing a total of over $50 billion U.S. dollars in on-chain value!
Our firm is well-reputed in the community and is trusted as a top smart contract auditing company for the review of solidity code, no matter how complex. Our team of experienced solidity smart contract auditors performs audits for tokens, NFTs, crowdsales, marketplaces, gambling games, financial protocols, and more!

Contact us today to get a free quote for a smart contract audit of your project!

What is a SourceHat Audit?

Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A SourceHat Audit takes this a step further by verifying economic logic to ensure the stability of smart contracts and highlighting privileged functionality to create a report that is easy to understand for developers and community members alike.

How Do I Interpret the Findings?

Each of our Findings will be labeled with a Severity level. We always recommend the team resolve High, Medium, and Low severity findings prior to deploying the code to the mainnet. Here is a breakdown on what each Severity level means for the project:

  • High severity indicates that the issue puts a large number of users' funds at risk and has a high probability of exploitation, or the smart contract contains serious logical issues which can prevent the code from operating as intended.
  • Medium severity issues are those which place at least some users' funds at risk and has a medium to high probability of exploitation.
  • Low severity issues have a relatively minor risk association; these issues have a low probability of occurring or may have a minimal impact.
  • Informational issues pose no immediate risk, but inform the project team of opportunities for gas optimizations and following smart contract security best practices.