DeFiHardhat
12,000 USDC
View results
Submission Details
Severity: low
Invalid

The input arrays in `ConstantProduct2::calcReserveAtRatioLiquidity` are never checked

Summary

The input arrays in ConstantProduct2::calcReserveAtRatioLiquidity are never checked. This can can lead to weird situation.

Vulnerability Details

The input arrays are never checked. If the reserves.length != ratios.length != 2 then the whole uint256 i = j == 1 ? 0 : 1; can have unexpected results.

Impact

Impact is high because these numbers are a central piece of the constant product calculation.

Likelihood is extremely low.

Overall the impact is low.

Tools Used

Manual review

Recommendations

Perform the following changes:

function calcReserveAtRatioLiquidity(
uint256[] calldata reserves,
uint256 j,
uint256[] calldata ratios,
bytes calldata
) external pure override returns (uint256 reserve) {
++ require(reserves.length == 2 && ratios.length == 2, "Invalid arrays");
uint256 i = j == 1 ? 0 : 1;
reserve = reserves[i] * ratios[j] / ratios[i];
}
Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Informational/Invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.