@rabby-wallet/rabby-swap 0.0.89-alpha.1 → 0.0.89-alpha.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.
@@ -21,8 +21,11 @@ export const walkCommands = (commands, inputs, swap, ctx, profile) => {
21
21
  walkV4(inputs[i], swap, ctx, profile.version);
22
22
  continue;
23
23
  }
24
+ // 2.1.2 retains the full-precision fee command introduced in 2.1.1.
25
+ // https://github.com/Uniswap/universal-router/blob/2.1.2/contracts/libraries/Commands.sol
24
26
  if ((command === CommandType.PAY_PORTION_FULL_PRECISION &&
25
- profile.version !== UniversalRouterVersion.V2_1_1) ||
27
+ profile.version !== UniversalRouterVersion.V2_1_1 &&
28
+ profile.version !== UniversalRouterVersion.V2_1_2) ||
26
29
  (command === CommandType.BALANCE_CHECK_ERC20 &&
27
30
  profile.commandMask === 0x1f))
28
31
  throw unsupported();
@@ -1,27 +1,36 @@
1
1
  import { UNIVERSAL_ROUTER_ADDRESS, UniversalRouterVersion, } from "@uniswap/universal-router-sdk";
2
2
  import { isSameAddress } from "../../../utils";
3
3
  export const getRouterProfile = (chainId, router) => {
4
- // Match the current backend's x-universal-router-version configuration.
5
- const requestedVersion = chainId === 4663 || chainId === 5042
6
- ? UniversalRouterVersion.V2_1_1
7
- : UniversalRouterVersion.V2_0;
8
- let expectedRouter;
9
- try {
10
- expectedRouter = UNIVERSAL_ROUTER_ADDRESS(requestedVersion, chainId);
4
+ // Resolve the actual deployment instead of assuming the quote's API version.
5
+ // 2.1.2 keeps the 2.1.1 calldata layout; its addresses are supplied by the SDK.
6
+ // https://developers.uniswap.org/docs/changelog/active-notifications/sunset-of-universal-router-2-0-and-2-1-1
7
+ const versions = [
8
+ UniversalRouterVersion.V2_1_2,
9
+ // Retain the deployments accepted before the 2.1.2 API migration.
10
+ chainId === 4663 || chainId === 5042
11
+ ? UniversalRouterVersion.V2_1_1
12
+ : UniversalRouterVersion.V2_0,
13
+ ];
14
+ for (const version of versions) {
15
+ let expectedRouter;
16
+ try {
17
+ expectedRouter = UNIVERSAL_ROUTER_ADDRESS(version, chainId);
18
+ }
19
+ catch (_a) {
20
+ // This version is not deployed on the chain; never guess its layout.
21
+ continue;
22
+ }
23
+ if (!isSameAddress(router, expectedRouter))
24
+ continue;
25
+ // The SDK's zkSync 2.0 address aliases the deployed 1.2 Router. Its verified
26
+ // Commands.sol uses a 5-bit mask and has no V4 swap command.
27
+ if (chainId === 324 && version === UniversalRouterVersion.V2_0) {
28
+ return { version: UniversalRouterVersion.V1_2, commandMask: 0x1f };
29
+ }
30
+ return {
31
+ version,
32
+ commandMask: version === UniversalRouterVersion.V2_0 ? 0x3f : 0x7f,
33
+ };
11
34
  }
12
- catch (_a) {
13
- // Unsupported chains and addresses must not fall back to a guessed layout.
14
- }
15
- if (!expectedRouter || !isSameAddress(router, expectedRouter)) {
16
- throw new Error(`Unknown Universal Router version for chain ${chainId}, router ${router}; expected the current quote deployment (${requestedVersion})`);
17
- }
18
- // The SDK's zkSync 2.0 address aliases the deployed 1.2 Router. Its verified
19
- // Commands.sol uses a 5-bit mask and has no V4 swap command.
20
- if (chainId === 324) {
21
- return { version: UniversalRouterVersion.V1_2, commandMask: 0x1f };
22
- }
23
- return {
24
- version: requestedVersion,
25
- commandMask: requestedVersion === UniversalRouterVersion.V2_0 ? 0x3f : 0x7f,
26
- };
35
+ throw new Error(`Unknown Universal Router version for chain ${chainId}, router ${router}; supported quote deployments (${versions.join(", ")})`);
27
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-swap",
3
- "version": "0.0.89-alpha.1",
3
+ "version": "0.0.89-alpha.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {