However, there is a problem with the calculation logic. The function uses the logic of startBalance - nativeToken.balanceOf(address(this)). It is wrong to subtract the balance at the end from the balance at the beginning. This may result in a negative number and cause the transaction to be rolled back.
Bubbly Golden Hamster
Medium
The initializeCollection function cannot be used due to incorrect implementation logic
Summary
The initializeCollection function cannot be used due to incorrect implementation logic.
Vulnerability Detail
In the logic of the initializeCollection function, the used token will be returned.
However, there is a problem with the calculation logic. The function uses the logic of startBalance - nativeToken.balanceOf(address(this)). It is wrong to subtract the balance at the end from the balance at the beginning. This may result in a negative number and cause the transaction to be rolled back.
Impact
The initializeCollection function cannot be used.
Code Snippet
https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Locker.sol#L397
Tool used
Manual Review
Recommendation
Locker.sol