You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
gangov
changed the title
Pool: Split deposit should target the new pool ratio
[V-PHX-VUL-006] Split deposit should target the new pool ratio
Feb 6, 2024
We have decided to disable the feature allowing to provide liquidity on the single side for now.
We will enable it after getting to the bottom of the issue.
https://veridise.notion.site/Split-deposit-should-target-the-new-pool-ratio-c04d2ccddf1c433abfe48bc2912f6a1a
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 offinal_offer_amount
andfinal_ask_amount
so thattarget_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.The text was updated successfully, but these errors were encountered: