AIT Protocol

Smart Contract Audit Report

Audit Summary

AIT Protocol Audit Report AIT Protocol is building a new ERC-20 token.

For this audit, we reviewed the project team's AITMainToken contract at commit fb835d4006d77fba47956f85d1513afa7923f629 on the team's GitHub repository.

Audit Findings

All findings have been resolved, though some centralized aspects are present.
Date: December 15th, 2023.
Updated: December 21st, 2023 to reflect updates made to the contract from commit a900fbd0d53f6a039213d9e5a50086a7f611ff23 to commit 764864bb9fe5d61190851e0f045c16fa86eaa5dc that resolves all Findings.
Updated: December 29th, 2023 to reflect updates made to the contract from commit 764864bb9fe5d61190851e0f045c16fa86eaa5dc to commit fb835d4006d77fba47956f85d1513afa7923f629.

Finding #1 - AITMainToken - Medium (Resolved)

Description: The takeFee() function incorrectly applies the contract's buy fee during a sell transaction and the contract's sell fee during a buy transaction.
function takeFee(address sender, address recipient, uint256 amount) internal view returns (uint256) {
    uint256 fee = 0;

    if(lpPairs[sender]){
        // SELL
        fee = amount * getTaxRate(_taxRates.sellFee) / masterTaxDivisor;
    }
    if(lpPairs[recipient]){
        // BUY
        fee = amount * getTaxRate(_taxRates.buyFee) / masterTaxDivisor;
    }
Risk/Impact: Users are charged the contract's sell fee on buys and the contract's buy fee on sells.
Recommendation: The takeFee() function should be modified as follows to properly charge the sell fee on sell transactions and the buy fee on buy transactions:
function takeFee(address sender, address recipient, uint256 amount) internal view returns (uint256) {
    uint256 fee = 0;

    if(lpPairs[sender]){
        // BUY
        fee = amount * getTaxRate(_taxRates.buyFee) / masterTaxDivisor;
    }
    if(lpPairs[recipient]){
        // SELL
        fee = amount * getTaxRate(_taxRates.sellFee) / masterTaxDivisor;
    }
Resolution: The team has implemented the above recommendation.

Finding #2 - AITMainToken - Informational (Resolved)

Description: The pairContract and router state variables can only be set one time in the constructor but are not declared immutable.
Recommendation: The above state variables could be declared immutable for additional gas savings on each reference.
Resolution: The team has removed the pairContract and router state variables and the router logic is now implemented directly in the constructor.

Contract Overview

  • The total supply of the token is set to 1 billion $AIT [1,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.
  • There is a fee charged on all buy and sell transactions via Uniswap, except when either the sender or the recipient is exempt from fees or if fees have been disabled in the contract by the owner.
  • The tokens collected through the fee are sent to the Treasury Receiver address set by the team.
  • For buys and sells occurring within the first 20 seconds of the first sell of the token, a 40% fee is applied.
  • For buys and sells occurring between 20 and 40 seconds of the first sell of the token, a 20% fee is applied.
  • For buys and sells occurring between 40 seconds and 24 hours of the first sell of the token, the contract's first-day buy fee and first-day sell fee are applied depending on whether the transaction is a buy or sell.
  • After 24 hours have passed from the first sell, the contract's buy fee and sell fee are applied depending on whether the transaction is a buy or sell.
  • The owner can enable/disable fees on buy and sell transactions at any time.
  • The owner can set the Buy fee and Sell fee to any percentages up to 20% each at any time.
  • The owner can set the first-day Buy fee and first-day Sell fee to any percentages up to 20% each at any time.
  • The owner can exclude and include accounts from fees at any time.
  • The owner can add/remove any address as an LP Pair address at any time.
  • The owner can set the Treasury Receiver address to any address at any time.
  • The contract utilizes LayerZero contracts to support cross-chain functionality.
  • As the contract is implemented with Solidity v0.8.x, it is safe from any possible overflows/underflows.
  • The contract complies with the ERC-20 token standard.

Audit Results

Vulnerability Category Notes Result
Arbitrary Jump/Storage Write N/A PASS
Centralization of Control The owner can set the Buy fee and Sell fee to any percentages up to 20% each at any time. PASS
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 N/A PASS
Improper Events N/A PASS
Improper Authorization Scheme N/A PASS
Integer Over/Underflow N/A PASS
Logical Issues N/A 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

 +  Ownable (Context)
    - [Pub]  #
    - [Pub] owner
    - [Int] _checkOwner
    - [Pub] renounceOwnership #
       - modifiers: onlyOwner
    - [Pub] transferOwnership #
       - modifiers: onlyOwner
    - [Int] _transferOwnership #

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

 + [Int] IERC20Metadata (IERC20)
    - [Ext] name
    - [Ext] symbol
    - [Ext] decimals

 +  ERC20 (Context, IERC20, IERC20Metadata)
    - [Pub]  #
    - [Pub] name
    - [Pub] symbol
    - [Pub] decimals
    - [Pub] totalSupply
    - [Pub] balanceOf
    - [Pub] transfer #
    - [Pub] allowance
    - [Pub] approve #
    - [Pub] transferFrom #
    - [Pub] increaseAllowance #
    - [Pub] decreaseAllowance #
    - [Int] _transfer #
    - [Int] _mint #
    - [Int] _burn #
    - [Int] _approve #
    - [Int] _spendAllowance #
    - [Int] _beforeTokenTransfer #
    - [Int] _afterTokenTransfer #

 + [Int] IERC165 
    - [Ext] supportsInterface

 +  ERC165 (IERC165)
    - [Pub] supportsInterface

 + [Int] ILayerZeroUserApplicationConfig 
    - [Ext] setConfig #
    - [Ext] setSendVersion #
    - [Ext] setReceiveVersion #
    - [Ext] forceResumeReceive #

 + [Int] ILayerZeroEndpoint (ILayerZeroUserApplicationConfig)
    - [Ext] send ($)
    - [Ext] receivePayload #
    - [Ext] getInboundNonce
    - [Ext] getOutboundNonce
    - [Ext] estimateFees
    - [Ext] getChainId
    - [Ext] retryPayload #
    - [Ext] hasStoredPayload
    - [Ext] getSendLibraryAddress
    - [Ext] getReceiveLibraryAddress
    - [Ext] isSendingPayload
    - [Ext] isReceivingPayload
    - [Ext] getConfig
    - [Ext] getSendVersion
    - [Ext] getReceiveVersion

 + [Int] ILayerZeroReceiver 
    - [Ext] lzReceive #

 + [Lib] BytesLib 
    - [Int] concat
    - [Int] concatStorage #
    - [Int] slice
    - [Int] toAddress
    - [Int] toUint8
    - [Int] toUint16
    - [Int] toUint32
    - [Int] toUint64
    - [Int] toUint96
    - [Int] toUint128
    - [Int] toUint256
    - [Int] toBytes32
    - [Int] equal
    - [Int] equalStorage

 +  LzApp (Ownable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig)
    - [Pub]  #
    - [Pub] lzReceive #
    - [Int] _blockingLzReceive #
    - [Int] _lzSend #
    - [Int] _checkGasLimit
    - [Int] _getGasLimit
    - [Int] _checkPayloadSize
    - [Ext] getConfig
    - [Ext] setConfig #
       - modifiers: onlyOwner
    - [Ext] setSendVersion #
       - modifiers: onlyOwner
    - [Ext] setReceiveVersion #
       - modifiers: onlyOwner
    - [Ext] forceResumeReceive #
       - modifiers: onlyOwner
    - [Ext] setTrustedRemote #
       - modifiers: onlyOwner
    - [Ext] setTrustedRemoteAddress #
       - modifiers: onlyOwner
    - [Ext] getTrustedRemoteAddress
    - [Ext] setPrecrime #
       - modifiers: onlyOwner
    - [Ext] setMinDstGas #
       - modifiers: onlyOwner
    - [Ext] setPayloadSizeLimit #
       - modifiers: onlyOwner
    - [Ext] isTrustedRemote

 + [Lib] ExcessivelySafeCall 
    - [Int] excessivelySafeCall #
    - [Int] excessivelySafeStaticCall
    - [Int] swapSelector

 +  NonblockingLzApp (LzApp)
    - [Pub]  #
       - modifiers: LzApp
    - [Int] _blockingLzReceive #
    - [Int] _storeFailedMessage #
    - [Pub] nonblockingLzReceive #
    - [Int] _nonblockingLzReceive #
    - [Pub] retryMessage ($)

 + [Int] IOFTCore (IERC165)
    - [Ext] estimateSendFee
    - [Ext] sendFrom ($)
    - [Ext] circulatingSupply
    - [Ext] token

 + [Int] IOFT (IOFTCore, IERC20)

 +  OFTCore (NonblockingLzApp, ERC165, IOFTCore)
    - [Pub]  #
       - modifiers: NonblockingLzApp
    - [Pub] supportsInterface
    - [Pub] estimateSendFee
    - [Pub] sendFrom ($)
    - [Pub] setUseCustomAdapterParams #
       - modifiers: onlyOwner
    - [Int] _nonblockingLzReceive #
    - [Int] _send #
    - [Int] _sendAck #
    - [Int] _checkAdapterParams #
    - [Int] _debitFrom #
    - [Int] _creditTo #

 +  OFT (OFTCore, ERC20, IOFT)
    - [Pub]  #
       - modifiers: ERC20,OFTCore
    - [Pub] supportsInterface
    - [Pub] token
    - [Pub] circulatingSupply
    - [Int] _debitFrom #
    - [Int] _creditTo #

 +  BasedOFT (OFT)
    - [Pub]  #
       - modifiers: OFT
    - [Pub] circulatingSupply
    - [Int] _debitFrom #
    - [Int] _creditTo #

 + [Int] IDEXPair 
    - [Ext] sync #

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

 + [Int] IDEXFactory 
    - [Ext] createPair #

 +  AITMainToken (BasedOFT)
    - [Pub]  #
       - modifiers: BasedOFT
    - [Ext] changeTreasuryReceiver #
       - modifiers: onlyOwner
    - [Ext] changeFeeStatus #
       - modifiers: onlyOwner
    - [Pub] setExcludedFees #
       - modifiers: onlyOwner
    - [Ext] setTaxes #
       - modifiers: onlyOwner
    - [Ext] setLpPair #
       - modifiers: onlyOwner
    - [Ext] isExcludedFees
    - [Int] getTaxRate
    - [Int] takeFee
    - [Int] _transfer #
    - [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.