Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.