Skip to content

Commit 66ffc3f

Browse files
authored
feat: Settable LP Fee Recipient on ERC20CreatorV3 (#22)
* Settable LP Fee Recipient on `ERC20CreatorV3` * test fee recipient set * test setting lp fee recipient not party * update test wording
1 parent a244657 commit 66ffc3f

5 files changed

+43
-4
lines changed

src/ERC20CreatorV3.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ contract ERC20CreatorV3 is IERC721Receiver {
106106

107107
/// @notice Creates a new ERC20 token, LPs it in a locked full range Uniswap V3 position, and distributes some of the new token to party members.
108108
/// @dev The party is assumed to be `msg.sender`
109-
/// @param party The party to allocate this token to
109+
/// @param party The party to allocate the token distribution to
110+
/// @param lpFeeRecipient The address to receive the LP fee
110111
/// @param name The name of the new token
111112
/// @param symbol The symbol of the new token
112113
/// @param config Token distribution configuration. See above for additional information.
113114
/// @param tokenRecipientAddress The address to receive the tokens allocated for the token recipient
114115
/// @return token The address of the newly created token
115116
function createToken(
116117
address party,
118+
address lpFeeRecipient,
117119
string memory name,
118120
string memory symbol,
119121
TokenDistributionConfiguration memory config,
@@ -245,7 +247,7 @@ contract ERC20CreatorV3 is IERC721Receiver {
245247

246248
FeeRecipient[] memory recipients = new FeeRecipient[](1);
247249
recipients[0] = FeeRecipient({
248-
recipient: payable(party),
250+
recipient: payable(lpFeeRecipient),
249251
percentageBps: 10_000
250252
});
251253

test/ERC20CreatorV3ForkTest.t.sol

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ contract ERC20CreatorV3ForkTest is Test {
8686
ERC20Votes token = ERC20Votes(
8787
address(
8888
creator.createToken{value: eth}(
89+
address(party),
8990
address(party),
9091
"Leet H4x0rs",
9192
"1337",

test/ERC20CreatorV3Test.t.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ contract ERC20CreatorV3Test is Test, MockUniswapV3Deployer {
5757

5858
function testCreatorV3_createToken(
5959
ERC20CreatorV3.TokenDistributionConfiguration memory tokenConfig,
60-
uint256 ethForLp
60+
uint256 ethForLp,
61+
address feeRecipient
6162
) public {
6263
tokenConfig.numTokensForDistribution = bound(
6364
tokenConfig.numTokensForDistribution,
@@ -104,6 +105,7 @@ contract ERC20CreatorV3Test is Test, MockUniswapV3Deployer {
104105
IERC20 token = IERC20(
105106
creator.createToken{value: ethForLp}(
106107
address(party),
108+
feeRecipient,
107109
"My Test Token",
108110
"MTT",
109111
tokenConfig,
@@ -139,7 +141,7 @@ contract ERC20CreatorV3Test is Test, MockUniswapV3Deployer {
139141
assertEq(
140142
abi.encode(feeRecipients[0]),
141143
abi.encode(
142-
FeeRecipient({recipient: address(party), percentageBps: 10_000})
144+
FeeRecipient({recipient: feeRecipient, percentageBps: 10_000})
143145
)
144146
);
145147

test/FeeCollector.t.sol

+33
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ contract FeeCollectorTest is Test, MockUniswapV3Deployer {
6161
vm.prank(address(party));
6262
token = IERC20(
6363
creator.createToken{value: 10e18}(
64+
address(party),
6465
address(party),
6566
"My Test Token",
6667
"MTT",
@@ -128,4 +129,36 @@ contract FeeCollectorTest is Test, MockUniswapV3Deployer {
128129
);
129130
feeCollector.setPartyDaoFeeBps(newFeeBps);
130131
}
132+
133+
function test_createToken_lpFeeRecipientNotParty() external {
134+
ERC20CreatorV3.TokenDistributionConfiguration
135+
memory tokenConfig = ERC20CreatorV3.TokenDistributionConfiguration({
136+
totalSupply: 1000000,
137+
numTokensForDistribution: 500000,
138+
numTokensForRecipient: 250000,
139+
numTokensForLP: 250000
140+
});
141+
142+
vm.deal(address(party), 10e18);
143+
vm.prank(address(party));
144+
145+
creator.createToken{value: 10e18}(
146+
address(party),
147+
address(this),
148+
"My Test Token",
149+
"MTT",
150+
tokenConfig,
151+
address(this)
152+
);
153+
uint256 tokenId = MockUniswapNonfungiblePositionManager(
154+
address(positionManager)
155+
).lastTokenId();
156+
157+
assertEq(feeCollector.getFeeRecipients(tokenId).length, 1);
158+
assertEq(
159+
feeCollector.getFeeRecipients(tokenId)[0].recipient,
160+
address(this)
161+
);
162+
assertEq(feeCollector.getFeeRecipients(tokenId)[0].percentageBps, 1e4);
163+
}
131164
}

test/FeeCollectorForked.t.sol

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ contract FeeCollectorForkedTest is Test {
8282
vm.recordLogs();
8383
token = IERC20(
8484
creator.createToken{value: 10e18}(
85+
address(party),
8586
address(party),
8687
"My Test Token",
8788
"MTT",

0 commit comments

Comments
 (0)