Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

minhtrng - Deposit fees can by bypassed #474

Closed
sherlock-admin opened this issue Mar 27, 2023 · 0 comments
Closed

minhtrng - Deposit fees can by bypassed #474

sherlock-admin opened this issue Mar 27, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Mar 27, 2023

minhtrng

high

Deposit fees can by bypassed

Summary

The deposit fees are not accounted for when using the deposit queue mechanism.

Vulnerability Detail

In Carousel._deposit the full input amount is added into the queue:

//WARDEN: fees handled if not put into queue:
if (depositFee > 0) {
    (uint256 maxX, , uint256 minX) = getEpochConfig(_id);
    // deposit fee is calcualted linearly between time of epoch creation and epoch starting (deposit window)
    // this is because late depositors have an informational advantage
    uint256 fee = _calculateFeePercent(int256(minX), int256(maxX));
    // min minRequiredDeposit modifier ensures that _assets has high enough value to not devide by 0
    // 0.5% = multiply by 10000 then divide by 50
    uint256 feeAmount = _assets.mulDivDown(fee, 10000);
    assetsToDeposit = _assets - feeAmount;
    _asset().safeTransfer(treasury, feeAmount);
}
...
//WARDEN: when put into queue, no fee deduction happens
depositQueue.push(
    QueueItem({assets: _assets, receiver: _receiver, epochId: _id})
);

In Carousel.mintDepositInQueue only relayer fees are subtracted when minting shares:

_mintShares(
    queue[i].receiver,
    _epochId,
    queue[i].assets - relayerFee
);
...
asset.safeTransfer(msg.sender, _operations * relayerFee);

This way a user could bypass deposit fees by putting them into the queue and minting the deposit right after, so that relayer fees also end up back with them.

Impact

Deposit fees can be bypassed, causing loss of revenue for the protocol

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/ae7f210d8fbf21b9abf09ef30edfa548f7ae1aef/Earthquake/src/v2/Carousel/Carousel.sol#L494-L497

Tool used

Manual Review

Recommendation

Handle deposit fees before pushing them into queue. Make sure to adjust minRequiredDeposit.

Duplicate of #75

@github-actions github-actions bot closed this as completed Apr 3, 2023
@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Apr 3, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant