-
Notifications
You must be signed in to change notification settings - Fork 7
Description
file: pool/src/contract.rs
location: fn split_deposit_based_on_pool_ratio
The function split_deposit_based_on_pool_ratio
tries to match the amount deposited to the ratio of balances held by the pool. However, the target ratio is based on the pool ratio before the swap occurs.
Impact After the swap occurs, the ratio changes, and so the user is rewarded fewer LP shares and ends up losing equity even on a fee-less pool.
Recommendation At a minimum, we recommend updating target_ratio
during the computation of final_offer_amount
and final_ask_amount
so that target_ratio
is the ratio of pool balances after the swap, not before (e.g., target_ratio = Decimal::from_ratio(b_pool - swapped_b, a_pool + swapped_a
) if the swapped asset is tokenA.
However, we would prefer to see the use of a precise formula for computing split_deposit_based_on_pool_ratio
rather than the current binary search method.