Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor feeGrowthInsideLastX128 #74

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions contracts/BNBPartyFee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,10 @@ abstract contract BNBPartyFee is BNBPartyModifiers {
uint256 feeGrowthInside1LastX128
)
{
Ticks memory ticks = _getTicks(pool.token0(), party.lpTicks);
(
feeGrowthInside0LastX128,
feeGrowthInside1LastX128
) = _getFeeGrowthInsideLastX128(
(feeGrowthInside0LastX128, feeGrowthInside1LastX128) = _getFeeGrowthInsideLastX128(
positionManager,
pool,
keccak256(
abi.encodePacked(
address(positionManager),
ticks.tickLower,
ticks.tickUpper
)
)
party.lpTicks
);
}

Expand All @@ -49,15 +40,25 @@ abstract contract BNBPartyFee is BNBPartyModifiers {
uint256 feeGrowthInside1LastX128
)
{
Ticks memory ticks = _getTicks(pool.token0(), party.partyTicks);
(
feeGrowthInside0LastX128,
feeGrowthInside1LastX128
) = _getFeeGrowthInsideLastX128(
(feeGrowthInside0LastX128, feeGrowthInside1LastX128) = _getFeeGrowthInsideLastX128(
BNBPositionManager,
pool,
party.partyTicks
);
}

/// @notice Internal function to retrieve the fee growth inside the position from the last observation
function _getFeeGrowthInsideLastX128(
INonfungiblePositionManager manager,
IUniswapV3Pool pool,
Ticks memory lpTicks
) internal view returns (uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128) {
Ticks memory ticks = _getTicks(pool.token0(), lpTicks);
(feeGrowthInside0LastX128, feeGrowthInside1LastX128) = _getFeeGrowthInsideLastX128(
pool,
keccak256(
abi.encodePacked(
address(BNBPositionManager),
address(manager),
ticks.tickLower,
ticks.tickUpper
)
Expand Down