From ce34a2167d54d1ad2c17601d04a5dcb98130268c Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Sat, 13 Jan 2024 19:09:45 -0500 Subject: [PATCH] Allow the factory owner to set fee protocol on a pool --- src/V3FactoryOwner.sol | 9 +++++++++ test/V3FactoryOwner.t.sol | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/V3FactoryOwner.sol b/src/V3FactoryOwner.sol index cca3f6d..73392a5 100644 --- a/src/V3FactoryOwner.sol +++ b/src/V3FactoryOwner.sol @@ -60,6 +60,15 @@ contract V3FactoryOwner { FACTORY.enableFeeAmount(_fee, _tickSpacing); } + function setFeeProtocol( + IUniswapV3PoolOwnerActions _pool, + uint8 _feeProtocol0, + uint8 _feeProtocol1 + ) external { + _revertIfNotAdmin(); + _pool.setFeeProtocol(_feeProtocol0, _feeProtocol1); + } + function claimFees( IUniswapV3PoolOwnerActions _pool, address _recipient, diff --git a/test/V3FactoryOwner.t.sol b/test/V3FactoryOwner.t.sol index ba90a2d..b8b592a 100644 --- a/test/V3FactoryOwner.t.sol +++ b/test/V3FactoryOwner.t.sol @@ -194,6 +194,34 @@ contract EnableFeeAmount is V3FactoryOwnerTest { } } +contract SetFeeProtocol is V3FactoryOwnerTest { + function testFuzz_CurriesParametersToSetFeeProtocolToAPool( + uint8 _feeProtocol0, + uint8 _feeProtocol1 + ) public { + _deployFactoryOwnerWithPayoutAmount(0); + + vm.prank(admin); + factoryOwner.setFeeProtocol(pool, _feeProtocol0, _feeProtocol1); + + assertEq(pool.lastParam__setFeeProtocol_feeProtocol0(), _feeProtocol0); + assertEq(pool.lastParam__setFeeProtocol_feeProtocol1(), _feeProtocol1); + } + + function testFuzz_RevertIf_TheCallerIsNotTheAdmin( + address _notAdmin, + uint8 _feeProtocol0, + uint8 _feeProtocol1 + ) public { + _deployFactoryOwnerWithPayoutAmount(0); + vm.assume(_notAdmin != admin); + + vm.expectRevert(V3FactoryOwner.V3FactoryOwner__Unauthorized.selector); + vm.prank(_notAdmin); + factoryOwner.setFeeProtocol(pool, _feeProtocol0, _feeProtocol1); + } +} + contract ClaimFees is V3FactoryOwnerTest { function testFuzz_TransfersThePayoutFromTheCallerToTheRewardReceiver( uint256 _payoutAmount,