Open hats-bug-reporter[bot] opened 1 month ago
if needed, we will add more information. we thought its straight forward mistake done.
no,it works as expected as lets say for 6 decimal token
uint256 dy = xp_reduced[i] - get_y_D(amp, i, xp_reduced, D1);
here dy will have precision of 10^18
dy = (dy - 1) / precisions[i];
and here dy will be 10^18-10^12 = 10^6 for 6 decimals token,which is correct!
Github username: -- Twitter username: -- Submission hash (on-chain): 0x1924c3ac29209174e34ccc1d7a57b5723428c77c9ac8e6a437272f98c3969d8e Severity: high
Description: Description\
When we cross checking with standard curve implementation on the function _calc_withdraw_one_coin , we found discreency in how the precision is used to get the final output.
The function
_calc_withdraw_one_coin
is mainly used inremove_liquidity_one_coin
which is called by the lp.Lets see the precison part of the Thorn
_calc_withdraw_one_coin
_xp
the
_xp()
returns with precison value of RATES/PRECISION.But the
_calc_withdraw_one_coin
just divides the final outut byPRECISION_MUL
which is incorrect.Lets see the curve 2 pool implementation . referred from here https://arbiscan.io/address/0x7f90122BF0700F9E7e1F688fe926940E8839F353#code
_xp_mem
returns with precisionRATE_MULTIPLIER /PRECISION
and this has handlned in_calc_withdraw_one_coin
as shown in above function.Impact
Incorrect value computation from the function
_calc_withdraw_one_coin
Revised Code File (Optional)
We would suggest to update the code as done in the curve implementation.