From a43c893609701e4864b4b113d938cb538b6f8a96 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 29 Sep 2025 17:32:09 -0400 Subject: [PATCH] PoolBase; warnings cleanup --- src/LMSRStabilized.sol | 3 --- src/PartyPool.sol | 8 +++----- src/PoolBase.sol | 14 ++++++++++++++ test/LMSRStabilized.t.sol | 6 +++--- 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 src/PoolBase.sol diff --git a/src/LMSRStabilized.sol b/src/LMSRStabilized.sol index 864acdc..2e41401 100644 --- a/src/LMSRStabilized.sol +++ b/src/LMSRStabilized.sol @@ -597,9 +597,6 @@ library LMSRStabilized { int128 newTotal = _computeSizeMetric(newQInternal); require(newTotal > int128(0), "LMSR: new total zero"); - // With kappa formulation, b automatically scales with pool size - int128 newB = s.kappa.mul(newTotal); - // Update the cached qInternal with new values for (uint i = 0; i < s.nAssets; ) { s.qInternal[i] = newQInternal[i]; diff --git a/src/PartyPool.sol b/src/PartyPool.sol index 98c7bb4..1bdfb7e 100644 --- a/src/PartyPool.sol +++ b/src/PartyPool.sol @@ -6,6 +6,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "./PoolLib.sol"; import "./IPartyPool.sol"; +import {PoolBase} from "./PoolBase.sol"; /// @title PartyPool - LMSR-backed multi-asset pool with LP ERC20 token /// @notice A multi-asset liquidity pool backed by the LMSRStabilized pricing model. @@ -17,12 +18,9 @@ import "./IPartyPool.sol"; /// - Flash loans via a callback interface. /// /// @dev The contract uses PoolLib for all implementation logic and maintains state in a PoolLib.State struct -contract PartyPool is IPartyPool, ERC20, ReentrancyGuard { +contract PartyPool is PoolBase, IPartyPool { using PoolLib for PoolLib.State; - /// @notice Pool state containing all storage variables - PoolLib.State internal s; - /// @notice Liquidity parameter κ (Q64.64) used by the LMSR kernel: b = κ * S(q) /// @dev Pool is constructed with a fixed κ. Clients may use LMSRStabilized.computeKappaFromSlippage(...) to /// derive κ and pass it here. @@ -136,7 +134,7 @@ contract PartyPool is IPartyPool, ERC20, ReentrancyGuard { /// @param lpAmount amount of LP tokens to burn (proportional withdrawal) /// @param deadline timestamp after which the transaction will revert. Pass 0 to ignore. function burn(address payer, address receiver, uint256 lpAmount, uint256 deadline) external nonReentrant { - uint256[] memory withdrawAmounts = s.burn(payer, receiver, lpAmount, deadline, totalSupply(), balanceOf(payer)); + /* uint256[] memory withdrawAmounts = */ s.burn(payer, receiver, lpAmount, deadline, totalSupply(), balanceOf(payer)); // Handle LP token burning with allowance if (msg.sender != payer) { diff --git a/src/PoolBase.sol b/src/PoolBase.sol new file mode 100644 index 0000000..31db259 --- /dev/null +++ b/src/PoolBase.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.30; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; +import "./PoolLib.sol"; + +/// @notice This contract has all the storage for PartyPool and can be inherited by implementation contracts that +/// are delegate-called +abstract contract PoolBase is ERC20, ReentrancyGuard { + /// @notice Pool state containing all storage variables + PoolLib.State internal s; +} diff --git a/test/LMSRStabilized.t.sol b/test/LMSRStabilized.t.sol index 02bb6f9..bd4db07 100644 --- a/test/LMSRStabilized.t.sol +++ b/test/LMSRStabilized.t.sol @@ -711,7 +711,7 @@ contract LMSRStabilizedTest is Test { } // Path 1: Direct swap from asset 0 to asset 2 - (int128 directAmountIn, int128 directAmountOut) = s.swapAmountsForExactInput(0, 2, directSwapAmount, 0); + (/* int128 directAmountIn */, int128 directAmountOut) = s.swapAmountsForExactInput(0, 2, directSwapAmount, 0); // Restore original state for second path _updateCachedQInternal(backupQ); @@ -724,7 +724,7 @@ contract LMSRStabilizedTest is Test { s.qInternal[1] = s.qInternal[1].add(indirectAmountOut1); // Second swap: asset 1 -> asset 2 - (int128 indirectAmountIn2, int128 indirectAmountOut2) = s.swapAmountsForExactInput(1, 2, indirectAmountOut1, 0); + (/* int128 indirectAmountIn2 */, int128 indirectAmountOut2) = s.swapAmountsForExactInput(1, 2, indirectAmountOut1, 0); // The path independence property isn't perfect due to discrete swap mechanics, // but the difference should be within reasonable bounds @@ -765,7 +765,7 @@ contract LMSRStabilizedTest is Test { s.qInternal[1] = s.qInternal[1].add(amountOut1); // Step 2: Swap back asset 1 -> asset 0 - (int128 amountIn2, int128 amountOut2) = s.swapAmountsForExactInput(1, 0, amountOut1, 0); + (/* int128 amountIn2 */, int128 amountOut2) = s.swapAmountsForExactInput(1, 0, amountOut1, 0); // Calculate round-trip slippage: (initial amount - final amount) / initial amount int128 roundTripSlippage = (amountIn1.sub(amountOut2)).div(amountIn1);