Skip to content

Commit

Permalink
feat: internal feedback (#225)
Browse files Browse the repository at this point in the history
* internal: s48 doc about on feeGrowth

* feat: update forge-std dependency

* internal: s49 add initi code hash

* gas: gas update after updating foundry

* internal: s52 update CI to usse foundry stable version

* test: revert test.yml foundry version
  • Loading branch information
ChefMist authored Jan 22, 2025
1 parent fc9c125 commit 5305a1c
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
63109
63178
Original file line number Diff line number Diff line change
@@ -1 +1 @@
63078
63147
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57403
57469
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148676
148674
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: stable

# install dependency
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: stable

- name: Compile
run: yarn prettier-check
3 changes: 3 additions & 0 deletions snapshots/BinPoolManagerTest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"binPoolManager initcode hash (without constructor params, as uint256)": "73425840329377707764016122574450195738786283045901954729586336840188059167782"
}
3 changes: 3 additions & 0 deletions snapshots/CLPoolManagerTest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"clPoolManager initcode hash (without constructor params, as uint256)": "43498189724800683414039944409888665118981458752163755806370462274516389565331"
}
3 changes: 3 additions & 0 deletions snapshots/VaultTest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Vault initcode hash (without constructor params, as uint256)": "42285739453326546745334574088065442781095713906976306156700703402717362931041"
}
8 changes: 8 additions & 0 deletions src/pool-cl/interfaces/ICLPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ interface ICLPoolManager is IProtocolFees, IPoolManager, IExtsload {
function getPoolBitmapInfo(PoolId id, int16 word) external view returns (uint256 tickBitmap);

/// @notice Get the fee growth global for the given pool
/// @return feeGrowthGlobal0x128 The global fee growth for token0
/// @return feeGrowthGlobal1x128 The global fee growth for token1
/// @dev feeGrowthGlobal can be artificially inflated by a malicious actor and integrators should be careful using the value
/// For pools with a single liquidity position, actors can donate to themselves to freely inflate feeGrowthGlobal
/// atomically donating and collecting fees in the same lockAcquired callback may make the inflated value more extreme
function getFeeGrowthGlobals(PoolId id)
external
view
Expand Down Expand Up @@ -135,6 +140,9 @@ interface ICLPoolManager is IProtocolFees, IPoolManager, IExtsload {
/// @notice Modify the position for the given pool
/// @return delta The total balance delta of the caller of modifyLiquidity.
/// @return feeDelta The balance delta of the fees generated in the liquidity range.
/// @dev feeDelta can be artificially inflated by a malicious actor and integrators should be careful using the value
/// For pools with a single liquidity position, actors can donate to themselves to inflate feeGrowthGlobal (and consequently feeDelta)
/// atomically donating and collecting fees in the same lockAcquired callback may make the inflated value more extreme
function modifyLiquidity(PoolKey memory key, ModifyLiquidityParams memory params, bytes calldata hookData)
external
returns (BalanceDelta delta, BalanceDelta feeDelta);
Expand Down
4 changes: 4 additions & 0 deletions src/pool-cl/libraries/CLPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ library CLPool {
/// @notice Thrown by donate if there is currently 0 liquidity, since the fees will not go to any liquidity providers
error NoLiquidityToReceiveFees();

/// @notice The state of a pool
/// @dev feeGrowthGlobal can be artificially inflated
/// For pools with a single liquidity position, actors can donate to themselves to freely inflate feeGrowthGlobal
/// atomically donating and collecting fees in the same lockAcquired callback may make the inflated value more extreme
struct State {
CLSlot0 slot0;
/// @dev accumulated lp fees
Expand Down
7 changes: 7 additions & 0 deletions test/pool-bin/BinPoolManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper {
}
}

function test_initcodeHash() public {
vm.snapshotValue(
"binPoolManager initcode hash (without constructor params, as uint256)",
uint256(keccak256(type(BinPoolManager).creationCode))
);
}

function testInitialize_gasCheck_withoutHooks() public {
snapStart("BinPoolManagerTest#testInitialize_gasCheck_withoutHooks");
poolManager.initialize(key, activeId);
Expand Down
10 changes: 7 additions & 3 deletions test/pool-cl/CLPoolManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps
}
}

function test_initcodeHash() public {
vm.snapshotValue(
"clPoolManager initcode hash (without constructor params, as uint256)",
uint256(keccak256(type(CLPoolManager).creationCode))
);
}

// ************** *************** //
// ************** initialize *************** //
// ************** *************** //
Expand Down Expand Up @@ -1811,9 +1818,6 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps
""
);
snapEnd();

console2.log("token0 balance: ", IERC20(Currency.unwrap(currency0)).balanceOf(address(vault)));
console2.log("token1 balance: ", IERC20(Currency.unwrap(currency1)).balanceOf(address(vault)));
}

function testSwap_failsIfNotInitialized(uint160 sqrtPriceX96) public {
Expand Down
6 changes: 6 additions & 0 deletions test/vault/Vault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ contract VaultTest is Test, NoIsolate, GasSnapshot, TokenFixture {
}
}

function test_initcodeHash() public {
vm.snapshotValue(
"Vault initcode hash (without constructor params, as uint256)", uint256(keccak256(type(Vault).creationCode))
);
}

function testRegisterPoolManager() public {
assertEq(vault.isAppRegistered(address(unRegPoolManager)), false);
assertEq(vault.isAppRegistered(address(poolManager1)), true);
Expand Down

0 comments on commit 5305a1c

Please sign in to comment.