From ab00d4ecf795231c9008013044bdf1bda2695c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Lakhal?= <39790678+clemlak@users.noreply.github.com> Date: Fri, 29 Mar 2024 11:54:33 +0400 Subject: [PATCH 1/6] Revert "fix: rounding in LogNormal trading function" --- src/LogNormal/LogNormalMath.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LogNormal/LogNormalMath.sol b/src/LogNormal/LogNormalMath.sol index 400d3d33..5a5c9a08 100644 --- a/src/LogNormal/LogNormalMath.sol +++ b/src/LogNormal/LogNormalMath.sol @@ -22,7 +22,7 @@ function computeTradingFunction( LogNormalParams memory params ) pure returns (int256) { int256 a = Gaussian.ppf(int256(rX.divWadDown(L))); - int256 b = Gaussian.ppf(int256(rY.divWadDown(L.mulWadUp(params.mean)))); + int256 b = Gaussian.ppf(int256(rY.divWadDown(L.mulWadDown(params.mean)))); return a + b + int256(params.width); } From 744e716cbb8528b5ccf55ef5f97508b1a526f476 Mon Sep 17 00:00:00 2001 From: clemlak Date: Fri, 29 Mar 2024 14:44:45 +0400 Subject: [PATCH 2/6] fix: remove useless return in decodeFeeUpdate in ConstantSumUtils --- src/ConstantSum/ConstantSumUtils.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ConstantSum/ConstantSumUtils.sol b/src/ConstantSum/ConstantSumUtils.sol index 12064357..71b98d25 100644 --- a/src/ConstantSum/ConstantSumUtils.sol +++ b/src/ConstantSum/ConstantSumUtils.sol @@ -20,7 +20,6 @@ function encodeControllerUpdate(address controller) function decodeFeeUpdate(bytes memory data) pure returns (uint256 swapFee) { (, swapFee) = abi.decode(data, (UpdateCode, uint256)); - return swapFee; } function decodePriceUpdate(bytes memory data) From da8d520ce0336c1b05cd369ce950c1a24519d222 Mon Sep 17 00:00:00 2001 From: clemlak Date: Fri, 29 Mar 2024 14:45:37 +0400 Subject: [PATCH 3/6] fix: remove useless library using in ConstantSumMath --- src/ConstantSum/ConstantSumMath.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ConstantSum/ConstantSumMath.sol b/src/ConstantSum/ConstantSumMath.sol index 5e58f9e2..51f8c203 100644 --- a/src/ConstantSum/ConstantSumMath.sol +++ b/src/ConstantSum/ConstantSumMath.sol @@ -6,7 +6,6 @@ import { ConstantSumParams } from "src/ConstantSum/ConstantSum.sol"; import { ONE } from "src/lib/StrategyLib.sol"; using FixedPointMathLib for uint256; -using FixedPointMathLib for int256; function computeTradingFunction( uint256[] memory reserves, From 802491bba184ec9b162c5722733c43c79e116b18 Mon Sep 17 00:00:00 2001 From: clemlak Date: Fri, 29 Mar 2024 14:46:23 +0400 Subject: [PATCH 4/6] fix: remove useless library using in ConstantSumSolver --- src/ConstantSum/ConstantSumSolver.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ConstantSum/ConstantSumSolver.sol b/src/ConstantSum/ConstantSumSolver.sol index 1144d382..2645edaf 100644 --- a/src/ConstantSum/ConstantSumSolver.sol +++ b/src/ConstantSum/ConstantSumSolver.sol @@ -19,7 +19,6 @@ contract ConstantSumSolver { error NotEnoughLiquidity(); using FixedPointMathLib for uint256; - using FixedPointMathLib for int256; struct Reserves { uint256 rx; From 5c5200354c281acc0f1ef8505070f38126825cba Mon Sep 17 00:00:00 2001 From: clemlak Date: Fri, 29 Mar 2024 14:47:15 +0400 Subject: [PATCH 5/6] fix: remove unused wX parameter in InitState in NTokenG3M --- src/NTokenGeometricMean/NTokenGeometricMean.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NTokenGeometricMean/NTokenGeometricMean.sol b/src/NTokenGeometricMean/NTokenGeometricMean.sol index be7e88d4..f1e876c3 100644 --- a/src/NTokenGeometricMean/NTokenGeometricMean.sol +++ b/src/NTokenGeometricMean/NTokenGeometricMean.sol @@ -69,7 +69,6 @@ contract NTokenGeometricMean is NTokenStrategy { int256 invariant; address controller; uint256 swapFee; - uint256 wX; uint256 totalLiquidity; uint256[] reserves; uint256[] weights; From 28315ced69e73873a198a11489787669cde396ca Mon Sep 17 00:00:00 2001 From: clemlak Date: Fri, 29 Mar 2024 14:57:23 +0400 Subject: [PATCH 6/6] fix: move test constants in StrategyLib into test files --- src/lib/StrategyLib.sol | 3 --- test/utils/LogNormalArbitrage.sol | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/StrategyLib.sol b/src/lib/StrategyLib.sol index d1d60387..03f733ed 100644 --- a/src/lib/StrategyLib.sol +++ b/src/lib/StrategyLib.sol @@ -6,9 +6,6 @@ import { FixedPointMathLib } from "solmate/utils/FixedPointMathLib.sol"; uint256 constant HALF = 0.5e18; uint256 constant ONE = 1e18; uint256 constant TWO = 2e18; -int256 constant I_ONE = int256(ONE); -int256 constant I_TWO = int256(TWO); -int256 constant I_HALF = int256(HALF); using FixedPointMathLib for uint256; using FixedPointMathLib for int256; diff --git a/test/utils/LogNormalArbitrage.sol b/test/utils/LogNormalArbitrage.sol index f7283127..ebc66414 100644 --- a/test/utils/LogNormalArbitrage.sol +++ b/test/utils/LogNormalArbitrage.sol @@ -34,6 +34,10 @@ interface SolverLike { returns (LogNormalParams memory); } +int256 constant I_ONE = int256(ONE); +int256 constant I_TWO = int256(TWO); +int256 constant I_HALF = int256(HALF); + contract LogNormalArbitrage { using FixedPointMathLib for uint256; using FixedPointMathLib for int256;