Description
Swapping will be halted in pools with tokens represented with a high number of decimals due to overflow an issue arising from the multiplication of offer_pool and ask_pool in the swap function. This overflow causes the function to panic, halting the swap function.
Recommendation
Store intermediate results in a u256 variable and safely convert it to i128. Alternatively, explore using an approximation formula that avoids cross product calculations between pool reserves, similar to what is done in UniswapV2.
Description Swapping will be halted in pools with tokens represented with a high number of decimals due to overflow an issue arising from the multiplication of offer_pool and ask_pool in the swap function. This overflow causes the function to panic, halting the swap function.
Recommendation Store intermediate results in a u256 variable and safely convert it to i128. Alternatively, explore using an approximation formula that avoids cross product calculations between pool reserves, similar to what is done in UniswapV2.