@metamask-previews/bridge-controller 81.2.0-preview-c6cdff1dd → 81.2.0-preview-d3f9964be
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 +6 -0
- package/dist/utils/quote-metadata/to-currency-values.d.ts.map +1 -1
- package/dist/utils/quote-metadata/to-currency-values.js +11 -6
- package/dist/utils/quote-metadata/to-currency-values.js.map +1 -1
- package/dist/utils/quote-metadata/to-normalized-amounts.d.ts.map +1 -1
- package/dist/utils/quote-metadata/to-normalized-amounts.js +5 -0
- package/dist/utils/quote-metadata/to-normalized-amounts.js.map +1 -1
- package/dist/validators/quote-response.d.ts +150 -0
- package/dist/validators/quote-response.d.ts.map +1 -1
- package/dist/validators/quote.d.ts +30 -0
- package/dist/validators/quote.d.ts.map +1 -1
- package/dist/validators/quote.js +4 -0
- package/dist/validators/quote.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add optional `quote.feeData.reserve` on V2 quotes for native minimum-balance requirements ([#10241](https://github.com/MetaMask/core/pull/10241))
|
|
13
|
+
- Sibling of `feeData.network`, not a `FeeType`, so fee aggregators do not treat it as spendable
|
|
14
|
+
- Normalized via `toNormalizedAmounts` and converted to fiat via `toCurrencyValues`
|
|
15
|
+
|
|
10
16
|
## [81.2.0]
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-currency-values.d.ts","sourceRoot":"","sources":["../../../src/utils/quote-metadata/to-currency-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAiBxE;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,UACpB,aAAa,0BACI,SAAS,KAChC,WAAW,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"to-currency-values.d.ts","sourceRoot":"","sources":["../../../src/utils/quote-metadata/to-currency-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAiBxE;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,UACpB,aAAa,0BACI,SAAS,KAChC,WAAW,CAAC,aAAa,CA8D3B,CAAC"}
|
|
@@ -36,12 +36,17 @@ export const toCurrencyValues = (quote, usdToFiatExchangeRate) => {
|
|
|
36
36
|
}),
|
|
37
37
|
},
|
|
38
38
|
feeData: feeData &&
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
{
|
|
40
|
+
...Object.fromEntries(Object.values(FeeType)
|
|
41
|
+
.filter((feeType) => feeData[feeType])
|
|
42
|
+
.map((feeType) => [
|
|
43
|
+
feeType,
|
|
44
|
+
feeData[feeType]?.map((fee) => toCurrency(fee, usdToFiatExchangeRate)),
|
|
45
|
+
])),
|
|
46
|
+
...(feeData.reserve && {
|
|
47
|
+
reserve: feeData.reserve.map((reserve) => toCurrency(reserve, usdToFiatExchangeRate) ?? {}),
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
45
50
|
...((priceImpactFiat ?? adjustedReturnFiat ?? costFiat) && {
|
|
46
51
|
priceData: {
|
|
47
52
|
...(priceImpactFiat && {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-currency-values.js","sourceRoot":"","sources":["../../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AQ,IAAI;wBACd,IAAI,EAAE,QAAQ;qBACf,CAAC;iBACH;aACF,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { BigNumber } from 'bignumber.js';\n\nimport type { DeepPartial } from '../../types.js';\nimport type { AmountsAndAsset } from '../../validators/amount-and-asset.js';\nimport type { QuoteResponse } from '../../validators/quote-response.js';\nimport { FeeType } from '../../validators/quote.js';\n\nconst toCurrency = (\n fee?: Pick<AmountsAndAsset, 'usd' | 'valueInCurrency'>,\n usdToFiatExchangeRate?: BigNumber,\n): Pick<AmountsAndAsset, 'valueInCurrency'> | undefined => {\n const { usd, valueInCurrency } = fee ?? {};\n if (usd && usdToFiatExchangeRate) {\n return { valueInCurrency: usdToFiatExchangeRate.times(usd).toFixed() };\n }\n if (valueInCurrency) {\n return { valueInCurrency };\n }\n return undefined;\n};\n\n/**\n * Builds a partial {@link QuoteResponse} object with fiat values derived from the usd values provided by the bridge-api\n *\n * @param quote - The quote response to calculate the metadata for\n * @param usdToFiatExchangeRate - The usd to fiat exchange rate\n * @returns The partial {@link QuoteResponse} object with fiat values\n */\nexport const toCurrencyValues = (\n quote: QuoteResponse,\n usdToFiatExchangeRate?: BigNumber,\n): DeepPartial<QuoteResponse> => {\n const {\n quote: { src, dest, feeData, priceData },\n } = quote;\n\n const { adjustedReturn, priceImpact, cost } = priceData ?? {};\n\n const priceImpactFiat = toCurrency(priceImpact, usdToFiatExchangeRate);\n const adjustedReturnFiat = toCurrency(adjustedReturn, usdToFiatExchangeRate);\n const costFiat = toCurrency(cost, usdToFiatExchangeRate);\n\n const minAmountValueInCurrency = toCurrency(\n {\n usd: dest.minAmountUsd,\n valueInCurrency: dest.minAmountValueInCurrency,\n },\n usdToFiatExchangeRate,\n )?.valueInCurrency;\n\n return {\n quote: {\n src: toCurrency(src, usdToFiatExchangeRate),\n dest: {\n ...toCurrency(dest, usdToFiatExchangeRate),\n ...(minAmountValueInCurrency && {\n minAmountValueInCurrency,\n }),\n },\n feeData:\n feeData &&\n ({\n ...Object.fromEntries(\n Object.values(FeeType)\n .filter((feeType) => feeData[feeType])\n .map((feeType) => [\n feeType,\n feeData[feeType]?.map((fee) =>\n toCurrency(fee, usdToFiatExchangeRate),\n ),\n ]),\n ),\n ...(feeData.reserve && {\n reserve: feeData.reserve.map(\n (reserve) => toCurrency(reserve, usdToFiatExchangeRate) ?? {},\n ),\n }),\n } as DeepPartial<QuoteResponse['quote']['feeData']>),\n ...((priceImpactFiat ?? adjustedReturnFiat ?? costFiat) && {\n priceData: {\n ...(priceImpactFiat && {\n priceImpact: priceImpactFiat,\n }),\n ...(adjustedReturnFiat && {\n adjustedReturn: adjustedReturnFiat,\n }),\n ...(costFiat && {\n cost: costFiat,\n }),\n },\n }),\n },\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-normalized-amounts.d.ts","sourceRoot":"","sources":["../../../src/utils/quote-metadata/to-normalized-amounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAIxE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,oBACb,WAAW,CAAC,aAAa,CAAC,KAC1C,WAAW,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"to-normalized-amounts.d.ts","sourceRoot":"","sources":["../../../src/utils/quote-metadata/to-normalized-amounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAIxE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,oBACb,WAAW,CAAC,aAAa,CAAC,KAC1C,WAAW,CAAC,aAAa,CAmD3B,CAAC"}
|
|
@@ -21,6 +21,11 @@ export const toNormalizedAmounts = (quoteResponseV2) => {
|
|
|
21
21
|
network: feeData?.[FeeType.NETWORK]?.map((networkFee) => ({
|
|
22
22
|
normalizedAmount: calcNormalizedTokenAmount(networkFee?.amount, networkFee?.asset?.decimals),
|
|
23
23
|
})),
|
|
24
|
+
...(feeData?.reserve && {
|
|
25
|
+
reserve: feeData.reserve.map((reserve) => ({
|
|
26
|
+
normalizedAmount: calcNormalizedTokenAmount(reserve?.amount, reserve?.asset?.decimals),
|
|
27
|
+
})),
|
|
28
|
+
}),
|
|
24
29
|
relayer: feeData?.[FeeType.RELAYER]?.map((relayerFee) => ({
|
|
25
30
|
normalizedAmount: calcNormalizedTokenAmount(relayerFee.amount, relayerFee.asset?.decimals),
|
|
26
31
|
})),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-normalized-amounts.js","sourceRoot":"","sources":["../../../src/utils/quote-metadata/to-normalized-amounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,eAA2C,EACf,EAAE;IAC9B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,KAAK,IAAI,EAAE,CAAC;IAE3D,OAAO;QACL,KAAK,EAAE;YACL,GAAG,EAAE;gBACH,gBAAgB,EAAE,yBAAyB,CACzC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,KAAK,EAAE,QAAQ,CACrB;aACF;YACD,IAAI,EAAE;gBACJ,gBAAgB,EAAE,yBAAyB,CACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,EAAE,QAAQ,CACtB;gBACD,mBAAmB,EAAE,yBAAyB,CAC5C,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,KAAK,EAAE,QAAQ,CACtB;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;oBACxD,gBAAgB,EAAE,yBAAyB,CACzC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,KAAK,EAAE,QAAQ,CAC5B;iBACF,CAAC,CAAC;gBACH,OAAO,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;oBACxD,gBAAgB,EAAE,yBAAyB,CACzC,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,KAAK,EAAE,QAAQ,CAC3B;iBACF,CAAC,CAAC;gBACH,KAAK,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAChD,gBAAgB,EAAE,yBAAyB,CACzC,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,KAAK,EAAE,QAAQ,CACtB;iBACF,CAAC,CAAC;aACJ;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { DeepPartial } from '../../types.js';\nimport type { QuoteResponse } from '../../validators/quote-response.js';\nimport { FeeType } from '../../validators/quote.js';\nimport { calcNormalizedTokenAmount } from '../number-formatters.js';\n\n/**\n * Builds a partial {@link QuoteResponese} with normalized amounts\n *\n * @param quoteResponseV2 - The {@link QuoteResponse} to convert\n * @returns The {@link DeepPartial<QuoteResponse>}\n */\nexport const toNormalizedAmounts = (\n quoteResponseV2: DeepPartial<QuoteResponse>,\n): DeepPartial<QuoteResponse> => {\n const { src, dest, feeData } = quoteResponseV2.quote ?? {};\n\n return {\n quote: {\n src: {\n normalizedAmount: calcNormalizedTokenAmount(\n src?.amount,\n src?.asset?.decimals,\n ),\n },\n dest: {\n normalizedAmount: calcNormalizedTokenAmount(\n dest?.amount,\n dest?.asset?.decimals,\n ),\n minAmountNormalized: calcNormalizedTokenAmount(\n dest?.minAmount,\n dest?.asset?.decimals,\n ),\n },\n feeData: {\n network: feeData?.[FeeType.NETWORK]?.map((networkFee) => ({\n normalizedAmount: calcNormalizedTokenAmount(\n networkFee?.amount,\n networkFee?.asset?.decimals,\n ),\n })),\n relayer: feeData?.[FeeType.RELAYER]?.map((relayerFee) => ({\n normalizedAmount: calcNormalizedTokenAmount(\n relayerFee.amount,\n relayerFee.asset?.decimals,\n ),\n })),\n txFee: feeData?.[FeeType.TX_FEE]?.map((txFee) => ({\n normalizedAmount: calcNormalizedTokenAmount(\n txFee.amount,\n txFee.asset?.decimals,\n ),\n })),\n },\n },\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"to-normalized-amounts.js","sourceRoot":"","sources":["../../../src/utils/quote-metadata/to-normalized-amounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,eAA2C,EACf,EAAE;IAC9B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,KAAK,IAAI,EAAE,CAAC;IAE3D,OAAO;QACL,KAAK,EAAE;YACL,GAAG,EAAE;gBACH,gBAAgB,EAAE,yBAAyB,CACzC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,KAAK,EAAE,QAAQ,CACrB;aACF;YACD,IAAI,EAAE;gBACJ,gBAAgB,EAAE,yBAAyB,CACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,EAAE,QAAQ,CACtB;gBACD,mBAAmB,EAAE,yBAAyB,CAC5C,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,KAAK,EAAE,QAAQ,CACtB;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;oBACxD,gBAAgB,EAAE,yBAAyB,CACzC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,KAAK,EAAE,QAAQ,CAC5B;iBACF,CAAC,CAAC;gBACH,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI;oBACtB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;wBACzC,gBAAgB,EAAE,yBAAyB,CACzC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,KAAK,EAAE,QAAQ,CACzB;qBACF,CAAC,CAAC;iBACJ,CAAC;gBACF,OAAO,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;oBACxD,gBAAgB,EAAE,yBAAyB,CACzC,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,KAAK,EAAE,QAAQ,CAC3B;iBACF,CAAC,CAAC;gBACH,KAAK,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAChD,gBAAgB,EAAE,yBAAyB,CACzC,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,KAAK,EAAE,QAAQ,CACtB;iBACF,CAAC,CAAC;aACJ;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { DeepPartial } from '../../types.js';\nimport type { QuoteResponse } from '../../validators/quote-response.js';\nimport { FeeType } from '../../validators/quote.js';\nimport { calcNormalizedTokenAmount } from '../number-formatters.js';\n\n/**\n * Builds a partial {@link QuoteResponese} with normalized amounts\n *\n * @param quoteResponseV2 - The {@link QuoteResponse} to convert\n * @returns The {@link DeepPartial<QuoteResponse>}\n */\nexport const toNormalizedAmounts = (\n quoteResponseV2: DeepPartial<QuoteResponse>,\n): DeepPartial<QuoteResponse> => {\n const { src, dest, feeData } = quoteResponseV2.quote ?? {};\n\n return {\n quote: {\n src: {\n normalizedAmount: calcNormalizedTokenAmount(\n src?.amount,\n src?.asset?.decimals,\n ),\n },\n dest: {\n normalizedAmount: calcNormalizedTokenAmount(\n dest?.amount,\n dest?.asset?.decimals,\n ),\n minAmountNormalized: calcNormalizedTokenAmount(\n dest?.minAmount,\n dest?.asset?.decimals,\n ),\n },\n feeData: {\n network: feeData?.[FeeType.NETWORK]?.map((networkFee) => ({\n normalizedAmount: calcNormalizedTokenAmount(\n networkFee?.amount,\n networkFee?.asset?.decimals,\n ),\n })),\n ...(feeData?.reserve && {\n reserve: feeData.reserve.map((reserve) => ({\n normalizedAmount: calcNormalizedTokenAmount(\n reserve?.amount,\n reserve?.asset?.decimals,\n ),\n })),\n }),\n relayer: feeData?.[FeeType.RELAYER]?.map((relayerFee) => ({\n normalizedAmount: calcNormalizedTokenAmount(\n relayerFee.amount,\n relayerFee.asset?.decimals,\n ),\n })),\n txFee: feeData?.[FeeType.TX_FEE]?.map((txFee) => ({\n normalizedAmount: calcNormalizedTokenAmount(\n txFee.amount,\n txFee.asset?.decimals,\n ),\n })),\n },\n },\n };\n};\n"]}
|
|
@@ -223,6 +223,36 @@ export declare const QuoteResponseSchemaV2: import("@metamask/superstruct").Stru
|
|
|
223
223
|
usd?: string | undefined;
|
|
224
224
|
valueInCurrency?: string | undefined;
|
|
225
225
|
}[] | undefined;
|
|
226
|
+
reserve?: {
|
|
227
|
+
amount: string;
|
|
228
|
+
asset: {
|
|
229
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
230
|
+
symbol: string;
|
|
231
|
+
name: string;
|
|
232
|
+
decimals: number;
|
|
233
|
+
} & {
|
|
234
|
+
isVerified?: boolean | undefined;
|
|
235
|
+
securityData?: {
|
|
236
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
237
|
+
metadata?: {
|
|
238
|
+
features: {
|
|
239
|
+
featureId: string;
|
|
240
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
241
|
+
description: string;
|
|
242
|
+
}[];
|
|
243
|
+
} | undefined;
|
|
244
|
+
} | undefined;
|
|
245
|
+
} & {
|
|
246
|
+
iconUrl?: string | null | undefined;
|
|
247
|
+
noFee?: {
|
|
248
|
+
isDestination?: boolean | null | undefined;
|
|
249
|
+
isSource?: boolean | null | undefined;
|
|
250
|
+
} | undefined;
|
|
251
|
+
};
|
|
252
|
+
normalizedAmount?: string | undefined;
|
|
253
|
+
usd?: string | undefined;
|
|
254
|
+
valueInCurrency?: string | undefined;
|
|
255
|
+
}[] | undefined;
|
|
226
256
|
relayer?: {
|
|
227
257
|
amount: string;
|
|
228
258
|
asset: {
|
|
@@ -621,6 +651,36 @@ export declare const QuoteResponseSchemaV2: import("@metamask/superstruct").Stru
|
|
|
621
651
|
usd?: string | undefined;
|
|
622
652
|
valueInCurrency?: string | undefined;
|
|
623
653
|
}[] | undefined;
|
|
654
|
+
reserve?: {
|
|
655
|
+
amount: string;
|
|
656
|
+
asset: {
|
|
657
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
658
|
+
symbol: string;
|
|
659
|
+
name: string;
|
|
660
|
+
decimals: number;
|
|
661
|
+
} & {
|
|
662
|
+
isVerified?: boolean | undefined;
|
|
663
|
+
securityData?: {
|
|
664
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
665
|
+
metadata?: {
|
|
666
|
+
features: {
|
|
667
|
+
featureId: string;
|
|
668
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
669
|
+
description: string;
|
|
670
|
+
}[];
|
|
671
|
+
} | undefined;
|
|
672
|
+
} | undefined;
|
|
673
|
+
} & {
|
|
674
|
+
iconUrl?: string | null | undefined;
|
|
675
|
+
noFee?: {
|
|
676
|
+
isDestination?: boolean | null | undefined;
|
|
677
|
+
isSource?: boolean | null | undefined;
|
|
678
|
+
} | undefined;
|
|
679
|
+
};
|
|
680
|
+
normalizedAmount?: string | undefined;
|
|
681
|
+
usd?: string | undefined;
|
|
682
|
+
valueInCurrency?: string | undefined;
|
|
683
|
+
}[] | undefined;
|
|
624
684
|
relayer?: {
|
|
625
685
|
amount: string;
|
|
626
686
|
asset: {
|
|
@@ -1012,6 +1072,36 @@ export declare const QuoteResponseSchemaV2: import("@metamask/superstruct").Stru
|
|
|
1012
1072
|
usd?: string | undefined;
|
|
1013
1073
|
valueInCurrency?: string | undefined;
|
|
1014
1074
|
}[] | undefined;
|
|
1075
|
+
reserve?: {
|
|
1076
|
+
amount: string;
|
|
1077
|
+
asset: {
|
|
1078
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
1079
|
+
symbol: string;
|
|
1080
|
+
name: string;
|
|
1081
|
+
decimals: number;
|
|
1082
|
+
} & {
|
|
1083
|
+
isVerified?: boolean | undefined;
|
|
1084
|
+
securityData?: {
|
|
1085
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
1086
|
+
metadata?: {
|
|
1087
|
+
features: {
|
|
1088
|
+
featureId: string;
|
|
1089
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
1090
|
+
description: string;
|
|
1091
|
+
}[];
|
|
1092
|
+
} | undefined;
|
|
1093
|
+
} | undefined;
|
|
1094
|
+
} & {
|
|
1095
|
+
iconUrl?: string | null | undefined;
|
|
1096
|
+
noFee?: {
|
|
1097
|
+
isDestination?: boolean | null | undefined;
|
|
1098
|
+
isSource?: boolean | null | undefined;
|
|
1099
|
+
} | undefined;
|
|
1100
|
+
};
|
|
1101
|
+
normalizedAmount?: string | undefined;
|
|
1102
|
+
usd?: string | undefined;
|
|
1103
|
+
valueInCurrency?: string | undefined;
|
|
1104
|
+
}[] | undefined;
|
|
1015
1105
|
relayer?: {
|
|
1016
1106
|
amount: string;
|
|
1017
1107
|
asset: {
|
|
@@ -1393,6 +1483,36 @@ export declare const QuoteResponseSchemaV2: import("@metamask/superstruct").Stru
|
|
|
1393
1483
|
usd?: string | undefined;
|
|
1394
1484
|
valueInCurrency?: string | undefined;
|
|
1395
1485
|
}[] | undefined;
|
|
1486
|
+
reserve?: {
|
|
1487
|
+
amount: string;
|
|
1488
|
+
asset: {
|
|
1489
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
1490
|
+
symbol: string;
|
|
1491
|
+
name: string;
|
|
1492
|
+
decimals: number;
|
|
1493
|
+
} & {
|
|
1494
|
+
isVerified?: boolean | undefined;
|
|
1495
|
+
securityData?: {
|
|
1496
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
1497
|
+
metadata?: {
|
|
1498
|
+
features: {
|
|
1499
|
+
featureId: string;
|
|
1500
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
1501
|
+
description: string;
|
|
1502
|
+
}[];
|
|
1503
|
+
} | undefined;
|
|
1504
|
+
} | undefined;
|
|
1505
|
+
} & {
|
|
1506
|
+
iconUrl?: string | null | undefined;
|
|
1507
|
+
noFee?: {
|
|
1508
|
+
isDestination?: boolean | null | undefined;
|
|
1509
|
+
isSource?: boolean | null | undefined;
|
|
1510
|
+
} | undefined;
|
|
1511
|
+
};
|
|
1512
|
+
normalizedAmount?: string | undefined;
|
|
1513
|
+
usd?: string | undefined;
|
|
1514
|
+
valueInCurrency?: string | undefined;
|
|
1515
|
+
}[] | undefined;
|
|
1396
1516
|
relayer?: {
|
|
1397
1517
|
amount: string;
|
|
1398
1518
|
asset: {
|
|
@@ -1777,6 +1897,36 @@ export declare const QuoteResponseSchemaV2: import("@metamask/superstruct").Stru
|
|
|
1777
1897
|
usd?: string | undefined;
|
|
1778
1898
|
valueInCurrency?: string | undefined;
|
|
1779
1899
|
}[] | undefined;
|
|
1900
|
+
reserve?: {
|
|
1901
|
+
amount: string;
|
|
1902
|
+
asset: {
|
|
1903
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
1904
|
+
symbol: string;
|
|
1905
|
+
name: string;
|
|
1906
|
+
decimals: number;
|
|
1907
|
+
} & {
|
|
1908
|
+
isVerified?: boolean | undefined;
|
|
1909
|
+
securityData?: {
|
|
1910
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
1911
|
+
metadata?: {
|
|
1912
|
+
features: {
|
|
1913
|
+
featureId: string;
|
|
1914
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
1915
|
+
description: string;
|
|
1916
|
+
}[];
|
|
1917
|
+
} | undefined;
|
|
1918
|
+
} | undefined;
|
|
1919
|
+
} & {
|
|
1920
|
+
iconUrl?: string | null | undefined;
|
|
1921
|
+
noFee?: {
|
|
1922
|
+
isDestination?: boolean | null | undefined;
|
|
1923
|
+
isSource?: boolean | null | undefined;
|
|
1924
|
+
} | undefined;
|
|
1925
|
+
};
|
|
1926
|
+
normalizedAmount?: string | undefined;
|
|
1927
|
+
usd?: string | undefined;
|
|
1928
|
+
valueInCurrency?: string | undefined;
|
|
1929
|
+
}[] | undefined;
|
|
1780
1930
|
relayer?: {
|
|
1781
1931
|
amount: string;
|
|
1782
1932
|
asset: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote-response.d.ts","sourceRoot":"","sources":["../../src/validators/quote-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EAYN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,WAAW,EAEX,kBAAkB,EAGnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EACL,gBAAgB,EAEhB,gBAAgB,EAEhB,aAAa,EAEb,MAAM,EAEP,MAAM,YAAY,CAAC;AAgFpB,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"quote-response.d.ts","sourceRoot":"","sources":["../../src/validators/quote-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EAYN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,WAAW,EAEX,kBAAkB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IACrB,KAAK,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC;AAaJ,eAAO,MAAM,qBAAqB,kBACjB,OAAO,KACrB,aAAa,IAAI,aAyBnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,UACrB;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAC3C,KAAK,IAAI,aAKX,CAAC"}
|
|
@@ -447,6 +447,36 @@ export declare const QuoteSchemaV2: import("@metamask/superstruct").Struct<{
|
|
|
447
447
|
usd?: string | undefined;
|
|
448
448
|
valueInCurrency?: string | undefined;
|
|
449
449
|
}[] | undefined;
|
|
450
|
+
reserve?: {
|
|
451
|
+
amount: string;
|
|
452
|
+
asset: {
|
|
453
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
454
|
+
symbol: string;
|
|
455
|
+
name: string;
|
|
456
|
+
decimals: number;
|
|
457
|
+
} & {
|
|
458
|
+
isVerified?: boolean | undefined;
|
|
459
|
+
securityData?: {
|
|
460
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
461
|
+
metadata?: {
|
|
462
|
+
features: {
|
|
463
|
+
featureId: string;
|
|
464
|
+
type: import("./bridge-asset.js").BridgeAssetSecurityDataType;
|
|
465
|
+
description: string;
|
|
466
|
+
}[];
|
|
467
|
+
} | undefined;
|
|
468
|
+
} | undefined;
|
|
469
|
+
} & {
|
|
470
|
+
iconUrl?: string | null | undefined;
|
|
471
|
+
noFee?: {
|
|
472
|
+
isDestination?: boolean | null | undefined;
|
|
473
|
+
isSource?: boolean | null | undefined;
|
|
474
|
+
} | undefined;
|
|
475
|
+
};
|
|
476
|
+
normalizedAmount?: string | undefined;
|
|
477
|
+
usd?: string | undefined;
|
|
478
|
+
valueInCurrency?: string | undefined;
|
|
479
|
+
}[] | undefined;
|
|
450
480
|
relayer?: {
|
|
451
481
|
amount: string;
|
|
452
482
|
asset: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/validators/quote.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAYnD,oBAAY,OAAO;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IAEjB,MAAM,UAAU;IAChB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,GAAG,QAAQ;CACZ;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIxB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;EAG/B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;IAElC;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0DtB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE9C,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/validators/quote.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAYnD,oBAAY,OAAO;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IAEjB,MAAM,UAAU;IAChB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,GAAG,QAAQ;CACZ;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIxB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;EAG/B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;IAElC;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0DtB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE9C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4ExB,CAAC"}
|
package/dist/validators/quote.js
CHANGED
|
@@ -146,6 +146,10 @@ export const QuoteSchemaV2 = intersection([
|
|
|
146
146
|
* The gas fees for the quote, excluding any provider or relayer fees
|
|
147
147
|
*/
|
|
148
148
|
[FeeType.NETWORK]: optional(array(AmountsAndAssetSchema)),
|
|
149
|
+
/**
|
|
150
|
+
* The native balance that must remain in the source account.
|
|
151
|
+
*/
|
|
152
|
+
reserve: optional(array(AmountsAndAssetSchema)),
|
|
149
153
|
/**
|
|
150
154
|
* The relayer or provider fees for the quote,
|
|
151
155
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../src/validators/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,GACL,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEvE,MAAM,CAAN,IAAY,OAOX;AAPD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;IACjB,gEAAgE;IAChE,2BAAgB,CAAA;IAChB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;AACrB,CAAC,EAPW,OAAO,KAAP,OAAO,QAOlB;AAED,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,+BAAe,CAAA;IACf,2BAAW,CAAA;AACb,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,uBAAuB;IAC/B,KAAK,EAAE,iBAAiB;IACxB,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CAC3C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,o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1D,CAAC;QACF,UAAU,EAAE,MAAM,EAAE;QACpB,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;QAC5B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC;QAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n type,\n optional,\n boolean,\n intersection,\n string,\n number,\n array,\n nullable,\n partial,\n pick,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { AmountsAndAssetSchema } from './amount-and-asset.js';\nimport { ChainIdSchema, BridgeAssetSchema } from './bridge-asset.js';\nimport { IntentSchema } from './intent.js';\nimport {\n TruthyDigitStringSchema,\n PositiveNumberStringSchema,\n FloatStringSchema,\n} from './number.js';\nimport { RefuelDataSchema, StepSchema, StepSchemaV2 } from './step.js';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n // eslint-disable-next-line @typescript-eslint/naming-convention\n TX_FEE = 'txFee',\n NETWORK = 'network',\n RELAYER = 'relayer',\n}\n\nexport enum DiscountType {\n VIP = 'vip',\n PROMO = 'promo',\n DAO = 'dao',\n}\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n discountType: optional(nullable(string())),\n});\n\nexport const TxFeeGasLimitsSchema = type({\n maxFeePerGas: PositiveNumberStringSchema,\n maxPriorityFeePerGas: PositiveNumberStringSchema,\n});\n\nexport const GaslessPropertiesSchema = type({\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n /**\n * A third party sponsors the gas. If true, then gasIncluded7702 is also true.\n */\n gasSponsored: optional(boolean()),\n});\n\nexport const QuoteSchema = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: optional(string()),\n feeData: type({\n [FeeType.METABRIDGE]: intersection([\n FeeDataSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n }),\n ]),\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([FeeDataSchema, TxFeeGasLimitsSchema]),\n ),\n }),\n bridgeId: string(),\n bridges: array(string()),\n // TODO require this after v2 migration\n aggregator: optional(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n intent: optional(IntentSchema),\n walletAddress: optional(string()),\n destWalletAddress: optional(string()),\n slippage: optional(number()),\n // TODO require this after v2 migration\n protocols: optional(array(string())),\n }),\n]);\n\nexport type Quote = Infer<typeof QuoteSchema>;\n\nexport const QuoteSchemaV2 = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n src: intersection([\n AmountsAndAssetSchema,\n type({\n walletAddress: optional(string()),\n }),\n ]),\n dest: intersection([\n AmountsAndAssetSchema,\n type({\n minAmount: optional(string()),\n minAmountUsd: optional(string()),\n minAmountValueInCurrency: optional(string()),\n minAmountNormalized: optional(string()),\n walletAddress: optional(string()),\n }),\n ]),\n priceData: optional(\n partial(\n type({\n swapRate: FloatStringSchema,\n priceImpact: intersection([\n type({\n amount: optional(FloatStringSchema),\n }),\n pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n ]),\n adjustedReturn: pick(AmountsAndAssetSchema, [\n 'usd',\n 'valueInCurrency',\n ]),\n cost: pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n }),\n ),\n ),\n feeData: type({\n [FeeType.METABRIDGE]: array(\n intersection([\n AmountsAndAssetSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n discountType: optional(nullable(string())),\n }),\n ]),\n ),\n [FeeType.REFUEL]: optional(array(AmountsAndAssetSchema)),\n /**\n * The tx fees included in the quote for gasless execution\n */\n [FeeType.TX_FEE]: optional(\n array(intersection([AmountsAndAssetSchema, TxFeeGasLimitsSchema])),\n ),\n /**\n * The gas fees for the quote, excluding any provider or relayer fees\n */\n [FeeType.NETWORK]: optional(array(AmountsAndAssetSchema)),\n /**\n * The relayer or provider fees for the quote,\n */\n [FeeType.RELAYER]: optional(array(AmountsAndAssetSchema)),\n }),\n aggregator: string(),\n protocols: array(string()),\n steps: optional(array(StepSchemaV2)),\n refuel: optional(StepSchema),\n intent: optional(IntentSchema),\n slippage: optional(number()),\n }),\n]);\n"]}
|
|
1
|
+
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../src/validators/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,GACL,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAA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Q,CAAC,MAAM,EAAE,CAAC;oBAC/B,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;oBAC9B,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;iBAC3C,CAAC;aACH,CAAC,CACH;YACD,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACxD;;eAEG;YACH,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,CACxB,KAAK,CAAC,YAAY,CAAC,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,CAAC,CAAC,CACnE;YACD;;eAEG;YACH,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACzD;;eAEG;YACH,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAC/C;;eAEG;YACH,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;SAC1D,CAAC;QACF,UAAU,EAAE,MAAM,EAAE;QACpB,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;QAC5B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC;QAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n type,\n optional,\n boolean,\n intersection,\n string,\n number,\n array,\n nullable,\n partial,\n pick,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { AmountsAndAssetSchema } from './amount-and-asset.js';\nimport { ChainIdSchema, BridgeAssetSchema } from './bridge-asset.js';\nimport { IntentSchema } from './intent.js';\nimport {\n TruthyDigitStringSchema,\n PositiveNumberStringSchema,\n FloatStringSchema,\n} from './number.js';\nimport { RefuelDataSchema, StepSchema, StepSchemaV2 } from './step.js';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n // eslint-disable-next-line @typescript-eslint/naming-convention\n TX_FEE = 'txFee',\n NETWORK = 'network',\n RELAYER = 'relayer',\n}\n\nexport enum DiscountType {\n VIP = 'vip',\n PROMO = 'promo',\n DAO = 'dao',\n}\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n discountType: optional(nullable(string())),\n});\n\nexport const TxFeeGasLimitsSchema = type({\n maxFeePerGas: PositiveNumberStringSchema,\n maxPriorityFeePerGas: PositiveNumberStringSchema,\n});\n\nexport const GaslessPropertiesSchema = type({\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n /**\n * A third party sponsors the gas. If true, then gasIncluded7702 is also true.\n */\n gasSponsored: optional(boolean()),\n});\n\nexport const QuoteSchema = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: optional(string()),\n feeData: type({\n [FeeType.METABRIDGE]: intersection([\n FeeDataSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n }),\n ]),\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([FeeDataSchema, TxFeeGasLimitsSchema]),\n ),\n }),\n bridgeId: string(),\n bridges: array(string()),\n // TODO require this after v2 migration\n aggregator: optional(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n intent: optional(IntentSchema),\n walletAddress: optional(string()),\n destWalletAddress: optional(string()),\n slippage: optional(number()),\n // TODO require this after v2 migration\n protocols: optional(array(string())),\n }),\n]);\n\nexport type Quote = Infer<typeof QuoteSchema>;\n\nexport const QuoteSchemaV2 = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n src: intersection([\n AmountsAndAssetSchema,\n type({\n walletAddress: optional(string()),\n }),\n ]),\n dest: intersection([\n AmountsAndAssetSchema,\n type({\n minAmount: optional(string()),\n minAmountUsd: optional(string()),\n minAmountValueInCurrency: optional(string()),\n minAmountNormalized: optional(string()),\n walletAddress: optional(string()),\n }),\n ]),\n priceData: optional(\n partial(\n type({\n swapRate: FloatStringSchema,\n priceImpact: intersection([\n type({\n amount: optional(FloatStringSchema),\n }),\n pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n ]),\n adjustedReturn: pick(AmountsAndAssetSchema, [\n 'usd',\n 'valueInCurrency',\n ]),\n cost: pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n }),\n ),\n ),\n feeData: type({\n [FeeType.METABRIDGE]: array(\n intersection([\n AmountsAndAssetSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n discountType: optional(nullable(string())),\n }),\n ]),\n ),\n [FeeType.REFUEL]: optional(array(AmountsAndAssetSchema)),\n /**\n * The tx fees included in the quote for gasless execution\n */\n [FeeType.TX_FEE]: optional(\n array(intersection([AmountsAndAssetSchema, TxFeeGasLimitsSchema])),\n ),\n /**\n * The gas fees for the quote, excluding any provider or relayer fees\n */\n [FeeType.NETWORK]: optional(array(AmountsAndAssetSchema)),\n /**\n * The native balance that must remain in the source account.\n */\n reserve: optional(array(AmountsAndAssetSchema)),\n /**\n * The relayer or provider fees for the quote,\n */\n [FeeType.RELAYER]: optional(array(AmountsAndAssetSchema)),\n }),\n aggregator: string(),\n protocols: array(string()),\n steps: optional(array(StepSchemaV2)),\n refuel: optional(StepSchema),\n intent: optional(IntentSchema),\n slippage: optional(number()),\n }),\n]);\n"]}
|
package/package.json
CHANGED