@metamask-previews/bridge-controller 79.0.1-preview-58a4a8b71 → 79.0.1-preview-4c8a5dfcb
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/CHANGELOG.md +8 -0
- package/dist/coercers/quote-response-v1-to-v2.cjs +4 -4
- package/dist/coercers/quote-response-v1-to-v2.cjs.map +1 -1
- package/dist/coercers/quote-response-v1-to-v2.mjs +4 -4
- package/dist/coercers/quote-response-v1-to-v2.mjs.map +1 -1
- package/dist/index.cjs +11 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +40 -4
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +1199 -105
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +1199 -105
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +40 -4
- package/dist/selectors.mjs.map +1 -1
- package/dist/utils/quote-metadata/calculators.cjs +6 -11
- package/dist/utils/quote-metadata/calculators.cjs.map +1 -1
- package/dist/utils/quote-metadata/calculators.d.cts.map +1 -1
- package/dist/utils/quote-metadata/calculators.d.mts.map +1 -1
- package/dist/utils/quote-metadata/calculators.mjs +6 -11
- package/dist/utils/quote-metadata/calculators.mjs.map +1 -1
- package/dist/utils/quote-metadata/include-if-truthy.cjs +14 -0
- package/dist/utils/quote-metadata/include-if-truthy.cjs.map +1 -0
- package/dist/utils/quote-metadata/include-if-truthy.d.cts +2 -0
- package/dist/utils/quote-metadata/include-if-truthy.d.cts.map +1 -0
- package/dist/utils/quote-metadata/include-if-truthy.d.mts +2 -0
- package/dist/utils/quote-metadata/include-if-truthy.d.mts.map +1 -0
- package/dist/utils/quote-metadata/include-if-truthy.mjs +10 -0
- package/dist/utils/quote-metadata/include-if-truthy.mjs.map +1 -0
- package/dist/utils/quote-metadata/merge.cjs +12 -10
- package/dist/utils/quote-metadata/merge.cjs.map +1 -1
- package/dist/utils/quote-metadata/merge.d.cts +6 -3
- package/dist/utils/quote-metadata/merge.d.cts.map +1 -1
- package/dist/utils/quote-metadata/merge.d.mts +6 -3
- package/dist/utils/quote-metadata/merge.d.mts.map +1 -1
- package/dist/utils/quote-metadata/merge.mjs +12 -10
- package/dist/utils/quote-metadata/merge.mjs.map +1 -1
- package/dist/utils/quote-metadata/to-currency-values.cjs +58 -0
- package/dist/utils/quote-metadata/to-currency-values.cjs.map +1 -0
- package/dist/utils/quote-metadata/to-currency-values.d.cts +12 -0
- package/dist/utils/quote-metadata/to-currency-values.d.cts.map +1 -0
- package/dist/utils/quote-metadata/to-currency-values.d.mts +12 -0
- package/dist/utils/quote-metadata/to-currency-values.d.mts.map +1 -0
- package/dist/utils/quote-metadata/to-currency-values.mjs +54 -0
- package/dist/utils/quote-metadata/to-currency-values.mjs.map +1 -0
- package/dist/utils/quote-metadata/to-quote-metadata-v1.cjs +66 -16
- package/dist/utils/quote-metadata/to-quote-metadata-v1.cjs.map +1 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.cts +3 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.cts.map +1 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.mts +3 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.mts.map +1 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.mjs +66 -16
- package/dist/utils/quote-metadata/to-quote-metadata-v1.mjs.map +1 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.cjs +21 -42
- package/dist/utils/quote-metadata/to-quote-metadata-v2.cjs.map +1 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.d.cts.map +1 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.d.mts.map +1 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.mjs +21 -42
- package/dist/utils/quote-metadata/to-quote-metadata-v2.mjs.map +1 -1
- package/dist/utils/quote-metadata/types.cjs +16 -0
- package/dist/utils/quote-metadata/types.cjs.map +1 -1
- package/dist/utils/quote-metadata/types.d.cts +21 -0
- package/dist/utils/quote-metadata/types.d.cts.map +1 -1
- package/dist/utils/quote-metadata/types.d.mts +21 -0
- package/dist/utils/quote-metadata/types.d.mts.map +1 -1
- package/dist/utils/quote-metadata/types.mjs +15 -1
- package/dist/utils/quote-metadata/types.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuoteMetadataMigrationPhase = void 0;
|
|
4
|
+
exports.QuoteMetadataMigrationPhase = {
|
|
5
|
+
/**
|
|
6
|
+
* Phase 1: omit API V2 currency metadata; serve legacy calcQuoteMetadata
|
|
7
|
+
* into V2 nested shape
|
|
8
|
+
*/
|
|
9
|
+
V1Data: '1',
|
|
10
|
+
/**
|
|
11
|
+
* Phase 1.5: prefer API V2 metadata (+ fiat from usd); fall back to legacy.
|
|
12
|
+
*/
|
|
13
|
+
V2WithV1Fallback: '1.5',
|
|
14
|
+
/**
|
|
15
|
+
* Phase 2: API V2 metadata only; legacy metadata utils can be removed.
|
|
16
|
+
*/
|
|
17
|
+
V2Only: '2',
|
|
18
|
+
};
|
|
3
19
|
//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/utils/quote-metadata/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DeepPartial } from '../../types.js';\n\n/**\n * The types of values for the token amount and its values when converted to the user's selected currency and USD\n */\nexport type TokenAmountValues = {\n /**\n * The amount of the token\n *\n * @example \"1.005\"\n */\n amount: string;\n /**\n * The amount of the token in the user's selected currency\n *\n * @example \"4.55\"\n */\n valueInCurrency: string;\n /**\n * The amount of the token in USD\n *\n * @example \"1.234\"\n */\n usd: string;\n};\n\n/**\n * Values derived from the quote response\n *\n * @deprecated Avoid introducing new usages and use the QuoteResponse V2 type instead\n */\ntype QuoteMetadataV1 = {\n /**\n * If gas is included, this is the value of the src or dest token that was used to pay for the gas.\n * Show this value to indicate transaction fees for gasless quotes.\n */\n includedTxFees?: Partial<TokenAmountValues>;\n /**\n * The gas fee for the bridge transaction.\n * effective is the gas fee that is shown to the user. If this value is not\n * included in the trade, the calculation falls back to the gasLimit (total)\n * total is the gas fee that is spent by the user, including refunds.\n * max is the max gas fee that will be used by the transaction.\n */\n gasFee: Record<'total', TokenAmountValues>;\n relayerFee?: Partial<TokenAmountValues>; // relayer/provider fee in native units\n /**\n * The total network fee required to submit the trade and any approvals. This includes\n * the relayer fee or other native fees. Should be used for balance checks and tx submission.\n * Note: This is only accurate for non-gasless transactions. Use {@link QuoteMetadata.includedTxFees} to\n * get the total network fee for gasless transactions.\n */\n totalNetworkFee: TokenAmountValues; // gasFee.total + relayerFee\n /**\n * The amount that the user will receive (destTokenAmount)\n */\n toTokenAmount: TokenAmountValues;\n /**\n * The minimum amount that the user will receive (minDestTokenAmount)\n */\n minToTokenAmount: TokenAmountValues;\n /**\n * If gas is included: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.includedTxFees}.\n * Otherwise: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.totalNetworkFee}.\n */\n adjustedReturn: Omit<TokenAmountValues, 'amount'>;\n /**\n * The amount that the user will send, including fees that are paid in the src token\n * {@link Quote.srcTokenAmount} + {@link Quote.feeData[FeeType.METABRIDGE].amount} + {@link Quote.feeData[FeeType.TX_FEE].amount}\n */\n sentAmount: TokenAmountValues;\n /**\n * The swap rate is the amount that the user will receive per amount sent. Accounts for fees paid in the src or dest token.\n * This is calculated as {@link QuoteMetadata.toTokenAmount} / {@link QuoteMetadata.sentAmount}.\n */\n swapRate: string;\n /**\n * The cost of the trade, which is the difference between the amount sent and the adjusted return.\n * This is calculated as {@link QuoteMetadata.sentAmount} - {@link QuoteMetadata.adjustedReturn}.\n */\n cost: Omit<TokenAmountValues, 'amount'>; // sentAmount - adjustedReturn\n\n /**\n * The price impact for the quote.\n */\n priceImpact: Omit<TokenAmountValues, 'amount'>; // abs(sentAmount - toTokenAmount);\n};\n\nexport type QuoteMetadata = DeepPartial<QuoteMetadataV1>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/utils/quote-metadata/types.ts"],"names":[],"mappings":";;;AA+Fa,QAAA,2BAA2B,GAAG;IACzC;;;OAGG;IACH,MAAM,EAAE,GAAG;IACX;;OAEG;IACH,gBAAgB,EAAE,KAAK;IACvB;;OAEG;IACH,MAAM,EAAE,GAAG;CACH,CAAC","sourcesContent":["import type { DeepPartial } from '../../types.js';\n\n/**\n * The types of values for the token amount and its values when converted to the user's selected currency and USD\n */\nexport type TokenAmountValues = {\n /**\n * The amount of the token\n *\n * @example \"1.005\"\n */\n amount: string;\n /**\n * The amount of the token in the user's selected currency\n *\n * @example \"4.55\"\n */\n valueInCurrency: string;\n /**\n * The amount of the token in USD\n *\n * @example \"1.234\"\n */\n usd: string;\n};\n\n/**\n * Values derived from the quote response\n *\n * @deprecated Avoid introducing new usages and use the QuoteResponse V2 type instead\n */\ntype QuoteMetadataV1 = {\n /**\n * If gas is included, this is the value of the src or dest token that was used to pay for the gas.\n * Show this value to indicate transaction fees for gasless quotes.\n */\n includedTxFees?: Partial<TokenAmountValues>;\n /**\n * The gas fee for the bridge transaction.\n * effective is the gas fee that is shown to the user. If this value is not\n * included in the trade, the calculation falls back to the gasLimit (total)\n * total is the gas fee that is spent by the user, including refunds.\n * max is the max gas fee that will be used by the transaction.\n */\n gasFee: Record<'total', TokenAmountValues>;\n relayerFee?: Partial<TokenAmountValues>; // relayer/provider fee in native units\n /**\n * The total network fee required to submit the trade and any approvals. This includes\n * the relayer fee or other native fees. Should be used for balance checks and tx submission.\n * Note: This is only accurate for non-gasless transactions. Use {@link QuoteMetadata.includedTxFees} to\n * get the total network fee for gasless transactions.\n */\n totalNetworkFee: TokenAmountValues; // gasFee.total + relayerFee\n /**\n * The amount that the user will receive (destTokenAmount)\n */\n toTokenAmount: TokenAmountValues;\n /**\n * The minimum amount that the user will receive (minDestTokenAmount)\n */\n minToTokenAmount: TokenAmountValues;\n /**\n * If gas is included: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.includedTxFees}.\n * Otherwise: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.totalNetworkFee}.\n */\n adjustedReturn: Omit<TokenAmountValues, 'amount'>;\n /**\n * The amount that the user will send, including fees that are paid in the src token\n * {@link Quote.srcTokenAmount} + {@link Quote.feeData[FeeType.METABRIDGE].amount} + {@link Quote.feeData[FeeType.TX_FEE].amount}\n */\n sentAmount: TokenAmountValues;\n /**\n * The swap rate is the amount that the user will receive per amount sent. Accounts for fees paid in the src or dest token.\n * This is calculated as {@link QuoteMetadata.toTokenAmount} / {@link QuoteMetadata.sentAmount}.\n */\n swapRate: string;\n /**\n * The cost of the trade, which is the difference between the amount sent and the adjusted return.\n * This is calculated as {@link QuoteMetadata.sentAmount} - {@link QuoteMetadata.adjustedReturn}.\n */\n cost: Omit<TokenAmountValues, 'amount'>; // sentAmount - adjustedReturn\n\n /**\n * The price impact for the quote.\n */\n priceImpact: Omit<TokenAmountValues, 'amount'>; // abs(sentAmount - toTokenAmount);\n};\n\n/**\n * The partial legacy quote metadata\n *\n * @deprecated Avoid introducing new usages and use the nested QuoteResponse metadata instead\n */\nexport type QuoteMetadata = DeepPartial<QuoteMetadataV1>;\n\nexport const QuoteMetadataMigrationPhase = {\n /**\n * Phase 1: omit API V2 currency metadata; serve legacy calcQuoteMetadata\n * into V2 nested shape\n */\n V1Data: '1',\n /**\n * Phase 1.5: prefer API V2 metadata (+ fiat from usd); fall back to legacy.\n */\n V2WithV1Fallback: '1.5',\n /**\n * Phase 2: API V2 metadata only; legacy metadata utils can be removed.\n */\n V2Only: '2',\n} as const;\n\nexport type QuoteMetadataMigrationPhase =\n (typeof QuoteMetadataMigrationPhase)[keyof typeof QuoteMetadataMigrationPhase];\n"]}
|
|
@@ -82,6 +82,27 @@ type QuoteMetadataV1 = {
|
|
|
82
82
|
*/
|
|
83
83
|
priceImpact: Omit<TokenAmountValues, 'amount'>;
|
|
84
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* The partial legacy quote metadata
|
|
87
|
+
*
|
|
88
|
+
* @deprecated Avoid introducing new usages and use the nested QuoteResponse metadata instead
|
|
89
|
+
*/
|
|
85
90
|
export type QuoteMetadata = DeepPartial<QuoteMetadataV1>;
|
|
91
|
+
export declare const QuoteMetadataMigrationPhase: {
|
|
92
|
+
/**
|
|
93
|
+
* Phase 1: omit API V2 currency metadata; serve legacy calcQuoteMetadata
|
|
94
|
+
* into V2 nested shape
|
|
95
|
+
*/
|
|
96
|
+
readonly V1Data: "1";
|
|
97
|
+
/**
|
|
98
|
+
* Phase 1.5: prefer API V2 metadata (+ fiat from usd); fall back to legacy.
|
|
99
|
+
*/
|
|
100
|
+
readonly V2WithV1Fallback: "1.5";
|
|
101
|
+
/**
|
|
102
|
+
* Phase 2: API V2 metadata only; legacy metadata utils can be removed.
|
|
103
|
+
*/
|
|
104
|
+
readonly V2Only: "2";
|
|
105
|
+
};
|
|
106
|
+
export type QuoteMetadataMigrationPhase = (typeof QuoteMetadataMigrationPhase)[keyof typeof QuoteMetadataMigrationPhase];
|
|
86
107
|
export {};
|
|
87
108
|
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/utils/quote-metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAuB;AAElD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,eAAe,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,cAAc,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC5C;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACxC;;;;;OAKG;IACH,eAAe,EAAE,iBAAiB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IACjC;;OAEG;IACH,gBAAgB,EAAE,iBAAiB,CAAC;IACpC;;;OAGG;IACH,cAAc,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAClD;;;OAGG;IACH,UAAU,EAAE,iBAAiB,CAAC;IAC9B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAExC;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;AAEzD,eAAO,MAAM,2BAA2B;IACtC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEK,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -82,6 +82,27 @@ type QuoteMetadataV1 = {
|
|
|
82
82
|
*/
|
|
83
83
|
priceImpact: Omit<TokenAmountValues, 'amount'>;
|
|
84
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* The partial legacy quote metadata
|
|
87
|
+
*
|
|
88
|
+
* @deprecated Avoid introducing new usages and use the nested QuoteResponse metadata instead
|
|
89
|
+
*/
|
|
85
90
|
export type QuoteMetadata = DeepPartial<QuoteMetadataV1>;
|
|
91
|
+
export declare const QuoteMetadataMigrationPhase: {
|
|
92
|
+
/**
|
|
93
|
+
* Phase 1: omit API V2 currency metadata; serve legacy calcQuoteMetadata
|
|
94
|
+
* into V2 nested shape
|
|
95
|
+
*/
|
|
96
|
+
readonly V1Data: "1";
|
|
97
|
+
/**
|
|
98
|
+
* Phase 1.5: prefer API V2 metadata (+ fiat from usd); fall back to legacy.
|
|
99
|
+
*/
|
|
100
|
+
readonly V2WithV1Fallback: "1.5";
|
|
101
|
+
/**
|
|
102
|
+
* Phase 2: API V2 metadata only; legacy metadata utils can be removed.
|
|
103
|
+
*/
|
|
104
|
+
readonly V2Only: "2";
|
|
105
|
+
};
|
|
106
|
+
export type QuoteMetadataMigrationPhase = (typeof QuoteMetadataMigrationPhase)[keyof typeof QuoteMetadataMigrationPhase];
|
|
86
107
|
export {};
|
|
87
108
|
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/utils/quote-metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAuB;AAElD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,KAAK,eAAe,GAAG;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC5C;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACxC;;;;;OAKG;IACH,eAAe,EAAE,iBAAiB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IACjC;;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;IACH,UAAU,EAAE,iBAAiB,CAAC;IAC9B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAExC;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;AAEzD,eAAO,MAAM,2BAA2B;IACtC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEK,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export const QuoteMetadataMigrationPhase = {
|
|
2
|
+
/**
|
|
3
|
+
* Phase 1: omit API V2 currency metadata; serve legacy calcQuoteMetadata
|
|
4
|
+
* into V2 nested shape
|
|
5
|
+
*/
|
|
6
|
+
V1Data: '1',
|
|
7
|
+
/**
|
|
8
|
+
* Phase 1.5: prefer API V2 metadata (+ fiat from usd); fall back to legacy.
|
|
9
|
+
*/
|
|
10
|
+
V2WithV1Fallback: '1.5',
|
|
11
|
+
/**
|
|
12
|
+
* Phase 2: API V2 metadata only; legacy metadata utils can be removed.
|
|
13
|
+
*/
|
|
14
|
+
V2Only: '2',
|
|
15
|
+
};
|
|
2
16
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/quote-metadata/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DeepPartial } from '../../types.js';\n\n/**\n * The types of values for the token amount and its values when converted to the user's selected currency and USD\n */\nexport type TokenAmountValues = {\n /**\n * The amount of the token\n *\n * @example \"1.005\"\n */\n amount: string;\n /**\n * The amount of the token in the user's selected currency\n *\n * @example \"4.55\"\n */\n valueInCurrency: string;\n /**\n * The amount of the token in USD\n *\n * @example \"1.234\"\n */\n usd: string;\n};\n\n/**\n * Values derived from the quote response\n *\n * @deprecated Avoid introducing new usages and use the QuoteResponse V2 type instead\n */\ntype QuoteMetadataV1 = {\n /**\n * If gas is included, this is the value of the src or dest token that was used to pay for the gas.\n * Show this value to indicate transaction fees for gasless quotes.\n */\n includedTxFees?: Partial<TokenAmountValues>;\n /**\n * The gas fee for the bridge transaction.\n * effective is the gas fee that is shown to the user. If this value is not\n * included in the trade, the calculation falls back to the gasLimit (total)\n * total is the gas fee that is spent by the user, including refunds.\n * max is the max gas fee that will be used by the transaction.\n */\n gasFee: Record<'total', TokenAmountValues>;\n relayerFee?: Partial<TokenAmountValues>; // relayer/provider fee in native units\n /**\n * The total network fee required to submit the trade and any approvals. This includes\n * the relayer fee or other native fees. Should be used for balance checks and tx submission.\n * Note: This is only accurate for non-gasless transactions. Use {@link QuoteMetadata.includedTxFees} to\n * get the total network fee for gasless transactions.\n */\n totalNetworkFee: TokenAmountValues; // gasFee.total + relayerFee\n /**\n * The amount that the user will receive (destTokenAmount)\n */\n toTokenAmount: TokenAmountValues;\n /**\n * The minimum amount that the user will receive (minDestTokenAmount)\n */\n minToTokenAmount: TokenAmountValues;\n /**\n * If gas is included: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.includedTxFees}.\n * Otherwise: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.totalNetworkFee}.\n */\n adjustedReturn: Omit<TokenAmountValues, 'amount'>;\n /**\n * The amount that the user will send, including fees that are paid in the src token\n * {@link Quote.srcTokenAmount} + {@link Quote.feeData[FeeType.METABRIDGE].amount} + {@link Quote.feeData[FeeType.TX_FEE].amount}\n */\n sentAmount: TokenAmountValues;\n /**\n * The swap rate is the amount that the user will receive per amount sent. Accounts for fees paid in the src or dest token.\n * This is calculated as {@link QuoteMetadata.toTokenAmount} / {@link QuoteMetadata.sentAmount}.\n */\n swapRate: string;\n /**\n * The cost of the trade, which is the difference between the amount sent and the adjusted return.\n * This is calculated as {@link QuoteMetadata.sentAmount} - {@link QuoteMetadata.adjustedReturn}.\n */\n cost: Omit<TokenAmountValues, 'amount'>; // sentAmount - adjustedReturn\n\n /**\n * The price impact for the quote.\n */\n priceImpact: Omit<TokenAmountValues, 'amount'>; // abs(sentAmount - toTokenAmount);\n};\n\nexport type QuoteMetadata = DeepPartial<QuoteMetadataV1>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/quote-metadata/types.ts"],"names":[],"mappings":"AA+FA,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC;;;OAGG;IACH,MAAM,EAAE,GAAG;IACX;;OAEG;IACH,gBAAgB,EAAE,KAAK;IACvB;;OAEG;IACH,MAAM,EAAE,GAAG;CACH,CAAC","sourcesContent":["import type { DeepPartial } from '../../types.js';\n\n/**\n * The types of values for the token amount and its values when converted to the user's selected currency and USD\n */\nexport type TokenAmountValues = {\n /**\n * The amount of the token\n *\n * @example \"1.005\"\n */\n amount: string;\n /**\n * The amount of the token in the user's selected currency\n *\n * @example \"4.55\"\n */\n valueInCurrency: string;\n /**\n * The amount of the token in USD\n *\n * @example \"1.234\"\n */\n usd: string;\n};\n\n/**\n * Values derived from the quote response\n *\n * @deprecated Avoid introducing new usages and use the QuoteResponse V2 type instead\n */\ntype QuoteMetadataV1 = {\n /**\n * If gas is included, this is the value of the src or dest token that was used to pay for the gas.\n * Show this value to indicate transaction fees for gasless quotes.\n */\n includedTxFees?: Partial<TokenAmountValues>;\n /**\n * The gas fee for the bridge transaction.\n * effective is the gas fee that is shown to the user. If this value is not\n * included in the trade, the calculation falls back to the gasLimit (total)\n * total is the gas fee that is spent by the user, including refunds.\n * max is the max gas fee that will be used by the transaction.\n */\n gasFee: Record<'total', TokenAmountValues>;\n relayerFee?: Partial<TokenAmountValues>; // relayer/provider fee in native units\n /**\n * The total network fee required to submit the trade and any approvals. This includes\n * the relayer fee or other native fees. Should be used for balance checks and tx submission.\n * Note: This is only accurate for non-gasless transactions. Use {@link QuoteMetadata.includedTxFees} to\n * get the total network fee for gasless transactions.\n */\n totalNetworkFee: TokenAmountValues; // gasFee.total + relayerFee\n /**\n * The amount that the user will receive (destTokenAmount)\n */\n toTokenAmount: TokenAmountValues;\n /**\n * The minimum amount that the user will receive (minDestTokenAmount)\n */\n minToTokenAmount: TokenAmountValues;\n /**\n * If gas is included: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.includedTxFees}.\n * Otherwise: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.totalNetworkFee}.\n */\n adjustedReturn: Omit<TokenAmountValues, 'amount'>;\n /**\n * The amount that the user will send, including fees that are paid in the src token\n * {@link Quote.srcTokenAmount} + {@link Quote.feeData[FeeType.METABRIDGE].amount} + {@link Quote.feeData[FeeType.TX_FEE].amount}\n */\n sentAmount: TokenAmountValues;\n /**\n * The swap rate is the amount that the user will receive per amount sent. Accounts for fees paid in the src or dest token.\n * This is calculated as {@link QuoteMetadata.toTokenAmount} / {@link QuoteMetadata.sentAmount}.\n */\n swapRate: string;\n /**\n * The cost of the trade, which is the difference between the amount sent and the adjusted return.\n * This is calculated as {@link QuoteMetadata.sentAmount} - {@link QuoteMetadata.adjustedReturn}.\n */\n cost: Omit<TokenAmountValues, 'amount'>; // sentAmount - adjustedReturn\n\n /**\n * The price impact for the quote.\n */\n priceImpact: Omit<TokenAmountValues, 'amount'>; // abs(sentAmount - toTokenAmount);\n};\n\n/**\n * The partial legacy quote metadata\n *\n * @deprecated Avoid introducing new usages and use the nested QuoteResponse metadata instead\n */\nexport type QuoteMetadata = DeepPartial<QuoteMetadataV1>;\n\nexport const QuoteMetadataMigrationPhase = {\n /**\n * Phase 1: omit API V2 currency metadata; serve legacy calcQuoteMetadata\n * into V2 nested shape\n */\n V1Data: '1',\n /**\n * Phase 1.5: prefer API V2 metadata (+ fiat from usd); fall back to legacy.\n */\n V2WithV1Fallback: '1.5',\n /**\n * Phase 2: API V2 metadata only; legacy metadata utils can be removed.\n */\n V2Only: '2',\n} as const;\n\nexport type QuoteMetadataMigrationPhase =\n (typeof QuoteMetadataMigrationPhase)[keyof typeof QuoteMetadataMigrationPhase];\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/bridge-controller",
|
|
3
|
-
"version": "79.0.1-preview-
|
|
3
|
+
"version": "79.0.1-preview-4c8a5dfcb",
|
|
4
4
|
"description": "Manages bridge-related quote fetching functionality for MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@ethersproject/providers": "^5.7.0",
|
|
62
62
|
"@metamask/accounts-controller": "^39.0.7",
|
|
63
63
|
"@metamask/assets-controller": "^13.1.1",
|
|
64
|
-
"@metamask/assets-controllers": "^111.
|
|
64
|
+
"@metamask/assets-controllers": "^111.1.0",
|
|
65
65
|
"@metamask/base-controller": "^9.1.0",
|
|
66
66
|
"@metamask/controller-utils": "^12.3.0",
|
|
67
67
|
"@metamask/gas-fee-controller": "^26.3.1",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@metamask/profile-sync-controller": "^29.0.0",
|
|
75
75
|
"@metamask/remote-feature-flag-controller": "^5.0.0",
|
|
76
76
|
"@metamask/snaps-controllers": "^19.0.0",
|
|
77
|
-
"@metamask/transaction-controller": "^69.5.
|
|
77
|
+
"@metamask/transaction-controller": "^69.5.1",
|
|
78
78
|
"@metamask/utils": "^11.11.0",
|
|
79
79
|
"bignumber.js": "^9.1.2",
|
|
80
80
|
"reselect": "^5.1.1",
|