Phoenix-Protocol-Group / phoenix-contracts

Source code of the smart contracts of the Phoenix DeFi hub DEX protocol
GNU General Public License v3.0
10 stars 6 forks source link

PHOAM-001: Integer overflow will prevent swaps #315

Open gangov opened 3 weeks ago

gangov commented 3 weeks ago

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.