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

Add getFeeGrowthInside view function for off-chain farming #17

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
54822
54779
Original file line number Diff line number Diff line change
@@ -1 +1 @@
102898
102855
Original file line number Diff line number Diff line change
@@ -1 +1 @@
25042646
25042603
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_simple.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36022
35979
Original file line number Diff line number Diff line change
@@ -1 +1 @@
101660
101617
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_withHooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
41672
41629
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_withNative.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36025
35982
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#testNoOp_gas_Swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21667
21624
2 changes: 1 addition & 1 deletion .forge-snapshots/ExtsloadTest#extsloadInBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11352
11397
8 changes: 8 additions & 0 deletions src/pool-cl/CLPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ contract CLPoolManager is ICLPoolManager, Fees, Extsload {
return pools[id].tickBitmap[word];
}

function getPoolFeeGrowthInside(PoolId id, int24 tickLower, int24 tickUpper)
external
view
returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128)
{
return pools[id].getFeeGrowthInside(tickLower, tickUpper);
}

/// @inheritdoc ICLPoolManager
function setMasterChef(address _masterChef) external override onlyOwner {
masterChef = _masterChef;
Expand Down
10 changes: 10 additions & 0 deletions src/pool-cl/libraries/CLPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,14 @@ library CLPool {
function isNotInitialized(State storage self) internal view returns (bool) {
return self.slot0.sqrtPriceX96 == 0;
}

function getFeeGrowthInside(State storage self, int24 tickLower, int24 tickUpper)
internal
view
returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128)
{
return self.ticks.getFeeGrowthInside(
tickLower, tickUpper, self.slot0.tick, self.feeGrowthGlobal0X128, self.feeGrowthGlobal1X128
);
}
}