You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update the reserve indexes (liquidity and/or variable borrow) since the last action on the pool. This currently includes also the update of reserve.lastUpdateTimestamp.
Accrue "reserve factor" to the collector, via _accrueToTreasury().
Even if this works properly, there are 2 aspects that could be improved:
On the same block (timestamp) and actions affecting the same reserve, currently there are unnecessary updates of the indexes and lastUpdateTimestamp, writing the same values over and over. This can be improved by checking that the lastUpdateTimestamp is different from block.timestamp, as it should be an invariant of the system that, if time doesn't pass, indexes remain the same in what concerns borrow/deposit dynamics.
Given that it should not be the responsibility of the _updateIndexes() to also update the lastUpdateTimestamp, better to move it to updateState() too.
_updateIndexes() also includes initial loading of the reserveCache, specifically for reserveCache.nextLiquidityIndex and reserveCache.nextVariableBorrowIndex on https://github.com/aave/aave-v3-core/blob/master/contracts/protocol/libraries/logic/ReserveLogic.sol#L286. Even if this currently works properly, it does because always the calls to cache() strictly precede updateState(), but there is not really any assurance of that. It is probably better to move that cache setup away from _updateIndexes() to cache()
The text was updated successfully, but these errors were encountered:
Currently, the
updateState()
function onReserveLogic
https://github.com/aave/aave-v3-core/blob/master/contracts/protocol/libraries/logic/ReserveLogic.sol#L97 has 2 responsibilities:reserve.lastUpdateTimestamp
._accrueToTreasury()
.Even if this works properly, there are 2 aspects that could be improved:
lastUpdateTimestamp
is different fromblock.timestamp
, as it should be an invariant of the system that, if time doesn't pass, indexes remain the same in what concerns borrow/deposit dynamics.Given that it should not be the responsibility of the
_updateIndexes()
to also update thelastUpdateTimestamp
, better to move it toupdateState()
too._updateIndexes()
also includes initial loading of thereserveCache
, specifically forreserveCache.nextLiquidityIndex
andreserveCache.nextVariableBorrowIndex
on https://github.com/aave/aave-v3-core/blob/master/contracts/protocol/libraries/logic/ReserveLogic.sol#L286. Even if this currently works properly, it does because always the calls tocache()
strictly precedeupdateState()
, but there is not really any assurance of that. It is probably better to move that cache setup away from_updateIndexes()
tocache()
The text was updated successfully, but these errors were encountered: