contract size fix

This commit is contained in:
tim
2025-10-19 15:46:41 -04:00
parent d55be28cba
commit b64f5f6648
2 changed files with 26 additions and 16 deletions

View File

@@ -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);

View File

@@ -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);
}
}
}