In the StableSwapFactory contract, the createSwapLP and createSwapPair functions use the create2 opcode to deploy contracts. However, if the contract deployment fails, create2 will return the zero address (address(0)). Currently, there is no check to handle this failure, allowing the contract to proceed as if the deployment succeeded. This can lead to corrupting the factory’s internal state and state variables.
Attachments
Revised Code
Add a check to handle failed contract deployments in the createSwapLP and createSwapPair functions. This will ensure that the contract reverts if the deployment fails, preventing the propagation of invalid states.
Github username: -- Twitter username: -- Submission hash (on-chain): 0xd65f86398f17c88bb2f6add723893e43349b8e7b58c5f67a0bc607b43fb97324 Severity: medium
Description: Description
In the
StableSwapFactory
contract, thecreateSwapLP
andcreateSwapPair
functions use thecreate2
opcode to deploy contracts. However, if the contract deployment fails,create2
will return the zero address (address(0)
). Currently, there is no check to handle this failure, allowing the contract to proceed as if the deployment succeeded. This can lead to corrupting the factory’s internal state and state variables.Attachments
Add a check to handle failed contract deployments in the
createSwapLP
andcreateSwapPair
functions. This will ensure that the contract reverts if the deployment fails, preventing the propagation of invalid states.