_debtToMint() will return 0 decimals amounts and sqthToSell in depositAuction() will be insignificant, leading to ignoring the market orders used and depositing auction to be void as no external funding will be brought in.
Vulnerability Detail
feeAdjustment = _calcFeeAdjustment() is (squeethEthPrice * feeRate) / 10000 and have 18 decimals.
wSqueethToMint = (_amount * debt) / (collateral + (debt * feeAdjustment)) will have 36 decimals in numerator and the same 36 in denominator, yielding 0 decimals figure. That figure is sqthToSell, so no market buying orders will be ever filled.
Impact
depositAuction() will malfunction all the time, either reverting or producing less WETH and less CRAB than desired, i.e. there will be no deposit auction as market order part is needed to bring in the liquidity to be distributed.
Setting the severity to be high as this is system malfunction with material impact and no prerequisites.
Code Snippet
feeAdjustment is treated as if it has no decimals:
hyh
high
debtToMint incorrectly treats feeAdjustment decimals
Summary
_debtToMint() will return
0
decimals amounts andsqthToSell
in depositAuction() will be insignificant, leading to ignoring the market orders used and depositing auction to be void as no external funding will be brought in.Vulnerability Detail
feeAdjustment = _calcFeeAdjustment()
is(squeethEthPrice * feeRate) / 10000
and have18
decimals.wSqueethToMint = (_amount * debt) / (collateral + (debt * feeAdjustment))
will have36
decimals in numerator and the same36
in denominator, yielding0
decimals figure. That figure issqthToSell
, so no market buying orders will be ever filled.Impact
depositAuction() will malfunction all the time, either reverting or producing less WETH and less CRAB than desired, i.e. there will be no deposit auction as market order part is needed to bring in the liquidity to be distributed.
Setting the severity to be high as this is system malfunction with material impact and no prerequisites.
Code Snippet
feeAdjustment is treated as if it has no decimals:
https://github.com/sherlock-audit/2022-11-opyn/blob/main/crab-netting/src/CrabNetting.sol#L476-L485
while it has 18 decimals:
https://github.com/sherlock-audit/2022-11-opyn/blob/main/crab-netting/src/CrabNetting.sol#L795-L800
As
sqthToSell
to be insignificant, there will be no Squeeth selling at all:https://github.com/sherlock-audit/2022-11-opyn/blob/main/crab-netting/src/CrabNetting.sol#L491-L504
This renders sqth buying orders block void, i.e. it will be always
_p.orders[0].quantity >= remainingToSell
:https://github.com/sherlock-audit/2022-11-opyn/blob/main/crab-netting/src/CrabNetting.sol#L504-L524
Tool used
Manual Review
Recommendation
Consider adding decimals treatment, for example:
https://github.com/sherlock-audit/2022-11-opyn/blob/main/crab-netting/src/CrabNetting.sol#L476-L485