Open eboadom opened 2 years ago
As expected, there is a slight increase in gas on the most common actions, mainly because of the added condition to skip updates whenever the timestamp didn't change.
At the same time, there are savings on flashLoan()
, as the tests involve multiple actions, and there is where savings are noticeable.
Before fix
After fix
Changes
updateState()
ofReserveLogic
, add a condition to not do any update if the timestamp has not changed since the last stored on the reserve's data. This is not related to the 100% RF problem, but it simplifies reasoning about this part of the core code and saves important gas on actions happening in the same block._updateIndexes
ofReserveLogic
, split the 2 update conditions of supply/variable borrow indexes, this way covering the case of 100% RF, on which borrow variable index should be updated (if there is borrow variable debt). The change tries to keep the diff to the minimumTests
_updateIndexes
covers exactly the same cases as before, just adding also one when(currentLiquidityRate == 0)
and(scaledVariableDebt > 0)
, which is exactly the one of 100% RF in a reserve. Because of this a new https://github.com/aave/protocol-v2/blob/bf82b9f5287860786ca50c8ccfcb0ff5f6ddef87/test-suites/test-aave/reserve-factor.spec.ts file has been added, testing the case for both when variable and stable debt exists.