From c2ac0e3624a998fcd45f758f4339e3d4c8ca004f Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 12 Nov 2025 14:19:04 -0400 Subject: [PATCH] dropped USE_ from Funding constants --- src/Funding.sol | 4 ++-- src/PartyPool.sol | 4 ++-- test/FundingSwapTest.sol | 16 ++++++++-------- test/GasTest.sol | 12 ++++++------ test/NativeTest.t.sol | 14 +++++++------- test/PartyPool.t.sol | 8 ++++---- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Funding.sol b/src/Funding.sol index e72e106..a693010 100644 --- a/src/Funding.sol +++ b/src/Funding.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.30; library Funding { /// @notice a constant passed to swap as the fundingSelector to indicate that the payer has used regular ERC20 approvals to allow the pool to move the necessary input tokens. - bytes4 internal constant USE_APPROVALS = 0x00000000; + bytes4 internal constant APPROVALS = 0x00000000; /// @notice a constant passed to swap as the fundingSelector to indicate that the payer has already sent sufficient input tokens to the pool before calling swap, so no movement of input tokens is required. - bytes4 internal constant USE_PREFUNDING = 0x00000001; + bytes4 internal constant PREFUNDING = 0x00000001; } diff --git a/src/PartyPool.sol b/src/PartyPool.sol index 994a771..724fa5d 100644 --- a/src/PartyPool.sol +++ b/src/PartyPool.sol @@ -264,10 +264,10 @@ contract PartyPool is PartyPoolBase, OwnableExternal, ERC20External, IPartyPool IERC20 tokenIn = _tokens[inputTokenIndex]; IERC20 tokenOut = _tokens[outputTokenIndex]; - if (fundingSelector == Funding.USE_APPROVALS) + if (fundingSelector == Funding.APPROVALS) // Regular ERC20 permit of the pool to move the tokens _receiveTokenFrom(payer, tokenIn, totalTransferAmount); - else if (fundingSelector == Funding.USE_PREFUNDING) { + else if (fundingSelector == Funding.PREFUNDING) { require(limitPrice==0, 'Prefunding cannot be used with a limit price'); uint256 balance = tokenIn.balanceOf(address(this)); uint256 prevBalance = _cachedUintBalances[inputTokenIndex] + _protocolFeesOwed[inputTokenIndex]; diff --git a/test/FundingSwapTest.sol b/test/FundingSwapTest.sol index 13625ae..1d9e6d9 100644 --- a/test/FundingSwapTest.sol +++ b/test/FundingSwapTest.sol @@ -177,7 +177,7 @@ contract FundingTest is Test { // Execute swap using Funding.USE_PREFUNDING for pre-funded: token0 -> token1 (uint256 amountIn, uint256 amountOut, uint256 fee) = pool.swap( alice, // payer (not used with pre-funded) - Funding.USE_PREFUNDING, + Funding.PREFUNDING, bob, // receiver 0, // inputTokenIndex (token0) 1, // outputTokenIndex (token1) @@ -227,7 +227,7 @@ contract FundingTest is Test { // Execute swap (uint256 amountIn, uint256 amountOut, uint256 fee) = poolZeroFee.swap( alice, - Funding.USE_PREFUNDING, + Funding.PREFUNDING, bob, 0, // token0 -> token1 1, @@ -263,7 +263,7 @@ contract FundingTest is Test { vm.expectRevert(); pool.swap( alice, - Funding.USE_PREFUNDING, + Funding.PREFUNDING, bob, 0, 1, @@ -405,7 +405,7 @@ contract FundingTest is Test { (uint256 refAmountIn, uint256 refAmountOut, uint256 refFee) = pool.swap( bob, - Funding.USE_APPROVALS, + Funding.APPROVALS, bob, 0, 1, @@ -442,7 +442,7 @@ contract FundingTest is Test { (uint256 preAmountIn, uint256 preAmountOut, uint256 preFee) = testPool.swap( alice, - Funding.USE_PREFUNDING, + Funding.PREFUNDING, alice, 0, 1, @@ -469,7 +469,7 @@ contract FundingTest is Test { (uint256 refAmountIn, uint256 refAmountOut, uint256 refFee) = pool.swap( bob, - Funding.USE_APPROVALS, + Funding.APPROVALS, bob, 0, 1, @@ -574,7 +574,7 @@ contract FundingTest is Test { vm.startPrank(alice); token0.approve(address(poolApproval), type(uint256).max); (uint256 apprIn, uint256 apprOut, ) = poolApproval.swap( - alice, Funding.USE_APPROVALS, alice, 0, 1, swapAmount, 0, 0, false + alice, Funding.APPROVALS, alice, 0, 1, swapAmount, 0, 0, false ); vm.stopPrank(); @@ -582,7 +582,7 @@ contract FundingTest is Test { vm.startPrank(alice); token0.transfer(address(poolPreFund), swapAmount); (uint256 preIn, uint256 preOut, ) = poolPreFund.swap( - alice, Funding.USE_PREFUNDING, alice, 0, 1, swapAmount, 0, 0, false + alice, Funding.PREFUNDING, alice, 0, 1, swapAmount, 0, 0, false ); vm.stopPrank(); diff --git a/test/GasTest.sol b/test/GasTest.sol index 7db07a0..878b7b6 100644 --- a/test/GasTest.sol +++ b/test/GasTest.sol @@ -238,7 +238,7 @@ contract GasTest is Test { /// @notice Helper function: perform 10 swaps back-and-forth between the first two _tokens. function _performSwapGasTest(IPartyPool testPool) internal { - _performSwapGasTest(testPool, Funding.USE_APPROVALS); + _performSwapGasTest(testPool, Funding.APPROVALS); } function sendTokensCallback(IERC20 token, uint256 amount) external { @@ -253,11 +253,11 @@ contract GasTest is Test { address payer; address spender; - if (fundingSelector == Funding.USE_PREFUNDING) { + if (fundingSelector == Funding.PREFUNDING) { payer = address(this); spender = address(this); } - else if (fundingSelector == Funding.USE_APPROVALS) { + else if (fundingSelector == Funding.APPROVALS) { payer = alice; spender = address(testPool); } @@ -278,13 +278,13 @@ contract GasTest is Test { vm.startPrank(alice); for (uint256 i = 0; i < 20; i++) { if (i % 2 == 0) { - if (fundingSelector == Funding.USE_PREFUNDING) + if (fundingSelector == Funding.PREFUNDING) token0.transfer(address(testPool), maxIn); // swap token0 -> token1 testPool.swap(payer, fundingSelector, alice, 0, 1, maxIn, 0, 0, false); } else { // swap token1 -> token0 - if (fundingSelector == Funding.USE_PREFUNDING) + if (fundingSelector == Funding.PREFUNDING) token1.transfer(address(testPool), maxIn); testPool.swap(payer, fundingSelector, alice, 1, 0, maxIn, 0, 0, false); } @@ -312,7 +312,7 @@ contract GasTest is Test { /// @notice Gas measurement: perform 10 swaps back-and-forth between first two _tokens in the 10-token pool using the callback funding method. function testSwapGasPrefunding() public { - _performSwapGasTest(pool10, Funding.USE_PREFUNDING); + _performSwapGasTest(pool10, Funding.PREFUNDING); } /// @notice Gas measurement: perform 10 swaps back-and-forth between first two _tokens in the 20-token pool. diff --git a/test/NativeTest.t.sol b/test/NativeTest.t.sol index 926ab3d..9849624 100644 --- a/test/NativeTest.t.sol +++ b/test/NativeTest.t.sol @@ -148,7 +148,7 @@ contract NativeTest is Test { // Send native currency with {value: maxIn} (uint256 amountIn, uint256 amountOut, ) = pool.swap{value: maxIn}( alice, // payer - Funding.USE_APPROVALS, + Funding.APPROVALS, alice, // receiver 2, // inputTokenIndex (WETH) 0, // outputTokenIndex (token0) @@ -186,7 +186,7 @@ contract NativeTest is Test { // Execute swap: token0 (index 0) -> WETH (index 2) with unwrap=true (uint256 amountIn, uint256 amountOut, ) = pool.swap( alice, // payer - Funding.USE_APPROVALS, // no selector: use ERC20 approvals + Funding.APPROVALS, // no selector: use ERC20 approvals alice, // receiver 0, // inputTokenIndex (token0) 2, // outputTokenIndex (WETH) @@ -222,7 +222,7 @@ contract NativeTest is Test { // Execute swap with excess native currency (uint256 amountIn, , ) = pool.swap{value: totalSent}( alice, // payer - Funding.USE_APPROVALS, + Funding.APPROVALS, alice, // receiver 2, // inputTokenIndex (WETH) 0, // outputTokenIndex (token0) @@ -551,14 +551,14 @@ contract NativeTest is Test { // 2. Swap native currency for token0 uint256 swapAmount = 5_000; (, uint256 amountOut, ) = pool.swap{value: swapAmount}( - alice,Funding.USE_APPROVALS,alice, 2, 0, swapAmount, 0, 0, false + alice,Funding.APPROVALS,alice, 2, 0, swapAmount, 0, 0, false ); assertTrue(amountOut > 0, "Should receive token0"); // 3. Swap token0 back to native currency uint256 token0Balance = token0.balanceOf(alice); (, uint256 swapOut2, ) = pool.swap( - alice, Funding.USE_APPROVALS, alice, 0, 2, token0Balance / 2, 0, 0, true + alice, Funding.APPROVALS, alice, 0, 2, token0Balance / 2, 0, 0, true ); assertTrue(swapOut2 > 0, "Should receive native currency"); @@ -585,7 +585,7 @@ contract NativeTest is Test { // Swap token0 -> WETH without unwrap (, uint256 amountOut, ) = pool.swap( - alice, Funding.USE_APPROVALS, alice, 0, 2, maxIn, 0, 0, false // unwrap=false + alice, Funding.APPROVALS, alice, 0, 2, maxIn, 0, 0, false // unwrap=false ); assertTrue(amountOut > 0, "Should receive WETH tokens"); @@ -606,7 +606,7 @@ contract NativeTest is Test { // Try to swap token0 (not WETH) by sending native currency - should revert vm.expectRevert(); pool.swap{value: 10_000}( - alice, Funding.USE_APPROVALS, alice, 0, 1, 10_000, 0, 0, false + alice, Funding.APPROVALS, alice, 0, 1, 10_000, 0, 0, false ); vm.stopPrank(); diff --git a/test/PartyPool.t.sol b/test/PartyPool.t.sol index 5fdd7c8..6b0e9cb 100644 --- a/test/PartyPool.t.sol +++ b/test/PartyPool.t.sol @@ -431,7 +431,7 @@ contract PartyPoolTest is Test { // Execute swap: token0 -> token1 vm.prank(alice); - (uint256 amountInUsed, uint256 amountOut, uint256 fee) = pool.swap(alice, Funding.USE_APPROVALS, bob, 0, 1, maxIn, 0, 0, false); + (uint256 amountInUsed, uint256 amountOut, uint256 fee) = pool.swap(alice, Funding.APPROVALS, bob, 0, 1, maxIn, 0, 0, false); // Amounts should be positive and not exceed provided max assertTrue(amountInUsed > 0, "expected some input used"); @@ -460,7 +460,7 @@ contract PartyPoolTest is Test { vm.prank(alice); vm.expectRevert(bytes("LMSR: limitPrice <= current price")); - pool.swap(alice, Funding.USE_APPROVALS, alice, 0, 1, 1000, limitPrice, 0, false); + pool.swap(alice, Funding.APPROVALS, alice, 0, 1, 1000, limitPrice, 0, false); } /// @notice swapToLimit should compute input needed to reach a slightly higher price and execute. @@ -1032,8 +1032,8 @@ contract PartyPoolTest is Test { token0.approve(address(poolCustom), type(uint256).max); // Perform identical swaps: token0 -> token1 - (uint256 amountInDefault, uint256 amountOutDefault, uint256 feeDefault) = poolDefault.swap(alice, Funding.USE_APPROVALS, alice, 0, 1, swapAmount, 0, 0, false); - (uint256 amountInCustom, uint256 amountOutCustom, uint256 feeCustom) = poolCustom.swap(alice, Funding.USE_APPROVALS, alice, 0, 1, swapAmount, 0, 0, false); + (uint256 amountInDefault, uint256 amountOutDefault, uint256 feeDefault) = poolDefault.swap(alice, Funding.APPROVALS, alice, 0, 1, swapAmount, 0, 0, false); + (uint256 amountInCustom, uint256 amountOutCustom, uint256 feeCustom) = poolCustom.swap(alice, Funding.APPROVALS, alice, 0, 1, swapAmount, 0, 0, false); // Swap results should be identical assertEq(amountInDefault, amountInCustom, "Swap input amounts should be identical");