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

Middleware remove #145

Open
wants to merge 88 commits into
base: base-middleware
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
62f093a
discover deltas bug
Jun1on Jul 10, 2024
fcd3b34
forbid after remove returns delta
Jun1on Jul 10, 2024
bb2641c
override deltas edge case with internal delegatecall
Jun1on Jul 11, 2024
266c61e
fix bugs
Jun1on Jul 11, 2024
43717e8
add frontrun protection
Jun1on Jul 12, 2024
8f41cf5
fix bug
Jun1on Jul 12, 2024
802f466
remove unused struct
Jun1on Jul 14, 2024
feb48f2
use msg.data instead of params
Jun1on Jul 15, 2024
26524f4
add FailedImplementationCall error
Jun1on Jul 15, 2024
f3cc913
fix removeLiquidity in tests
Jun1on Jul 15, 2024
c7353bb
increase foundry gas_limit
Jun1on Jul 16, 2024
33b1775
update to solidity ^0.8.24
Jun1on Jul 16, 2024
23a8644
enforce implementations to be mined
Jun1on Jul 17, 2024
3cb9689
enforece remove implementations to be mined
Jun1on Jul 17, 2024
a54a92e
fix breaking ci (#157)
snreynolds Jul 17, 2024
087a262
Update core in periphery (#156)
hensha256 Jul 17, 2024
f242024
Clean up repo (#159)
hensha256 Jul 18, 2024
4ecb379
add posm to issue template (#166)
snreynolds Jul 19, 2024
9d1b36e
fix PR comments
Jun1on Jul 18, 2024
7602a8a
discover deltas bug
Jun1on Jul 10, 2024
368e318
override deltas edge case with internal delegatecall
Jun1on Jul 11, 2024
5e66d57
update imports
Jun1on Jul 19, 2024
17885b9
fix conflict
Jun1on Jul 19, 2024
a9cfd38
Shared actions router (#160)
hensha256 Jul 22, 2024
e5db8e2
create variant that bans deltas
Jun1on Jul 22, 2024
1abe26d
add position manager [wip] (#141)
snreynolds Jul 23, 2024
675e85b
separate middleware if they return deltas
Jun1on Jul 23, 2024
845aa81
add more tests and fix bug
Jun1on Jul 23, 2024
b98912f
add useless variables
Jun1on Jul 23, 2024
f1a680f
force MiddlewareRemove to return delta
Jun1on Jul 23, 2024
6f094c3
fix import (#190)
dianakocsis Jul 24, 2024
181b9ea
fix failing test
Jun1on Jul 24, 2024
e13ba65
reduce gas limit to 5M
Jun1on Jul 24, 2024
a266de8
posm: Native Token (#189)
saucepoint Jul 24, 2024
800e169
add natspec
Jun1on Jul 24, 2024
d3ee037
add state view contract (#187)
snreynolds Jul 24, 2024
6c4a6b6
Safe transfer ETH in posm (#193)
hensha256 Jul 24, 2024
511ce32
Test folder cleanup (#191)
hensha256 Jul 24, 2024
51f9aae
add return value griefing test
Jun1on Jul 24, 2024
dcadfc7
use using, fix import (#195)
snreynolds Jul 25, 2024
ffde495
Update core... again (#198)
hensha256 Jul 25, 2024
1c1d153
CurrencySettler -> DeltaResolver (#186)
hensha256 Jul 25, 2024
f3fc0ac
fix overflow griefing
Jun1on Jul 25, 2024
98e7fa5
uncomment
Jun1on Jul 25, 2024
d7c5302
feat: store PoolPositionId (#196)
snreynolds Jul 25, 2024
1d1d91e
Reentrancy lock posm (#204)
hensha256 Jul 25, 2024
cb902e1
clean up with baseremove
Jun1on Jul 25, 2024
2a9026f
update against latest core (#206)
snreynolds Jul 25, 2024
b973438
remove isApprovedOrOwner from increase (#207)
dianakocsis Jul 26, 2024
540664f
test override
Jun1on Jul 26, 2024
10f748e
use position key helper instead of manually hashing (#213)
saucepoint Jul 27, 2024
2603731
feat: Use permit2 transferFrom (#208)
snreynolds Jul 29, 2024
de79c94
Routing (#58)
ewilz Jul 29, 2024
9c134d1
Support native routing (#224)
hensha256 Jul 30, 2024
a96a8f6
posm : use actions router, remove return vals (#214)
snreynolds Jul 30, 2024
f37734c
rename lib (#228)
hensha256 Jul 30, 2024
b065dcd
Add transfer support (#218)
snreynolds Jul 31, 2024
463d030
some posm tests (#194)
saucepoint Jul 31, 2024
db359ca
Decode posm params in calldata (#226)
hensha256 Jul 31, 2024
0f03176
test SafeCallback (#220)
saucepoint Jul 31, 2024
f38a66f
fix testing compiler warnings (#232)
snreynolds Jul 31, 2024
b54c7bc
remove matching flags requirement
Jun1on Jul 31, 2024
e12bd98
Merge remote-tracking branch 'origin/main' into middleware-remove
Jun1on Jul 31, 2024
eda7534
clean imports
Jun1on Jul 31, 2024
e77f698
Slippage checks routing (#233)
hensha256 Aug 1, 2024
c77742c
Optimise actions encoding (#234)
hensha256 Aug 1, 2024
1f473ec
Make _handleAction virtual in position manager (#240)
qiwu7 Aug 1, 2024
256f7a7
clean imports
Jun1on Aug 1, 2024
598b02e
chore: remove recipient from QuoteParams (#241)
ConjunctiveNormalForm Aug 1, 2024
2e1cf9b
add gas snapshots
Jun1on Aug 1, 2024
c9cbfe2
make function abstract
Jun1on Aug 1, 2024
fff8413
Multi CurrencyDeltas Library (#245)
saucepoint Aug 2, 2024
83ca829
posm slippage (#225)
saucepoint Aug 2, 2024
a421a06
Router settle with balance (#235)
hensha256 Aug 2, 2024
a44f768
posm: Clear (#243)
saucepoint Aug 2, 2024
1bbeef5
Decode router params calldata (#230)
hensha256 Aug 2, 2024
8011598
use helper function and optimize gas
Jun1on Aug 2, 2024
f8f6deb
move files from contracts to src
Jun1on Aug 2, 2024
92d6f70
create HookFees library
Jun1on Aug 2, 2024
8c91ab3
Merge branch 'main' into middleware-remove
Jun1on Aug 2, 2024
8d99c45
Merge remote-tracking branch 'origin/base-middleware' into middleware…
Jun1on Aug 2, 2024
b230ee2
fix conflicts
Jun1on Aug 2, 2024
3eab6cb
store fee in factory
Jun1on Aug 2, 2024
e52fb04
remove BaseMiddlewareFactory
Jun1on Aug 2, 2024
fb02259
Create ABOUT_MIDDLEWARE.md
Jun1on Aug 2, 2024
5e7e959
require success on override
Jun1on Aug 5, 2024
2b62627
update docs
Jun1on Aug 5, 2024
564f941
add fuzz test
Jun1on Aug 5, 2024
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
7 changes: 0 additions & 7 deletions .env

This file was deleted.

1 change: 1 addition & 0 deletions .forge-snapshots/BaseActionsRouter_mock10commands.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
61756
1 change: 0 additions & 1 deletion .forge-snapshots/FullOracleObserve0After5Seconds.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/FullOracleObserve200By13.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/FullOracleObserve200By13Plus5.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/FullOracleObserve5After5Seconds.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/FullOracleObserveOldest.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/FullOracleObserveOldestAfter5Seconds.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/FullOracleObserveZero.snap

This file was deleted.

1 change: 1 addition & 0 deletions .forge-snapshots/MIDDLEWARE_REMOVE-deltas-protected.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
138303
1 change: 1 addition & 0 deletions .forge-snapshots/MIDDLEWARE_REMOVE-deltas-vanilla.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
124851
1 change: 1 addition & 0 deletions .forge-snapshots/MIDDLEWARE_REMOVE-fee-protected.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
153543
1 change: 1 addition & 0 deletions .forge-snapshots/MIDDLEWARE_REMOVE-fee-vanilla.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
140103
1 change: 1 addition & 0 deletions .forge-snapshots/MIDDLEWARE_REMOVE-override.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
133820
1 change: 1 addition & 0 deletions .forge-snapshots/MIDDLEWARE_REMOVE-protected.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
135757
1 change: 1 addition & 0 deletions .forge-snapshots/MIDDLEWARE_REMOVE-vanilla.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
124822
1 change: 0 additions & 1 deletion .forge-snapshots/OracleGrow10Slots.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleGrow1Slot.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleGrow1SlotCardinalityGreater.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleInitialize.snap

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleObserveCurrentTime.snap

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleObserveLast20Seconds.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleObserveLatestEqual.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleObserveLatestTransform.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleObserveMiddle.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleObserveOldest.snap

This file was deleted.

1 change: 0 additions & 1 deletion .forge-snapshots/OracleObserveSinceMostRecent.snap

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
134171
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
126966
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_burn_empty.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
47059
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_burn_empty_native.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
46876
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_burn_nonEmpty.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
129852
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_burn_nonEmpty_native.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
122773
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_collect.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
149984
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_collect_native.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
141136
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_collect_sameRange.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
149984
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_decreaseLiquidity.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
115527
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
108384
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_decrease_burnEmpty.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
133885
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
126624
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
128243
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
152100
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
133900
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
130065
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
170759
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
140581
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_mint.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
372012
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_mint_native.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
336712
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_mint_nativeWithSweep.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
345244
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_mint_onSameTickLower.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
314694
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_mint_onSameTickUpper.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
315336
1 change: 1 addition & 0 deletions .forge-snapshots/PositionManager_mint_sameRange.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
240918
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
370018
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
320712
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
416388
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2398
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8543
1 change: 1 addition & 0 deletions .forge-snapshots/StateView_extsload_getLiquidity.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1509
1 change: 1 addition & 0 deletions .forge-snapshots/StateView_extsload_getPositionInfo.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2927
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1746
1 change: 1 addition & 0 deletions .forge-snapshots/StateView_extsload_getSlot0.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1606
1 change: 1 addition & 0 deletions .forge-snapshots/StateView_extsload_getTickBitmap.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1704
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2756
1 change: 1 addition & 0 deletions .forge-snapshots/StateView_extsload_getTickInfo.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3090
1 change: 1 addition & 0 deletions .forge-snapshots/StateView_extsload_getTickLiquidity.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1901
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_Bytecode.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6942
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn1Hop_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
120501
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn1Hop_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
119696
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn1Hop_oneForZero.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
128568
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn1Hop_zeroForOne.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
135398
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn2Hops.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
186897
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn2Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
178832
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn3Hops.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
238421
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactIn3Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
230380
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactInputSingle.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
134171
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactInputSingle_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
119274
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactInputSingle_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
118447
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
126298
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut1Hop_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
120531
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut1Hop_oneForZero.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
129403
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut1Hop_zeroForOne.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
134204
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut2Hops.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
186306
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut2Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
183201
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut3Hops.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
238448
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut3Hops_nativeIn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
235367
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOut3Hops_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
229600
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOutputSingle.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
132975
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
125069
1 change: 1 addition & 0 deletions .forge-snapshots/V4Router_ExactOutputSingle_nativeOut.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
119360
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_IMPROVEMENT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ body:
description: Which area of code does your idea improve?
multiple: true
options:
- Position Manager
- Position Manager, documentation
- Position Manager, tests
- Pool Interaction, Hooks
- Pool Interaction, Swaps
- Pool Interaction, Positions
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run tests
run: forge test -vvv
env:
Expand Down
15 changes: 3 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/forge-gas-snapshot"]
path = lib/forge-gas-snapshot
url = https://github.com/marktoda/forge-gas-snapshot
[submodule "lib/v4-core"]
path = lib/v4-core
url = https://github.com/Uniswap/v4-core
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "lib/permit2"]
path = lib/permit2
url = https://github.com/Uniswap/permit2
24 changes: 2 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,6 @@ Uniswap v4 is a new automated market maker protocol that provides extensibility

If you’re interested in contributing please see the [contribution guidelines](https://github.com/Uniswap/v4-periphery/blob/main/CONTRIBUTING.md)!

## Repository Structure

```solidity
contracts/
----hooks/
----examples/
| GeomeanOracle.sol
| LimitOrder.sol
| TWAMM.sol
| VolatilityOracle.sol
----libraries/
| Oracle.sol
BaseHook.sol
test/
```

To showcase the power of hooks, this repository provides some interesting examples in the `/hooks/examples/` folder. Note that none of the contracts in this repository are fully production-ready, and the final design for some of the example hooks could look different.

Eventually, some hooks that have been audited and are considered production-ready will be placed in the root `hooks` folder. Not all hooks will be safe or valuable to users. This repository will maintain a limited set of hook contracts. Even a well-designed and audited hook contract may not be accepted in this repo.

## Local Deployment and Usage

To utilize the contracts and deploy to a local testnet, you can install the code in your repo with forge:
Expand All @@ -38,15 +18,15 @@ If you are building hooks, it may be useful to inherit from the `BaseHook` contr

```solidity

import {BaseHook} from 'v4-periphery/contracts/BaseHook.sol';
import {BaseHook} from 'v4-periphery/src/base/hooks/BaseHook.sol';

contract CoolHook is BaseHook {
// Override the hook callbacks you want on your hook
function beforeAddLiquidity(
address,
IPoolManager.PoolKey calldata key,
IPoolManager.ModifyLiquidityParams calldata params
) external override poolManagerOnly returns (bytes4) {
) external override onlyByPoolManager returns (bytes4) {
// hook logic
return BaseHook.beforeAddLiquidity.selector;
}
Expand Down
Loading
Loading