Lucene search

K
code423n4Code4renaCODE423N4:2023-05-VENUS-FINDINGS-ISSUES-430
HistoryMay 15, 2023 - 12:00 a.m.

Wrong blocksPerYear in WhitePaperInterestRateModel

2023-05-1500:00:00
Code4rena
github.com
3
vulnerability
ethereum
whitepaperinterestratemodel
bnb chain
basejumpratemodelv2

Lines of code
<https://github.com/code-423n4/2023-05-venus/blob/main/contracts/BaseJumpRateModelV2.sol#L23&gt;

Vulnerability details

Impact

Venus is deployed on BNB Chain instead of Ethereum. Their block times are different. And WhitePaperInterestRateModel.sol is modified from compound. Therefore, blocksPerYear should be modified or Venus would get the wrong rate when using WhitePaperInterestRateModel

Proof of Concept

WhitePaperInterestRateModel.sol set blocksPerYear to 2102400.
<https://github.com/code-423n4/2023-05-venus/blob/main/contracts/WhitePaperInterestRateModel.sol#L17&gt;

    /**
     * @notice The approximate number of blocks per year that is assumed by the interest rate model
     */
    uint256 public constant blocksPerYear = 2102400;

Which is the same in compound.
<https://github.com/compound-finance/compound-protocol/blob/master/contracts/WhitePaperInterestRateModel.sol#L19&gt;

    /**
     * @notice The approximate number of blocks per year that is assumed by the interest rate model
     */
    uint public constant blocksPerYear = 2102400;

However, BNB Chain has the different block time from Ethereum. BaseJumpRateModelV2.sol has the correct blocksPerYear.
<https://github.com/code-423n4/2023-05-venus/blob/main/contracts/BaseJumpRateModelV2.sol#L23&gt;

    /**
     * @notice The approximate number of blocks per year that is assumed by the interest rate model
     */
    uint256 public constant blocksPerYear = 10512000;

Tools Used

Manual Review

Recommended Mitigation Steps

Fix the blocksPerYear in WhitePaperInterestRateModel.sol

    /**
     * @notice The approximate number of blocks per year that is assumed by the interest rate model
     */
    uint256 public constant blocksPerYear = 10512000; // use 10512000 instead of 2102400 when deployed on BNB Chain

Assessed type

Context


The text was updated successfully, but these errors were encountered:

All reactions