REVIVE
Smart Contract Audit Report
Audit Summary
REVIVE is a new BEP-20 token on the Binance Smart Chain that can be minted in exchange for BNB and BUSD-T.
For this audit, we reviewed the project team's REVIVE contract at 0xba440ff0ab6123446bdddc2f24b53b7d5a900f6d and FeeRecipient contract at 0x2cce1e61336a524412acee1b48415b52b5d303ac on the Binance Smart Chain Mainnet.
Audit Findings
Informational findings were identified and the team may want to review them.
Date: March 24th, 2023.
Updated: March 30th, 2023 to reflect the FeeRecipient contract's newly deployed Mainnet address.
Updated: April 5th, 2023 to reflect the FeeRecipient contract's newly deployed Mainnet address.Finding #1 - FeeRecipient - High (Resolved)
Description: The token swapping functionality in the trigger() function can be manipulated through the use of flash loans.
Risk/Impact: Flash loans can be utilized by malicious users to manipulate the BUSD-T to BNB or Safuu to BNB liquidity pair ratios, to reduce the number of tokens that the contract will receive after the swap(s) are executed.
Recommendation: The team should implement a Time Weighted Average Price Oracle (TWAP) or use Chainlink for pricing to mitigate potential manipulation. Alternatively, the team could restrict the function to only be called by the contract's owner and add two additional parameters to the trigger() function, allowing the team to specify minimum output amount values to use during the token swaps.
Resolution: The team has restricted the trigger() function to only be called by the Revive contract owner or the Treasury address.
Finding #2 - REVIVE - Informational
Description: The following require statement in the transferIn() function is redundant since it was already verified in the _mintWithBacking() function that the user has a sufficient balance to support the transaction.
Recommendation: The above require statement in the transferIn() function could be removed for additional gas savings on each call.function _mintWithBacking(uint256 numBUSD, address recipient) internal returns (uint256) { require(userTokenBalance > 0 && numBUSD <= userTokenBalance, 'Insufficient Balance'); uint256 received = _transferIn(address(underlying), numBUSD); ... function _transferIn(address token, uint256 desiredAmount) internal returns (uint256) { require(IERC20(token).balanceOf(msg.sender) >= desiredAmount, 'Insufficient Balance');
Finding #3 - REVIVE - Informational
Description: Although the SafeMath library is utilized, the contract is deployed with Solidity v0.8.14 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.
Contracts Overview
REVIVE Contract:
- As the contracts are implemented with Solidity v0.8.0, they are safe from any possible overflows/underflows.
FeeRecipient Contract:
- The total supply of the token is currently 30.683 $REVIVE.
- At the time of writing this report, 100% of the total supply belongs to the owner.
- Any user can execute a native mint transaction by providing an amount of BNB and specifying a recipient address and a minimum out value.
- The contract's full BNB balance will be swapped for BUSD-T and sent back to this contract.
- A number of REVIVE tokens will be minted to the recipient based on the ratio of the number of exchanged BUSD-T to the total amount of BUSD-T in the contract.
- A Mint fee will be charged and a percentage of the collected tokens is minted to the FeeRecipient address.
- A native mint transaction is automatically triggered on behalf of the caller when any BNB is sent directly to the contract.
- Any user can initiate a BUSD-T mint transaction by specifying an amount of BUSD-T to send to the contract and a recipient address.
- A number of REVIVE tokens will be minted to the recipient based on the ratio of the amount of provided BUSD-T to the full BUSD-T balance of the contract.
- The Mint fee will be charged and a percentage of the collected tokens is minted to the FeeRecipient address.
- Any user can initiate a sell transaction by specifying a number of REVIVE tokens to exchange for BUSD-T.
- A Sell fee will be charged and a percentage of the collected tokens is minted to the FeeRecipient address.
- The amount of BUSD-T sent to the caller is based on the current price of the token.
- The specified number of REVIVE tokens are burned and the BUSD-T is sent to the user's wallet address.
- Users can elect to have the received BUSD-T sent to a specified recipient address on sells.
- There is a Transfer fee charged on all token transfers.
- The tokens collected through the fee are removed from the total supply.
- A percentage of the number of tokens collected through the fee is minted to the team's FeeRecipient address.
- The ratio of the number of BUSD-T in this contract to the REVIVE token total supply must increase in order for transfers, sells, mints, and burns to successfully occur.
- Any user can burn their own tokens to reduce the total supply. A percentage of the number of burned tokens is minted to the FeeRecipient address.
- If any REVIVE tokens are currently in the contract, they are automatically burned and a percentage of the number of burned tokens is minted to the Fee Receiver address on all mint transactions.
- The contract utilizes ReentrancyGuard to prevent reentrancy attacks in applicable functions.
- As the contract is deployed with Solidity v0.8.14, it is safe from any possible overflows/underflows.
- The owner can enable/disable all mint transactions at any time.
- The owner can set the Mint fee, Transfer fee, Contract fee, and Sell fee to any values up to 10% each at any time.
- The owner can include and exclude accounts from fees at any time.
- The owner can withdraw any tokens besides BUSD-T from the contract at any time.
- The owner can update the Router address at any time.
- The Fee Recipient Setter address can update the FeeRecipient address at any time.
- The Fee Recipient Setter address can set the percentage of tokens minted to the FeeRecipient address at any time.
- The Revive contract owner or Treasury address can trigger this contract's token swapping functionality as long as the contract's $Revive token balance is greater than ~zero.
- A sell transaction is triggered in the REVIVE contract for this contract's full REVIVE token balance.
- One-third of the contract's BUSD-T balance is swapped for BNB.
- The contract's full BNB balance is sent to the Apollo contract.
- The contract's full BUSD-T balance is transferred to the Treasury address.
- The contract's full Apollo balance is transferred to the Treasury address.
- The owner can withdraw any tokens or BNB from the contract at any time.
Audit Results
Vulnerability Category | Notes | Result |
---|---|---|
Arbitrary Jump/Storage Write | N/A | PASS |
Centralization of Control | N/A | 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 |
REVIVE Contract
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [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 #
+ [Int] IUniswapV2Factory
- [Ext] feeTo
- [Ext] feeToSetter
- [Ext] getPair
- [Ext] allPairs
- [Ext] allPairsLength
- [Ext] createPair #
- [Ext] setFeeTo #
- [Ext] setFeeToSetter #
+ [Lib] SafeMath
- [Int] add
- [Int] sub
- [Int] sub
- [Int] mul
- [Int] div
- [Int] div
- [Int] mod
- [Int] mod
+ [Int] IERC20
- [Ext] totalSupply
- [Ext] symbol
- [Ext] name
- [Ext] balanceOf
- [Ext] decimals
- [Ext] transfer #
- [Ext] allowance
- [Ext] approve #
- [Ext] transferFrom #
+ ReentrancyGuard
- [Pub] #
+ Ownable
- [Pub] #
- [Pub] changeOwner #
- modifiers: onlyOwner
- [Ext] getOwner
+ [Int] XUSDRoyalty
- [Ext] getFee
- [Ext] getFeeRecipient
+ REVIVE (IERC20, Ownable, ReentrancyGuard)
- [Pub] #
- [Ext] totalSupply
- [Pub] balanceOf
- [Ext] allowance
- [Pub] name
- [Pub] symbol
- [Pub] decimals
- [Pub] approve #
- [Ext] transfer #
- modifiers: nonReentrant
- [Ext] transferFrom #
- modifiers: nonReentrant
- [Int] _transferFrom #
- [Ext] mintWithNative ($)
- [Ext] mintWithBacking #
- modifiers: nonReentrant
- [Ext] sell #
- modifiers: nonReentrant
- [Ext] sell #
- modifiers: nonReentrant
- [Ext] burn #
- modifiers: nonReentrant
- [Int] _mintWithNative #
- modifiers: nonReentrant
- [Int] _mintWithBacking #
- [Int] _sell #
- [Int] _mintTo #
- [Int] _takeFee #
- [Int] _purchaseBUSD #
- [Int] _requirePriceRises #
- [Int] _transferIn #
- [Int] _mint #
- [Int] _burn #
- [Int] _checkGarbageCollector #
- [Ext] calculatePrice
- [Int] _calculatePrice
- [Pub] tokensToMint
- [Pub] mintFeeTaken
- [Pub] amountOut
- [Pub] getValueOfHoldings
- [Ext] viewAllPriceChanges
- [Ext] numPricePoints
- [Ext] viewPricePoints
- [Ext] viewSelectPricePoints
- [Ext] activateToken #
- modifiers: onlyOwner
- [Ext] deActivateToken #
- modifiers: onlyOwner
- [Ext] upgradeRouter #
- modifiers: onlyOwner
- [Ext] withdrawNonStableToken #
- modifiers: onlyOwner
- [Ext] setFees #
- modifiers: onlyOwner
- [Ext] setPermissions #
- modifiers: onlyOwner
- [Ext] setFeeRecipientSetter #
- [Ext] setFeeRecipient #
- [Ext] setFeeRecipientPercentage #
- [Ext] ($)
FeeRecipient Contract
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [Int] IERC20
- [Ext] totalSupply
- [Ext] symbol
- [Ext] name
- [Ext] balanceOf
- [Ext] decimals
- [Ext] transfer #
- [Ext] allowance
- [Ext] approve #
- [Ext] transferFrom #
+ [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 #
+ [Int] IUniswapV2Factory
- [Ext] feeTo
- [Ext] feeToSetter
- [Ext] getPair
- [Ext] allPairs
- [Ext] allPairsLength
- [Ext] createPair #
- [Ext] setFeeTo #
- [Ext] setFeeToSetter #
+ [Int] IStable
- [Ext] sell #
- [Ext] getOwner
+ FeeRecipient
- [Pub] #
- [Ext] trigger #
- [Ext] withdraw #
- modifiers: onlyOwner
- [Ext] withdrawETH #
- modifiers: onlyOwner
- [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.