Lucene search

K
code423n4Code4renaCODE423N4:2023-05-ASYMMETRY-MITIGATION-FINDINGS-ISSUES-65
HistoryMay 08, 2023 - 12:00 a.m.

Mitigation of M-11: Issue NOT mitigated

2023-05-0800:00:00
Code4rena
github.com
4
residual eth
unutilized
rounding losses
safeth.sol
mitigation
stake()
rebalance
dust
protocol loss
unstake()

Mitigated issue

M-11: Residual ETH unreachable and unuitilized in SafEth.sol

The issue was that the rounding losses from partitioning msg.value in stake() and rebalanceToWeights() was left irretrievably in the contract.

Mitigation review

Previously rebalanceToWeights() withdrew all staked funds and redeposited only the ether that the contract received. Now, it redeposits its entire balance. As such, the rounding losses still remain in the contract after a call to rebalanceToWeights(), but the next time it is called this dust will be redeposited. Thus, at least rebalanceToWeights() doesn’t gather dust (even though it’s “not going to be used often, if at all”).

The issue in stake() remains unmitigated per se. The dust generated there would of course also be picked up by rebalanceToWeights(), but since rebalanceToWeights() is “not going to be used often, if at all”, and causes a significant loss for the protocol (M-07), this issue cannot be considered mitigated.

Suggestion

Sweep the dust in stake() instead by adding the balance to msg.value. Or use the entire balance in unstake(). These functions will be called frequently and it doesn’t hurt to reward users with some dust.
Note that this would entail that this check in unstake() would have to be removed:

require(address(this).balance - ethBefore != 0, "Receive zero Ether");

See also the new issue titled “Reappearance of M-02 in SafEth.unstake()” for another reason this check should be removed.


The text was updated successfully, but these errors were encountered:

All reactions