From 0f0ce531850981954ccfb01137bd12a06a9e2561 Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 1 Apr 2024 11:35:11 +0400 Subject: [PATCH 1/6] fix: remove computeLGivenY in G3MMath --- src/GeometricMean/G3MMath.sol | 8 -------- src/GeometricMean/GeometricMeanSolver.sol | 1 - 2 files changed, 9 deletions(-) diff --git a/src/GeometricMean/G3MMath.sol b/src/GeometricMean/G3MMath.sol index 0e409569..c3cb4bc6 100644 --- a/src/GeometricMean/G3MMath.sol +++ b/src/GeometricMean/G3MMath.sol @@ -47,14 +47,6 @@ function computeLGivenX( 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, diff --git a/src/GeometricMean/GeometricMeanSolver.sol b/src/GeometricMean/GeometricMeanSolver.sol index 6cf9d359..54cf40ae 100644 --- a/src/GeometricMean/GeometricMeanSolver.sol +++ b/src/GeometricMean/GeometricMeanSolver.sol @@ -17,7 +17,6 @@ import { computeLGivenX, computeY, computeX, - computeLGivenY, computeNextLiquidity, computeNextRx, computeNextRy, From 8a6788fdec30243c2e7e0196acf0a98448c78584 Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 1 Apr 2024 11:39:25 +0400 Subject: [PATCH 2/6] fix: remove computeYGivenL --- src/GeometricMean/G3MMath.sol | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/GeometricMean/G3MMath.sol b/src/GeometricMean/G3MMath.sol index a3a7d7ae..2c01ab47 100644 --- a/src/GeometricMean/G3MMath.sol +++ b/src/GeometricMean/G3MMath.sol @@ -55,14 +55,6 @@ function computeXGivenL( 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, From 8a7fa2807e9ee4b60ee08cf3711b00cea6ad7dac Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 1 Apr 2024 11:43:33 +0400 Subject: [PATCH 3/6] fix: use mulDivUp in computeLGivenX --- src/GeometricMean/G3MMath.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GeometricMean/G3MMath.sol b/src/GeometricMean/G3MMath.sol index 2c01ab47..c028449f 100644 --- a/src/GeometricMean/G3MMath.sol +++ b/src/GeometricMean/G3MMath.sol @@ -42,7 +42,7 @@ 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)); } From 03ea7558e1878a87e828d060abd4d341ffa91b07 Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 1 Apr 2024 11:43:47 +0400 Subject: [PATCH 4/6] fix: delete unused imports in G3MSolver --- src/GeometricMean/GeometricMeanSolver.sol | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/GeometricMean/GeometricMeanSolver.sol b/src/GeometricMean/GeometricMeanSolver.sol index 6562798b..885f5fe1 100644 --- a/src/GeometricMean/GeometricMeanSolver.sol +++ b/src/GeometricMean/GeometricMeanSolver.sol @@ -12,19 +12,14 @@ import { } from "./G3MUtils.sol"; import { computeInitialPoolData, - computeL, - computePrice, - computeLGivenX, - computeY, - computeX, - computeNextLiquidity, computeNextRx, computeNextRy, computeTradingFunction, computeAllocationGivenDeltaX, computeAllocationGivenDeltaY, computeDeallocationGivenDeltaX, - computeDeallocationGivenDeltaY + computeDeallocationGivenDeltaY, + computePrice } from "./G3MMath.sol"; contract GeometricMeanSolver { From 11861e88db2bae3924ebde3b6728281a8639dc5a Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 1 Apr 2024 11:44:49 +0400 Subject: [PATCH 5/6] fix: remove computeXGivenL in G3MMath --- src/GeometricMean/G3MMath.sol | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/GeometricMean/G3MMath.sol b/src/GeometricMean/G3MMath.sol index c028449f..e814ebe5 100644 --- a/src/GeometricMean/G3MMath.sol +++ b/src/GeometricMean/G3MMath.sol @@ -47,14 +47,6 @@ function computeLGivenX( return x.mulWadUp(uint256(b)); } -function computeXGivenL( - uint256 L, - uint256 S, - GeometricMeanParams memory params -) pure returns (uint256) { - return params.wX.mulWadUp(L).divWadUp(params.wY.mulWadUp(S)); -} - function computeAllocationGivenDeltaX( uint256 deltaX, uint256 rX, From 1316bc2728ef6fd1683f5bad2bc9463234eeea4d Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 1 Apr 2024 11:45:40 +0400 Subject: [PATCH 6/6] fix: remove computeX in G3MMath --- src/GeometricMean/G3MMath.sol | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/GeometricMean/G3MMath.sol b/src/GeometricMean/G3MMath.sol index e814ebe5..76fea8bc 100644 --- a/src/GeometricMean/G3MMath.sol +++ b/src/GeometricMean/G3MMath.sol @@ -99,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,