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

cccz - When finalTVL == 0, the emissionsToken in the vault will be locked #388

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 Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Mar 27, 2023

cccz

medium

When finalTVL == 0, the emissionsToken in the vault will be locked

Summary

When finalTVL == 0, the emissionsToken in the vault cannot be claimed and will be locked in the contract

Vulnerability Detail

When the vault is created, emissionsTokens are sent to the vault, and when the epoch ends, users can claim these emissionsTokens.

        emissionsToken.safeTransferFrom(treasury, vaults[0], _permiumEmissions);
        ICarousel(vaults[0]).setEmissions(epochId, _permiumEmissions);

        emissionsToken.safeTransferFrom(treasury, vaults[1], _collatEmissions);
        ICarousel(vaults[1]).setEmissions(epochId, _collatEmissions);

However, if the finalTVL is 0, then these emissionsTokens will not be claimed and will be locked in the contract

    function previewEmissionsWithdraw(uint256 _id, uint256 _assets)
        public
        view
        returns (uint256 entitledAmount)
    {
        entitledAmount = _assets.mulDivDown(emissions[_id], finalTVL[_id]);
    }

Impact

If the finalTVL is 0, then these emissionsTokens will not be claimed and will be locked in the contract

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/CarouselFactory.sol#L148-L152
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L630-L636

Tool used

Manual Review

Recommendation

Consider transferring the emissionsToken out of the contract when finalTVL == 0 in resolveEpoch

    function resolveEpoch(uint256 _id)
        external
        onlyController
        epochIdExists(_id)
        epochHasStarted(_id)
    {
        if (epochResolved[_id]) revert EpochAlreadyEnded();
        epochResolved[_id] = true;
        finalTVL[_id] = totalAssets(_id);
    }

Duplicate of #122

@github-actions github-actions bot closed this as completed Apr 3, 2023
@github-actions github-actions bot added Medium A valid Medium 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 Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant