2
2
pragma solidity ^ 0.8.0 ;
3
3
4
4
import "@openzeppelin/contracts/access/Ownable.sol " ;
5
- import "@bnb-party/v3-periphery/contracts/interfaces/ISwapRouter.sol " ;
6
5
import "./interfaces/ISqrtPriceCalculator.sol " ;
7
6
import "./interfaces/INonfungiblePositionManager.sol " ;
8
- import "./interfaces/IBNBPartyFactory.sol " ;
9
7
import "./interfaces/IWBNB.sol " ;
8
+ import "./BNBPartyModifiers.sol " ;
10
9
11
10
/// @title BNBPartyState
12
11
/// @notice This abstract contract handles the state variables and initial setup for the BNBParty system.
13
- abstract contract BNBPartyState is IBNBPartyFactory , Ownable {
12
+ abstract contract BNBPartyState is BNBPartyModifiers , Ownable {
14
13
INonfungiblePositionManager public BNBPositionManager; // BNB Party position manager
15
14
INonfungiblePositionManager public positionManager; // Default Pancakeswap V3 position manager
16
15
ISwapRouter public BNBSwapRouter; // V3 swap router
17
16
ISwapRouter public swapRouter; // Pancakeswap V3 router
18
17
mapping (address => bool ) public isParty; // Mapping to track if a LiquidityPool is a party
19
18
mapping (address => uint256 ) public lpToTokenId; // Mapping from LiquidityPool to its NFT tokenId
20
19
mapping (address => address ) public lpToCreator; // Mapping from LiquidityPool to its creator
21
- mapping (address => bool ) public isTokenOnPartyLP ; // Mapping to track if a token is part of a party
22
- uint256 constant FEE_GROWTH_GLOBAL_SCALE = 2 ** 128 ;
20
+ mapping (address => bool ) public isTokenTargetReached ; // Mapping to track if a token has reached its target
21
+ uint256 constant public FEE_GROWTH_GLOBAL_SCALE = 2 ** 128 ;
23
22
24
23
Party public party; // store party parameters
25
24
@@ -29,27 +28,32 @@ abstract contract BNBPartyState is IBNBPartyFactory, Ownable {
29
28
/// @notice Constructor to initialize the BNBPartyState contract
30
29
/// @param _party Struct containing party parameters
31
30
/// @param _WBNB Address of the Wrapped BNB token contract
32
- constructor (Party memory _party , IWBNB _WBNB , ISqrtPriceCalculator _sqrtPriceCalculator ) Ownable (_msgSender ()) {
33
- if (address (_WBNB) == address (0 )) {
34
- revert ZeroAddress (); // Reverts if the WBNB address is zero
35
- }
36
- if (address (_sqrtPriceCalculator) == address (0 )) {
37
- revert ZeroAddress (); // Reverts if the sqrt price calculator address is zero
38
- }
39
- if (_party.partyTarget == 0 ) {
40
- revert ZeroAmount (); // Reverts if the party target is zero
41
- }
42
- if (_party.initialTokenAmount == 0 ) {
43
- revert ZeroAmount (); // Reverts if the initial token amount is zero
44
- }
45
- if (_party.partyTarget <= (_party.bonusPartyCreator + _party.bonusTargetReach + _party.targetReachFee)) {
46
- revert BonusGreaterThanTarget (); // Reverts if the party target is less than or equal to the sum of bonuses and fees
47
- }
48
- if (_party.sqrtPriceX96 == 0 ) {
49
- revert ZeroAmount (); // Reverts if the sqrt price is zero
50
- }
31
+ constructor (
32
+ Party memory _party ,
33
+ IWBNB _WBNB ,
34
+ ISqrtPriceCalculator _sqrtPriceCalculator
35
+ ) Ownable (_msgSender ()) {
36
+ _constructorValidation (_party, _WBNB, _sqrtPriceCalculator);
51
37
party = _party;
52
38
WBNB = _WBNB;
53
39
sqrtPriceCalculator = _sqrtPriceCalculator;
54
40
}
41
+
42
+ function _constructorValidation (
43
+ Party memory _party ,
44
+ IWBNB _WBNB ,
45
+ ISqrtPriceCalculator _sqrtPriceCalculator
46
+ )
47
+ private
48
+ pure
49
+ notZeroAddress (address (_WBNB))
50
+ notZeroAddress (address (_sqrtPriceCalculator))
51
+ notZeroAmount (_party.partyTarget)
52
+ notZeroAmount (_party.initialTokenAmount)
53
+ notZeroAmount (_party.sqrtPriceX96)
54
+ {
55
+ if (_party.partyTarget <= (_party.bonusPartyCreator + _party.bonusTargetReach + _party.targetReachFee)) {
56
+ revert BonusGreaterThanTarget (); // Reverts if the party target is less than or equal to the sum of bonuses and fees
57
+ }
58
+ }
55
59
}
0 commit comments