code-423n4 / 2021-09-yaxis-findings

0 stars 0 forks source link

Unnecessary `balanceOfWant() > 0` #141

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

0xsanson

Vulnerability details

Impact

During the _harvest function in NativeStrategyCurve3Crv.sol, there's a call to _deposit() only if (balanceOfWant() > 0). This if-statement can be removed since _deposit calculates again balanceOfWant() and makes the same check. This way the function saves a .balanceOf call.

Proof of Concept

https://github.com/code-423n4/2021-09-yaxis/blob/main/contracts/v3/strategies/NativeStrategyCurve3Crv.sol#L123

Tools Used

editor

GalloDaSballo commented 2 years ago

Redundant call to balanceOfWant() Sponsor mitigated