Part of CertiK’s series
CertiK reviewed Venus Protocol (Venus - VAI Peg) on 24 May 2023: 14 findings, 1 critical; 12 marked fixed, 2 open.
Report hosted on skynet.certik.com.
Trustblock does not review code.
Statuses are the security firm’s own, from its report.
| Severity | Open | Acknowledged | Fixed |
|---|---|---|---|
| Critical | 0 | 0 | 1 |
| High | 2 | 0 | 0 |
| Medium | 0 | 0 | 2 |
| Low | 0 | 0 | 9 |
In the function `swapVAIForStable()`, `safeTransferFrom()` is used to transfer the `stableTknAmountUSD` from `address(this)` to the `receiver`. However, the contract does not give approval to itself, so that this will cause a revert preventing `swapVAIForStable()` from being called successfully.
The function `swapVAIForStable()` is supposed to swap VAI for the input `stableTknAmount` of stable Token. However, it swaps VAI for the `stableTknAmountUSD` instead. This does not meet the specification outlined in this proposal: [https://community.venus.io/t/proposal-deploy-the-vai-peg-stability-module-and-supply-liquidity-to-pancakeswap-for-the-vai-usdt-pair/3461](https://community.venus.io/t/proposal-deploy-the-vai-peg-stability-module-and-supply-liquidity-to-pancakeswap-for-the-vai-usdt-pair/3461).
When VAI is swapped for stable tokens, if `vaiMinted` is zero it will burn VAI that has been borrowed. This can cause the total amount of VAI in circulation to be less than the amount of VAI borrowed, which can make it impossible to repay or liquidate all the borrows. Note that this is possible because if USDT is over peg more VAI is burned than USDT is transferred out and if USDT is under peg less VAI is minted than USDT is transferred in.
Contract `PegStability` extends ReentrancyGuardUpgradeable, while `__ReentrancyGuard_init()` is not called in the initialize function. Generally, the initializer function of an upgradeable contract should always call all the initializer functions of the contracts that it extends.
Note that on BSC all tokens USDT, USDC, and VAI have 18 decimals so there is no issue with the logic. However, if stable tokens with other decimals are used, then the logic must be adjusted to account for the difference in decimals.
Boolean constants can be used directly and do not need to be compared to true or false. ```solidity=85 require(isPaused == false, "Contract is paused."); ``` --- ```solidity=247 require(isPaused == false, "PSM is already paused."); ``` --- ```solidity=259 require(isPaused == true, "PSM is not paused."); ```
The input `feeIn_` and `feeOut_` of `initialize()` function are not checked to be less than `1000`.
In the function `setPriceOracle()`, the `oldPriceOracleAddress` is set to be the input `priceOracle_`. However, it should be the current `priceOracle`.
The event `VaiMintCapChanged` uses the storage variable `vaiMintCap`. However, gas can be saved by using `vaiMintCap_`.
As VAI can also be minted by borrowing against assets, there is more VAI in circulation than the value stored in `vaiMinted`. If a user attempts to call `swapVAIForStable()` so that the `stableTknAmountUSD` is greater than `vaiMinted` and `vaiMinted` is nonzero, then the call will revert with a non-descriptive error.
In the function `swapVAIForStable`, "enough" is misspelled as "enought". The error message "Amount must be greater than zero" does not use a period as all other error messages do.
In the function `swapStableForVAI`, the check ```solidity require(vaiMinted + actualTransferAmtInUSD <= vaiMintCap, "VAI mint cap reached."); ```` is preformed before incrementing `vaiMinted` by the `actualTransferAmtInUSD`. As the check adds `vaiMinted` and `actualTransferAmtInUSD` it already checks for overflow. Thus it does not need to be checked when incrementing.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (1)
1,045 projects reviewed · 1,376 reports · latest May 2025
See CertiK’s auditsSomething 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