Venus - Swap Router

CertiKFiles named in the report

Audit

Part of CertiK’s series

CertiK reviewed Venus Protocol (Venus - Swap Router) on 22 May 2023: 14 findings, 1 critical; 13 marked fixed, 1 open.

1 critical finding, fixed
Open the reportOpen Venus Protocol’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings14

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical001
High100
Medium000
Low0012
CriticalIncorrect Fee Amount Will Cause All Swaps To FailFixed

The `PancakeLibrary` is used to interact with pairs created through the `PancakeRouter v2` (See [0x10ed43c718714eb63d5aa57b78b54704e256024e](https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e#code) for deployed code). In `v1` the fee was $0.2\%$, however, the fees were changed in `v2` to be $0.25\%$. The logic here assumes that the fee is only $0.2\%$, when in fact a $0.25\%$ fee will be taken. This means that the calculated `amountIn` will be less than the amount needed and the `amountOut` will be greater than the amount that can be received, causing the constant product to not be preserved and reverting the transaction.

Low`Natspec` Comments Missing ParametersFixed

The `natspec` comments of many functions cited above are missing the parameter `deadline`. The `natspec` comment for the function `sweepToken()`, is missing the parameter `to`.

LowCan Use `safeTransfer()`Fixed

When transferring `WBNB` the call is checked to be successful via an assert statement. However, the `TransferHelper` library's functions can be used in place of this.

LowCan Use Single Address InputFixed

The functions `_checkForAmountOut()` and `_getSwapAmount()` have an input array of addresses `path`, however, only the last element is used. A single address can instead be taken as input to reduce gas costs. In addition, the last element of the path `path[path.length - 1]` is used multiple times in functions, storing this in a temporary variable and referencing the temporary variable can save gas.

LowComments For Functions Supporting FeeFixed

The comments above some of the functions that support fee on transfer tokens in the contract `SwapRouter` do not mention how it is intended to be used for fee on transfer tokens.

LowCustom Errors Can Be UsedFixed

Custom Errors are used throughout the codebase, however, string errors are still used in the codebase.

LowIncomplete CheckFixed

The following check is performed in the function `getAmountIn()` and `getAmountOut()`: ```solidity if (reserveIn == 0 && reserveOut == 0) { revert InsufficientLiquidity(); } ``` However, this check does not cover the case when either `reserveIn` or `reserveOut` is 0, while the other is nonzero.

LowIncorrect CommentFixed

The comment above `sweepToken` states that tokens are sent to admin (timelock). However, the tokens are sent to the input `to` address, which may not be the admin.

LowInefficient ChecksFixed

The following two checks are performed: ```solidity require(reserveA > 0 && reserveB > 0, "PancakeLibrary: INSUFFICIENT_LIQUIDITY"); ``` which will revert if `reserveA` or `reserveB` is zero. ```solidity if (reserveA == 0 && reserveB == 0) { revert InsufficientLiquidity(); } ``` which will revert if `reserveA` and `reserveB` are zero. Thus this check is not needed as the require statement covers it.

LowMissing ChecksFixed

It is checked that the input `vTokenAddress` is listed, however, there is no check that the final element of the input `path` is the underlying of the `vToken`. As approval is given for the last element of the input `path` to either repay or supply, it should be checked that it corresponds to the underlying of the `vToken`. It is not checked that the input `vBNBAddress` is listed. It should be checked that this is a listed market, or alternatively, the input can be removed and the address stored by the contract itself.

Show 3 more
LowMissing Zero Address ValidationFixed

In the `constructor()`, the input `_comptrollerAddress` is not checked if it is the zero address.

LowPotential Reentrancy (Out-of-Order Events)Fixed

A reentrancy attack can occur when the contract creates a function that makes an external call to another untrusted contract before resolving any effects. If the attacker can control the untrusted contract, they can make a recursive call back to the original function, repeating interactions that would have otherwise not run after the external call resolved the effects. * Reentrancy can occur during the swaps as they will make external calls to the receiver of the tokens, this will cause the corresponding swap events to be emitted out of order. * If a token implements hooks that make external calls, then reentrancy can also occur during token transfers, which may cause events to be emitted out of order. * Token addresses are also provided as inputs, so that it is possible that a token is provided that can cause reentrancy with any external call made to it (for example if `balanceOf`), which may cause events to be emitted out of order. *This finding is considered minor because the reentrancy only causes out-of-order events.*

LowUnchecked Blocks Can Optimize ContractFixed

In general, the counter in a for loop can be incremented or decremented in an unchecked block.

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (13)

  • contracts/Swap/interfaces/IPancakeSwapV2Factory.sol
  • contracts/Swap/RouterHelper.sol
  • contracts/Swap/interfaces/IVBNB.sol
  • contracts/Swap/interfaces/IPancakeSwapV2Router.sol
  • contracts/Swap/interfaces/IPancakePair.sol
  • contracts/Swap/interfaces/IWBNB.sol
  • contracts/Swap/SwapRouter.sol
  • contracts/Swap/interfaces/InterfaceComptroller.sol
  • contracts/Swap/interfaces/CustomErrors.sol
  • contracts/Swap/lib/PancakeLibrary.sol
  • contracts/Swap/interfaces/IVtoken.sol
  • contracts/Swap/lib/TransferHelper.sol
  • contracts/Swap/IRouterHelper.sol

Part of Venus Protocol’s security record

Venus Protocol
Audits67 audits by 7 firmsLast audit Sep 2025, by Quantstamp.
Critical findingsNo open critical findingsAcross the 67 reports, 4 critical findings were reported. Each is marked fixed by the firm that reported it.
IncidentIncident 12 May 2022Source: De.Fi incident database.
Open Venus Protocol’s security record

Security firm

CertiK

1,045 projects reviewed · 1,376 reports · latest May 2025

See CertiK’s audits

Something wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.

Tell us