generated from AngleProtocol/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: revert if zero amount for GenericHarvester
- Loading branch information
1 parent
08d8a28
commit e7fd84f
Showing
2 changed files
with
18 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,22 +108,19 @@ contract GenericHarvester is BaseHarvester, IERC3156FlashBorrower, RouterSwapper | |
YieldBearingParams memory yieldBearingInfo = yieldBearingData[yieldBearingAsset]; | ||
(uint8 increase, uint256 amount) = _computeRebalanceAmount(yieldBearingAsset, yieldBearingInfo); | ||
amount = (amount * scale) / 1e9; | ||
if (amount == 0) revert ZeroAmount(); | ||
|
||
(SwapType swapType, bytes memory data) = abi.decode(extraData, (SwapType, bytes)); | ||
|
||
if (amount > 0) { | ||
try transmuter.updateOracle(yieldBearingInfo.asset) {} catch {} | ||
|
||
adjustYieldExposure( | ||
amount, | ||
increase, | ||
yieldBearingAsset, | ||
yieldBearingInfo.asset, | ||
(amount * (1e9 - maxSlippage)) / 1e9, | ||
swapType, | ||
data | ||
); | ||
} | ||
try transmuter.updateOracle(yieldBearingInfo.asset) {} catch {} | ||
adjustYieldExposure( | ||
amount, | ||
increase, | ||
yieldBearingAsset, | ||
yieldBearingInfo.asset, | ||
(amount * (1e9 - maxSlippage)) / 1e9, | ||
swapType, | ||
data | ||
); | ||
} | ||
Check warning Code scanning / Slither Divide before multiply Medium
GenericHarvester.harvest(address,uint256,bytes) performs a multiplication on the result of a division:
- amount = (amount * scale) / 1e9 - adjustYieldExposure(amount,increase,yieldBearingAsset,yieldBearingInfo.asset,(amount * (1e9 - maxSlippage)) / 1e9,swapType,data) |
||
|
||
/// @notice Burns `amountStablecoins` for one yieldBearing asset, swap for asset then mints deposit tokens | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters