Skip to content

Commit 95c7bd5

Browse files
Merge pull request #76 from bnb-party/issue-71
add `isTokenTargetReached`
2 parents fd9ed36 + 9501a4d commit 95c7bd5

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

contracts/BNBPartyFactory.sol

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ contract BNBPartyFactory is BNBPartyLiquidity, ReentrancyGuard, BNBPartyManageab
4949
lpToCreator[liquidityPool] = msg.sender; // Set the creator of the liquidity pool
5050
lpToTokenId[liquidityPool] = tokenId; // Set the token ID of the liquidity pool
5151
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
5352
if (msg.value > party.createTokenFee) {
5453
_executeSwap(address(newToken));
5554
}

contracts/BNBPartyLiquidity.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract contract BNBPartyLiquidity is BNBPartyLiquidityHelper {
2525

2626
if (token0 == address(WBNB)) {
2727
amount0 -= unwrapAmount; // Deduct unwrap amount from token0 if it is WBNB
28-
isTokenOnPartyLP[token1] = false;
28+
isTokenTargetReached[token1] = true;
2929
newSqrtPriceX96 = sqrtPriceCalculator.getNextSqrtPriceFromAmount0RoundingUp(
3030
sqrtPriceX96,
3131
liquidity,
@@ -34,7 +34,7 @@ abstract contract BNBPartyLiquidity is BNBPartyLiquidityHelper {
3434
);
3535
} else {
3636
amount1 -= unwrapAmount; // Deduct unwrap amount from token1 if it is WBNB
37-
isTokenOnPartyLP[token0] = false;
37+
isTokenTargetReached[token0] = true;
3838
newSqrtPriceX96 = sqrtPriceCalculator.getNextSqrtPriceFromAmount1RoundingDown(
3939
sqrtPriceX96,
4040
liquidity,

contracts/BNBPartyState.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ abstract contract BNBPartyState is BNBPartyModifiers, Ownable {
1717
mapping(address => bool) public isParty; // Mapping to track if a LiquidityPool is a party
1818
mapping(address => uint256) public lpToTokenId; // Mapping from LiquidityPool to its NFT tokenId
1919
mapping(address => address) public lpToCreator; // Mapping from LiquidityPool to its creator
20-
mapping(address => bool) public isTokenOnPartyLP; // Mapping to track if a token is part of a party
21-
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;
2222

2323
Party public party; // store party parameters
2424

contracts/BNBPartySwaps.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ abstract contract BNBPartySwaps is BNBPartyView {
8181
/// @return router The address of the swap router
8282
/// @return fee The fee amount for the swap
8383
function _getRouterAndFee(address token) internal view returns (ISwapRouter router, uint24 fee) {
84-
if (isTokenOnPartyLP[token]) {
85-
router = BNBSwapRouter;
86-
fee = party.partyLpFee;
87-
} else {
84+
if (isTokenTargetReached[token]) {
8885
router = swapRouter;
8986
fee = party.lpFee;
87+
} else {
88+
router = BNBSwapRouter;
89+
fee = party.partyLpFee;
9090
}
9191
}
9292
}

0 commit comments

Comments
 (0)