From b64f5f664850410f4cb0a64847c79ddf00375ee4 Mon Sep 17 00:00:00 2001 From: tim Date: Sun, 19 Oct 2025 15:46:41 -0400 Subject: [PATCH] contract size fix --- src/PartyPool.sol | 22 ++++++---------------- src/PartyPoolSwapImpl.sol | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/PartyPool.sol b/src/PartyPool.sol index 007afc3..d682db8 100644 --- a/src/PartyPool.sol +++ b/src/PartyPool.sol @@ -80,7 +80,6 @@ contract PartyPool is PartyPoolBase, OwnableExternal, ERC20External, IPartyPool PartyPoolSwapImpl private immutable SWAP_IMPL; function swapMintImpl() external view returns (PartyPoolSwapImpl) { return SWAP_IMPL; } - /// @inheritdoc IPartyPool function getToken(uint256 i) external view returns (IERC20) { return _tokens[i]; } @@ -474,23 +473,14 @@ contract PartyPool is PartyPoolBase, OwnableExternal, ERC20External, IPartyPool /// @notice Transfer all protocol fees to the configured protocolFeeAddress and zero the ledger. /// @dev Anyone can call; must have protocolFeeAddress != address(0) to be operational. function collectProtocolFees() external nonReentrant { - address dest = PROTOCOL_FEE_ADDRESS; - require(dest != address(0), "collect: zero addr"); - - uint256 n = _tokens.length; - for (uint256 i = 0; i < n; i++) { - uint256 owed = _protocolFeesOwed[i]; - if (owed == 0) continue; - uint256 bal = IERC20(_tokens[i]).balanceOf(address(this)); - require(bal >= owed, "collect: fee > bal"); - _protocolFeesOwed[i] = 0; - // update cached to effective onchain minus owed - _cachedUintBalances[i] = bal - owed; - // transfer owed _tokens to protocol destination via centralized helper - _sendTokenTo(_tokens[i], dest, owed, false); - } + bytes memory data = abi.encodeWithSelector( + PartyPoolSwapImpl.collectProtocolFees.selector, + PROTOCOL_FEE_ADDRESS + ); + Address.functionDelegateCall(address(MINT_IMPL), data); } + function _swapAmountsForExactInput(uint256 i, uint256 j, int128 a, int128 limitPrice) internal virtual view returns (int128 amountIn, int128 amountOut) { return _lmsr.swapAmountsForExactInput(i, j, a, limitPrice); diff --git a/src/PartyPoolSwapImpl.sol b/src/PartyPoolSwapImpl.sol index fa92f62..6cc9eff 100644 --- a/src/PartyPoolSwapImpl.sol +++ b/src/PartyPoolSwapImpl.sol @@ -146,4 +146,24 @@ contract PartyPoolSwapImpl is PartyPoolBase { require(amountOutUint > 0, "swapToLimit: output zero"); } + + /// @notice Transfer all protocol fees to the configured protocolFeeAddress and zero the ledger. + /// @dev Anyone can call; must have protocolFeeAddress != address(0) to be operational. + function collectProtocolFees(address dest) external nonReentrant { + require(dest != address(0), "collect: zero addr"); + + uint256 n = _tokens.length; + for (uint256 i = 0; i < n; i++) { + uint256 owed = _protocolFeesOwed[i]; + if (owed == 0) continue; + uint256 bal = IERC20(_tokens[i]).balanceOf(address(this)); + require(bal >= owed, "collect: fee > bal"); + _protocolFeesOwed[i] = 0; + // update cached to effective onchain minus owed + _cachedUintBalances[i] = bal - owed; + // transfer owed _tokens to protocol destination via centralized helper + _sendTokenTo(_tokens[i], dest, owed, false); + } + } + }