Skip to content

Commit 24fb39c

Browse files
Merge a172122 into 9b689c6
2 parents 9b689c6 + a172122 commit 24fb39c

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

contracts/BNBPartyCreation.sol

+4-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ abstract contract BNBPartyCreation is BNBPartySwaps {
1313
/// @param _token Address of the token to be used in the liquidity pool
1414
/// @return liquidityPool Address of the newly created liquidity pool
1515
/// @dev Sets the token amounts based on the balance and initializes the pool
16-
function _createFLP(address _token) internal returns (address liquidityPool) {
16+
function _createFLP(address _token) internal returns (address liquidityPool, uint256 tokenId) {
1717
(address token0, address token1, uint160 sqrtPrice, Ticks memory ticks) = _getTokenPairAndPrice(_token);
1818
// Determine the token amounts
1919
(uint256 amount0, uint256 amount1) = _calculateAmounts(token0);
2020
IERC20(_token).safeIncreaseAllowance(address(BNBPositionManager), party.initialTokenAmount);
21-
liquidityPool = _createLP(
21+
(liquidityPool, tokenId) = _createLP(
2222
BNBPositionManager,
2323
token0,
2424
token1,
@@ -28,8 +28,6 @@ abstract contract BNBPartyCreation is BNBPartySwaps {
2828
party.partyLpFee,
2929
ticks
3030
);
31-
isParty[liquidityPool] = true; // Mark the liquidity pool as a party pool
32-
isTokenOnPartyLP[_token] = true; // Mark the token as part of the party LP
3331
}
3432

3533
/// @notice Creates a new liquidity pool and mints liquidity positions.
@@ -51,7 +49,7 @@ abstract contract BNBPartyCreation is BNBPartySwaps {
5149
uint160 sqrtPriceX96,
5250
uint24 fee,
5351
Ticks memory ticks
54-
) internal returns (address liquidityPool) {
52+
) internal returns (address liquidityPool, uint256 tokenId) {
5553
// Create LP
5654
liquidityPool = liquidityManager.createAndInitializePoolIfNecessary(
5755
token0,
@@ -61,7 +59,7 @@ abstract contract BNBPartyCreation is BNBPartySwaps {
6159
);
6260

6361
// Mint LP
64-
(lpToTokenId[liquidityPool], , , ) = liquidityManager.mint(
62+
(tokenId, , , ) = liquidityManager.mint(
6563
INonfungiblePositionManager.MintParams({
6664
token0: token0,
6765
token1: token1,

contracts/BNBPartyFactory.sol

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ contract BNBPartyFactory is BNBPartyLiquidity, ReentrancyGuard, BNBPartyManageab
4545
// Create new token
4646
newToken = new ERC20Token(name, symbol, party.initialTokenAmount);
4747
// Create First Liquidity Pool
48-
address liquidityPool = _createFLP(address(newToken));
49-
lpToCreator[liquidityPool] = msg.sender;
48+
(address liquidityPool, uint256 tokenId) = _createFLP(address(newToken));
49+
lpToCreator[liquidityPool] = msg.sender; // Set the creator of the liquidity pool
50+
lpToTokenId[liquidityPool] = tokenId; // Set the token ID of the liquidity pool
51+
isParty[liquidityPool] = true; // Mark the liquidity pool as a party pool
52+
isTokenOnPartyLP[address(newToken)] = true; // Mark the token as part of the party LP
5053
if (msg.value > party.createTokenFee) {
5154
_executeSwap(address(newToken));
5255
}
@@ -65,7 +68,8 @@ contract BNBPartyFactory is BNBPartyLiquidity, ReentrancyGuard, BNBPartyManageab
6568

6669
if (WBNBBalance - feesEarned < party.partyTarget) return;
6770
// Handle liquidity
68-
_handleLiquidity(recipient);
71+
(address liquidityPool, uint256 tokenId) = _handleLiquidity(recipient);
72+
lpToTokenId[liquidityPool] = tokenId;
6973
}
7074

7175
/// @notice Allows users to join the party by swapping BNB for the specified token

contracts/BNBPartyLiquidity.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract contract BNBPartyLiquidity is BNBPartyLiquidityHelper {
1111
/// @notice Handles liquidity by decreasing the liquidity, collecting tokens, and creating a new liquidity pool.
1212
/// @param recipient Address receiving the bonus BNB
1313
/// @dev Decreases liquidity, collects tokens, creates a new pool, and sends bonuses
14-
function _handleLiquidity(address recipient) internal {
14+
function _handleLiquidity(address recipient) internal returns (address liquidityPool, uint256 tokenId){
1515
IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);
1616
(uint160 sqrtPriceX96, , , , , , ) = pool.slot0();
1717
address token0 = pool.token0();
@@ -47,7 +47,7 @@ abstract contract BNBPartyLiquidity is BNBPartyLiquidityHelper {
4747
IERC20(token0).safeIncreaseAllowance(address(positionManager), amount0);
4848
IERC20(token1).safeIncreaseAllowance(address(positionManager), amount1);
4949
// Create new Liquidity Pool
50-
_createLP(positionManager, token0, token1, amount0, amount1, newSqrtPriceX96, party.lpFee, _getTicks(token0, party.lpTicks));
50+
(liquidityPool, tokenId) = _createLP(positionManager, token0, token1, amount0, amount1, newSqrtPriceX96, party.lpFee, _getTicks(token0, party.lpTicks));
5151

5252
// Send bonuses
5353
_unwrapAndSendBNB(recipient, unwrapAmount);

hardhat.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const LOW_OPTIMIZER_COMPILER_SETTINGS = {
2323
}
2424

2525
const BNB_FACTORY_COMPILER_SETTINGS = {
26-
version: "0.8.25",
26+
version: "0.8.26",
2727
settings: {
2828
evmVersion: "istanbul",
2929
optimizer: {

0 commit comments

Comments
 (0)