Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utsav - Locker:initializeCollection() will revert due to arithmetic underflow #779

Open
sherlock-admin4 opened this issue Sep 15, 2024 · 0 comments

Comments

@sherlock-admin4
Copy link
Contributor

sherlock-admin4 commented Sep 15, 2024

utsav

Medium

Locker:initializeCollection() will revert due to arithmetic underflow

Summary

Locker:initializeCollection() will revert due to arithmetic underflow

Vulnerability Detail

Locker:initializeCollection() refund any unused relative token to the user, but the problem is instead of writing finalBalance - startBalance, it uses startBalance - finalBalance

    function initializeCollection(address _collection, uint _eth, uint[] calldata _tokenIds, uint _tokenSlippage, uint160 _sqrtPriceX96) public virtual whenNotPaused collectionExists(_collection) {
//
        // Refund any unused relative token to the user
        nativeToken.transfer(
            msg.sender,
>           startBalance - nativeToken.balanceOf(address(this))
        );
    }

if there is any refund, it will revert the transaction due to arithmetic underflow

Impact

initializeCollection() will be DoSed

Code Snippet

https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Locker.sol#L394C3-L398C11

Tool used

Manual Review

Recommendation

Subtract finalBalance - startBalance

@sherlock-admin2 sherlock-admin2 changed the title Muscular Pebble Walrus - Locker:initializeCollection() will revert due to arithmetic underflow utsav - Locker:initializeCollection() will revert due to arithmetic underflow Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant