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 GeometricMean strategy uses an incorrect fee calculation for the increase in L that is off by a factor of 2.
Details
The fee calculation roughly looks like
fees = amountIn * swapFee;
deltaL = fees * L / R
where R is either one of the two reserves, and specifically is the reserve that is being tendered in for a swap.
Replication of the issue
To see why this is off, take a pool with a swap fee of 0.003, initial price of 1, initial X of 10E9, and then perform a swap of 1 of X or Y in. This liquidity depth and swap size should make it such that the pool is close to being a ConstantSum pool. What you find is that instead of getting out 0.997 of the other token, you get back 0.994 indicating the fee was double counted.
Fix
To fix the issue, simply divide the above deltaL by 2.
Testing in Mathematica notebooks seems to show this change fixes the fee problem.
The text was updated successfully, but these errors were encountered:
Description
The
GeometricMean
strategy uses an incorrect fee calculation for the increase inL
that is off by a factor of 2.Details
The fee calculation roughly looks like
where
R
is either one of the two reserves, and specifically is the reserve that is being tendered in for a swap.Replication of the issue
To see why this is off, take a pool with a swap fee of
0.003
, initial price of 1, initialX
of10E9
, and then perform a swap of1
ofX
orY
in. This liquidity depth and swap size should make it such that the pool is close to being aConstantSum
pool. What you find is that instead of getting out0.997
of the other token, you get back0.994
indicating the fee was double counted.Fix
To fix the issue, simply divide the above
deltaL
by 2.Testing in Mathematica notebooks seems to show this change fixes the fee problem.
The text was updated successfully, but these errors were encountered: