Skip to content

Commit cce88a9

Browse files
committed
refactor BNBPartyFee
1 parent 7083866 commit cce88a9

File tree

2 files changed

+20
-43
lines changed

2 files changed

+20
-43
lines changed

contracts/BNBPartyFee.sol

+10-42
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,6 @@ import "./interfaces/IUniswapV3Pool.sol";
77
/// @title BNBPartyFee
88
/// @notice This abstract contract provides internal functions for calculating fees in the BNB Party system.
99
abstract contract BNBPartyFee is BNBPartyState {
10-
/// @notice Internal function to retrieve the fee growth inside the position from the last observation
11-
/// @param pool Address of the Uniswap V3 pool
12-
/// @return feeGrowthInside0LastX128 Fee growth inside for token0 from the last observation
13-
/// @return feeGrowthInside1LastX128 Fee growth inside for token1 from the last observation
14-
function _getFeeGrowthInsideLastX128(
15-
IUniswapV3Pool pool
16-
)
17-
internal
18-
view
19-
returns (
20-
uint256 feeGrowthInside0LastX128,
21-
uint256 feeGrowthInside1LastX128
22-
)
23-
{
24-
(feeGrowthInside0LastX128, feeGrowthInside1LastX128) = _getFeeGrowthInsideLastX128(
25-
positionManager,
26-
pool,
27-
party.lpTicks
28-
);
29-
}
30-
31-
/// @notice Internal function to retrieve the fee growth inside the position from the last observation
32-
/// @param pool Address of the Uniswap V3 pool
33-
function _getPartyFeeGrowthInsideLastX128(
34-
IUniswapV3Pool pool
35-
)
36-
internal
37-
view
38-
returns (
39-
uint256 feeGrowthInside0LastX128,
40-
uint256 feeGrowthInside1LastX128
41-
)
42-
{
43-
(feeGrowthInside0LastX128, feeGrowthInside1LastX128) = _getFeeGrowthInsideLastX128(
44-
BNBPositionManager,
45-
pool,
46-
party.partyTicks
47-
);
48-
}
49-
5010
/// @notice Internal function to retrieve the fee growth inside the position from the last observation
5111
function _getFeeGrowthInsideLastX128(
5212
INonfungiblePositionManager manager,
@@ -88,10 +48,18 @@ abstract contract BNBPartyFee is BNBPartyState {
8848
IUniswapV3Pool pool
8949
) internal view returns (uint256 feeGrowthGlobal) {
9050
if (pool.token0() == address(WBNB)) {
91-
(uint256 feeGrowthInside0LastX128 , ) = _getPartyFeeGrowthInsideLastX128(pool);
51+
(uint256 feeGrowthInside0LastX128 , ) = _getFeeGrowthInsideLastX128(
52+
BNBPositionManager,
53+
pool,
54+
party.partyTicks
55+
);
9256
feeGrowthGlobal = pool.feeGrowthGlobal0X128() -feeGrowthInside0LastX128;
9357
} else {
94-
( , uint256 feeGrowthInside1LastX128) = _getPartyFeeGrowthInsideLastX128(pool);
58+
( , uint256 feeGrowthInside1LastX128) = _getFeeGrowthInsideLastX128(
59+
BNBPositionManager,
60+
pool,
61+
party.partyTicks
62+
);
9563
feeGrowthGlobal = pool.feeGrowthGlobal1X128() - feeGrowthInside1LastX128;
9664
}
9765
}

contracts/BNBPartyView.sol

+10-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ abstract contract BNBPartyView is BNBPartyFee {
5353
(
5454
feeGrowthInside0LastX128,
5555
feeGrowthInside1LastX128
56-
) = manager == BNBPositionManager ? _getPartyFeeGrowthInsideLastX128(pool) : _getFeeGrowthInsideLastX128(pool);
56+
) = manager == BNBPositionManager ? _getFeeGrowthInsideLastX128(
57+
BNBPositionManager,
58+
pool,
59+
party.partyTicks
60+
) :
61+
_getFeeGrowthInsideLastX128(
62+
positionManager,
63+
pool,
64+
party.lpTicks
65+
);
5766
}
5867
}

0 commit comments

Comments
 (0)