Sanctuary Token
Smart Contract Audit Report
Audit Summary
Sanctuary Token is a new BEP-20 token on the Binance Smart Chain that is an automatic liquidity providing protocol.
For this audit, we reviewed the project team's Sanctuary contract at 0x4670f3a2A8D35021257cda028c7ae3Cb854C7CaF on the Binance Smart Chain Mainnet.
Audit Findings
Low findings were identified and the team should consider resolving these issues. In addition, some centralized aspects are present.
Date: August 30th, 2023.
Updated: September 18th, 2023 to reflect the contract's newly deployed Mainnet address.Finding #1 - Sanctuary - Low (Resolved)
Description: In the swapAndLiquify() function,amountBNBCharity
will always equal zero asamountBNBMarketing
is set to the remainder of the contract's BNB balance before theamountBNBCharity
calculation.
Risk/Impact: Theuint256 amountReceived = address(this).balance; uint256 amountBNBLiquidity = amountReceived.mul(_liquidityShare).div(totalBNBFee).div(2); uint256 amountBNBDevelopment = amountReceived.mul(_developmentShare).div(totalBNBFee); uint256 amountBNBMarketing = amountReceived.sub(amountBNBLiquidity).sub(amountBNBDevelopment); uint256 amountBNBCharity = amountReceived.sub(amountBNBLiquidity).sub(amountBNBDevelopment).sub(amountBNBMarketing);
charityWalletAddress
will never be allocated any BNB as intended by the team.
Recommendation: The above calculations should be modified as follows to properly allocate BNB to the respective addresses based on their allocated shares:
Resolution: The team has implemented the above recommendation.uint256 amountBNBLiquidity = amountReceived.mul(_liquidityShare).div(totalBNBFee).div(2); uint256 amountBNBDevelopment = amountReceived.mul(_developmentShare).div(totalBNBFee); uint256 amountBNBMarketing = amountReceived.mul(_marketingShare).div(totalBNBFee); uint256 amountBNBCharity = amountReceived.sub(amountBNBLiquidity).sub(amountBNBDevelopment).sub(amountBNBMarketing);
Finding #2 - Sanctuary - Low
Description: The swapAndLiquify() function transfers BNB from the contract to the team's fee addresses using thetransfer()
function instead of thecall()
function.
Risk/Impact: Thetransfer()
function uses a hardcoded gas amount of 2300, meaning transactions could run out of gas as the team receives BNB 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 - Sanctuary - Low
Description: The owner can call the lock() function to temporarily transfer ownership toaddress(0)
. Ownership is restored when the unlock() function is invoked after the time duration set by the owner has elapsed; however,_previousOwner
is not reset.
Risk/Impact: The unlock() function can be used after ownership has been renounced, thereby restoring ownership to the original owner who initially invoked the lock() function. This capability could be nefariously used to regain ownership after it has been renounced.
Recommendation: The team should modify the unlock() function to set_previousOwner
toaddress(0)
at the end of the function or remove the lock functionality from the contract altogether.
Resolution: The team has not yet addressed this issue.
Finding #4 - Sanctuary - Low (Resolved)
Description: The_autoburnShare
state variable is included in the_totalDistributionShares
calculation upon deployment but is not allocated to any fund.
Risk/Impact: The_totalDistributionShares
value is inaccurate on deployment as_autoburnShare
is not used in the contract.
Recommendation: As the contract is deployed, the owner can call the setDistributionSettings() function to properly set the contract's shares as_autoburnShare
is not included in this function. Alternatively, the team could remove_autoburnShare
from the contract altogether or utilize it in a way that fits their intended functionality.
Resolution: The team has removed the_autoburnShare
state variable from the contract.
Finding #5 - Sanctuary - Informational (Resolved)
Description: The_buyAutoburnFee
and_sellAutoburnFee
state variables are redundant as the tokens collected through these fees are not allocated to any fund.
Recommendation: The team should remove_buyAutoburnFee
and_sellAutoburnFee
from the contract or utilize them in a way that fits their intended functionality. Alternatively, as the contract is deployed, the owner can call the setBuyTaxes() and setSellTaxes() functions to ensure the contract's fees are properly set, as_buyAutoburnFee
and_sellAutoburnFee
are not included in these functions.
Resolution: The team has removed the_buyAutoburnFee
and_sellAutoburnFee
state variables from the contract.
Finding #6 - Sanctuary - Informational (Resolved)
Description: The private _takeAutoBurn() function is never called in the contract.
Recommendation: The above function should either be removed to reduce contract size and deployment costs or utilized in a way that fits the project team's intended functionality.
Resolution: The team has removed the _takeAutoBurn() function from the contract.
Finding #7 - Sanctuary - Informational
Description: Although the SafeMath library is utilized, the contract is deployed with Solidity v0.8.4 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.
Finding #8 - Sanctuary - Informational
Description: The setBuybackWalletAddress() function incorrectly updatescharityWalletAddress
rather thanbuybackWalletAddress
.
Recommendation: The setBuybackWalletAddress() function should be modified to updatebuybackWalletAddress
rather thancharityWalletAddress
.
Contract Overview
Ownership Controls:
- The total supply of the token is set to 777.78 trillion $SANC [777,777,777,777,777].
- 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, there are 75 total token holders. The token allocation is as follows:
- 50% of the total supply has been sent to the 0x..dead address.
- 4.38% of the total supply is in Pancakeswap liquidity.
- Of that liquidity, 98.04% of the LP tokens are stored in a Pinksale token locking contract and will unlock on December 31st, 2023.
- The next five holders own a cumulative 13.72% of the total supply.
- The contract enforces a maximum transaction amount (determined by the owner) which imposes a limit to the number of tokens that can be transferred during a single transaction.
- The contract enforces a maximum wallet amount that prevents a transfer from occurring if the recipient's token balance will exceed the limit number of tokens (determined by the owner) after the transfer occurs. The team must ensure all created Pair addresses are properly excluded from this restriction.
- There is a Liquidity fee, Marketing fee, Development fee, Charity fee, and Buyback fee on all buys and sells via Pancakeswap 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 BNB for the purpose of funding Pancakeswap 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 Pancakeswap.
- 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 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, Development fee, Charity fee, and Buyback fee are swapped for BNB and sent to the team's Marketing wallet, Development wallet, Charity wallet, and Buyback wallet respectively.
- As the contract is deployed with Solidity v0.8.4, it is protected from overflows/underflows.
- The contract complies with the BEP-20 token standard.
- The owner can set the Liquidity fee, Marketing fee, Development fee, Charity fee, and Buyback fee for both the buy and sell fee structures to any percentage at any time.
- The owner can exclude and include accounts from transfer fees at any time.
- The owner can set the maximum transaction amount and maximum wallet amount to any values 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 the maximum wallet restriction 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, Development, and Charity fund allocations to any values at any time.
- The owner can set the Marketing wallet, Development wallet, and Charity wallet to any addresses 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 |
|
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 | N/A | PASS |
Improper Events | N/A | PASS |
Improper Authorization Scheme | N/A | PASS |
Integer Over/Underflow | N/A | PASS |
Logical Issues |
|
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
Function 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
- [Pub] getUnlockTime
- [Pub] getTime
- [Pub] lock #
- modifiers: onlyOwner
- [Pub] unlock #
+ [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] DOMAIN_SEPARATOR
- [Ext] PERMIT_TYPEHASH
- [Ext] nonces
- [Ext] permit #
- [Ext] MINIMUM_LIQUIDITY
- [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 #
+ Sanctuary (Context, IERC20, Ownable)
- [Pub] #
- [Pub] name
- [Pub] symbol
- [Pub] decimals
- [Pub] totalSupply
- [Pub] balanceOf
- [Pub] allowance
- [Pub] increaseAllowance #
- [Pub] decreaseAllowance #
- [Pub] minimumTokensBeforeSwapAmount
- [Pub] approve #
- [Prv] _approve #
- [Pub] setMarketPairStatus #
- modifiers: onlyOwner
- [Ext] setIsTxLimitExempt #
- modifiers: onlyOwner
- [Pub] setIsExcludedFromFee #
- modifiers: onlyOwner
- [Ext] setBuyTaxes #
- modifiers: onlyOwner
- [Ext] setSellTaxes #
- modifiers: onlyOwner
- [Ext] setDistributionSettings #
- modifiers: onlyOwner
- [Ext] setMaxTxAmount #
- modifiers: onlyOwner
- [Ext] enableDisableWalletLimit #
- modifiers: onlyOwner
- [Ext] setIsWalletLimitExempt #
- modifiers: onlyOwner
- [Ext] setWalletLimit #
- modifiers: onlyOwner
- [Ext] setNumTokensBeforeSwap #
- modifiers: onlyOwner
- [Ext] setMarketingWalletAddress #
- modifiers: onlyOwner
- [Ext] setDevelopmentWalletAddress #
- modifiers: onlyOwner
- [Ext] setCharityWalletAddress #
- modifiers: onlyOwner
- [Ext] setBuybackWalletAddress #
- 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 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.