@metamask-previews/bridge-controller 43.0.0-preview-8029191 → 43.0.0-preview-c896a02b

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +2 -6
  2. package/dist/constants/bridge.cjs +2 -1
  3. package/dist/constants/bridge.cjs.map +1 -1
  4. package/dist/constants/bridge.d.cts +1 -0
  5. package/dist/constants/bridge.d.cts.map +1 -1
  6. package/dist/constants/bridge.d.mts +1 -0
  7. package/dist/constants/bridge.d.mts.map +1 -1
  8. package/dist/constants/bridge.mjs +1 -0
  9. package/dist/constants/bridge.mjs.map +1 -1
  10. package/dist/index.cjs +3 -5
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +2 -3
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +2 -3
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +2 -3
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/selectors.cjs +1 -20
  19. package/dist/selectors.cjs.map +1 -1
  20. package/dist/selectors.d.cts +0 -75
  21. package/dist/selectors.d.cts.map +1 -1
  22. package/dist/selectors.d.mts +0 -75
  23. package/dist/selectors.d.mts.map +1 -1
  24. package/dist/selectors.mjs +0 -19
  25. package/dist/selectors.mjs.map +1 -1
  26. package/dist/utils/metrics/properties.cjs +0 -6
  27. package/dist/utils/metrics/properties.cjs.map +1 -1
  28. package/dist/utils/metrics/properties.d.cts +0 -6
  29. package/dist/utils/metrics/properties.d.cts.map +1 -1
  30. package/dist/utils/metrics/properties.d.mts +0 -6
  31. package/dist/utils/metrics/properties.d.mts.map +1 -1
  32. package/dist/utils/metrics/properties.mjs +0 -6
  33. package/dist/utils/metrics/properties.mjs.map +1 -1
  34. package/dist/utils/validators.cjs +0 -1
  35. package/dist/utils/validators.cjs.map +1 -1
  36. package/dist/utils/validators.d.cts +0 -5
  37. package/dist/utils/validators.d.cts.map +1 -1
  38. package/dist/utils/validators.d.mts +0 -5
  39. package/dist/utils/validators.d.mts.map +1 -1
  40. package/dist/utils/validators.mjs +0 -1
  41. package/dist/utils/validators.mjs.map +1 -1
  42. package/package.json +3 -3
  43. package/dist/utils/slippage.cjs +0 -49
  44. package/dist/utils/slippage.cjs.map +0 -1
  45. package/dist/utils/slippage.d.cts +0 -23
  46. package/dist/utils/slippage.d.cts.map +0 -1
  47. package/dist/utils/slippage.d.mts +0 -23
  48. package/dist/utils/slippage.d.mts.map +0 -1
  49. package/dist/utils/slippage.mjs +0 -45
  50. package/dist/utils/slippage.mjs.map +0 -1
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultSlippagePercentage = exports.BRIDGE_DEFAULT_SLIPPAGE = void 0;
4
- const bridge_1 = require("./bridge.cjs");
5
- exports.BRIDGE_DEFAULT_SLIPPAGE = 0.5;
6
- const SWAP_SOLANA_SLIPPAGE = undefined;
7
- const SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;
8
- const SWAP_EVM_DEFAULT_SLIPPAGE = 2;
9
- /**
10
- * Calculates the appropriate slippage based on the transaction context
11
- *
12
- * Rules:
13
- * - Bridge (cross-chain): Always 0.5%
14
- * - Swap on Solana: Always undefined (AUTO mode)
15
- * - Swap on EVM stablecoin pairs (same chain only): 0.5%
16
- * - Swap on EVM other pairs: 2%
17
- *
18
- * @param options - the options for the destination chain
19
- * @param options.srcTokenAddress - the source token address
20
- * @param options.destTokenAddress - the destination token address
21
- * @param options.srcChainId - the source chain id
22
- * @param options.destChainId - the destination chain id
23
- * @param srcStablecoins - the list of stablecoins on the source chain
24
- * @param destStablecoins - the list of stablecoins on the destination chain
25
-
26
- * @returns the default slippage percentage for the chain and token pair
27
- */
28
- const getDefaultSlippagePercentage = ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }, srcStablecoins, destStablecoins) => {
29
- if (!srcChainId || (0, bridge_1.isCrossChain)(srcChainId, destChainId)) {
30
- return exports.BRIDGE_DEFAULT_SLIPPAGE;
31
- }
32
- if ((0, bridge_1.isSolanaChainId)(srcChainId)) {
33
- return SWAP_SOLANA_SLIPPAGE;
34
- }
35
- if (srcTokenAddress &&
36
- destTokenAddress &&
37
- srcStablecoins
38
- ?.map((stablecoin) => stablecoin.toLowerCase())
39
- .includes(srcTokenAddress.toLowerCase()) &&
40
- // If destChainId is undefined, treat req as a swap and fallback to srcStablecoins
41
- (destStablecoins ?? srcStablecoins)
42
- ?.map((stablecoin) => stablecoin.toLowerCase())
43
- .includes(destTokenAddress.toLowerCase())) {
44
- return SWAP_EVM_STABLECOIN_SLIPPAGE;
45
- }
46
- return SWAP_EVM_DEFAULT_SLIPPAGE;
47
- };
48
- exports.getDefaultSlippagePercentage = getDefaultSlippagePercentage;
49
- //# sourceMappingURL=slippage.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slippage.cjs","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AAG5C,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,4BAA4B,GAAG,CAC1C,EACE,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,GAMZ,EACD,cAAyB,EACzB,eAA0B,EAC1B,EAAE;IACF,IAAI,CAAC,UAAU,IAAI,IAAA,qBAAY,EAAC,UAAU,EAAE,WAAW,CAAC,EAAE;QACxD,OAAO,+BAAuB,CAAC;KAChC;IAED,IAAI,IAAA,wBAAe,EAAC,UAAU,CAAC,EAAE;QAC/B,OAAO,oBAAoB,CAAC;KAC7B;IAED,IACE,eAAe;QACf,gBAAgB;QAChB,cAAc;YACZ,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;QAC1C,kFAAkF;QAClF,CAAC,eAAe,IAAI,cAAc,CAAC;YACjC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,EAC3C;QACA,OAAO,4BAA4B,CAAC;KACrC;IAED,OAAO,yBAAyB,CAAC;AACnC,CAAC,CAAC;AAtCW,QAAA,4BAA4B,gCAsCvC","sourcesContent":["import { isCrossChain, isSolanaChainId } from './bridge';\nimport type { GenericQuoteRequest } from '../types';\n\nexport const BRIDGE_DEFAULT_SLIPPAGE = 0.5;\nconst SWAP_SOLANA_SLIPPAGE = undefined;\nconst SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;\nconst SWAP_EVM_DEFAULT_SLIPPAGE = 2;\n\n/**\n * Calculates the appropriate slippage based on the transaction context\n *\n * Rules:\n * - Bridge (cross-chain): Always 0.5%\n * - Swap on Solana: Always undefined (AUTO mode)\n * - Swap on EVM stablecoin pairs (same chain only): 0.5%\n * - Swap on EVM other pairs: 2%\n *\n * @param options - the options for the destination chain\n * @param options.srcTokenAddress - the source token address\n * @param options.destTokenAddress - the destination token address\n * @param options.srcChainId - the source chain id\n * @param options.destChainId - the destination chain id\n * @param srcStablecoins - the list of stablecoins on the source chain\n * @param destStablecoins - the list of stablecoins on the destination chain\n \n * @returns the default slippage percentage for the chain and token pair\n */\nexport const getDefaultSlippagePercentage = (\n {\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n }: Partial<\n Pick<\n GenericQuoteRequest,\n 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'\n >\n >,\n srcStablecoins?: string[],\n destStablecoins?: string[],\n) => {\n if (!srcChainId || isCrossChain(srcChainId, destChainId)) {\n return BRIDGE_DEFAULT_SLIPPAGE;\n }\n\n if (isSolanaChainId(srcChainId)) {\n return SWAP_SOLANA_SLIPPAGE;\n }\n\n if (\n srcTokenAddress &&\n destTokenAddress &&\n srcStablecoins\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(srcTokenAddress.toLowerCase()) &&\n // If destChainId is undefined, treat req as a swap and fallback to srcStablecoins\n (destStablecoins ?? srcStablecoins)\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(destTokenAddress.toLowerCase())\n ) {\n return SWAP_EVM_STABLECOIN_SLIPPAGE;\n }\n\n return SWAP_EVM_DEFAULT_SLIPPAGE;\n};\n"]}
@@ -1,23 +0,0 @@
1
- import type { GenericQuoteRequest } from "../types.cjs";
2
- export declare const BRIDGE_DEFAULT_SLIPPAGE = 0.5;
3
- /**
4
- * Calculates the appropriate slippage based on the transaction context
5
- *
6
- * Rules:
7
- * - Bridge (cross-chain): Always 0.5%
8
- * - Swap on Solana: Always undefined (AUTO mode)
9
- * - Swap on EVM stablecoin pairs (same chain only): 0.5%
10
- * - Swap on EVM other pairs: 2%
11
- *
12
- * @param options - the options for the destination chain
13
- * @param options.srcTokenAddress - the source token address
14
- * @param options.destTokenAddress - the destination token address
15
- * @param options.srcChainId - the source chain id
16
- * @param options.destChainId - the destination chain id
17
- * @param srcStablecoins - the list of stablecoins on the source chain
18
- * @param destStablecoins - the list of stablecoins on the destination chain
19
-
20
- * @returns the default slippage percentage for the chain and token pair
21
- */
22
- export declare const getDefaultSlippagePercentage: ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }: Partial<Pick<GenericQuoteRequest, 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'>>, srcStablecoins?: string[], destStablecoins?: string[]) => 2 | 0.5 | undefined;
23
- //# sourceMappingURL=slippage.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slippage.d.cts","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAK3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B,oEAMpC,QACD,KACE,mBAAmB,EACnB,iBAAiB,GAAG,kBAAkB,GAAG,YAAY,GAAG,aAAa,CACtE,CACF,mBACgB,MAAM,EAAE,oBACP,MAAM,EAAE,wBAyB3B,CAAC"}
@@ -1,23 +0,0 @@
1
- import type { GenericQuoteRequest } from "../types.mjs";
2
- export declare const BRIDGE_DEFAULT_SLIPPAGE = 0.5;
3
- /**
4
- * Calculates the appropriate slippage based on the transaction context
5
- *
6
- * Rules:
7
- * - Bridge (cross-chain): Always 0.5%
8
- * - Swap on Solana: Always undefined (AUTO mode)
9
- * - Swap on EVM stablecoin pairs (same chain only): 0.5%
10
- * - Swap on EVM other pairs: 2%
11
- *
12
- * @param options - the options for the destination chain
13
- * @param options.srcTokenAddress - the source token address
14
- * @param options.destTokenAddress - the destination token address
15
- * @param options.srcChainId - the source chain id
16
- * @param options.destChainId - the destination chain id
17
- * @param srcStablecoins - the list of stablecoins on the source chain
18
- * @param destStablecoins - the list of stablecoins on the destination chain
19
-
20
- * @returns the default slippage percentage for the chain and token pair
21
- */
22
- export declare const getDefaultSlippagePercentage: ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }: Partial<Pick<GenericQuoteRequest, 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'>>, srcStablecoins?: string[], destStablecoins?: string[]) => 2 | 0.5 | undefined;
23
- //# sourceMappingURL=slippage.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slippage.d.mts","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAK3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B,oEAMpC,QACD,KACE,mBAAmB,EACnB,iBAAiB,GAAG,kBAAkB,GAAG,YAAY,GAAG,aAAa,CACtE,CACF,mBACgB,MAAM,EAAE,oBACP,MAAM,EAAE,wBAyB3B,CAAC"}
@@ -1,45 +0,0 @@
1
- import { isCrossChain, isSolanaChainId } from "./bridge.mjs";
2
- export const BRIDGE_DEFAULT_SLIPPAGE = 0.5;
3
- const SWAP_SOLANA_SLIPPAGE = undefined;
4
- const SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;
5
- const SWAP_EVM_DEFAULT_SLIPPAGE = 2;
6
- /**
7
- * Calculates the appropriate slippage based on the transaction context
8
- *
9
- * Rules:
10
- * - Bridge (cross-chain): Always 0.5%
11
- * - Swap on Solana: Always undefined (AUTO mode)
12
- * - Swap on EVM stablecoin pairs (same chain only): 0.5%
13
- * - Swap on EVM other pairs: 2%
14
- *
15
- * @param options - the options for the destination chain
16
- * @param options.srcTokenAddress - the source token address
17
- * @param options.destTokenAddress - the destination token address
18
- * @param options.srcChainId - the source chain id
19
- * @param options.destChainId - the destination chain id
20
- * @param srcStablecoins - the list of stablecoins on the source chain
21
- * @param destStablecoins - the list of stablecoins on the destination chain
22
-
23
- * @returns the default slippage percentage for the chain and token pair
24
- */
25
- export const getDefaultSlippagePercentage = ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }, srcStablecoins, destStablecoins) => {
26
- if (!srcChainId || isCrossChain(srcChainId, destChainId)) {
27
- return BRIDGE_DEFAULT_SLIPPAGE;
28
- }
29
- if (isSolanaChainId(srcChainId)) {
30
- return SWAP_SOLANA_SLIPPAGE;
31
- }
32
- if (srcTokenAddress &&
33
- destTokenAddress &&
34
- srcStablecoins
35
- ?.map((stablecoin) => stablecoin.toLowerCase())
36
- .includes(srcTokenAddress.toLowerCase()) &&
37
- // If destChainId is undefined, treat req as a swap and fallback to srcStablecoins
38
- (destStablecoins ?? srcStablecoins)
39
- ?.map((stablecoin) => stablecoin.toLowerCase())
40
- .includes(destTokenAddress.toLowerCase())) {
41
- return SWAP_EVM_STABLECOIN_SLIPPAGE;
42
- }
43
- return SWAP_EVM_DEFAULT_SLIPPAGE;
44
- };
45
- //# sourceMappingURL=slippage.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slippage.mjs","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,qBAAiB;AAGzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,EACE,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,GAMZ,EACD,cAAyB,EACzB,eAA0B,EAC1B,EAAE;IACF,IAAI,CAAC,UAAU,IAAI,YAAY,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE;QACxD,OAAO,uBAAuB,CAAC;KAChC;IAED,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE;QAC/B,OAAO,oBAAoB,CAAC;KAC7B;IAED,IACE,eAAe;QACf,gBAAgB;QAChB,cAAc;YACZ,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;QAC1C,kFAAkF;QAClF,CAAC,eAAe,IAAI,cAAc,CAAC;YACjC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,EAC3C;QACA,OAAO,4BAA4B,CAAC;KACrC;IAED,OAAO,yBAAyB,CAAC;AACnC,CAAC,CAAC","sourcesContent":["import { isCrossChain, isSolanaChainId } from './bridge';\nimport type { GenericQuoteRequest } from '../types';\n\nexport const BRIDGE_DEFAULT_SLIPPAGE = 0.5;\nconst SWAP_SOLANA_SLIPPAGE = undefined;\nconst SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;\nconst SWAP_EVM_DEFAULT_SLIPPAGE = 2;\n\n/**\n * Calculates the appropriate slippage based on the transaction context\n *\n * Rules:\n * - Bridge (cross-chain): Always 0.5%\n * - Swap on Solana: Always undefined (AUTO mode)\n * - Swap on EVM stablecoin pairs (same chain only): 0.5%\n * - Swap on EVM other pairs: 2%\n *\n * @param options - the options for the destination chain\n * @param options.srcTokenAddress - the source token address\n * @param options.destTokenAddress - the destination token address\n * @param options.srcChainId - the source chain id\n * @param options.destChainId - the destination chain id\n * @param srcStablecoins - the list of stablecoins on the source chain\n * @param destStablecoins - the list of stablecoins on the destination chain\n \n * @returns the default slippage percentage for the chain and token pair\n */\nexport const getDefaultSlippagePercentage = (\n {\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n }: Partial<\n Pick<\n GenericQuoteRequest,\n 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'\n >\n >,\n srcStablecoins?: string[],\n destStablecoins?: string[],\n) => {\n if (!srcChainId || isCrossChain(srcChainId, destChainId)) {\n return BRIDGE_DEFAULT_SLIPPAGE;\n }\n\n if (isSolanaChainId(srcChainId)) {\n return SWAP_SOLANA_SLIPPAGE;\n }\n\n if (\n srcTokenAddress &&\n destTokenAddress &&\n srcStablecoins\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(srcTokenAddress.toLowerCase()) &&\n // If destChainId is undefined, treat req as a swap and fallback to srcStablecoins\n (destStablecoins ?? srcStablecoins)\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(destTokenAddress.toLowerCase())\n ) {\n return SWAP_EVM_STABLECOIN_SLIPPAGE;\n }\n\n return SWAP_EVM_DEFAULT_SLIPPAGE;\n};\n"]}