Sempsun AI

Smart Contract Audit Report

Audit Summary

Sempsun AI Audit Report Sempsun AI is a new ERC-20 token on Ethereum that is an automatic liquidity providing protocol.

For this audit, we reviewed the project team's SempsunAI contract at 0x02a97Fd243B8301BCd6bA3a87693162d6bD130BD on the Ethereum Mainnet.

Audit Findings

Low findings were identified and the team should consider resolving these issues. In addition, some centralized aspects are present.
Date: September 18th, 2023.
Updated: September 25th, 2023 to reflect the project's newly deployed mainnet address.

Finding #1 - SempsunAI - Low (Resolved)

Description: The _totalTaxIfBuying state variable is incorrectly and permanently initialized to zero in the constructor as it erroneously adds _buyDragonFee twice instead of incorporating _buyLiquidityFee.
_totalTaxIfBuying = _buyDragonFee.add(_buyMarketingFee).add(_buyDragonFee);
Risk/Impact: A fee is never charged on buy transactions as intended by the team as _totalTaxIfBuying is permanently set to zero.
Recommendation: _totalTaxIfBuying should be set to the sum of _buyDragonFee, _buyMarketingFee, and _buyLiquidityFee in the constructor.
Resolution: The team has implemented the above recommendation.

Finding #2 - SempsunAI - Low

Description: The swapAndLiquify() function transfers ETH from the contract to the team's fee addresses using the transfer() function instead of the call() function.
Risk/Impact: The transfer() function uses a hardcoded gas amount of 2300, meaning transactions could run out of gas as the team receives ETH if the receiver is a contract.
Recommendation: The team should use .call.value{...}("") instead as it does not have a gas limitation.
Resolution: The team has not yet addressed this issue.

Finding #3 - SempsunAI - Informational

Description: The checkWalletLimit boolean condition in the _transfer() function is redundant as this value is permanently set to true.
Recommendation: The team should either remove the checkWalletLimit boolean condition from the _transfer() function for additional gas savings on each call or add a function that allows the owner to toggle the checkWalletLimit state variable.

Finding #4 - SempsunAI - Informational

Description: The _totalTaxIfBuying, _totalTaxIfSelling, and _totalDistributionShares are initially declared with default values but are then immediately overwritten in the constructor with new values.
Recommendation: The initial declarations of the above state variables could be removed to decrease deployment costs. If implemented, the _totalTaxIfBuying and _totalTaxIfSelling could be declared immutable for additional gas savings on each reference.

Finding #5 - SempsunAI - Informational

Description: The below state variables cannot be modified but are not declared constant.
DragonWallet, MarketingWallet, _buyDragonFee, _buyLiquidityFee, _buyMarketingFee, _decimals, _maxTxAmount, _name, _sellDragonFee, _sellLiquidityFee, _sellMarketingFee, _symbol, _totalSupply, _walletMax
Recommendation: The above state variables could be declared constant for additional gas savings on each reference.

Finding #6 - SempsunAI - Informational

Description: Although the SafeMath library is utilized, the contract is deployed with Solidity v0.8.9 which has built-in overflow checks.
Recommendation: SafeMath could be safely removed to reduce contract size, deployment costs, and gas costs on all transactions that utilize it.

Contract Overview

  • The total supply of the token is set to 420 trillion $SmAi2.0 [420,000,000,000,000].
  • No mint or burn functions are publicly accessible, though the circulating supply can be decreased by sending tokens to the 0x..dead address.
  • At the time of writing this report, 99.2% of the total supply belongs to the owner.

  • The contract enforces a maximum transaction amount of 8.4 trillion tokens that can be transferred in a single transaction.
  • The contract enforces a maximum wallet amount that prevents a transfer from occurring if the recipient's token balance exceeds 8.4 trillion tokens after the transfer occurs. The team must ensure all created Pair addresses are properly excluded from this restriction.
  • There is a 1% Liquidity fee, 1% Dragon fee, and 2% Marketing fee on all sells via Uniswap and a 1% Liquidity fee and 2% Marketing fee on all buys via Uniswap where neither the sender nor the recipient is excluded from fees.
  • The tokens collected through fees are stored in the contract address. The tokens are swapped for ETH for the purpose of funding Uniswap liquidity and team wallets 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 Uniswap.
  • Liquidity-adds are automatically performed by selling the tokens collected as fees, pairing the received ETH with the token, and adding it as liquidity to the pair.
  • The LP tokens received through this process are sent to the owner. We recommend the team lock these newly acquired LP tokens.
  • The tokens collected through the Marketing fee and Dragon fee are swapped for ETH and sent to the team's Marketing wallet and Dragon wallet respectively.
  • As the contract is deployed with Solidity v0.8.9, it is protected from overflows/underflows.
  • The contract complies with the ERC-20 token standard.
Ownership Controls:
  • The owner can exclude and include accounts from transfer fees at any time.
  • The owner can exclude and include accounts from maximum transaction and maximum wallet restrictions at any time.
  • The owner can enable/disable automatic liquidity adds at any time.
  • The owner can update the threshold number of tokens needed to trigger an automatic liquidity add to any value at any time.
  • The owner can enable/disable the contract's token swapping limit at any time.
  • The owner can update the contract's Liquidity, Marketing, and Dragon fund allocations to any values at any time.
  • The owner can add/remove any address from the Automated Market Maker Pair list at any time.
  • The owner can update the Router address used in the contract at any time.

Audit Results

Vulnerability Category Notes Result
Arbitrary Jump/Storage Write N/A PASS
Centralization of Control The LP tokens generated through automatic liquidity adds are sent to the owner. WARNING
Compiler Issues N/A PASS
Delegate Call to Untrusted Contract N/A PASS
Dependence on Predictable Variables N/A PASS
Ether/Token Theft N/A PASS
Flash Loans N/A PASS
Front Running The automatic token swapping functionality may be susceptible to front-running. The team should monitor, and if any suspicious activity is detected, should lower the minimumTokensBeforeSwap threshold. PASS
Improper Events N/A PASS
Improper Authorization Scheme N/A PASS
Integer Over/Underflow N/A PASS
Logical Issues The _totalTaxIfBuying state variable is incorrectly and permanently initialized to zero in the constructor as it erroneously adds _buyDragonFee twice instead of incorporating _buyLiquidityFee. PASS
Oracle Issues N/A PASS
Outdated Compiler Version N/A PASS
Race Conditions N/A PASS
Reentrancy N/A PASS
Signature Issues N/A PASS
Sybil Attack N/A PASS
Unbounded Loops N/A PASS
Unused Code N/A PASS
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

 +  Context 
    - [Int] _msgSender
    - [Int] _msgData

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

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

 + [Lib] Address 
    - [Int] isContract
    - [Int] sendValue #
    - [Int] functionCall #
    - [Int] functionCall #
    - [Int] functionCallWithValue #
    - [Int] functionCallWithValue #
    - [Prv] _functionCallWithValue #

 +  Ownable (Context)
    - [Pub]  #
    - [Pub] owner
    - [Pub] waiveOwnership #
       - modifiers: onlyOwner
    - [Pub] transferOwnership #
       - modifiers: onlyOwner

 + [Int] IUniswapV2Factory 
    - [Ext] feeTo
    - [Ext] feeToSetter
    - [Ext] getPair
    - [Ext] allPairs
    - [Ext] allPairsLength
    - [Ext] createPair #
    - [Ext] setFeeTo #
    - [Ext] setFeeToSetter #

 + [Int] IUniswapV2Pair 
    - [Ext] name
    - [Ext] symbol
    - [Ext] decimals
    - [Ext] totalSupply
    - [Ext] balanceOf
    - [Ext] allowance
    - [Ext] approve #
    - [Ext] transfer #
    - [Ext] transferFrom #
    - [Ext] nonces
    - [Ext] permit #
    - [Ext] factory
    - [Ext] token0
    - [Ext] token1
    - [Ext] getReserves
    - [Ext] price0CumulativeLast
    - [Ext] price1CumulativeLast
    - [Ext] kLast
    - [Ext] burn #
    - [Ext] swap #
    - [Ext] skim #
    - [Ext] sync #
    - [Ext] initialize #

 + [Int] IUniswapV2Router01 
    - [Ext] factory
    - [Ext] WETH
    - [Ext] addLiquidity #
    - [Ext] addLiquidityETH ($)
    - [Ext] removeLiquidity #
    - [Ext] removeLiquidityETH #
    - [Ext] removeLiquidityWithPermit #
    - [Ext] removeLiquidityETHWithPermit #
    - [Ext] swapExactTokensForTokens #
    - [Ext] swapTokensForExactTokens #
    - [Ext] swapExactETHForTokens ($)
    - [Ext] swapTokensForExactETH #
    - [Ext] swapExactTokensForETH #
    - [Ext] swapETHForExactTokens ($)
    - [Ext] quote
    - [Ext] getAmountOut
    - [Ext] getAmountIn
    - [Ext] getAmountsOut
    - [Ext] getAmountsIn

 + [Int] IUniswapV2Router02 (IUniswapV2Router01)
    - [Ext] removeLiquidityETHSupportingFeeOnTransferTokens #
    - [Ext] removeLiquidityETHWithPermitSupportingFeeOnTransferTokens #
    - [Ext] swapExactTokensForTokensSupportingFeeOnTransferTokens #
    - [Ext] swapExactETHForTokensSupportingFeeOnTransferTokens ($)
    - [Ext] swapExactTokensForETHSupportingFeeOnTransferTokens #

 +  SempsunAI (Context, IERC20, Ownable)
    - [Pub]  #
    - [Pub] name
    - [Pub] symbol
    - [Pub] decimals
    - [Pub] totalSupply
    - [Pub] balanceOf
    - [Pub] allowance
    - [Pub] increaseAllowance #
    - [Pub] decreaseAllowance #
    - [Pub] approve #
    - [Prv] _approve #
    - [Pub] addMarketPair #
       - modifiers: onlyOwner
    - [Ext] setIsTxLimitExempt #
       - modifiers: onlyOwner
    - [Pub] setIsExcludedFromFee #
       - modifiers: onlyOwner
    - [Ext] setDistributionSettings #
       - modifiers: onlyOwner
    - [Ext] setIsWalletLimitExempt #
       - modifiers: onlyOwner
    - [Ext] setNumTokensBeforeSwap #
       - modifiers: onlyOwner
    - [Pub] setSwapAndLiquifyEnabled #
       - modifiers: onlyOwner
    - [Pub] setSwapAndLiquifyByLimitOnly #
       - modifiers: onlyOwner
    - [Pub] getCirculatingSupply
    - [Prv] transferToAddressETH #
    - [Pub] changeRouterVersion #
       - modifiers: onlyOwner
    - [Ext]  ($)
    - [Pub] transfer #
    - [Pub] transferFrom #
    - [Prv] _transfer #
    - [Int] _basicTransfer #
    - [Prv] swapAndLiquify #
       - modifiers: lockTheSwap
    - [Prv] swapTokensForEth #
    - [Prv] addLiquidity #
    - [Int] takeFee #

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 1300+ 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 across 1500 projects!. 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.