y * x = k
curve that allows users to deposit two assets and enable them to be traded against each other. The price of the assets is determined by the ratio of the two assets in the pool.
(Reserve_A + ΔA - fees) * (Reserve_B - ΔB) = k
where k is the constant product of the reserves.v_A^0
and v_B^0
with k_v = v_A^0 * v_B^0
. As tokens are sold, we maintain:
current_v_a = v_A^0 - tokens_sold
current_v_b = v_B^0 + quote_raised
P = current_v_b / current_v_a
Swaps update virtual reserves using constant product math:
new_v_b = current_v_b + ΔB
, new_v_a = k_v / new_v_b
, output ΔA = current_v_a - new_v_a
.new_v_a = current_v_a + ΔA
, new_v_b = k_v / new_v_a
, output ΔB = current_v_b - new_v_b
.L = (ΔA * sqrt(P_upper) * sqrt(P_lower)) / (sqrt(P_upper) - sqrt(P_lower))
L = ΔB / (sqrt(P_upper) - sqrt(P_lower))
L = min(L_A, L_B)
where both assets may be required