First Flight #18: T-Swap

First Flight #18
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

creating pool can lead to some race conditions and multiple pools cration

Summary

creating pool can lead to some race conditions, if two or more users will in the same block try deposit tokens which don;t have pool already.

Vulnerability Details

If some people will want to drop some "low" value token the first guys will get the best price.
Such possibility of race conditions can lead to some races.

Multi creation of the same pool for token X1 can lead to errors in logic of application.

Impact

As user You will not sell your hot "bad" coin before others. You will need to race with others paying much more gas.

Your transaction will be reverted if you loose the race and some else will create the pool for this token.
or in worst case scenario , many pools will be created and your funds will be lost.

Tools Used

code review, slither.

Recommendations

Reentrancy guard or similar solution for creation of new pool

bool private locked;

modifier noReentrancy() {
require(!locked, "Reentrant call detected");
locked = true;
_;
locked = false;
}

function createPool(address tokenAddress) external noReentrancy returns (address) {
if (s_pools[tokenAddress] != address(0)) {
revert PoolFactory__PoolAlreadyExists(tokenAddress);
}
// rest of the code
}

Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.