@@ -161,13 +161,9 @@ contract G3MSolver {
161161 {
162162 if (swapXIn) {
163163 uint256 fees = amountIn.mulWadUp (poolParams.swapFee);
164- uint256 weightedPrice = uint256 (
165- int256 (startReserves.ry.divWadUp (startReserves.rx)).powWad (
166- int256 (poolParams.wY)
167- )
164+ uint256 deltaL = (ONE.divWadDown (2 * ONE)).mulWadUp (
165+ fees.mulWadUp (startComputedL).divWadUp (startReserves.rx)
168166 );
169- uint256 deltaL = fees.mulWadUp (weightedPrice);
170- deltaL += 1 ;
171167
172168 endReserves.rx = startReserves.rx + amountIn;
173169 endReserves.L = startComputedL + deltaL;
@@ -183,13 +179,9 @@ contract G3MSolver {
183179 amountOut = startReserves.ry - endReserves.ry;
184180 } else {
185181 uint256 fees = amountIn.mulWadUp (poolParams.swapFee);
186- uint256 weightedPrice = uint256 (
187- int256 (startReserves.rx.divWadUp (startReserves.ry)).powWad (
188- int256 (poolParams.wX)
189- )
182+ uint256 deltaL = (ONE.divWadDown (2 * ONE)).mulWadUp (
183+ fees.mulWadUp (startComputedL).divWadUp (startReserves.rx)
190184 );
191- uint256 deltaL = fees.mulWadUp (weightedPrice);
192- deltaL += 1 ;
193185
194186 endReserves.ry = startReserves.ry + amountIn;
195187 endReserves.L = startComputedL + deltaL;
@@ -209,7 +201,6 @@ contract G3MSolver {
209201 bytes memory swapData =
210202 abi.encode (endReserves.rx, endReserves.ry, endReserves.L);
211203
212- uint256 poolId = poolId;
213204 (bool valid ,,,,,) =
214205 IStrategy (strategy).validateSwap (address (this ), poolId, swapData);
215206 return (
0 commit comments