Leverage operations of ETH market change debt, but do not accrue linked BB markets, corrupting their interest rate accrual logic
Summary
BBLeverage of ETH market calls accrue before changing the debt with buyCollateral() or sellCollateral(), but doesn't invoke penrose.reAccrueBigBangMarkets(). It will corrupt the interest rate logic of the linked BB markets.
Vulnerability Detail
BB markets have interest rate logic linked to the utilization of the main ETH market. That's why the accrual needs to be performed for them each time ETH market debt changes (they might have the rate changed due to that and the accrual with old rate needs to be reflected in their accounting). It's not done in ETH market BBLeverage buyCollateral() and sellCollateral().
Impact
Linked markets will have the interest rate accrued incorrectly, namely old rate will be used for a longer period that it has to be according to the system logic. The period between ETH market debt change to the next accrual operation will have old rate in the linked BB markets, while it has to be new rate already. It will be a loss for lenders or borrowers depending on the direction of the change.
Likelihood: Medium + Impact: High = Severity: High.
Code Snippet
solvent modifier calls accrue operation only for the current market:
/// @dev Checks if the user is solvent in the closed liquidation case at the end of the function body.
modifier solvent(address from, bool liquidation) {
updateExchangeRate();
>> _accrue();
_;
require(_isSolvent(from, exchangeRate, liquidation), "Market: insolvent");
}
This way the issue of not updating the linked markets on accrual, while being fixed for borrow/repay and liquidations, is still in place for BBLeverage:
hyh
high
Leverage operations of ETH market change debt, but do not accrue linked BB markets, corrupting their interest rate accrual logic
Summary
BBLeverage of ETH market calls accrue before changing the debt with
buyCollateral()
orsellCollateral()
, but doesn't invokepenrose.reAccrueBigBangMarkets()
. It will corrupt the interest rate logic of the linked BB markets.Vulnerability Detail
BB markets have interest rate logic linked to the utilization of the main ETH market. That's why the accrual needs to be performed for them each time ETH market debt changes (they might have the rate changed due to that and the accrual with old rate needs to be reflected in their accounting). It's not done in ETH market BBLeverage
buyCollateral()
andsellCollateral()
.Impact
Linked markets will have the interest rate accrued incorrectly, namely old rate will be used for a longer period that it has to be according to the system logic. The period between ETH market debt change to the next accrual operation will have old rate in the linked BB markets, while it has to be new rate already. It will be a loss for lenders or borrowers depending on the direction of the change.
Likelihood: Medium + Impact: High = Severity: High.
Code Snippet
solvent
modifier calls accrue operation only for the current market:https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/Market.sol#L162-L170
This way the issue of not updating the linked markets on accrual, while being fixed for borrow/repay and liquidations, is still in place for BBLeverage:
https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/bigBang/BBLeverage.sol#L53-L91
https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/bigBang/BBLeverage.sol#L126-L161
Tool used
Manual Review
Recommendation
Consider calling the linked markets update, e.g.:
https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/bigBang/BBLeverage.sol#L53-L62
https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/bigBang/BBLeverage.sol#L126-L137
Duplicate of #128