Closed code423n4 closed 1 year ago
thanks
This describes both how the issue hasn't been mitigated, and a new issue. As a new issue it is a duplicate of #71, which is submitted as a new issue.
Picodes marked the issue as satisfactory
Picodes marked the issue as duplicate of #71
Picodes changed the severity to QA (Quality Assurance)
This previously downgraded issue has been upgraded by Picodes
MITIGATION IS NOT CONFIRMED
MITIGATION IS NOT CONFIRMED
Mitigation of M-01: Issue not mitigated
Link to Issue: https://github.com/code-423n4/2023-03-asymmetry-findings/issues/1078
Comments
While the "division before multiplication" issues described in M-01 have been mitigated in the proposed changeset, there are other cases which should be addressed too.
Technical Details
SafEth::stake
the calculation ofpreDepositPrice
(now present in the functionapproxPrice()
) multipliesunderlyingValue
by 1e18, butunderlyingValue
is first divided by 1e18:https://github.com/asymmetryfinance/smart-contracts/blob/fixMath/contracts/SafEth/SafEth.sol#L356-L370
SafEth::stake
, something similar happens withtotalStakeValueEth
, as this is the sum ofderivativeReceivedEthValue
that is divided by 1e18, but thentotalStakeValueEth
is multiplied by 1e18 in the calculation ofmintAmount
:https://github.com/asymmetryfinance/smart-contracts/blob/fixMath/contracts/SafEth/SafEth.sol#L97-L114
Reth::deposit
,rethPerEth
is calculated as(1e36) / ethPerDerivative()
but thenrethPerEth
is used in theminOut
calculation that ends dividing again by 1e36. The expression can be simplified to avoid any division before multiplication. The same applies toidealOut
:https://github.com/asymmetryfinance/smart-contracts/blob/fixMath/contracts/SafEth/derivatives/Reth.sol#L148-L151
Recommendation
Fix these other cases of "division before multiplication". In most of these, the expressions can be simplified as there is a division that is later multiplied by the same number.