Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Conversation

@kyzia551
Copy link
Collaborator

This PR removes one operation in the balance/debt increase-related calculations. Also because of this opt it's no need to use AccrueToTreasuryLocalVars on the _accrueToTreasury function

uint256 balanceIncrease = scaledBalance.rayMul(index) -
scaledBalance.rayMul(_userState[onBehalfOf].additionalData);

uint256 balanceIncrease = scaledBalance.rayMul(index - _userState[onBehalfOf].additionalData);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is not exactly equivalent to the other because of math rounding and precision. We should stick to the original approach

reserveCache.nextVariableBorrowIndex
// calculate the total variable debt increase after the moment of the last interaction
uint256 variableDebtIncrease = reserveCache.currScaledVariableDebt.rayMul(
reserveCache.nextVariableBorrowIndex - reserveCache.currVariableBorrowIndex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants