@uniswap/universal-router-sdk 1.5.0-beta.1 → 1.5.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -98,13 +98,12 @@ Make sure you are running `node v16`
98
98
  Install dependencies and run typescript unit tests
99
99
  ```bash
100
100
  yarn install
101
- yarn test
101
+ yarn test:hardhat
102
102
  ```
103
103
 
104
104
  Run forge integration tests
105
105
  ```bash
106
106
  yarn symlink # must install git submodules
107
107
  forge install
108
- forge build
109
- forge test
108
+ yarn test:forge
110
109
  ```
@@ -102,7 +102,7 @@ var CommandType;
102
102
  CommandType[CommandType["PERMIT2_TRANSFER_FROM_BATCH"] = 13] = "PERMIT2_TRANSFER_FROM_BATCH";
103
103
  CommandType[CommandType["BALANCE_CHECK_ERC20"] = 14] = "BALANCE_CHECK_ERC20";
104
104
  // NFT-related command types
105
- CommandType[CommandType["SEAPORT"] = 16] = "SEAPORT";
105
+ CommandType[CommandType["SEAPORT_V1_5"] = 16] = "SEAPORT_V1_5";
106
106
  CommandType[CommandType["LOOKS_RARE_V2"] = 17] = "LOOKS_RARE_V2";
107
107
  CommandType[CommandType["NFTX"] = 18] = "NFTX";
108
108
  CommandType[CommandType["CRYPTOPUNKS"] = 19] = "CRYPTOPUNKS";
@@ -122,12 +122,12 @@ var CommandType;
122
122
  CommandType[CommandType["APPROVE_ERC20"] = 34] = "APPROVE_ERC20";
123
123
  })(CommandType || (CommandType = {}));
124
124
  var ALLOW_REVERT_FLAG = 0x80;
125
- var REVERTIBLE_COMMANDS = /*#__PURE__*/new Set([CommandType.SEAPORT, CommandType.SEAPORT_V1_4, CommandType.NFTX, CommandType.LOOKS_RARE_V2, CommandType.X2Y2_721, CommandType.X2Y2_1155, CommandType.FOUNDATION, CommandType.SUDOSWAP, CommandType.NFT20, CommandType.EXECUTE_SUB_PLAN, CommandType.CRYPTOPUNKS, CommandType.ELEMENT_MARKET]);
125
+ var REVERTIBLE_COMMANDS = /*#__PURE__*/new Set([CommandType.SEAPORT_V1_5, CommandType.SEAPORT_V1_4, CommandType.NFTX, CommandType.LOOKS_RARE_V2, CommandType.X2Y2_721, CommandType.X2Y2_1155, CommandType.FOUNDATION, CommandType.SUDOSWAP, CommandType.NFT20, CommandType.EXECUTE_SUB_PLAN, CommandType.CRYPTOPUNKS, CommandType.ELEMENT_MARKET]);
126
126
  var PERMIT_STRUCT = '((address token,uint160 amount,uint48 expiration,uint48 nonce) details,address spender,uint256 sigDeadline)';
127
127
  var PERMIT_BATCH_STRUCT = '((address token,uint160 amount,uint48 expiration,uint48 nonce)[] details,address spender,uint256 sigDeadline)';
128
128
  var PERMIT2_TRANSFER_FROM_STRUCT = '(address from,address to,uint160 amount,address token)';
129
129
  var PERMIT2_TRANSFER_FROM_BATCH_STRUCT = PERMIT2_TRANSFER_FROM_STRUCT + '[]';
130
- var ABI_DEFINITION = (_ABI_DEFINITION = {}, _ABI_DEFINITION[CommandType.EXECUTE_SUB_PLAN] = ['bytes', 'bytes[]'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT] = [PERMIT_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT_BATCH] = [PERMIT_BATCH_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM] = ['address', 'address', 'uint160'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM_BATCH] = [PERMIT2_TRANSFER_FROM_BATCH_STRUCT], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.WRAP_ETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.UNWRAP_WETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.TRANSFER] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.PAY_PORTION] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.BALANCE_CHECK_ERC20] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.APPROVE_ERC20] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SEAPORT] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.SEAPORT_V1_4] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFTX] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.LOOKS_RARE_V2] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.X2Y2_721] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.X2Y2_1155] = ['uint256', 'bytes', 'address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.FOUNDATION] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SUDOSWAP] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFT20] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.CRYPTOPUNKS] = ['uint256', 'address', 'uint256'], _ABI_DEFINITION[CommandType.ELEMENT_MARKET] = ['uint256', 'bytes'], _ABI_DEFINITION);
130
+ var ABI_DEFINITION = (_ABI_DEFINITION = {}, _ABI_DEFINITION[CommandType.EXECUTE_SUB_PLAN] = ['bytes', 'bytes[]'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT] = [PERMIT_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT_BATCH] = [PERMIT_BATCH_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM] = ['address', 'address', 'uint160'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM_BATCH] = [PERMIT2_TRANSFER_FROM_BATCH_STRUCT], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.WRAP_ETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.UNWRAP_WETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.TRANSFER] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.PAY_PORTION] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.BALANCE_CHECK_ERC20] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.APPROVE_ERC20] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SEAPORT_V1_5] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.SEAPORT_V1_4] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFTX] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.LOOKS_RARE_V2] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.X2Y2_721] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.X2Y2_1155] = ['uint256', 'bytes', 'address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.FOUNDATION] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SUDOSWAP] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFT20] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.CRYPTOPUNKS] = ['uint256', 'address', 'uint256'], _ABI_DEFINITION[CommandType.ELEMENT_MARKET] = ['uint256', 'bytes'], _ABI_DEFINITION);
131
131
  var RoutePlanner = /*#__PURE__*/function () {
132
132
  function RoutePlanner() {
133
133
  this.commands = '0x';
@@ -164,8 +164,8 @@ function createCommand(type, parameters) {
164
164
  var UNIVERSAL_ROUTER_ADDRESS = function UNIVERSAL_ROUTER_ADDRESS(chainId) {
165
165
  switch (chainId) {
166
166
  case 1:
167
- // mainnet
168
- return '0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5';
167
+ // mainnet. UR v1.2, all others are v1
168
+ return '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD';
169
169
  case 5:
170
170
  // goerli
171
171
  return '0x4648a43B2C14Da09FdF82B161150d3F634f40491';
@@ -436,8 +436,8 @@ function encodeInputTokenOptions(planner, options) {
436
436
  }
437
437
  function mapApprovalProtocol(protocolAddress) {
438
438
  switch (protocolAddress.toLowerCase()) {
439
- case '0x00000000006c3852cbef3e08e8df289169ede581':
440
- // Seaport v1.1
439
+ case '0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC':
440
+ // Seaport v1.5
441
441
  return OPENSEA_CONDUIT_SPENDER_ID;
442
442
  case '0x00000000000001ad428e4906ae43d8f9852d0dd6':
443
443
  // Seaport v1.4
@@ -522,7 +522,8 @@ var SwapRouter = /*#__PURE__*/function () {
522
522
  }
523
523
  }
524
524
  // TODO: matches current logic for now, but should eventually only sweep for multiple NFT trades
525
- // or NFT trades with potential slippage (i.e. sudo)
525
+ // or NFT trades with potential slippage (i.e. sudo).
526
+ // Note: NFTXV2 sends excess ETH to the caller (router), not the specified recipient
526
527
  if (nftTrades.length > 0) planner.addCommand(CommandType.SWEEP, [ETH_ADDRESS, SENDER_AS_RECIPIENT, 0]);
527
528
  return SwapRouter.encodePlan(planner, transactionValue, config);
528
529
  }
@@ -8061,9 +8062,9 @@ var SeaportTrade = /*#__PURE__*/function (_NFTTrade) {
8061
8062
  };
8062
8063
  _proto.commandMap = function commandMap(protocolAddress) {
8063
8064
  switch (protocolAddress.toLowerCase()) {
8064
- case '0x00000000006c3852cbef3e08e8df289169ede581':
8065
- // Seaport v1.1
8066
- return CommandType.SEAPORT;
8065
+ case '0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC':
8066
+ // Seaport v1.5
8067
+ return CommandType.SEAPORT_V1_5;
8067
8068
  case '0x00000000000001ad428e4906ae43d8f9852d0dd6':
8068
8069
  // Seaport v1.4
8069
8070
  return CommandType.SEAPORT_V1_4;