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

hickuphh3 - Users lose profit in mintRollovers from incorrect variable used #106

Closed
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

hickuphh3

high

Users lose profit in mintRollovers from incorrect variable used

Summary

If users win an epoch, they are credited entitledShares which is greater than queueItem.assets, but assetsToMint uses the latter instead, resulting in the difference being unaccounted for / lost.

Vulnerability Detail

Minting rollovers only happen if the user won an epoch, where entitledShares is expected to be greater than queueItem.assets.

uint256 entitledShares = previewWithdraw(
  queueItem.epochId,
  queueItem.assets
);
// mint only if user won epoch he is rolling over
if (entitledShares > queueItem.assets) {

However, the assetsToMint is calculated as

uint256 assetsToMint = queueItem.assets - relayerFee;

where queueItem.assets is used instead of entitledShares. The difference entitledShares - queueItem.assets is therefore unaccounted for.

Impact

Users' profits are lost.

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L396-L401
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L436-L437

Tool used

Manual Review

Recommendation

- uint256 assetsToMint = queueItem.assets - relayerFee;
+ uint256 assetsToMint = entitledShares - relayerFee;

Technically, the same change can be applied for the minimum relayer fee check too:

- if (queueItem.assets < relayerFee) {
+ if (entitledShares < relayerFee) {

Duplicate of #163

@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