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

Prevent pool creation with a rogue token #30

Open
gabririgo opened this issue Nov 7, 2023 · 0 comments
Open

Prevent pool creation with a rogue token #30

gabririgo opened this issue Nov 7, 2023 · 0 comments

Comments

@gabririgo
Copy link
Contributor

gabririgo commented Nov 7, 2023

Summary

Pool creation does not fail when a standard wallet or a smart contract that does not implement decimals() is used as the base token.

Motivation

Pool creation should be allowed only with correct initialization. Otherwise, the name is reserved in the registry and the pool cannot be used. This is relevant for users trying to deploy a pool with the same name and address on multiple chains.

Specification

The call IERC20(initParams.baseToken).decimals() will fail silently if the target address does not implement the method. Therefore, the following part of the code will be skipped, which is the pool initialization. In order to guarantee that the pool is initialized correctly, we have to use a try/catch statement and revert with an error. It is not important to revert with the message error as the pool proxy initializePool() call will fail with POOL_INITIALIZATION_FAILED_ERROR without catching the revert reason for gas optimizations.

The decimals initialization should not make an assertion when the token is base currency as we define 18 decimals. The token assertion should be moved in the try/catch statement and decimals should be defined case by case instead of initially set to 18 and overwritten if different.

Notes

Github issue
Proposed implementation

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