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

Merge dev into main #436

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6cf84c8
Prepare for v4 work (#346)
gretzke Jun 14, 2024
d573cb7
V3 liquidity commands (#355)
dianakocsis Jul 23, 2024
8757822
Reentrancy guard transient (#354)
hensha256 Jul 24, 2024
cc0e7c0
V4 liquidity commands (#359)
dianakocsis Jul 24, 2024
6c91122
update v4-periphery, change remapping, and update deploy test (#361)
dianakocsis Jul 29, 2024
43f1443
Make msgSender public (#365)
hensha256 Jul 31, 2024
12132d5
make maximum input transient (#366)
dianakocsis Aug 1, 2024
49848f9
update v4 periphery to main and update deployRouter (#367)
dianakocsis Aug 1, 2024
bc3d8dd
v4 planner (#368)
hensha256 Aug 1, 2024
297efe5
separate uniswap tests (#369)
hensha256 Aug 1, 2024
b143c03
final decode in calldata (#363)
hensha256 Aug 2, 2024
15c26c2
V4 posm call (#364)
dianakocsis Aug 2, 2024
1b67109
Add v4 routing (#360)
hensha256 Aug 3, 2024
b46ca05
Update posm with tests (#370)
dianakocsis Aug 4, 2024
972579a
Update periphery in UR (#371)
hensha256 Aug 4, 2024
4ce107d
update to audit commit (#372)
hensha256 Aug 5, 2024
00d4824
V4 Native Tests (#373)
hensha256 Aug 21, 2024
5486943
Add v4 to receive (#376)
hensha256 Aug 21, 2024
1180951
Take portion tests (#377)
hensha256 Aug 21, 2024
a888522
Oz L-09 (#382)
dianakocsis Aug 30, 2024
cfacb1d
update periphery to main (#380)
dianakocsis Aug 30, 2024
d1e3741
add different tests for increasing and add tests for forwarding eth (…
dianakocsis Aug 30, 2024
05906be
OZ N-06 (#383)
dianakocsis Aug 30, 2024
a85d5c0
OZ N-16 (#388)
dianakocsis Sep 2, 2024
473ba4f
ABDK CVF-107 (#385)
dianakocsis Sep 3, 2024
59a002d
spearbit 94 (#389)
dianakocsis Sep 3, 2024
a76242a
ABDK CVF106 (#387)
dianakocsis Sep 4, 2024
fe4c8a3
oz-L13: missing natspec (#390)
saucepoint Sep 4, 2024
f414f1b
Spearbit 59 (#391)
dianakocsis Sep 4, 2024
912b9b0
Spearbit 60 & 61 (#392)
dianakocsis Sep 4, 2024
6322395
OZ N-11 (#393)
dianakocsis Sep 5, 2024
2c728fd
update periphery (#394)
hensha256 Sep 5, 2024
2493262
Audit reports (#395)
hensha256 Sep 5, 2024
a81e1ce
Periphery update - calldata decoder (#396)
hensha256 Sep 6, 2024
398d7c4
feat: update to 1.6.1-beta.1 (#398)
marktoda Sep 12, 2024
ef3dede
Chore/push button deploy (#400)
mr-uniswap Sep 12, 2024
cbff29f
chore: fix yarn publish (#401)
mr-uniswap Sep 12, 2024
5b13e16
chore(infra): deploy with npm (#403)
mr-uniswap Sep 12, 2024
0590a2f
Update deploy.yml
mr-uniswap Sep 12, 2024
20dc7dc
Update deploy.yml
mr-uniswap Sep 12, 2024
7f0cc5c
Update package.json
mr-uniswap Sep 13, 2024
4552b93
compile contracts in workflow
ewilz Sep 17, 2024
d569f63
2.0.0-beta.1 (#407)
ewilz Sep 19, 2024
9451282
Release workflow needs forge install (#408)
ewilz Sep 19, 2024
adb863a
init submodules in release workflow (#409)
ewilz Sep 19, 2024
5e9f4c9
gitmodules should use https (#410)
ewilz Sep 19, 2024
1889511
Update v4 initialize (#415)
saucepoint Oct 15, 2024
5db48b1
restrict increase, decrease, and burn and v4 initialize pool call (#416)
dianakocsis Oct 17, 2024
419b9e6
deploy script for Base Sepolia (#381)
saucepoint Oct 18, 2024
c63d611
Latest v4 periphery (#420)
hensha256 Nov 5, 2024
1337089
v3 refactor and pull latest periphery (#418)
dianakocsis Nov 15, 2024
5aefc7e
allow permit2 to silently fail to avoid dos (#417)
dianakocsis Nov 15, 2024
a029362
update periphery (#424)
dianakocsis Dec 3, 2024
8465e7d
move file (#425)
dianakocsis Dec 3, 2024
f6ac0a2
Merge updates into dev (#428)
hensha256 Dec 4, 2024
c6cbdc3
merge main
hensha256 Dec 4, 2024
d06472b
update periphery
hensha256 Jan 10, 2025
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
13 changes: 11 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,20 @@ jobs:
with:
cache: yarn
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies and compile contracts
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install dependencies
run: |
yarn install --immutable --immutable-cache
yarn compile
git submodule update --init --recursive

- name: Compile
run: yarn compile

- name: Release
env:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ jobs:
# Must Insall node modules for forge to reference in remappings
- uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
registry-url: https://registry.npmjs.org

- name: Install Yarn
run: npm install -g yarn

- id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

Expand All @@ -53,7 +56,7 @@ jobs:

- name: Run Forge tests
run: |
forge test -vvv
forge test --isolate -vvv
id: test
env:
FORK_URL: https://mainnet.infura.io/v3/${{ secrets.INFURA_API_KEY }}
7 changes: 5 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ jobs:
- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
registry-url: https://registry.npmjs.org

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

Expand All @@ -37,4 +40,4 @@ jobs:
id: build

- name: Run linter
run: yarn run prettier
run: yarn run lint:check
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ jobs:

- uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
registry-url: https://registry.npmjs.org

- name: Install Yarn
run: npm install -g yarn

- id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

Expand All @@ -34,11 +37,16 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

# This is required separately from yarn test because it generates the typechain definitions
- name: Compile
run: yarn compile

- name: Run Integration tests
run: yarn test
run: yarn test:hardhat
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Compiler files
cache/
cache_hardhat/
out/

# Ignores development broadcast logs
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
[submodule "lib/permit2"]
path = lib/permit2
url = https://github.com/Uniswap/permit2
[submodule "lib/v3-periphery"]
path = lib/v3-periphery
url = https://github.com/uniswap/v3-periphery
[submodule "lib/v4-periphery"]
path = lib/v4-periphery
url = https://github.com/Uniswap/v4-periphery
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ out
openzeppelin-contracts
permit2
solmate
cache_hardhat
44 changes: 3 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,49 +84,12 @@ Each command is a `bytes1` containing the following 8 bits:
├──────┼───────────────────────────────┤
│ 0x0d │ PERMIT2_TRANSFER_FROM_BATCH │
├──────┼───────────────────────────────┤
│ 0x0e │ ------- │
├──────┼───────────────────────────────┤
│ 0x0f │ ------- │
├──────┼───────────────────────────────┤
│ 0x10 │ SEAPORT_V1_5 │
├──────┼───────────────────────────────┤
│ 0x11 │ LOOKS_RARE_721 │
├──────┼───────────────────────────────┤
│ 0x12 │ NFTX │
├──────┼───────────────────────────────┤
│ 0x13 │ CRYPTOPUNKS │
├──────┼───────────────────────────────┤
│ 0x14 │ LOOKS_RARE_1155 │
├──────┼───────────────────────────────┤
│ 0x15 │ OWNER_CHECK_721 │
├──────┼───────────────────────────────┤
│ 0x16 │ OWNER_CHECK_1155 │
├──────┼───────────────────────────────┤
│ 0x17 │ SWEEP_ERC721 │
├──────┼───────────────────────────────┤
│ 0x18 │ X2Y2_721 │
├──────┼───────────────────────────────┤
│ 0x19 │ SUDOSWAP │
├──────┼───────────────────────────────┤
│ 0x1a │ NFT20 │
├──────┼───────────────────────────────┤
│ 0x1b │ X2Y2_1155 │
├──────┼───────────────────────────────┤
│ 0x1c │ FOUNDATION │
├──────┼───────────────────────────────┤
│ 0x1d │ SWEEP_ERC1155 │
├──────┼───────────────────────────────┤
│ 0x1e │ ELEMENT_MARKET │
├──────┼───────────────────────────────┤
│ 0x1f │ ------- │
├──────┼───────────────────────────────┤
│ 0x20 │ SEAPORT_V1_4 │
│ 0x0e-│ ------- │
│ 0x20 │ │
├──────┼───────────────────────────────┤
│ 0x21 │ EXECUTE_SUB_PLAN │
├──────┼───────────────────────────────┤
│ 0x22 │ APPROVE_ERC20 │
├──────┼───────────────────────────────┤
│ 0x23-│ ------- │
│ 0x22-│ ------- │
│ 0x3f │ │
└──────┴───────────────────────────────┘
```
Expand Down Expand Up @@ -180,7 +143,6 @@ INFURA_API_KEY='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

```console
yarn install
yarn symlink
yarn compile
yarn test
```
Expand Down
Binary file not shown.
Binary file added audit/DRAFT_Spearbit_audit_UR.pdf
Binary file not shown.
Binary file not shown.
55 changes: 19 additions & 36 deletions contracts/UniversalRouter.sol
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
pragma solidity ^0.8.24;

// Command implementations
import {Dispatcher} from './base/Dispatcher.sol';
import {RewardsCollector} from './base/RewardsCollector.sol';
import {RouterParameters} from './base/RouterImmutables.sol';
import {RouterParameters} from './types/RouterParameters.sol';
import {PaymentsImmutables, PaymentsParameters} from './modules/PaymentsImmutables.sol';
import {NFTImmutables, NFTParameters} from './modules/NFTImmutables.sol';
import {UniswapImmutables, UniswapParameters} from './modules/uniswap/UniswapImmutables.sol';
import {V4SwapRouter} from './modules/uniswap/v4/V4SwapRouter.sol';
import {Commands} from './libraries/Commands.sol';
import {IUniversalRouter} from './interfaces/IUniversalRouter.sol';
import {MigratorImmutables, MigratorParameters} from './modules/MigratorImmutables.sol';

contract UniversalRouter is IUniversalRouter, Dispatcher, RewardsCollector {
modifier checkDeadline(uint256 deadline) {
if (block.timestamp > deadline) revert TransactionDeadlinePassed();
_;
}

contract UniversalRouter is IUniversalRouter, Dispatcher {
constructor(RouterParameters memory params)
UniswapImmutables(
UniswapParameters(params.v2Factory, params.v3Factory, params.pairInitCodeHash, params.poolInitCodeHash)
)
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9, params.openseaConduit, params.sudoswap))
NFTImmutables(
NFTParameters(
params.seaportV1_5,
params.seaportV1_4,
params.nftxZap,
params.x2y2,
params.foundation,
params.sudoswap,
params.elementMarket,
params.nft20Zap,
params.cryptopunks,
params.looksRareV2,
params.routerRewardsDistributor,
params.looksRareRewardsDistributor,
params.looksRareToken
)
)
V4SwapRouter(params.v4PoolManager)
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9))
MigratorImmutables(MigratorParameters(params.v3NFTPositionManager, params.v4PositionManager))
{}

modifier checkDeadline(uint256 deadline) {
if (block.timestamp > deadline) revert TransactionDeadlinePassed();
_;
}

/// @notice To receive ETH from WETH
receive() external payable {
if (msg.sender != address(WETH9) && msg.sender != address(poolManager)) revert InvalidEthSender();
}

/// @inheritdoc IUniversalRouter
function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline)
external
Expand All @@ -58,7 +48,7 @@ contract UniversalRouter is IUniversalRouter, Dispatcher, RewardsCollector {
if (inputs.length != numCommands) revert LengthMismatch();

// loop through all given commands, execute them and pass along outputs as defined
for (uint256 commandIndex = 0; commandIndex < numCommands;) {
for (uint256 commandIndex = 0; commandIndex < numCommands; commandIndex++) {
bytes1 command = commands[commandIndex];

bytes calldata input = inputs[commandIndex];
Expand All @@ -68,17 +58,10 @@ contract UniversalRouter is IUniversalRouter, Dispatcher, RewardsCollector {
if (!success && successRequired(command)) {
revert ExecutionFailed({commandIndex: commandIndex, message: output});
}

unchecked {
commandIndex++;
}
}
}

function successRequired(bytes1 command) internal pure returns (bool) {
return command & Commands.FLAG_ALLOW_REVERT == 0;
}

/// @notice To receive ETH from WETH and NFT protocols
receive() external payable {}
}
32 changes: 0 additions & 32 deletions contracts/base/Callbacks.sol

This file was deleted.

Loading
Loading