Skip to content

Commit

Permalink
Allow the factory owner to set fee protocol on a pool
Browse files Browse the repository at this point in the history
  • Loading branch information
apbendi committed Jan 23, 2024
1 parent 49b09eb commit ce34a21
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/V3FactoryOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 28 additions & 0 deletions test/V3FactoryOwner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ce34a21

Please sign in to comment.