Skip to content

Commit

Permalink
A few cleanup tasks (#437)
Browse files Browse the repository at this point in the history
* Fix compiler warnings

* todo for mapping transient

* fixing tests with fuzzing

* remove console logs

* Update PoolDonateTest.sol

* remove amount overload

---------

Co-authored-by: Sara Reynolds <[email protected]>
  • Loading branch information
2 people authored and zhongeric committed Dec 14, 2023
1 parent cf6f514 commit e7db92e
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 242 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/mint with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
319005
319063
2 changes: 1 addition & 1 deletion .forge-snapshots/mint with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
201786
201844
2 changes: 1 addition & 1 deletion .forge-snapshots/mint.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
201706
201764
2 changes: 1 addition & 1 deletion .forge-snapshots/mintWithEmptyHookEOAInitiated.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
250901
250959
2 changes: 1 addition & 1 deletion .forge-snapshots/modify position with noop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56472
56530
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with noop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
49689
49690
5 changes: 2 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}, { access
cancun = true

[profile.default.fuzz]
runs = 100
runs = 1000
seed = "0x4444"

[profile.ci.fuzz]
runs = 1000
runs = 100000

[profile.ci]
fuzz_runs = 100000
solc = "./bin/solc-static-linux"

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
5 changes: 3 additions & 2 deletions src/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ contract PoolManager is IPoolManager, Fees, NoDelegateCall, ERC6909Claims {

/// @dev Represents the currencies due/owed to each locker.
/// Must all net to zero when the last lock is released.
/// TODO this needs to be transient
mapping(address locker => mapping(Currency currency => int256 currencyDelta)) public currencyDelta;

/// @inheritdoc IPoolManager
Expand Down Expand Up @@ -82,13 +83,13 @@ contract PoolManager is IPoolManager, Fees, NoDelegateCall, ERC6909Claims {
return pools[id].positions.get(_owner, tickLower, tickUpper).liquidity;
}

function getPosition(PoolId id, address owner, int24 tickLower, int24 tickUpper)
function getPosition(PoolId id, address _owner, int24 tickLower, int24 tickUpper)
external
view
override
returns (Position.Info memory position)
{
return pools[id].positions.get(owner, tickLower, tickUpper);
return pools[id].positions.get(_owner, tickLower, tickUpper);
}

/// @inheritdoc IPoolManager
Expand Down
2 changes: 1 addition & 1 deletion src/test/PoolModifyPositionTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract PoolModifyPositionTest is Test, PoolTestBase {
(,,, int256 delta1) = _fetchBalances(data.key.currency1, data.sender);

// These assertions only apply in non lock-accessing pools.
if (!data.key.hooks.hasPermissionToAccessLock()) {
if (!data.key.hooks.hasPermissionToAccessLock() && !data.key.fee.hasHookWithdrawFee()) {
if (data.params.liquidityDelta > 0) {
assert(delta0 > 0 || delta1 > 0 || data.key.hooks.hasPermissionToNoOp());
assert(!(delta0 < 0 || delta1 < 0));
Expand Down
6 changes: 3 additions & 3 deletions src/test/ProtocolFeeControllerTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ contract ProtocolFeeControllerTest is IProtocolFeeController {

/// @notice Reverts on call
contract RevertingProtocolFeeControllerTest is IProtocolFeeController {
function protocolFeesForPool(PoolKey memory /* key */ ) external view returns (uint24) {
function protocolFeesForPool(PoolKey memory /* key */ ) external pure returns (uint24) {
revert();
}
}

/// @notice Returns an out of bounds protocol fee
contract OutOfBoundsProtocolFeeControllerTest is IProtocolFeeController {
function protocolFeesForPool(PoolKey memory /* key */ ) external view returns (uint24) {
function protocolFeesForPool(PoolKey memory /* key */ ) external pure returns (uint24) {
// set both swap and withdraw fees to 1, which is less than MIN_PROTOCOL_FEE_DENOMINATOR
return 0x001001;
}
}

/// @notice Return a value that overflows a uint24
contract OverflowProtocolFeeControllerTest is IProtocolFeeController {
function protocolFeesForPool(PoolKey memory /* key */ ) external view returns (uint24) {
function protocolFeesForPool(PoolKey memory /* key */ ) external pure returns (uint24) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0xFFFFAAA001)
Expand Down
Loading

0 comments on commit e7db92e

Please sign in to comment.