Skip to content

Commit

Permalink
update router with core
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Mar 21, 2024
2 parents 8605406 + 6616b12 commit a1a9fa9
Show file tree
Hide file tree
Showing 66 changed files with 363 additions and 345 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/FullOracleObserve0After5Seconds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2681
1912
2 changes: 1 addition & 1 deletion .forge-snapshots/FullOracleObserve200By13.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22914
20210
2 changes: 1 addition & 1 deletion .forge-snapshots/FullOracleObserve200By13Plus5.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23161
20443
2 changes: 1 addition & 1 deletion .forge-snapshots/FullOracleObserve5After5Seconds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2727
2024
2 changes: 1 addition & 1 deletion .forge-snapshots/FullOracleObserveOldest.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21874
19279
2 changes: 1 addition & 1 deletion .forge-snapshots/FullOracleObserveOldestAfter5Seconds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22172
19555
2 changes: 1 addition & 1 deletion .forge-snapshots/FullOracleObserveZero.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2069
1477
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeAddInitialLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
407968
383728
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeAddLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
201962
178095
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeFirstSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
153306
126975
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeInitialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1112212
1017530
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeRemoveLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
197519
168275
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
379147
344152
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeSecondSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
111940
87904
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
151523
125777
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow10Slots.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
254652
232960
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
245352
223649
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow1Slot.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
54861
32845
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow1SlotCardinalityGreater.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
45561
23545
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleInitialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72306
51310
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6473
5368
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleObserveCurrentTime.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2069
1477
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2069
1477
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleObserveLast20Seconds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
86537
73037
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleObserveLatestEqual.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2069
1477
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleObserveLatestTransform.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2681
1912
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleObserveMiddle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6665
5541
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleObserveOldest.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6175
5092
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleObserveSinceMostRecent.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3365
2522
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterBytecode.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5482
5727
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactIn1Hop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
188383
155453
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactIn2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
266802
231596
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactIn3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
352577
315113
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactInputSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
186643
161384
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOut1Hop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
187893
156465
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOut2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
267441
233506
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOut3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
352616
315986
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOutputSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
186092
160355
2 changes: 1 addition & 1 deletion .forge-snapshots/TWAMMSubmitOrder.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
145810
122867
22 changes: 22 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Semgrep
on:
workflow_dispatch: {}
pull_request: {}
push:
branches:
- main
schedule:
# random HH:MM to avoid a load spike on GitHub Actions at 00:00
- cron: '35 11 * * *'
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-20.04
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
container:
image: returntocorp/semgrep
if: (github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- run: semgrep ci
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
version: nightly

- name: Run tests
run: forge test -vvv --via-ir
run: forge test -vvv
env:
FOUNDRY_PROFILE: ci
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
url = https://github.com/marktoda/forge-gas-snapshot
[submodule "lib/v4-core"]
path = lib/v4-core
url = git@github.com:Uniswap/v4-core.git
url = https://github.com/Uniswap/v4-core
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ There are many ways to contribute, but here are a few if you want a place to sta

## Opening an Issue

When opening an [issue](https://github.com/Uniswap/periphery-next/issues/new/choose), choose a template to start from: Bug Report or Feature Improvement. For bug reports, you should be able to reproduce the bug through tests or proof of concept integrations. For feature improvements, please title it with a concise problem statement and check that a similar request is not already open or already in progress. Not all issues may be deemed worth resolving, so please follow through with responding to any questions or comments that others may have regarding the issue.
When opening an [issue](https://github.com/Uniswap/v4-periphery/issues/new/choose), choose a template to start from: Bug Report or Feature Improvement. For bug reports, you should be able to reproduce the bug through tests or proof of concept integrations. For feature improvements, please title it with a concise problem statement and check that a similar request is not already open or already in progress. Not all issues may be deemed worth resolving, so please follow through with responding to any questions or comments that others may have regarding the issue.

Feel free to tag the issue as a “good first issue” for any clean-up related issues, or small scoped changes to help encourage pull requests from first time contributors!

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Uniswap v4 is a new automated market maker protocol that provides extensibility

## Contributing

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

## Repository Structure

Expand All @@ -31,29 +31,29 @@ Eventually, some hooks that have been audited and are considered production-read
To utilize the contracts and deploy to a local testnet, you can install the code in your repo with forge:

```solidity
forge install https://github.com/Uniswap/periphery-next
forge install https://github.com/Uniswap/v4-periphery
```

If you are building hooks, it may be useful to inherit from the `BaseHook` contract:

```solidity
import {BaseHook} from 'periphery-next/contracts/BaseHook.sol';
import {BaseHook} from 'v4-periphery/contracts/BaseHook.sol';
contract CoolHook is BaseHook {
// Override the hook callbacks you want on your hook
function beforeModifyPosition(
function beforeAddLiquidity(
address,
IPoolManager.PoolKey calldata key,
IPoolManager.ModifyPositionParams calldata params
IPoolManager.ModifyLiquidityParams calldata params
) external override poolManagerOnly returns (bytes4) {
// hook logic
return BaseHook.beforeModifyPosition.selector;
return BaseHook.beforeAddLiquidity.selector;
}
}
```

## License

The license for Uniswap V4 Periphery is the GNU General Public License (GPL 2.0), see [LICENSE](https://github.com/Uniswap/periphery-next/blob/main/LICENSE).
The license for Uniswap V4 Periphery is the GNU General Public License (GPL 2.0), see [LICENSE](https://github.com/Uniswap/v4-periphery/blob/main/LICENSE).
24 changes: 10 additions & 14 deletions contracts/BaseHook.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
pragma solidity ^0.8.24;

import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
Expand Down Expand Up @@ -40,21 +40,16 @@ abstract contract BaseHook is IHooks {
_;
}

function getHooksCalls() public pure virtual returns (Hooks.Permissions memory);
function getHookPermissions() public pure virtual returns (Hooks.Permissions memory);

// this function is virtual so that we can override it during testing,
// which allows us to deploy an implementation to any address
// and then etch the bytecode into the correct address
function validateHookAddress(BaseHook _this) internal pure virtual {
Hooks.validateHookPermissions(_this, getHooksCalls());
Hooks.validateHookPermissions(_this, getHookPermissions());
}

function unlockCallback(bytes calldata data)
external
virtual
poolManagerOnly
returns (bytes memory)
{
function unlockCallback(bytes calldata data) external virtual poolManagerOnly returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).call(data);
if (success) return returnData;
if (returnData.length == 0) revert LockFailure();
Expand Down Expand Up @@ -85,11 +80,12 @@ abstract contract BaseHook is IHooks {
revert HookNotImplemented();
}

function beforeRemoveLiquidity(address, PoolKey calldata, IPoolManager.ModifyLiquidityParams calldata, bytes calldata)
external
virtual
returns (bytes4)
{
function beforeRemoveLiquidity(
address,
PoolKey calldata,
IPoolManager.ModifyLiquidityParams calldata,
bytes calldata
) external virtual returns (bytes4) {
revert HookNotImplemented();
}

Expand Down
Loading

0 comments on commit a1a9fa9

Please sign in to comment.