In the updateTokens function of the Rebalancing contract, there is a potential out-of-bounds error when calculating the dustValue for each token. The current implementation assumes a direct correspondence between the _tokens array and the rebalanceData._sellAmounts array, which may not always be the case.
Code -
for (uint256 i; i < tokenLength; i++) {
address _portfolioToken = _tokens[i];
if (tokensMapping[_portfolioToken]) {
uint256 dustValue = (rebalanceData._sellAmounts[i] *
protocolConfig.allowedDustTolerance()) / TOTAL_WEIGHT;
if (_getTokenBalanceOf(_portfolioToken, _vault) > dustValue)
revert ErrorLibrary.BalanceOfVaultShouldNotExceedDust();
}
delete tokensMapping[_portfolioToken];
}
In the
updateTokens
function of theRebalancing
contract, there is a potential out-of-bounds error when calculating thedustValue
for each token. The current implementation assumes a direct correspondence between the_tokens
array and therebalanceData._sellAmounts
array, which may not always be the case.Code -