Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 committed Apr 26, 2024
2 parents b8be10f + b9f442c commit 4ee5ef8
Show file tree
Hide file tree
Showing 74 changed files with 237 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/BitMathMostSignificantBitMaxUint128.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
392
393
2 changes: 1 addition & 1 deletion .forge-snapshots/BitMathMostSignificantBitMaxUint256.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
412
413
2 changes: 1 addition & 1 deletion .forge-snapshots/BitMathMostSignificantBitSmallNumber.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
320
321
1 change: 1 addition & 0 deletions .forge-snapshots/ERC6909Claims approve.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
46492
1 change: 1 addition & 0 deletions .forge-snapshots/ERC6909Claims burn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
29428
1 change: 1 addition & 0 deletions .forge-snapshots/ERC6909Claims mint.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
46815
1 change: 1 addition & 0 deletions .forge-snapshots/ERC6909Claims transfer.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
52046
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
54699
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
60247
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
57049
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
258504
278788
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
135869
136156
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
138703
145947
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 1 token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98008
108949
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 2 tokens.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
126137
149549
2 changes: 1 addition & 1 deletion .forge-snapshots/erc20 collect protocol fees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24960
57332
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
33

This file was deleted.

2 changes: 1 addition & 1 deletion .forge-snapshots/initialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
51288
61933
2 changes: 1 addition & 1 deletion .forge-snapshots/native collect protocol fees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36633
59565

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
33
2 changes: 1 addition & 1 deletion .forge-snapshots/poolManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22586
22560
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
53085
115868
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140857
113155
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
137135
115856
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap with native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
126052
130538
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
137445
148889
Original file line number Diff line number Diff line change
@@ -1 +1 @@
70347
113433
2 changes: 1 addition & 1 deletion .forge-snapshots/swap against liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60666
124803
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
78655
136807
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn native 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
74498
125922
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint native output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134785
148001
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
151448
164904
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157359
224124
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
89935
149105
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with hooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60645
124815
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with lp fee and protocol fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150265
181394
2 changes: 1 addition & 1 deletion .forge-snapshots/update dynamic fee in before swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
130962
159641
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ body:
attributes:
label: To Reproduce
description: If you have written tests to showcase the bug, what can we run to reproduce the issue?
placeholder: "git checkout <branchname> / forge test --match-test <testName>"
placeholder: "git checkout <branchname> / forge test --isolate --mt <testName>"
- type: textarea
attributes:
label: Additional context
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
FOUNDRY_PROFILE: ci

- name: Run tests
run: forge test -vvv
run: forge test --isolate -vvv
env:
FOUNDRY_PROFILE: ci
FORGE_SNAPSHOT_CHECK: true

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ All contributions must follow the below standards. Maintainers will close out PR

`forge build` to get contract artifacts and dependencies for forge

`forge test` to run forge tests and update snapshots
`forge test --isolate` to run forge tests and update snapshots

## Code of Conduct

Expand Down
9 changes: 4 additions & 5 deletions src/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,14 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim
external
override
onlyWhenUnlocked
returns (BalanceDelta delta)
returns (BalanceDelta)
{
PoolId id = key.toId();
_checkPoolInitialized(id);

key.hooks.beforeSwap(key, params, hookData);

uint256 feeForProtocol;
uint24 swapFee;
Pool.SwapState memory state;
(delta, feeForProtocol, swapFee, state) = pools[id].swap(
(BalanceDelta delta, uint256 feeForProtocol, uint24 swapFee, Pool.SwapState memory state) = pools[id].swap(
Pool.SwapParams({
tickSpacing: key.tickSpacing,
zeroForOne: params.zeroForOne,
Expand All @@ -240,6 +237,8 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim
);

key.hooks.afterSwap(key, params, delta, hookData);

return delta;
}

/// @inheritdoc IPoolManager
Expand Down
9 changes: 2 additions & 7 deletions src/interfaces/IPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload {
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param hooks The hooks contract address for the pool, or address(0) if none
event Initialize(
PoolId indexed id,
Currency indexed currency0,
Currency indexed currency1,
uint24 fee,
int24 tickSpacing,
IHooks hooks
PoolId id, Currency indexed currency0, Currency indexed currency1, uint24 fee, int24 tickSpacing, IHooks hooks
);

/// @notice Emitted when a liquidity position is modified
Expand All @@ -77,7 +72,7 @@ interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload {
/// @param fee The swap fee in hundredths of a bip
event Swap(
PoolId indexed id,
address indexed sender,
address sender,
int128 amount0,
int128 amount1,
uint160 sqrtPriceX96,
Expand Down
9 changes: 5 additions & 4 deletions src/libraries/NonZeroDeltaCount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import {IHooks} from "../interfaces/IHooks.sol";
/// TODO: This library can be deleted when we have the transient keyword support in solidity.
library NonZeroDeltaCount {
// The slot holding the number of nonzero deltas. uint256(keccak256("NonzeroDeltaCount")) - 1
uint256 constant NONZERO_DELTA_COUNT = uint256(0x7d4b3164c6e45b97e7d87b7125a44c5828d005af88f9d751cfd78729c5d99a0b);
uint256 constant NONZERO_DELTA_COUNT_SLOT =
uint256(0x7d4b3164c6e45b97e7d87b7125a44c5828d005af88f9d751cfd78729c5d99a0b);

function read() internal view returns (uint256 count) {
uint256 slot = NONZERO_DELTA_COUNT;
uint256 slot = NONZERO_DELTA_COUNT_SLOT;
assembly {
count := tload(slot)
}
}

function increment() internal {
uint256 slot = NONZERO_DELTA_COUNT;
uint256 slot = NONZERO_DELTA_COUNT_SLOT;
assembly {
let count := tload(slot)
count := add(count, 1)
Expand All @@ -29,7 +30,7 @@ library NonZeroDeltaCount {
/// @notice Potential to underflow.
/// Current usage ensures this will not happen because we call decrement with known boundaries (only up to the number of times we call increment).
function decrement() internal {
uint256 slot = NONZERO_DELTA_COUNT;
uint256 slot = NONZERO_DELTA_COUNT_SLOT;
assembly {
let count := tload(slot)
count := sub(count, 1)
Expand Down
14 changes: 6 additions & 8 deletions src/libraries/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,12 @@ library Pool {

bool exactInput = params.amountSpecified < 0;

state = SwapState({
amountSpecifiedRemaining: params.amountSpecified,
amountCalculated: 0,
sqrtPriceX96: slot0Start.sqrtPriceX96,
tick: slot0Start.tick,
feeGrowthGlobalX128: zeroForOne ? self.feeGrowthGlobal0X128 : self.feeGrowthGlobal1X128,
liquidity: cache.liquidityStart
});
state.amountSpecifiedRemaining = params.amountSpecified;
state.amountCalculated = 0;
state.sqrtPriceX96 = slot0Start.sqrtPriceX96;
state.tick = slot0Start.tick;
state.feeGrowthGlobalX128 = zeroForOne ? self.feeGrowthGlobal0X128 : self.feeGrowthGlobal1X128;
state.liquidity = cache.liquidityStart;

StepComputations memory step;
swapFee =
Expand Down
4 changes: 4 additions & 0 deletions src/test/ActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ contract ActionsRouter is IUnlockCallback, Test {

error ActionNotSupported();

// error thrown so that incorrectly formatted tests don't pass silently
error CheckParameters();

IPoolManager manager;

constructor(IPoolManager _manager) {
Expand All @@ -40,6 +43,7 @@ contract ActionsRouter is IUnlockCallback, Test {

function unlockCallback(bytes calldata data) external returns (bytes memory) {
(Actions[] memory actions, bytes[] memory params) = abi.decode(data, (Actions[], bytes[]));
if (actions.length != params.length || actions.length == 0) revert CheckParameters();
for (uint256 i = 0; i < actions.length; i++) {
Actions action = actions[i];
bytes memory param = params[i];
Expand Down
22 changes: 0 additions & 22 deletions src/test/BitMathEchidnaTest.sol

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/UnsafeMathEchidnaTest.sol

This file was deleted.

Loading

0 comments on commit 4ee5ef8

Please sign in to comment.