-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaces next reserves by deltas in swap
functions
#42
Conversation
int256 a = Gaussian.ppf(int256(rX.divWadDown(L))); | ||
int256 b = | ||
Gaussian.ppf(int256(rY.divWadDown(L.mulWadDown(params.mean)))); | ||
return a + b + int256(params.width); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make it too difficult to do the arb loop since invalid inputs will cause reverts instead of return values, why was it changed? If rx / L is truncated to 0 it will cause ppf to revert.
function _computeDeltaXGivenDeltaL( | ||
uint256 deltaLiquidity, | ||
IDFMM.Pool calldata pool, | ||
bytes memory | ||
) internal pure override returns (uint256) { | ||
return pool.reserveX.mulWadDown( | ||
deltaLiquidity.divWadDown(pool.totalLiquidity) | ||
); | ||
} | ||
|
||
function _computeDeltaYGivenDeltaL( | ||
uint256 deltaLiquidity, | ||
IDFMM.Pool calldata pool, | ||
bytes memory | ||
) internal pure override returns (uint256) { | ||
return pool.reserveY.mulWadDown( | ||
deltaLiquidity.divWadDown(pool.totalLiquidity) | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions use the same rounding direction for both allocate and deallocate, which means we can take advantage of the rounding direction and potentially take more out than we put in
This PR refactors the
swap
functions of DFMM and strategy contracts to use deltas instead of reserves.