sherlock-audit / 2024-05-sophon-judging

7 stars 6 forks source link

bronze_pickaxe - Users depositing rebase tokens will lose points and funds #25

Closed sherlock-admin3 closed 5 months ago

sherlock-admin3 commented 5 months ago

bronze_pickaxe

medium

Users depositing rebase tokens will lose points and funds

Summary

Usage of rebase tokens will lead to lost points and funds.

Vulnerability Detail

A user can deposit rebase tokens likestETH and eETH into SophonFarming.sol using the deposit* functions. We will be focussing on stETH in this report but the same applies to eETH.

A user can deposit stETH usingdepositStEth(): SophonFarming.sol#L473-L481)

    function depositStEth(uint256 _amount, uint256 _boostAmount) external {
        IERC20(stETH).safeTransferFrom(
            msg.sender,
            address(this),
            _amount
        );

        _depositPredefinedAsset(_amount, _amount, _boostAmount, PredefinedPool.wstETH);
    }

As per the Lido docs:

stETH is a transferable rebasing utility token representing a share of the total ETH staked 
through the protocol, which consists of user deposits and staking rewards. 
Because stETH rebases daily, it communicates the position of the share daily.
The mechanism which updates the stETH balances every day is called a “rebase”. 
Every day at 12PM UTC the amount of stETH in your address will increase with the current APR. 

stETH is a rebase token, which means that overtime, the balance of a user increases with the current APR. This is a problem in the current iteration of the project.

Impact

Note that the same applies to the usage of eETH.

Code Snippet

    function depositStEth(uint256 _amount, uint256 _boostAmount) external {
        IERC20(stETH).safeTransferFrom(
            msg.sender,
            address(this),
            _amount
        );

        _depositPredefinedAsset(_amount, _amount, _boostAmount, PredefinedPool.wstETH);
    }

Tool used

Manual Review

Recommendation

Handle rebase tokens differently or don't use them at all.

sherlock-admin4 commented 5 months ago

1 comment(s) were left on this issue during the judging contest.

0xmystery commented:

invalid because that's the trade off for point farming. However, stETH rebases based off its value against ETH