Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: remove computeLGivenY in G3MMath #108

Merged
merged 9 commits into from
Apr 2, 2024
34 changes: 1 addition & 33 deletions src/GeometricMean/G3MMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,11 @@ function computeLGivenX(
uint256 S,
GeometricMeanParams memory params
) pure returns (uint256) {
int256 a = int256(params.wY.divWadUp(params.wX).mulWadUp(S));
int256 a = int256(params.wY.mulDivUp(S, params.wX));
int256 b = a.powWad(int256(params.wY));
return x.mulWadUp(uint256(b));
}

function computeLGivenY(
uint256 y,
uint256 S,
GeometricMeanParams memory params
) pure returns (uint256) {
return y.mulWadUp(params.wX).divWadUp(params.wY.mulWadUp(S));
}

function computeXGivenL(
uint256 L,
uint256 S,
GeometricMeanParams memory params
) pure returns (uint256) {
return params.wX.mulWadUp(L).divWadUp(params.wY.mulWadUp(S));
}

function computeYGivenL(
uint256 L,
uint256 S,
GeometricMeanParams memory params
) pure returns (uint256) {
return params.wY.mulWadUp(L).divWadUp(params.wX.mulWadUp(S));
}

function computeAllocationGivenDeltaX(
uint256 deltaX,
uint256 rX,
Expand Down Expand Up @@ -123,14 +99,6 @@ function computeY(
return params.wY.divWadDown(params.wX).mulWadDown(S).mulWadDown(x);
}

function computeX(
uint256 y,
uint256 S,
GeometricMeanParams memory params
) pure returns (uint256) {
return params.wX.divWadDown(params.wY.mulWadDown(S)).mulWadDown(y);
}

function computeL(
uint256 x,
uint256 y,
Expand Down
10 changes: 2 additions & 8 deletions src/GeometricMean/GeometricMeanSolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ import {
} from "./G3MUtils.sol";
import {
computeInitialPoolData,
computeL,
computePrice,
computeLGivenX,
computeY,
computeX,
computeLGivenY,
computeNextLiquidity,
computeNextRx,
computeNextRy,
computeTradingFunction,
computeAllocationGivenDeltaX,
computeAllocationGivenDeltaY,
computeDeallocationGivenDeltaX,
computeDeallocationGivenDeltaY
computeDeallocationGivenDeltaY,
computePrice
} from "./G3MMath.sol";

contract GeometricMeanSolver {
Expand Down
Loading