Skip to content

Commit a84aaa9

Browse files
Update briefcase
Changes: M deployments/196.json A src/deployers/universal-router-2_0/UniversalRouter2_0Deployer.sol M src/deployers/v2-core/UniswapV2FactoryDeployer.sol M src/protocols/uniswapx/v4/hooks/dca/DCAStructs.sol A src/protocols/universal-router-2_0/interfaces/IUniversalRouter.sol A src/protocols/universal-router-2_0/libraries/Commands.sol A src/protocols/universal-router-2_0/libraries/Constants.sol A src/protocols/universal-router-2_0/libraries/Locker.sol A src/protocols/universal-router-2_0/libraries/MaxInputAmount.sol A src/protocols/universal-router-2_0/types/RouterParameters.sol
1 parent 270d72d commit a84aaa9

File tree

10 files changed

+258
-40
lines changed

10 files changed

+258
-40
lines changed

deployments/196.json

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,21 @@
136136
"timestamp": 1764875909160,
137137
"commitHash": "f09f3a7"
138138
},
139-
"UniversalRouter": {
139+
"UniversalRouter#v2.1": {
140140
"address": "0xda00ae15d3a71466517129255255db7c0c0956d3",
141141
"proxy": false,
142142
"deploymentTxn": "0xef4f41d44a228ab30f23ddcf0fad3ea9801615c99db3acdd57f941cb3b9541d1",
143143
"timestamp": 1767717302508,
144144
"commitHash": "2c1a28f"
145145
},
146+
"UniversalRouter#v2.0": {
147+
"address": "0x5507749f2c558bb3e162c6e90c314c092e7372ff",
148+
"proxy": false,
149+
"deploymentTxn": "0x9c328139dbc811d23475825532dacbf4f3b5996cded6af17bc290e5d72cb50f1",
150+
"initcodeHash": "2020f2ead4859ca86396db346fa74c45cfb1ea50f6672fbaae3f26b43ea6d841",
151+
"timestamp": 1767749509833,
152+
"commitHash": "781b4c9"
153+
},
146154
"FeeOnTransferDetector": {
147155
"address": "0xfe31f71c1b106eac32f1a19239c9a9a72ddfb900",
148156
"proxy": false,
@@ -166,6 +174,33 @@
166174
}
167175
},
168176
"history": [
177+
{
178+
"contracts": {
179+
"UniversalRouter#v2.0": {
180+
"address": "0x5507749f2c558bb3e162c6e90c314c092e7372ff",
181+
"proxy": false,
182+
"deploymentTxn": "0x9c328139dbc811d23475825532dacbf4f3b5996cded6af17bc290e5d72cb50f1",
183+
"initcodeHash": "2020f2ead4859ca86396db346fa74c45cfb1ea50f6672fbaae3f26b43ea6d841",
184+
"input": {
185+
"constructor": {
186+
"params": {
187+
"permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
188+
"weth9": "0xe538905cf8410324e03A5A23C1c177a474D59b2b",
189+
"v2Factory": "0xDf38F24fE153761634Be942F9d859f3DBA857E95",
190+
"v3Factory": "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804",
191+
"pairInitCodeHash": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
192+
"poolInitCodeHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54",
193+
"v4PoolManager": "0x360E68faCcca8cA495c1B759Fd9EEe466db9FB32",
194+
"v3NFTPositionManager": "0x315e413A11AB0df498eF83873012430ca36638Ae",
195+
"v4PositionManager": "0xcF1EAFC6928dC385A342E7C6491d371d2871458"
196+
}
197+
}
198+
}
199+
}
200+
},
201+
"timestamp": 1767749509833,
202+
"commitHash": "781b4c9"
203+
},
169204
{
170205
"contracts": {
171206
"PositionManager": {
@@ -182,7 +217,7 @@
182217
}
183218
}
184219
},
185-
"UniversalRouter": {
220+
"UniversalRouter#v2.1": {
186221
"address": "0xda00ae15d3a71466517129255255db7c0c0956d3",
187222
"proxy": false,
188223
"deploymentTxn": "0xef4f41d44a228ab30f23ddcf0fad3ea9801615c99db3acdd57f941cb3b9541d1",
@@ -357,20 +392,6 @@
357392
"initializeData": "0x"
358393
}
359394
},
360-
"PositionManager": {
361-
"address": "0xbc9f3a5d767dd46e040f1ca48ab17f29f59dc806",
362-
"proxy": false,
363-
"deploymentTxn": "0x079e5c2466d46c84b65cee2d1ed21cdbde7592e5bf1bd1843a5e6e52813b7295",
364-
"input": {
365-
"constructor": {
366-
"_poolManager": "0x360E68faCcca8cA495c1B759Fd9EEe466db9FB32",
367-
"_permit2": "0x000000000004444c5dc75cB358380D2e3dE08A90",
368-
"_unsubscribeGasLimit": "300000",
369-
"_tokenDescriptor": "0x9e9FBbEf0e1Bd752E83De5aCff3D0c936A9E5A4b",
370-
"_weth9": "0xe538905cf8410324e03A5A23C1c177a474D59b2b"
371-
}
372-
}
373-
},
374395
"V4Quoter": {
375396
"address": "0x8928074ca1b241d8ec02815881c1af11e8bc5219",
376397
"proxy": false,
@@ -426,27 +447,6 @@
426447
}
427448
}
428449
},
429-
"UniversalRouter": {
430-
"address": "0xc498381f53525a30a2c22d4cbe8758e79bcff2a5",
431-
"proxy": false,
432-
"deploymentTxn": "0xd332671e6b016a2f2871746dded59b927819403907476f9356954a293ca93c13",
433-
"input": {
434-
"constructor": {
435-
"params": {
436-
"permit2": "0x000000000004444c5dc75cB358380D2e3dE08A90",
437-
"weth9": "0xe538905cf8410324e03A5A23C1c177a474D59b2b",
438-
"v2Factory": "0xDf38F24fE153761634Be942F9d859f3DBA857E95",
439-
"v3Factory": "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804",
440-
"pairInitCodeHash": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
441-
"poolInitCodeHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54",
442-
"v4PoolManager": "0x360E68faCcca8cA495c1B759Fd9EEe466db9FB32",
443-
"v3NFTPositionManager": "0x315e413A11AB0df498eF83873012430ca36638Ae",
444-
"v4PositionManager": "0xbc9f3A5D767dD46E040F1CA48Ab17f29F59DC806",
445-
"spokePool": "0x1707327F626496A7b5b3872e7E4d2879Df7d7a9"
446-
}
447-
}
448-
}
449-
},
450450
"FeeOnTransferDetector": {
451451
"address": "0xfe31f71c1b106eac32f1a19239c9a9a72ddfb900",
452452
"proxy": false,

src/deployers/universal-router-2_0/UniversalRouter2_0Deployer.sol

Lines changed: 48 additions & 0 deletions
Large diffs are not rendered by default.

src/deployers/v2-core/UniswapV2FactoryDeployer.sol

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/protocols/uniswapx/v4/hooks/dca/DCAStructs.sol

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ pragma solidity ^0.8.0;
33

44
import {IAllowanceTransfer} from '../../../../permit2/interfaces/IAllowanceTransfer.sol';
55

6+
struct FeedTemplate {
7+
string name;
8+
string expression;
9+
string[] parameters;
10+
string[] secrets;
11+
uint256 retryCount;
12+
}
13+
614
struct FeedInfo {
7-
bytes32 feedId;
8-
address feed_address;
15+
FeedTemplate feedTemplate;
16+
address feedAddress;
917
string feedType;
1018
}
1119

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity >=0.6.2;
3+
4+
interface IUniversalRouter {
5+
/// @notice Thrown when a required command has failed
6+
error ExecutionFailed(uint256 commandIndex, bytes message);
7+
8+
/// @notice Thrown when attempting to send ETH directly to the contract
9+
error ETHNotAccepted();
10+
11+
/// @notice Thrown when executing commands with an expired deadline
12+
error TransactionDeadlinePassed();
13+
14+
/// @notice Thrown when attempting to execute commands and an incorrect number of inputs are provided
15+
error LengthMismatch();
16+
17+
// @notice Thrown when an address that isn't WETH tries to send ETH to the router without calldata
18+
error InvalidEthSender();
19+
20+
/// @notice Executes encoded commands along with provided inputs. Reverts if deadline has expired.
21+
/// @param commands A set of concatenated commands, each 1 byte in length
22+
/// @param inputs An array of byte strings containing abi encoded inputs for each command
23+
/// @param deadline The deadline by which the transaction must be executed
24+
function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable;
25+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity ^0.8.24;
3+
4+
/// @title Commands
5+
/// @notice Command Flags used to decode commands
6+
library Commands {
7+
// Masks to extract certain bits of commands
8+
bytes1 internal constant FLAG_ALLOW_REVERT = 0x80;
9+
bytes1 internal constant COMMAND_TYPE_MASK = 0x3f;
10+
11+
// Command Types. Maximum supported command at this moment is 0x3f.
12+
// The commands are executed in nested if blocks to minimise gas consumption
13+
14+
// Command Types where value<=0x07, executed in the first nested-if block
15+
uint256 constant V3_SWAP_EXACT_IN = 0x00;
16+
uint256 constant V3_SWAP_EXACT_OUT = 0x01;
17+
uint256 constant PERMIT2_TRANSFER_FROM = 0x02;
18+
uint256 constant PERMIT2_PERMIT_BATCH = 0x03;
19+
uint256 constant SWEEP = 0x04;
20+
uint256 constant TRANSFER = 0x05;
21+
uint256 constant PAY_PORTION = 0x06;
22+
// COMMAND_PLACEHOLDER = 0x07;
23+
24+
// Command Types where 0x08<=value<=0x0f, executed in the second nested-if block
25+
uint256 constant V2_SWAP_EXACT_IN = 0x08;
26+
uint256 constant V2_SWAP_EXACT_OUT = 0x09;
27+
uint256 constant PERMIT2_PERMIT = 0x0a;
28+
uint256 constant WRAP_ETH = 0x0b;
29+
uint256 constant UNWRAP_WETH = 0x0c;
30+
uint256 constant PERMIT2_TRANSFER_FROM_BATCH = 0x0d;
31+
uint256 constant BALANCE_CHECK_ERC20 = 0x0e;
32+
// COMMAND_PLACEHOLDER = 0x0f;
33+
34+
// Command Types where 0x10<=value<=0x20, executed in the third nested-if block
35+
uint256 constant V4_SWAP = 0x10;
36+
uint256 constant V3_POSITION_MANAGER_PERMIT = 0x11;
37+
uint256 constant V3_POSITION_MANAGER_CALL = 0x12;
38+
uint256 constant V4_INITIALIZE_POOL = 0x13;
39+
uint256 constant V4_POSITION_MANAGER_CALL = 0x14;
40+
// COMMAND_PLACEHOLDER = 0x15 -> 0x20
41+
42+
// Command Types where 0x21<=value<=0x3f
43+
uint256 constant EXECUTE_SUB_PLAN = 0x21;
44+
// COMMAND_PLACEHOLDER for 0x22 to 0x3f
45+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity ^0.8.24;
3+
4+
/// @title Constant state
5+
/// @notice Constant state used by the Universal Router
6+
library Constants {
7+
/// @dev Used for identifying cases when a v2 pair has already received input tokens
8+
uint256 internal constant ALREADY_PAID = 0;
9+
10+
/// @dev Used as a flag for identifying the transfer of ETH instead of a token
11+
address internal constant ETH = address(0);
12+
13+
/// @dev The length of the bytes encoded address
14+
uint256 internal constant ADDR_SIZE = 20;
15+
16+
/// @dev The length of the bytes encoded fee
17+
uint256 internal constant V3_FEE_SIZE = 3;
18+
19+
/// @dev The offset of a single token address (20) and pool fee (3)
20+
uint256 internal constant NEXT_V3_POOL_OFFSET = ADDR_SIZE + V3_FEE_SIZE;
21+
22+
/// @dev The offset of an encoded pool key
23+
/// Token (20) + Fee (3) + Token (20) = 43
24+
uint256 internal constant V3_POP_OFFSET = NEXT_V3_POOL_OFFSET + ADDR_SIZE;
25+
26+
/// @dev The minimum length of an encoding that contains 2 or more pools
27+
uint256 internal constant MULTIPLE_V3_POOLS_MIN_LENGTH = V3_POP_OFFSET + NEXT_V3_POOL_OFFSET;
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity ^0.8.24;
3+
4+
/// @notice A library to implement a reentrancy lock in transient storage.
5+
/// @dev Instead of storing a boolean, the locker's address is stored to allow the contract to know who locked the contract
6+
/// TODO: This library can be deleted when we have the transient keyword support in solidity.
7+
library Locker {
8+
// The slot holding the locker state, transiently. bytes32(uint256(keccak256("Locker")) - 1)
9+
bytes32 constant LOCKER_SLOT = 0x0e87e1788ebd9ed6a7e63c70a374cd3283e41cad601d21fbe27863899ed4a708;
10+
11+
function set(address locker) internal {
12+
// The locker is always msg.sender or address(0) so does not need to be cleaned
13+
assembly ('memory-safe') {
14+
tstore(LOCKER_SLOT, locker)
15+
}
16+
}
17+
18+
function get() internal view returns (address locker) {
19+
assembly ('memory-safe') {
20+
locker := tload(LOCKER_SLOT)
21+
}
22+
}
23+
24+
function isLocked() internal view returns (bool) {
25+
return Locker.get() != address(0);
26+
}
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity ^0.8.24;
3+
4+
/// @notice A library used to store the maximum desired amount of input tokens for exact output swaps; used for checking slippage
5+
library MaxInputAmount {
6+
// The slot holding the the maximum desired amount of input tokens, transiently. bytes32(uint256(keccak256("MaxAmountIn")) - 1)
7+
bytes32 constant MAX_AMOUNT_IN_SLOT = 0xaf28d9864a81dfdf71cab65f4e5d79a0cf9b083905fb8971425e6cb581b3f692;
8+
9+
function set(uint256 maxAmountIn) internal {
10+
assembly ('memory-safe') {
11+
tstore(MAX_AMOUNT_IN_SLOT, maxAmountIn)
12+
}
13+
}
14+
15+
function get() internal view returns (uint256 maxAmountIn) {
16+
assembly ('memory-safe') {
17+
maxAmountIn := tload(MAX_AMOUNT_IN_SLOT)
18+
}
19+
}
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity >=0.6.2;
3+
4+
struct RouterParameters {
5+
// Payment parameters
6+
address permit2;
7+
address weth9;
8+
// Uniswap swapping parameters
9+
address v2Factory;
10+
address v3Factory;
11+
bytes32 pairInitCodeHash;
12+
bytes32 poolInitCodeHash;
13+
address v4PoolManager;
14+
// Uniswap v3->v4 migration parameters
15+
address v3NFTPositionManager;
16+
address v4PositionManager;
17+
}

0 commit comments

Comments
 (0)