Skip to content

Commit 63c2767

Browse files
authored
Curve pool booster Factory (#2707)
* initial curve factory commit * add ability to verify pool booster address before deployment * correct deployment files * simplify deployment file * add a view function to generate salt for easier operations * comment adjust * add more tests and prettier * undo change * linter * slither * styling * use full error word
1 parent 2bd763b commit 63c2767

File tree

9 files changed

+848
-12
lines changed

9 files changed

+848
-12
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
// SPDX-License-Identifier: AGPL-3.0-only
2+
pragma solidity ^0.8.4;
3+
4+
/**
5+
* @title CreateX Factory Interface Definition
6+
* @author pcaversaccio (https://web.archive.org/web/20230921103111/https://pcaversaccio.com/)
7+
* @custom:coauthor Matt Solomon (https://web.archive.org/web/20230921103335/https://mattsolomon.dev/)
8+
*/
9+
interface ICreateX {
10+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
11+
/* TYPES */
12+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
13+
14+
struct Values {
15+
uint256 constructorAmount;
16+
uint256 initCallAmount;
17+
}
18+
19+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
20+
/* EVENTS */
21+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
22+
23+
event ContractCreation(address indexed newContract, bytes32 indexed salt);
24+
event ContractCreation(address indexed newContract);
25+
event Create3ProxyContractCreation(
26+
address indexed newContract,
27+
bytes32 indexed salt
28+
);
29+
30+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
31+
/* CUSTOM ERRORS */
32+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
33+
34+
error FailedContractCreation(address emitter);
35+
error FailedContractInitialisation(address emitter, bytes revertData);
36+
error InvalidSalt(address emitter);
37+
error InvalidNonceValue(address emitter);
38+
error FailedEtherTransfer(address emitter, bytes revertData);
39+
40+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
41+
/* CREATE */
42+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
43+
44+
function deployCreate(bytes memory initCode)
45+
external
46+
payable
47+
returns (address newContract);
48+
49+
function deployCreateAndInit(
50+
bytes memory initCode,
51+
bytes memory data,
52+
Values memory values,
53+
address refundAddress
54+
) external payable returns (address newContract);
55+
56+
function deployCreateAndInit(
57+
bytes memory initCode,
58+
bytes memory data,
59+
Values memory values
60+
) external payable returns (address newContract);
61+
62+
function deployCreateClone(address implementation, bytes memory data)
63+
external
64+
payable
65+
returns (address proxy);
66+
67+
function computeCreateAddress(address deployer, uint256 nonce)
68+
external
69+
view
70+
returns (address computedAddress);
71+
72+
function computeCreateAddress(uint256 nonce)
73+
external
74+
view
75+
returns (address computedAddress);
76+
77+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
78+
/* CREATE2 */
79+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
80+
81+
function deployCreate2(bytes32 salt, bytes memory initCode)
82+
external
83+
payable
84+
returns (address newContract);
85+
86+
function deployCreate2(bytes memory initCode)
87+
external
88+
payable
89+
returns (address newContract);
90+
91+
function deployCreate2AndInit(
92+
bytes32 salt,
93+
bytes memory initCode,
94+
bytes memory data,
95+
Values memory values,
96+
address refundAddress
97+
) external payable returns (address newContract);
98+
99+
function deployCreate2AndInit(
100+
bytes32 salt,
101+
bytes memory initCode,
102+
bytes memory data,
103+
Values memory values
104+
) external payable returns (address newContract);
105+
106+
function deployCreate2AndInit(
107+
bytes memory initCode,
108+
bytes memory data,
109+
Values memory values,
110+
address refundAddress
111+
) external payable returns (address newContract);
112+
113+
function deployCreate2AndInit(
114+
bytes memory initCode,
115+
bytes memory data,
116+
Values memory values
117+
) external payable returns (address newContract);
118+
119+
function deployCreate2Clone(
120+
bytes32 salt,
121+
address implementation,
122+
bytes memory data
123+
) external payable returns (address proxy);
124+
125+
function deployCreate2Clone(address implementation, bytes memory data)
126+
external
127+
payable
128+
returns (address proxy);
129+
130+
function computeCreate2Address(
131+
bytes32 salt,
132+
bytes32 initCodeHash,
133+
address deployer
134+
) external pure returns (address computedAddress);
135+
136+
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash)
137+
external
138+
view
139+
returns (address computedAddress);
140+
141+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
142+
/* CREATE3 */
143+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
144+
145+
function deployCreate3(bytes32 salt, bytes memory initCode)
146+
external
147+
payable
148+
returns (address newContract);
149+
150+
function deployCreate3(bytes memory initCode)
151+
external
152+
payable
153+
returns (address newContract);
154+
155+
function deployCreate3AndInit(
156+
bytes32 salt,
157+
bytes memory initCode,
158+
bytes memory data,
159+
Values memory values,
160+
address refundAddress
161+
) external payable returns (address newContract);
162+
163+
function deployCreate3AndInit(
164+
bytes32 salt,
165+
bytes memory initCode,
166+
bytes memory data,
167+
Values memory values
168+
) external payable returns (address newContract);
169+
170+
function deployCreate3AndInit(
171+
bytes memory initCode,
172+
bytes memory data,
173+
Values memory values,
174+
address refundAddress
175+
) external payable returns (address newContract);
176+
177+
function deployCreate3AndInit(
178+
bytes memory initCode,
179+
bytes memory data,
180+
Values memory values
181+
) external payable returns (address newContract);
182+
183+
function computeCreate3Address(bytes32 salt, address deployer)
184+
external
185+
pure
186+
returns (address computedAddress);
187+
188+
function computeCreate3Address(bytes32 salt)
189+
external
190+
view
191+
returns (address computedAddress);
192+
}

contracts/contracts/strategies/CurvePoolBooster.sol

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ contract CurvePoolBooster is Initializable, Strategizable {
1919
/// @notice Base fee for the contract, 100%
2020
uint16 public constant FEE_BASE = 10_000;
2121

22+
/// @notice Arbitrum where the votemarket is running
23+
uint256 public constant targetChainId = 42161;
24+
2225
/// @notice Address of the gauge to manage
2326
address public immutable gauge;
2427

2528
/// @notice Address of the reward token
2629
address public immutable rewardToken;
2730

28-
/// @notice Chain id of the target chain
29-
uint256 public immutable targetChainId;
30-
3131
////////////////////////////////////////////////////
3232
/// --- STORAGE
3333
////////////////////////////////////////////////////
34+
3435
/// @notice Fee in FEE_BASE unit payed when managing campaign.
3536
uint16 public fee;
3637

@@ -70,12 +71,7 @@ contract CurvePoolBooster is Initializable, Strategizable {
7071
////////////////////////////////////////////////////
7172
/// --- CONSTRUCTOR && INITIALIZATION
7273
////////////////////////////////////////////////////
73-
constructor(
74-
uint256 _targetChainId,
75-
address _rewardToken,
76-
address _gauge
77-
) {
78-
targetChainId = _targetChainId;
74+
constructor(address _rewardToken, address _gauge) {
7975
rewardToken = _rewardToken;
8076
gauge = _gauge;
8177

@@ -265,6 +261,7 @@ contract CurvePoolBooster is Initializable, Strategizable {
265261
/// @dev This function only work on the L2 chain. Not on mainnet.
266262
/// @dev The _campaignId parameter is not related to the campaignId of this contract, allowing greater flexibility.
267263
/// @param _campaignId Id of the campaign to close
264+
// slither-disable-start reentrancy-eth
268265
function closeCampaign(
269266
uint256 _campaignId,
270267
uint256 bridgeFee,
@@ -283,6 +280,7 @@ contract CurvePoolBooster is Initializable, Strategizable {
283280
campaignId = 0;
284281
emit CampaignClosed(_campaignId);
285282
}
283+
// slither-disable-end reentrancy-eth
286284

287285
/// @notice calculate the fee amount and transfer it to the feeCollector
288286
/// @return Balance after fee
@@ -406,7 +404,7 @@ contract CurvePoolBooster is Initializable, Strategizable {
406404
}
407405

408406
/// @notice Internal logic to set the votemarket address
409-
function _setVotemarket(address _votemarket) internal onlyGovernor {
407+
function _setVotemarket(address _votemarket) internal {
410408
require(_votemarket != address(0), "Invalid votemarket");
411409
votemarket = _votemarket;
412410
emit VotemarketUpdated(_votemarket);

0 commit comments

Comments
 (0)