Skip to content

Commit

Permalink
update constructor parameters for pool manager
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 committed Nov 1, 2024
1 parent 1a27be0 commit 7ee4dea
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
185177
179521
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
239949
228613
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactIn3Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
225213
219557
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
183515
179643
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
237372
229604
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut3Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
229613
225741
2 changes: 1 addition & 1 deletion .forge-snapshots/V4Router_ExactOut3Hops_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
216949
220813
2 changes: 1 addition & 1 deletion lib/v4-core
4 changes: 1 addition & 3 deletions src/UniswapV4DeployerCompetition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ contract UniswapV4DeployerCompetition is IUniswapV4DeployerCompetition {
revert NotAllowedToDeploy(msg.sender, deployer);
}

// the owner of the contract must be encoded in the bytecode
Create2.deploy(0, bestAddressSalt, bytecode);

// set owner of the pool manager contract
Owned(bestAddress).transferOwnership(v4Owner);
}
}
24 changes: 12 additions & 12 deletions test/UniswapV4DeployerCompetition.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ contract UniswapV4DeployerCompetitionTest is Test {
address deployer;
address v4Owner;
address winner;
uint256 constant controllerGasLimit = 10000;
uint256 competitionDeadline;

function setUp() public {
Expand All @@ -27,7 +26,7 @@ contract UniswapV4DeployerCompetitionTest is Test {
winner = makeAddr("Winner");
deployer = makeAddr("Deployer");
vm.prank(deployer);
initCodeHash = keccak256(abi.encodePacked(type(PoolManager).creationCode, controllerGasLimit));
initCodeHash = keccak256(abi.encodePacked(type(PoolManager).creationCode, uint256(uint160(v4Owner))));
competition = new UniswapV4DeployerCompetition(initCodeHash, v4Owner, competitionDeadline);
assertEq(competition.v4Owner(), v4Owner);
}
Expand All @@ -43,16 +42,16 @@ contract UniswapV4DeployerCompetitionTest is Test {
vm.expectEmit(true, true, true, false, address(competition));
emit IUniswapV4DeployerCompetition.NewAddressFound(newAddress, winner, VanityAddressLib.score(newAddress));
competition.updateBestAddress(salt);
assertFalse(competition.bestAddress() == address(0));
assertEq(competition.bestAddress(), newAddress);
assertEq(competition.bestAddressSubmitter(), winner);
assertEq(competition.bestAddressSalt(), salt);
assertFalse(competition.bestAddress() == address(0), "best address not set");
assertEq(competition.bestAddress(), newAddress, "wrong address set");
assertEq(competition.bestAddressSubmitter(), winner, "wrong submitter set");
assertEq(competition.bestAddressSalt(), salt, "incorrect salt set");
address v4Core = competition.bestAddress();

assertEq(v4Core.code.length, 0);
vm.warp(competition.competitionDeadline() + 1);
vm.prank(deployer);
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, controllerGasLimit));
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, uint256(uint160(v4Owner))));
assertFalse(v4Core.code.length == 0);
assertEq(Owned(v4Core).owner(), v4Owner);
assertEq(address(competition).balance, 0 ether);
Expand All @@ -76,7 +75,7 @@ contract UniswapV4DeployerCompetitionTest is Test {
address v4Core = competition.bestAddress();

vm.warp(competition.competitionDeadline() + 1.1 days);
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, controllerGasLimit));
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, uint256(uint160(v4Owner))));
assertFalse(v4Core.code.length == 0);
assertEq(Owned(v4Core).owner(), v4Owner);
assertEq(TickMath.MAX_TICK_SPACING, type(int16).max);
Expand All @@ -92,14 +91,15 @@ contract UniswapV4DeployerCompetitionTest is Test {
IUniswapV4DeployerCompetition.CompetitionNotOver.selector, timestamp, competition.competitionDeadline()
)
);
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, controllerGasLimit));
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, uint256(uint160(v4Owner))));
}

function testInvalidBytecode(bytes32 salt) public {
vm.prank(winner);
competition.updateBestAddress(salt);
vm.expectRevert(IUniswapV4DeployerCompetition.InvalidBytecode.selector);
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, controllerGasLimit + 1));
// set the owner as the winner not the correct owner
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, uint256(uint160(winner))));
}

function testInvalidMsgSender(bytes32 salt) public {
Expand All @@ -110,15 +110,15 @@ contract UniswapV4DeployerCompetitionTest is Test {
vm.expectRevert(
abi.encodeWithSelector(IUniswapV4DeployerCompetition.NotAllowedToDeploy.selector, address(1), deployer)
);
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, controllerGasLimit));
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, uint256(uint160(v4Owner))));
}

function testAfterExcusiveDeployDeadline(bytes32 salt) public {
vm.prank(winner);
competition.updateBestAddress(salt);
vm.warp(competition.exclusiveDeployDeadline() + 1);
vm.prank(address(1));
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, controllerGasLimit));
competition.deploy(abi.encodePacked(type(PoolManager).creationCode, uint256(uint160(v4Owner))));
}

function testEqualSaltNotChanged(bytes32 salt) public {
Expand Down

0 comments on commit 7ee4dea

Please sign in to comment.