Improper calculation of token 0 will return an erroneous output for the required amounts of token 0 .
Proof of Concept
Based on the documentation the amount of token 0 is calculated as L(1/sqrt(pb) but this is incorrect as it would not lead to2L(sqrt(x)`. the calculation of the sqrt is as follows https://docs.predy.finance/predy-v6/dev/squart where equation 1 is added to equation 4 but it is L(x/sqrt(pb) that is used within the equation.
Recommended Mitigation Steps
Check the uniswap pool for the given pair and return the current price X and use it in the calculation for token 0 Amt.
Lines of code
https://github.com/code-423n4/2024-05-predy/blob/a9246db5f874a91fb71c296aac6a66902289306a/src/libraries/Perp.sol#L768
Vulnerability details
Impact
Improper calculation of token 0 will return an erroneous output for the required amounts of token 0 .
Proof of Concept
Based on the documentation the amount of token 0 is calculated as
L(1/sqrt(pb) but this is incorrect as it would not lead to
2L(sqrt(x)`. the calculation of the sqrt is as follows https://docs.predy.finance/predy-v6/dev/squart where equation 1 is added to equation 4 but it is L(x/sqrt(pb) that is used within the equation.Recommended Mitigation Steps
Check the uniswap pool for the given pair and return the current price X and use it in the calculation for token 0 Amt.
Assessed type
Math