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

PHOAM-014: Stable pool does not support tokens with more than 18 decimals #344

Open
gangov opened this issue Jul 9, 2024 · 1 comment · May be fixed by #369
Open

PHOAM-014: Stable pool does not support tokens with more than 18 decimals #344

gangov opened this issue Jul 9, 2024 · 1 comment · May be fixed by #369
Assignees
Labels

Comments

@gangov
Copy link
Collaborator

gangov commented Jul 9, 2024

Location

./contracts/pool_stable/src/contract.rs:319

Description
The provide_liquidity function triggers an integer underflow issue when at least one of the tokens of the pair use more than 18 decimals. This prevents liquidity providers from adding funds to the pool.
This is due to the following pow function, which expects an u32 number. Should greatest_precision be greater than DECIMAL_PRECISION, the provide_liquidity function would end execution with a panic.

let divisor = 10u128.pow(DECIMAL_PRECISION - greatest_precision);

The likelihood of this issue occurring was determined to be low, as tokens with more than 18 decimals are less likely to exist.

Recommendation
Contemplate the case where greatest_precision is greater than DECIMAL_PRECISION, similarly to what is done in the scale_value value function.
Otherwise, clearly document this limitation and prevent tokens with more than 18 decimals from being included in stable liquidity pools.

@gangov gangov self-assigned this Jul 9, 2024
@gangov gangov added the audit label Jul 9, 2024
@gangov
Copy link
Collaborator Author

gangov commented Jul 9, 2024

I'm pretty sure that we're keeping 18 decimals for now, making this for tracking purposes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant