@metamask/bridge-controller 74.0.0 → 75.1.0
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 +31 -1
- package/dist/bridge-controller.cjs +17 -19
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +5 -13
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +5 -13
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +18 -20
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/bridge.cjs +2 -0
- package/dist/constants/bridge.cjs.map +1 -1
- package/dist/constants/bridge.d.cts +4 -1
- package/dist/constants/bridge.d.cts.map +1 -1
- package/dist/constants/bridge.d.mts +4 -1
- package/dist/constants/bridge.d.mts.map +1 -1
- package/dist/constants/bridge.mjs +2 -0
- package/dist/constants/bridge.mjs.map +1 -1
- package/dist/constants/chains.cjs +4 -1
- package/dist/constants/chains.cjs.map +1 -1
- package/dist/constants/chains.d.cts +3 -0
- package/dist/constants/chains.d.cts.map +1 -1
- package/dist/constants/chains.d.mts +3 -0
- package/dist/constants/chains.d.mts.map +1 -1
- package/dist/constants/chains.mjs +3 -0
- package/dist/constants/chains.mjs.map +1 -1
- package/dist/constants/tokens.cjs +12 -0
- package/dist/constants/tokens.cjs.map +1 -1
- package/dist/constants/tokens.d.cts +7 -0
- package/dist/constants/tokens.d.cts.map +1 -1
- package/dist/constants/tokens.d.mts +7 -0
- package/dist/constants/tokens.d.mts.map +1 -1
- package/dist/constants/tokens.mjs +12 -0
- package/dist/constants/tokens.mjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.d.cts +143 -143
- package/dist/selectors.d.mts +143 -143
- package/dist/types.cjs +12 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +12 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +12 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +11 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +1 -1
- package/dist/utils/feature-flags.d.mts +1 -1
- package/dist/utils/fetch.cjs +3 -1
- package/dist/utils/fetch.cjs.map +1 -1
- package/dist/utils/fetch.d.cts +3 -3
- package/dist/utils/fetch.d.cts.map +1 -1
- package/dist/utils/fetch.d.mts +3 -3
- package/dist/utils/fetch.d.mts.map +1 -1
- package/dist/utils/fetch.mjs +3 -1
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/metrics/properties.cjs +2 -0
- package/dist/utils/metrics/properties.cjs.map +1 -1
- package/dist/utils/metrics/properties.d.cts +2 -0
- package/dist/utils/metrics/properties.d.cts.map +1 -1
- package/dist/utils/metrics/properties.d.mts +2 -0
- package/dist/utils/metrics/properties.d.mts.map +1 -1
- package/dist/utils/metrics/properties.mjs +2 -0
- package/dist/utils/metrics/properties.mjs.map +1 -1
- package/dist/utils/metrics/types.cjs.map +1 -1
- package/dist/utils/metrics/types.d.cts +30 -17
- package/dist/utils/metrics/types.d.cts.map +1 -1
- package/dist/utils/metrics/types.d.mts +30 -17
- package/dist/utils/metrics/types.d.mts.map +1 -1
- package/dist/utils/metrics/types.mjs.map +1 -1
- package/dist/utils/quote.cjs +2 -2
- package/dist/utils/quote.cjs.map +1 -1
- package/dist/utils/quote.d.cts +1 -1
- package/dist/utils/quote.d.cts.map +1 -1
- package/dist/utils/quote.d.mts +1 -1
- package/dist/utils/quote.d.mts.map +1 -1
- package/dist/utils/quote.mjs +1 -1
- package/dist/utils/quote.mjs.map +1 -1
- package/dist/utils/validators.cjs +2 -9
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +3 -8
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +3 -8
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +1 -8
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CaipAssetType, CaipChainId } from "@metamask/utils";
|
|
2
|
-
import type { SortOrder, StatusTypes } from "../../types.cjs";
|
|
2
|
+
import type { FeatureId, SortOrder, StatusTypes } from "../../types.cjs";
|
|
3
3
|
import type { UnifiedSwapBridgeEventName, MetaMetricsSwapsEventSource, MetricsActionType, MetricsSwapType, PollingStatus } from "./constants.cjs";
|
|
4
4
|
/**
|
|
5
5
|
* These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml
|
|
@@ -11,6 +11,13 @@ export type RequestParams = {
|
|
|
11
11
|
token_symbol_destination: string | null;
|
|
12
12
|
token_address_source: CaipAssetType;
|
|
13
13
|
token_address_destination: CaipAssetType | null;
|
|
14
|
+
/**
|
|
15
|
+
* Client-supplied security classification for the destination token
|
|
16
|
+
* (e.g. from token security/scanning data). Stored on the controller
|
|
17
|
+
* and merged into every analytics event that includes
|
|
18
|
+
* `token_address_destination`. Pass `null` when no security data is
|
|
19
|
+
* available for the selected destination token.
|
|
20
|
+
*/
|
|
14
21
|
token_security_type_destination: string | null;
|
|
15
22
|
};
|
|
16
23
|
export type AccountHardwareType = 'Ledger' | 'Trezor' | 'QR Hardware' | 'Lattice' | null;
|
|
@@ -82,6 +89,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
82
89
|
[UnifiedSwapBridgeEventName.QuotesRequested]: Pick<RequestMetadata, 'stx_enabled' | 'usd_amount_source'> & {
|
|
83
90
|
token_symbol_source: RequestParams['token_symbol_source'];
|
|
84
91
|
token_symbol_destination: RequestParams['token_symbol_destination'];
|
|
92
|
+
token_security_type_destination: RequestParams['token_security_type_destination'];
|
|
85
93
|
};
|
|
86
94
|
[UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {
|
|
87
95
|
warnings: QuoteWarning[];
|
|
@@ -97,6 +105,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
97
105
|
} & Pick<RequestMetadata, 'security_warnings'>;
|
|
98
106
|
[UnifiedSwapBridgeEventName.Submitted]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'chain_id_source' | 'chain_id_destination' | 'token_security_type_destination'> & {
|
|
99
107
|
action_type: MetricsActionType;
|
|
108
|
+
batch_id?: string;
|
|
100
109
|
};
|
|
101
110
|
[UnifiedSwapBridgeEventName.Completed]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & TxStatusData & RequestParams & {
|
|
102
111
|
actual_time_minutes: number;
|
|
@@ -105,14 +114,23 @@ type RequiredEventContextFromClientBase = {
|
|
|
105
114
|
quote_vs_execution_ratio: number;
|
|
106
115
|
quoted_vs_used_gas_ratio: number;
|
|
107
116
|
action_type: MetricsActionType;
|
|
117
|
+
batch_id?: string;
|
|
108
118
|
};
|
|
109
|
-
[UnifiedSwapBridgeEventName.Failed]: // Tx failed before confirmation
|
|
110
|
-
(
|
|
111
|
-
error_message: string;
|
|
112
|
-
}) | (RequestParams & RequestMetadata & Pick<QuoteFetchData, 'price_impact'> & TxStatusData & TradeData & {
|
|
119
|
+
[UnifiedSwapBridgeEventName.Failed]: (// Tx failed before confirmation
|
|
120
|
+
(Pick<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet' | 'account_hardware_type'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'token_security_type_destination'>) | (RequestParams & RequestMetadata & TxStatusData & {
|
|
113
121
|
actual_time_minutes: number;
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
})) & TradeData & Pick<QuoteFetchData, 'price_impact'> & {
|
|
123
|
+
error_message: string;
|
|
124
|
+
batch_id?: string;
|
|
125
|
+
};
|
|
126
|
+
[UnifiedSwapBridgeEventName.PollingStatusUpdated]: {
|
|
127
|
+
polling_status: PollingStatus;
|
|
128
|
+
retry_attempts: number;
|
|
129
|
+
};
|
|
130
|
+
[UnifiedSwapBridgeEventName.StatusValidationFailed]: {
|
|
131
|
+
failures: string[];
|
|
132
|
+
refresh_count: number;
|
|
133
|
+
};
|
|
116
134
|
[UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<TradeData, 'gas_included'> & Pick<QuoteFetchData, 'price_impact'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {
|
|
117
135
|
stx_enabled: RequestMetadata['stx_enabled'];
|
|
118
136
|
can_submit: QuoteFetchData['can_submit'];
|
|
@@ -139,18 +157,9 @@ type RequiredEventContextFromClientBase = {
|
|
|
139
157
|
[UnifiedSwapBridgeEventName.QuotesValidationFailed]: {
|
|
140
158
|
failures: string[];
|
|
141
159
|
};
|
|
142
|
-
[UnifiedSwapBridgeEventName.StatusValidationFailed]: {
|
|
143
|
-
failures: string[];
|
|
144
|
-
refresh_count: number;
|
|
145
|
-
};
|
|
146
160
|
[UnifiedSwapBridgeEventName.AssetPickerOpened]: {
|
|
147
161
|
asset_location: 'source' | 'destination';
|
|
148
162
|
};
|
|
149
|
-
[UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'chain_id_source' | 'chain_id_destination'> & {
|
|
150
|
-
action_type: MetricsActionType;
|
|
151
|
-
polling_status: PollingStatus;
|
|
152
|
-
retry_attempts: number;
|
|
153
|
-
};
|
|
154
163
|
};
|
|
155
164
|
/**
|
|
156
165
|
* Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.
|
|
@@ -169,6 +178,7 @@ export type RequiredEventContextFromClient = {
|
|
|
169
178
|
key: string;
|
|
170
179
|
value: string;
|
|
171
180
|
}[];
|
|
181
|
+
feature_id: FeatureId;
|
|
172
182
|
};
|
|
173
183
|
};
|
|
174
184
|
/**
|
|
@@ -206,7 +216,9 @@ export type EventPropertiesFromControllerState = {
|
|
|
206
216
|
};
|
|
207
217
|
[UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;
|
|
208
218
|
[UnifiedSwapBridgeEventName.AssetPickerOpened]: null;
|
|
209
|
-
[UnifiedSwapBridgeEventName.PollingStatusUpdated]:
|
|
219
|
+
[UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'chain_id_source' | 'chain_id_destination'> & {
|
|
220
|
+
batch_id?: string;
|
|
221
|
+
};
|
|
210
222
|
};
|
|
211
223
|
/**
|
|
212
224
|
* trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client
|
|
@@ -216,6 +228,7 @@ export type EventPropertiesFromControllerState = {
|
|
|
216
228
|
* `ab_tests` and `active_ab_tests` intentionally coexist during migration.
|
|
217
229
|
*/
|
|
218
230
|
export type CrossChainSwapsEventProperties<T extends UnifiedSwapBridgeEventName> = {
|
|
231
|
+
feature_id: FeatureId;
|
|
219
232
|
action_type: MetricsActionType;
|
|
220
233
|
location: MetaMetricsSwapsEventSource;
|
|
221
234
|
ab_tests?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAoB;
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/utils/met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,GACd,SAAS,CAAC;IACZ,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,IAAI,CAAC;IAC7D,CAAC,0BAA0B,CAAC,sBAAsB,CAAC,EAAE,aAAa,GAAG;QACnE,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,CAAC,0BAA0B,CAAC,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACnE,CAAC,0BAA0B,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACrD,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,EAAE,SAAS,GAC1D,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GACpC,IAAI,CAAC,eAAe,EAAE,mBAAmB,CAAC,GAC1C,IAAI,CACF,aAAa,EACX,qBAAqB,GACrB,0BAA0B,GAC1B,iBAAiB,GACjB,sBAAsB,CACzB,GAAG;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,CACxC,CAAC,SAAS,0BAA0B,IAElC;IACE,UAAU,EAAE,SAAS,CAAC;IACtB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD,GACD,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CaipAssetType, CaipChainId } from "@metamask/utils";
|
|
2
|
-
import type { SortOrder, StatusTypes } from "../../types.mjs";
|
|
2
|
+
import type { FeatureId, SortOrder, StatusTypes } from "../../types.mjs";
|
|
3
3
|
import type { UnifiedSwapBridgeEventName, MetaMetricsSwapsEventSource, MetricsActionType, MetricsSwapType, PollingStatus } from "./constants.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml
|
|
@@ -11,6 +11,13 @@ export type RequestParams = {
|
|
|
11
11
|
token_symbol_destination: string | null;
|
|
12
12
|
token_address_source: CaipAssetType;
|
|
13
13
|
token_address_destination: CaipAssetType | null;
|
|
14
|
+
/**
|
|
15
|
+
* Client-supplied security classification for the destination token
|
|
16
|
+
* (e.g. from token security/scanning data). Stored on the controller
|
|
17
|
+
* and merged into every analytics event that includes
|
|
18
|
+
* `token_address_destination`. Pass `null` when no security data is
|
|
19
|
+
* available for the selected destination token.
|
|
20
|
+
*/
|
|
14
21
|
token_security_type_destination: string | null;
|
|
15
22
|
};
|
|
16
23
|
export type AccountHardwareType = 'Ledger' | 'Trezor' | 'QR Hardware' | 'Lattice' | null;
|
|
@@ -82,6 +89,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
82
89
|
[UnifiedSwapBridgeEventName.QuotesRequested]: Pick<RequestMetadata, 'stx_enabled' | 'usd_amount_source'> & {
|
|
83
90
|
token_symbol_source: RequestParams['token_symbol_source'];
|
|
84
91
|
token_symbol_destination: RequestParams['token_symbol_destination'];
|
|
92
|
+
token_security_type_destination: RequestParams['token_security_type_destination'];
|
|
85
93
|
};
|
|
86
94
|
[UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {
|
|
87
95
|
warnings: QuoteWarning[];
|
|
@@ -97,6 +105,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
97
105
|
} & Pick<RequestMetadata, 'security_warnings'>;
|
|
98
106
|
[UnifiedSwapBridgeEventName.Submitted]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'chain_id_source' | 'chain_id_destination' | 'token_security_type_destination'> & {
|
|
99
107
|
action_type: MetricsActionType;
|
|
108
|
+
batch_id?: string;
|
|
100
109
|
};
|
|
101
110
|
[UnifiedSwapBridgeEventName.Completed]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & TxStatusData & RequestParams & {
|
|
102
111
|
actual_time_minutes: number;
|
|
@@ -105,14 +114,23 @@ type RequiredEventContextFromClientBase = {
|
|
|
105
114
|
quote_vs_execution_ratio: number;
|
|
106
115
|
quoted_vs_used_gas_ratio: number;
|
|
107
116
|
action_type: MetricsActionType;
|
|
117
|
+
batch_id?: string;
|
|
108
118
|
};
|
|
109
|
-
[UnifiedSwapBridgeEventName.Failed]: // Tx failed before confirmation
|
|
110
|
-
(
|
|
111
|
-
error_message: string;
|
|
112
|
-
}) | (RequestParams & RequestMetadata & Pick<QuoteFetchData, 'price_impact'> & TxStatusData & TradeData & {
|
|
119
|
+
[UnifiedSwapBridgeEventName.Failed]: (// Tx failed before confirmation
|
|
120
|
+
(Pick<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet' | 'account_hardware_type'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'token_security_type_destination'>) | (RequestParams & RequestMetadata & TxStatusData & {
|
|
113
121
|
actual_time_minutes: number;
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
})) & TradeData & Pick<QuoteFetchData, 'price_impact'> & {
|
|
123
|
+
error_message: string;
|
|
124
|
+
batch_id?: string;
|
|
125
|
+
};
|
|
126
|
+
[UnifiedSwapBridgeEventName.PollingStatusUpdated]: {
|
|
127
|
+
polling_status: PollingStatus;
|
|
128
|
+
retry_attempts: number;
|
|
129
|
+
};
|
|
130
|
+
[UnifiedSwapBridgeEventName.StatusValidationFailed]: {
|
|
131
|
+
failures: string[];
|
|
132
|
+
refresh_count: number;
|
|
133
|
+
};
|
|
116
134
|
[UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<TradeData, 'gas_included'> & Pick<QuoteFetchData, 'price_impact'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {
|
|
117
135
|
stx_enabled: RequestMetadata['stx_enabled'];
|
|
118
136
|
can_submit: QuoteFetchData['can_submit'];
|
|
@@ -139,18 +157,9 @@ type RequiredEventContextFromClientBase = {
|
|
|
139
157
|
[UnifiedSwapBridgeEventName.QuotesValidationFailed]: {
|
|
140
158
|
failures: string[];
|
|
141
159
|
};
|
|
142
|
-
[UnifiedSwapBridgeEventName.StatusValidationFailed]: {
|
|
143
|
-
failures: string[];
|
|
144
|
-
refresh_count: number;
|
|
145
|
-
};
|
|
146
160
|
[UnifiedSwapBridgeEventName.AssetPickerOpened]: {
|
|
147
161
|
asset_location: 'source' | 'destination';
|
|
148
162
|
};
|
|
149
|
-
[UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'chain_id_source' | 'chain_id_destination'> & {
|
|
150
|
-
action_type: MetricsActionType;
|
|
151
|
-
polling_status: PollingStatus;
|
|
152
|
-
retry_attempts: number;
|
|
153
|
-
};
|
|
154
163
|
};
|
|
155
164
|
/**
|
|
156
165
|
* Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.
|
|
@@ -169,6 +178,7 @@ export type RequiredEventContextFromClient = {
|
|
|
169
178
|
key: string;
|
|
170
179
|
value: string;
|
|
171
180
|
}[];
|
|
181
|
+
feature_id: FeatureId;
|
|
172
182
|
};
|
|
173
183
|
};
|
|
174
184
|
/**
|
|
@@ -206,7 +216,9 @@ export type EventPropertiesFromControllerState = {
|
|
|
206
216
|
};
|
|
207
217
|
[UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;
|
|
208
218
|
[UnifiedSwapBridgeEventName.AssetPickerOpened]: null;
|
|
209
|
-
[UnifiedSwapBridgeEventName.PollingStatusUpdated]:
|
|
219
|
+
[UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'chain_id_source' | 'chain_id_destination'> & {
|
|
220
|
+
batch_id?: string;
|
|
221
|
+
};
|
|
210
222
|
};
|
|
211
223
|
/**
|
|
212
224
|
* trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client
|
|
@@ -216,6 +228,7 @@ export type EventPropertiesFromControllerState = {
|
|
|
216
228
|
* `ab_tests` and `active_ab_tests` intentionally coexist during migration.
|
|
217
229
|
*/
|
|
218
230
|
export type CrossChainSwapsEventProperties<T extends UnifiedSwapBridgeEventName> = {
|
|
231
|
+
feature_id: FeatureId;
|
|
219
232
|
action_type: MetricsActionType;
|
|
220
233
|
location: MetaMetricsSwapsEventSource;
|
|
221
234
|
ab_tests?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAoB;
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAoB;AACrE,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EACf,aAAa,EACd,wBAAoB;AAErB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE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,0BAA0B,CAAC,oBAAoB,CAAC,EAAE,SAAS,GAC1D,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GACpC,IAAI,CAAC,eAAe,EAAE,mBAAmB,CAAC,GAC1C,IAAI,CACF,aAAa,EACX,qBAAqB,GACrB,0BAA0B,GAC1B,iBAAiB,GACjB,sBAAsB,CACzB,GAAG;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,CACxC,CAAC,SAAS,0BAA0B,IAElC;IACE,UAAU,EAAE,SAAS,CAAC;IACtB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD,GACD,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type { SortOrder, StatusTypes } from '../../types';\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n PollingStatus,\n} from './constants';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n token_security_type_destination: string | null;\n};\n\nexport type AccountHardwareType =\n | 'Ledger'\n | 'Trezor'\n | 'QR Hardware'\n | 'Lattice'\n | null;\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n account_hardware_type: AccountHardwareType;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n token_amount_source: string;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'market_closed'\n | 'price_impact'\n | 'quote_expired'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This is the base type without the `location` property which is added to all events\n * via the RequiredEventContextFromClient mapped type.\n */\ntype RequiredEventContextFromClientBase = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n >;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n input_value: InputValues[keyof InputValues];\n input_amount_preset?: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n has_sufficient_gas_for_quote?: boolean | null;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n | 'token_security_type_destination'\n > & {\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Failed]:\n | // Tx failed before confirmation\n (TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'is_hardware_wallet'\n | 'account_hardware_type'\n > &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'token_security_type_destination'\n > & { error_message: string }) // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n Pick<QuoteFetchData, 'price_impact'> &\n TxStatusData &\n TradeData & {\n actual_time_minutes: number;\n error_message?: string;\n });\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: {\n asset_location: 'source' | 'destination';\n };\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n action_type: MetricsActionType;\n polling_status: PollingStatus;\n retry_attempts: number;\n };\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This combines the event-specific properties from RequiredEventContextFromClientBase\n * with an optional `location` property. When `location` is omitted, the controller\n * falls back to the value stored via `setLocation()` (defaults to MainView).\n *\n * `ab_tests` is the legacy field and `active_ab_tests` is the newer field.\n * Both are kept for a migration window and are treated as separate payloads.\n */\nexport type RequiredEventContextFromClient = {\n [K in keyof RequiredEventContextFromClientBase]: RequiredEventContextFromClientBase[K] & {\n location?: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams &\n Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n >;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: null;\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: null;\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n *\n * `ab_tests` will be deprecated in favor of `active_ab_tests` in the future.\n * `ab_tests` and `active_ab_tests` intentionally coexist during migration.\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n action_type: MetricsActionType;\n location: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type { FeatureId, SortOrder, StatusTypes } from '../../types';\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n PollingStatus,\n} from './constants';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n /**\n * Client-supplied security classification for the destination token\n * (e.g. from token security/scanning data). Stored on the controller\n * and merged into every analytics event that includes\n * `token_address_destination`. Pass `null` when no security data is\n * available for the selected destination token.\n */\n token_security_type_destination: string | null;\n};\n\nexport type AccountHardwareType =\n | 'Ledger'\n | 'Trezor'\n | 'QR Hardware'\n | 'Lattice'\n | null;\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n account_hardware_type: AccountHardwareType;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n token_amount_source: string;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'market_closed'\n | 'price_impact'\n | 'quote_expired'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This is the base type without the `location` property which is added to all events\n * via the RequiredEventContextFromClient mapped type.\n */\ntype RequiredEventContextFromClientBase = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n >;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n input_value: InputValues[keyof InputValues];\n input_amount_preset?: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n has_sufficient_gas_for_quote?: boolean | null;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n | 'token_security_type_destination'\n > & {\n action_type: MetricsActionType;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.Failed]: (\n | // Tx failed before confirmation\n (Pick<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'is_hardware_wallet'\n | 'account_hardware_type'\n > &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'token_security_type_destination'\n >)\n // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n TxStatusData & {\n actual_time_minutes: number;\n })\n ) &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n error_message: string;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: {\n polling_status: PollingStatus;\n retry_attempts: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n refresh_count: number;\n };\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: {\n asset_location: 'source' | 'destination';\n };\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This combines the event-specific properties from RequiredEventContextFromClientBase\n * with an optional `location` property. When `location` is omitted, the controller\n * falls back to the value stored via `setLocation()` (defaults to MainView).\n *\n * `ab_tests` is the legacy field and `active_ab_tests` is the newer field.\n * Both are kept for a migration window and are treated as separate payloads.\n */\nexport type RequiredEventContextFromClient = {\n [K in keyof RequiredEventContextFromClientBase]: RequiredEventContextFromClientBase[K] & {\n location?: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n feature_id: FeatureId;\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams &\n Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n >;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: null;\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n batch_id?: string;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n *\n * `ab_tests` will be deprecated in favor of `active_ab_tests` in the future.\n * `ab_tests` and `active_ab_tests` intentionally coexist during migration.\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n feature_id: FeatureId;\n action_type: MetricsActionType;\n location: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|
package/dist/utils/quote.cjs
CHANGED
|
@@ -4,8 +4,8 @@ exports.sortQuotes = exports.formatEtaInMinutes = exports.calcSlippagePercentage
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
5
5
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
6
6
|
const bignumber_js_1 = require("bignumber.js");
|
|
7
|
+
const types_1 = require("../types.cjs");
|
|
7
8
|
const bridge_1 = require("./bridge.cjs");
|
|
8
|
-
const validators_1 = require("./validators.cjs");
|
|
9
9
|
const isValidQuoteRequest = (partialRequest, requireAmount = true) => {
|
|
10
10
|
const stringFields = [
|
|
11
11
|
'srcTokenAddress',
|
|
@@ -357,7 +357,7 @@ const formatEtaInMinutes = (estimatedProcessingTimeInSeconds) => {
|
|
|
357
357
|
exports.formatEtaInMinutes = formatEtaInMinutes;
|
|
358
358
|
const sortQuotes = (quotes, featureId) => {
|
|
359
359
|
// Sort perps quotes by increasing estimated processing time (fastest first)
|
|
360
|
-
if (featureId ===
|
|
360
|
+
if (featureId === types_1.FeatureId.PERPS) {
|
|
361
361
|
return quotes.sort((a, b) => {
|
|
362
362
|
return (a.estimatedProcessingTimeInSeconds - b.estimatedProcessingTimeInSeconds);
|
|
363
363
|
});
|
package/dist/utils/quote.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.cjs","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,iEAIoC;AACpC,+CAAyC;AAazC,yCAA4D;AAC5D,iDAAyC;AAElC,MAAM,mBAAmB,GAAG,CACjC,cAA4C,EAC5C,aAAa,GAAG,IAAI,EACmB,EAAE;IACzC,MAAM,YAAY,GAAG;QACnB,iBAAiB;QACjB,kBAAkB;QAClB,YAAY;QACZ,aAAa;QACb,eAAe;KAChB,CAAC;IACF,IAAI,aAAa,EAAE,CAAC;QAClB,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IACD,qGAAqG;IACrG,qCAAqC;IACrC,oBAAoB;IACpB,oBAAoB;IACpB,qDAAqD;IACrD,qDAAqD;IACrD,IACE,cAAc,CAAC,WAAW;QAC1B,cAAc,CAAC,UAAU;QACzB,cAAc,CAAC,WAAW,KAAK,cAAc,CAAC,UAAU,IAAI,mBAAmB;QAC/E,CAAC,IAAA,wBAAe,EAAC,cAAc,CAAC,WAAW,CAAC;YAC1C,IAAA,wBAAe,EAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,0BAA0B;MACxE,CAAC;QACD,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvC,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;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vC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC;aAC/B,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,EAAE;aACL,QAAQ,EAAE,CAAC;IAChB,CAAC;IAED,IAAI,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,CAAC;QAC/B,OAAO,IAAI,wBAAS,CAAC,IAAI,CAAC,GAAG,CAAC;aAC3B,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;aACnB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,EAAE;aACL,QAAQ,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAvBW,QAAA,sBAAsB,0BAuBjC;AAEK,MAAM,kBAAkB,GAAG,CAChC,gCAAwC,EACxC,EAAE;IACF,IAAI,gCAAgC,GAAG,EAAE,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,gCAAgC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAC3D,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B;AAEK,MAAM,UAAU,GAAG,CACxB,MAAuB,EACvB,SAA2B,EAC3B,EAAE;IACF,4EAA4E;IAC5E,IAAI,SAAS,KAAK,sBAAS,CAAC,KAAK,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,OAAO,CACL,CAAC,CAAC,gCAAgC,GAAG,CAAC,CAAC,gCAAgC,CACxE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAbW,QAAA,UAAU,cAarB","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n convertHexToDecimal,\n toHex,\n weiHexToGweiDec,\n} from '@metamask/controller-utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type {\n BridgeAsset,\n ExchangeRate,\n GenericQuoteRequest,\n L1GasFees,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n NonEvmFees,\n TxData,\n} from '../types';\nimport { isNativeAddress, isNonEvmChainId } from './bridge';\nimport { FeatureId } from './validators';\n\nexport const isValidQuoteRequest = (\n partialRequest: Partial<GenericQuoteRequest>,\n requireAmount = true,\n): partialRequest is GenericQuoteRequest => {\n const stringFields = [\n 'srcTokenAddress',\n 'destTokenAddress',\n 'srcChainId',\n 'destChainId',\n 'walletAddress',\n ];\n if (requireAmount) {\n stringFields.push('srcTokenAmount');\n }\n // If bridging between different chain types or different non-EVM chains, require dest wallet address\n // Cases that need destWalletAddress:\n // 1. EVM -> non-EVM\n // 2. non-EVM -> EVM\n // 3. non-EVM -> different non-EVM (e.g., SOL -> BTC)\n // Only same-chain swaps don't need destWalletAddress\n if (\n partialRequest.destChainId &&\n partialRequest.srcChainId &&\n partialRequest.destChainId !== partialRequest.srcChainId && // Different chains\n (isNonEvmChainId(partialRequest.destChainId) ||\n isNonEvmChainId(partialRequest.srcChainId)) // At least one is non-EVM\n ) {\n stringFields.push('destWalletAddress');\n if (!partialRequest.destWalletAddress) {\n return false;\n }\n }\n const numberFields = [];\n // if slippage is defined, require it to be a number\n if (partialRequest.slippage !== undefined) {\n numberFields.push('slippage');\n }\n\n return (\n stringFields.every(\n (field) =>\n field in partialRequest &&\n typeof partialRequest[field as keyof typeof partialRequest] ===\n 'string' &&\n partialRequest[field as keyof typeof partialRequest] !== undefined &&\n partialRequest[field as keyof typeof partialRequest] !== '' &&\n partialRequest[field as keyof typeof partialRequest] !== null,\n ) &&\n numberFields.every(\n (field) =>\n field in partialRequest &&\n typeof partialRequest[field as keyof typeof partialRequest] ===\n 'number' &&\n partialRequest[field as keyof typeof partialRequest] !== undefined &&\n !isNaN(Number(partialRequest[field as keyof typeof partialRequest])) &&\n partialRequest[field as keyof typeof partialRequest] !== null,\n ) &&\n (requireAmount\n ? Boolean((partialRequest.srcTokenAmount ?? '').match(/^[1-9]\\d*$/u))\n : true)\n );\n};\n\nexport const isValidBatchSellQuoteRequest = (\n quoteRequests: Partial<GenericQuoteRequest>[],\n requireAmount = true,\n): quoteRequests is GenericQuoteRequest[] =>\n quoteRequests.every((req) => isValidQuoteRequest(req, requireAmount));\n\n/**\n * Generates a pseudo-unique string that identifies each quote by aggregator, bridge, and steps\n *\n * @param quote - The quote to generate an identifier for\n * @returns A pseudo-unique string that identifies the quote\n */\nexport const getQuoteIdentifier = (quote: QuoteResponse['quote']) =>\n `${quote.bridgeId}-${quote.bridges[0]}-${quote.steps.length}`;\n\nconst calcTokenAmount = (value: string | BigNumber, decimals: number) => {\n const divisor = new BigNumber(10).pow(decimals ?? 0);\n return new BigNumber(value).div(divisor);\n};\n\nexport const calcNonEvmTotalNetworkFee = (\n bridgeQuote: QuoteResponse & NonEvmFees,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const { nonEvmFeesInNative } = bridgeQuote;\n // Fees are now stored directly in native units (SOL, BTC) without conversion\n const feeInNative = new BigNumber(nonEvmFeesInNative ?? '0');\n\n return {\n amount: feeInNative.toString(),\n valueInCurrency: exchangeRate\n ? feeInNative.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate ? feeInNative.times(usdExchangeRate).toString() : null,\n };\n};\n\nexport const calcToAmount = (\n destTokenAmount: string,\n destAsset: BridgeAsset,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const normalizedDestAmount = calcTokenAmount(\n destTokenAmount,\n destAsset.decimals,\n );\n return {\n amount: normalizedDestAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedDestAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedDestAmount.times(usdExchangeRate).toString()\n : null,\n };\n};\n\nexport const calcSentAmount = (\n { srcTokenAmount, srcAsset, feeData, intent }: Quote,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n // For intent-based swaps (e.g. CoW Protocol), srcTokenAmount is the total\n // fixed commitment the user makes to the protocol — the protocol fee is\n // already baked in. Adding feeData fees on top would double-count them.\n // For conventional swaps, srcTokenAmount is the net routing amount (fees\n // excluded), so the src-token fees must be added to get the wallet deduction.\n const sentAmount = intent\n ? new BigNumber(srcTokenAmount)\n : Object.values(feeData)\n .filter(\n (fee) => fee && fee.amount && fee.asset?.assetId === srcAsset.assetId,\n )\n .reduce(\n (acc, { amount }) => acc.plus(amount),\n new BigNumber(srcTokenAmount),\n );\n const normalizedSentAmount = calcTokenAmount(sentAmount, srcAsset.decimals);\n return {\n amount: normalizedSentAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedSentAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedSentAmount.times(usdExchangeRate).toString()\n : null,\n };\n};\n\nexport const calcBatchFees = (\n amount: string,\n asset: BridgeAsset,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const normalizedAmount = calcTokenAmount(amount, asset.decimals);\n\n return {\n amount: normalizedAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedAmount.times(usdExchangeRate).toString()\n : null,\n asset,\n };\n};\n\nexport const calcRelayerFee = (\n quoteResponse: QuoteResponse<TxData, TxData>,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const { quote, trade } = quoteResponse;\n const relayerFeeAmount = new BigNumber(\n convertHexToDecimal(trade.value || '0x0'),\n );\n let relayerFeeInNative = calcTokenAmount(relayerFeeAmount, 18);\n\n // Subtract srcAmount and other fees from trade value if srcAsset is native\n if (isNativeAddress(quote.srcAsset.address)) {\n const sentAmountInNative = calcSentAmount(quote, {\n exchangeRate,\n usdExchangeRate,\n }).amount;\n relayerFeeInNative = relayerFeeInNative.minus(sentAmountInNative);\n }\n\n return {\n amount: relayerFeeInNative,\n valueInCurrency: exchangeRate\n ? relayerFeeInNative.times(exchangeRate)\n : null,\n usd: usdExchangeRate ? relayerFeeInNative.times(usdExchangeRate) : null,\n };\n};\n\nconst calcTotalGasFee = ({\n approvalGasLimit,\n resetApprovalGasLimit,\n tradeGasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n}: {\n approvalGasLimit?: number | null;\n resetApprovalGasLimit?: number | null;\n tradeGasLimit?: number | null;\n l1GasFeesInHexWei?: string | null;\n feePerGasInDecGwei?: string;\n nativeToDisplayCurrencyExchangeRate?: string;\n nativeToUsdExchangeRate?: string;\n}) => {\n const totalGasLimitInDec = new BigNumber(tradeGasLimit?.toString() ?? '0')\n .plus(approvalGasLimit?.toString() ?? '0')\n .plus(resetApprovalGasLimit?.toString() ?? '0');\n\n const l1GasFeesInDecGWei = weiHexToGweiDec(toHex(l1GasFeesInHexWei ?? '0'));\n const gasFeesInDecGwei = totalGasLimitInDec\n .times(feePerGasInDecGwei ?? '0')\n .plus(l1GasFeesInDecGWei);\n const gasFeesInDecEth = gasFeesInDecGwei.times(new BigNumber(10).pow(-9));\n\n const gasFeesInDisplayCurrency = nativeToDisplayCurrencyExchangeRate\n ? gasFeesInDecEth.times(nativeToDisplayCurrencyExchangeRate.toString())\n : null;\n const gasFeesInUSD = nativeToUsdExchangeRate\n ? gasFeesInDecEth.times(nativeToUsdExchangeRate.toString())\n : null;\n\n return {\n amount: gasFeesInDecEth.toString(),\n valueInCurrency: gasFeesInDisplayCurrency?.toString() ?? null,\n usd: gasFeesInUSD?.toString() ?? null,\n };\n};\n\nexport const calcEstimatedAndMaxTotalGasFee = ({\n bridgeQuote: { approval, trade, l1GasFeesInHexWei, resetApproval },\n feePerGasInDecGwei,\n maxFeePerGasInDecGwei,\n exchangeRate: nativeToDisplayCurrencyExchangeRate,\n usdExchangeRate: nativeToUsdExchangeRate,\n}: {\n bridgeQuote: QuoteResponse<TxData, TxData> & L1GasFees;\n maxFeePerGasInDecGwei?: string;\n feePerGasInDecGwei?: string;\n} & ExchangeRate): QuoteMetadata['gasFee'] => {\n // Estimated gas fees spent after receiving refunds, this is shown to the user\n const {\n amount: amountEffective,\n valueInCurrency: valueInCurrencyEffective,\n usd: usdEffective,\n } = calcTotalGasFee({\n // Fallback to gasLimit if effectiveGas is not available\n approvalGasLimit: approval?.effectiveGas ?? approval?.gasLimit,\n resetApprovalGasLimit:\n resetApproval?.effectiveGas ?? resetApproval?.gasLimit,\n tradeGasLimit: trade?.effectiveGas ?? trade?.gasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n });\n\n // Estimated total gas fee, including refunded fees (medium)\n const { amount, valueInCurrency, usd } = calcTotalGasFee({\n approvalGasLimit: approval?.gasLimit,\n resetApprovalGasLimit: resetApproval?.gasLimit,\n tradeGasLimit: trade?.gasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n });\n\n // Max gas fee (high), used to disable submission of the transaction\n const {\n amount: amountMax,\n valueInCurrency: valueInCurrencyMax,\n usd: usdMax,\n } = calcTotalGasFee({\n approvalGasLimit: approval?.gasLimit,\n resetApprovalGasLimit: resetApproval?.gasLimit,\n tradeGasLimit: trade?.gasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei: maxFeePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n });\n\n return {\n effective: {\n amount: amountEffective,\n valueInCurrency: valueInCurrencyEffective,\n usd: usdEffective,\n },\n total: {\n amount,\n valueInCurrency,\n usd,\n },\n max: {\n amount: amountMax,\n valueInCurrency: valueInCurrencyMax,\n usd: usdMax,\n },\n };\n};\n\n/**\n * Calculates the total estimated network fees for the bridge transaction\n *\n * @param gasFee - The gas fee for the bridge transaction\n * @param gasFee.total - The fee to display to the user. If not available, this is equal to the gasLimit (total)\n * @param relayerFee - The relayer fee paid to bridge providers\n * @returns The total estimated network fee for the bridge transaction, including the relayer fee paid to bridge providers\n */\nexport const calcTotalEstimatedNetworkFee = (\n { total: gasFeeToDisplay }: ReturnType<typeof calcEstimatedAndMaxTotalGasFee>,\n relayerFee: ReturnType<typeof calcRelayerFee>,\n) => {\n return {\n amount: new BigNumber(gasFeeToDisplay?.amount ?? '0')\n .plus(relayerFee.amount)\n .toString(),\n valueInCurrency: gasFeeToDisplay?.valueInCurrency\n ? new BigNumber(gasFeeToDisplay.valueInCurrency)\n .plus(relayerFee.valueInCurrency ?? '0')\n .toString()\n : null,\n usd: gasFeeToDisplay?.usd\n ? new BigNumber(gasFeeToDisplay.usd)\n .plus(relayerFee.usd ?? '0')\n .toString()\n : null,\n };\n};\n\nexport const calcTotalMaxNetworkFee = (\n gasFee: ReturnType<typeof calcEstimatedAndMaxTotalGasFee>,\n relayerFee: ReturnType<typeof calcRelayerFee>,\n) => {\n return {\n amount: new BigNumber(gasFee.max.amount).plus(relayerFee.amount).toString(),\n valueInCurrency: gasFee.max.valueInCurrency\n ? new BigNumber(gasFee.max.valueInCurrency)\n .plus(relayerFee.valueInCurrency ?? '0')\n .toString()\n : null,\n usd: gasFee.max.usd\n ? new BigNumber(gasFee.max.usd).plus(relayerFee.usd ?? '0').toString()\n : null,\n };\n};\n\n// Gas is included for some swap quotes and this is the value displayed in the client\nexport const calcIncludedTxFees = (\n { gasIncluded, gasIncluded7702, srcAsset, feeData: { txFee } }: Quote,\n srcTokenExchangeRate: ExchangeRate,\n destTokenExchangeRate: ExchangeRate,\n) => {\n if (!txFee || !(gasIncluded || gasIncluded7702)) {\n return null;\n }\n // Use exchange rate of the token that is being used to pay for the transaction\n const { exchangeRate, usdExchangeRate } =\n txFee.asset.assetId === srcAsset.assetId\n ? srcTokenExchangeRate\n : destTokenExchangeRate;\n const normalizedTxFeeAmount = calcTokenAmount(\n txFee.amount,\n txFee.asset.decimals,\n );\n\n return {\n amount: normalizedTxFeeAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedTxFeeAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedTxFeeAmount.times(usdExchangeRate).toString()\n : null,\n };\n};\n\nexport const calcAdjustedReturn = (\n toTokenAmount: ReturnType<typeof calcToAmount>,\n totalEstimatedNetworkFee: ReturnType<typeof calcTotalEstimatedNetworkFee>,\n { feeData: { txFee }, destAsset: { assetId: destAssetId } }: Quote,\n) => {\n // If gas is included and is taken from the dest token, don't subtract network fee from return\n if (txFee?.asset?.assetId === destAssetId) {\n return {\n valueInCurrency: toTokenAmount.valueInCurrency,\n usd: toTokenAmount.usd,\n };\n }\n return {\n valueInCurrency:\n toTokenAmount.valueInCurrency && totalEstimatedNetworkFee.valueInCurrency\n ? new BigNumber(toTokenAmount.valueInCurrency)\n .minus(totalEstimatedNetworkFee.valueInCurrency)\n .toString()\n : null,\n usd:\n toTokenAmount.usd && totalEstimatedNetworkFee.usd\n ? new BigNumber(toTokenAmount.usd)\n .minus(totalEstimatedNetworkFee.usd)\n .toString()\n : null,\n };\n};\n\nexport const calcSwapRate = (sentAmount: string, destTokenAmount: string) =>\n new BigNumber(destTokenAmount).div(sentAmount).toString();\n\nexport const calcCost = (\n adjustedReturn: ReturnType<typeof calcAdjustedReturn>,\n sentAmount: ReturnType<typeof calcSentAmount>,\n) => ({\n valueInCurrency:\n adjustedReturn.valueInCurrency && sentAmount.valueInCurrency\n ? new BigNumber(sentAmount.valueInCurrency)\n .minus(adjustedReturn.valueInCurrency)\n .toString()\n : null,\n usd:\n adjustedReturn.usd && sentAmount.usd\n ? new BigNumber(sentAmount.usd).minus(adjustedReturn.usd).toString()\n : null,\n});\n\n/**\n * Calculates the slippage absolute value percentage based on the adjusted return and sent amount.\n *\n * @param adjustedReturn - Adjusted return value\n * @param sentAmount - Sent amount value\n * @returns the slippage in percentage\n */\nexport const calcSlippagePercentage = (\n adjustedReturn: ReturnType<typeof calcAdjustedReturn>,\n sentAmount: ReturnType<typeof calcSentAmount>,\n): string | null => {\n const cost = calcCost(adjustedReturn, sentAmount);\n\n if (cost.valueInCurrency && sentAmount.valueInCurrency) {\n return new BigNumber(cost.valueInCurrency)\n .div(sentAmount.valueInCurrency)\n .times(100)\n .abs()\n .toString();\n }\n\n if (cost.usd && sentAmount.usd) {\n return new BigNumber(cost.usd)\n .div(sentAmount.usd)\n .times(100)\n .abs()\n .toString();\n }\n\n return null;\n};\n\nexport const formatEtaInMinutes = (\n estimatedProcessingTimeInSeconds: number,\n) => {\n if (estimatedProcessingTimeInSeconds < 60) {\n return `< 1`;\n }\n return (estimatedProcessingTimeInSeconds / 60).toFixed();\n};\n\nexport const sortQuotes = (\n quotes: QuoteResponse[],\n featureId: FeatureId | null,\n) => {\n // Sort perps quotes by increasing estimated processing time (fastest first)\n if (featureId === FeatureId.PERPS) {\n return quotes.sort((a, b) => {\n return (\n a.estimatedProcessingTimeInSeconds - b.estimatedProcessingTimeInSeconds\n );\n });\n }\n return quotes;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"quote.cjs","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,iEAIoC;AACpC,+CAAyC;AAazC,wCAAqC;AACrC,yCAA4D;AAErD,MAAM,mBAAmB,GAAG,CACjC,cAA4C,EAC5C,aAAa,GAAG,IAAI,EACmB,EAAE;IACzC,MAAM,YAAY,GAAG;QACnB,iBAAiB;QACjB,kBAAkB;QAClB,YAAY;QACZ,aAAa;QACb,eAAe;KAChB,CAAC;IACF,IAAI,aAAa,EAAE,CAAC;QAClB,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IACD,qGAAqG;IACrG,qCAAqC;IACrC,oBAAoB;IACpB,oBAAoB;IACpB,qDAAqD;IACrD,qDAAqD;IACrD,IACE,cAAc,CAAC,WAAW;QAC1B,cAAc,CAAC,UAAU;QACzB,cAAc,CAAC,WAAW,KAAK,cAAc,CAAC,UAAU,IAAI,mBAAmB;QAC/E,CAAC,IAAA,wBAAe,EAAC,cAAc,C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AAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAbW,QAAA,UAAU,cAarB","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n convertHexToDecimal,\n toHex,\n weiHexToGweiDec,\n} from '@metamask/controller-utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type {\n BridgeAsset,\n ExchangeRate,\n GenericQuoteRequest,\n L1GasFees,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n NonEvmFees,\n TxData,\n} from '../types';\nimport { FeatureId } from '../types';\nimport { isNativeAddress, isNonEvmChainId } from './bridge';\n\nexport const isValidQuoteRequest = (\n partialRequest: Partial<GenericQuoteRequest>,\n requireAmount = true,\n): partialRequest is GenericQuoteRequest => {\n const stringFields = [\n 'srcTokenAddress',\n 'destTokenAddress',\n 'srcChainId',\n 'destChainId',\n 'walletAddress',\n ];\n if (requireAmount) {\n stringFields.push('srcTokenAmount');\n }\n // If bridging between different chain types or different non-EVM chains, require dest wallet address\n // Cases that need destWalletAddress:\n // 1. EVM -> non-EVM\n // 2. non-EVM -> EVM\n // 3. non-EVM -> different non-EVM (e.g., SOL -> BTC)\n // Only same-chain swaps don't need destWalletAddress\n if (\n partialRequest.destChainId &&\n partialRequest.srcChainId &&\n partialRequest.destChainId !== partialRequest.srcChainId && // Different chains\n (isNonEvmChainId(partialRequest.destChainId) ||\n isNonEvmChainId(partialRequest.srcChainId)) // At least one is non-EVM\n ) {\n stringFields.push('destWalletAddress');\n if (!partialRequest.destWalletAddress) {\n return false;\n }\n }\n const numberFields = [];\n // if slippage is defined, require it to be a number\n if (partialRequest.slippage !== undefined) {\n numberFields.push('slippage');\n }\n\n return (\n stringFields.every(\n (field) =>\n field in partialRequest &&\n typeof partialRequest[field as keyof typeof partialRequest] ===\n 'string' &&\n partialRequest[field as keyof typeof partialRequest] !== undefined &&\n partialRequest[field as keyof typeof partialRequest] !== '' &&\n partialRequest[field as keyof typeof partialRequest] !== null,\n ) &&\n numberFields.every(\n (field) =>\n field in partialRequest &&\n typeof partialRequest[field as keyof typeof partialRequest] ===\n 'number' &&\n partialRequest[field as keyof typeof partialRequest] !== undefined &&\n !isNaN(Number(partialRequest[field as keyof typeof partialRequest])) &&\n partialRequest[field as keyof typeof partialRequest] !== null,\n ) &&\n (requireAmount\n ? Boolean((partialRequest.srcTokenAmount ?? '').match(/^[1-9]\\d*$/u))\n : true)\n );\n};\n\nexport const isValidBatchSellQuoteRequest = (\n quoteRequests: Partial<GenericQuoteRequest>[],\n requireAmount = true,\n): quoteRequests is GenericQuoteRequest[] =>\n quoteRequests.every((req) => isValidQuoteRequest(req, requireAmount));\n\n/**\n * Generates a pseudo-unique string that identifies each quote by aggregator, bridge, and steps\n *\n * @param quote - The quote to generate an identifier for\n * @returns A pseudo-unique string that identifies the quote\n */\nexport const getQuoteIdentifier = (quote: QuoteResponse['quote']) =>\n `${quote.bridgeId}-${quote.bridges[0]}-${quote.steps.length}`;\n\nconst calcTokenAmount = (value: string | BigNumber, decimals: number) => {\n const divisor = new BigNumber(10).pow(decimals ?? 0);\n return new BigNumber(value).div(divisor);\n};\n\nexport const calcNonEvmTotalNetworkFee = (\n bridgeQuote: QuoteResponse & NonEvmFees,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const { nonEvmFeesInNative } = bridgeQuote;\n // Fees are now stored directly in native units (SOL, BTC) without conversion\n const feeInNative = new BigNumber(nonEvmFeesInNative ?? '0');\n\n return {\n amount: feeInNative.toString(),\n valueInCurrency: exchangeRate\n ? feeInNative.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate ? feeInNative.times(usdExchangeRate).toString() : null,\n };\n};\n\nexport const calcToAmount = (\n destTokenAmount: string,\n destAsset: BridgeAsset,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const normalizedDestAmount = calcTokenAmount(\n destTokenAmount,\n destAsset.decimals,\n );\n return {\n amount: normalizedDestAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedDestAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedDestAmount.times(usdExchangeRate).toString()\n : null,\n };\n};\n\nexport const calcSentAmount = (\n { srcTokenAmount, srcAsset, feeData, intent }: Quote,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n // For intent-based swaps (e.g. CoW Protocol), srcTokenAmount is the total\n // fixed commitment the user makes to the protocol — the protocol fee is\n // already baked in. Adding feeData fees on top would double-count them.\n // For conventional swaps, srcTokenAmount is the net routing amount (fees\n // excluded), so the src-token fees must be added to get the wallet deduction.\n const sentAmount = intent\n ? new BigNumber(srcTokenAmount)\n : Object.values(feeData)\n .filter(\n (fee) => fee && fee.amount && fee.asset?.assetId === srcAsset.assetId,\n )\n .reduce(\n (acc, { amount }) => acc.plus(amount),\n new BigNumber(srcTokenAmount),\n );\n const normalizedSentAmount = calcTokenAmount(sentAmount, srcAsset.decimals);\n return {\n amount: normalizedSentAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedSentAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedSentAmount.times(usdExchangeRate).toString()\n : null,\n };\n};\n\nexport const calcBatchFees = (\n amount: string,\n asset: BridgeAsset,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const normalizedAmount = calcTokenAmount(amount, asset.decimals);\n\n return {\n amount: normalizedAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedAmount.times(usdExchangeRate).toString()\n : null,\n asset,\n };\n};\n\nexport const calcRelayerFee = (\n quoteResponse: QuoteResponse<TxData, TxData>,\n { exchangeRate, usdExchangeRate }: ExchangeRate,\n) => {\n const { quote, trade } = quoteResponse;\n const relayerFeeAmount = new BigNumber(\n convertHexToDecimal(trade.value || '0x0'),\n );\n let relayerFeeInNative = calcTokenAmount(relayerFeeAmount, 18);\n\n // Subtract srcAmount and other fees from trade value if srcAsset is native\n if (isNativeAddress(quote.srcAsset.address)) {\n const sentAmountInNative = calcSentAmount(quote, {\n exchangeRate,\n usdExchangeRate,\n }).amount;\n relayerFeeInNative = relayerFeeInNative.minus(sentAmountInNative);\n }\n\n return {\n amount: relayerFeeInNative,\n valueInCurrency: exchangeRate\n ? relayerFeeInNative.times(exchangeRate)\n : null,\n usd: usdExchangeRate ? relayerFeeInNative.times(usdExchangeRate) : null,\n };\n};\n\nconst calcTotalGasFee = ({\n approvalGasLimit,\n resetApprovalGasLimit,\n tradeGasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n}: {\n approvalGasLimit?: number | null;\n resetApprovalGasLimit?: number | null;\n tradeGasLimit?: number | null;\n l1GasFeesInHexWei?: string | null;\n feePerGasInDecGwei?: string;\n nativeToDisplayCurrencyExchangeRate?: string;\n nativeToUsdExchangeRate?: string;\n}) => {\n const totalGasLimitInDec = new BigNumber(tradeGasLimit?.toString() ?? '0')\n .plus(approvalGasLimit?.toString() ?? '0')\n .plus(resetApprovalGasLimit?.toString() ?? '0');\n\n const l1GasFeesInDecGWei = weiHexToGweiDec(toHex(l1GasFeesInHexWei ?? '0'));\n const gasFeesInDecGwei = totalGasLimitInDec\n .times(feePerGasInDecGwei ?? '0')\n .plus(l1GasFeesInDecGWei);\n const gasFeesInDecEth = gasFeesInDecGwei.times(new BigNumber(10).pow(-9));\n\n const gasFeesInDisplayCurrency = nativeToDisplayCurrencyExchangeRate\n ? gasFeesInDecEth.times(nativeToDisplayCurrencyExchangeRate.toString())\n : null;\n const gasFeesInUSD = nativeToUsdExchangeRate\n ? gasFeesInDecEth.times(nativeToUsdExchangeRate.toString())\n : null;\n\n return {\n amount: gasFeesInDecEth.toString(),\n valueInCurrency: gasFeesInDisplayCurrency?.toString() ?? null,\n usd: gasFeesInUSD?.toString() ?? null,\n };\n};\n\nexport const calcEstimatedAndMaxTotalGasFee = ({\n bridgeQuote: { approval, trade, l1GasFeesInHexWei, resetApproval },\n feePerGasInDecGwei,\n maxFeePerGasInDecGwei,\n exchangeRate: nativeToDisplayCurrencyExchangeRate,\n usdExchangeRate: nativeToUsdExchangeRate,\n}: {\n bridgeQuote: QuoteResponse<TxData, TxData> & L1GasFees;\n maxFeePerGasInDecGwei?: string;\n feePerGasInDecGwei?: string;\n} & ExchangeRate): QuoteMetadata['gasFee'] => {\n // Estimated gas fees spent after receiving refunds, this is shown to the user\n const {\n amount: amountEffective,\n valueInCurrency: valueInCurrencyEffective,\n usd: usdEffective,\n } = calcTotalGasFee({\n // Fallback to gasLimit if effectiveGas is not available\n approvalGasLimit: approval?.effectiveGas ?? approval?.gasLimit,\n resetApprovalGasLimit:\n resetApproval?.effectiveGas ?? resetApproval?.gasLimit,\n tradeGasLimit: trade?.effectiveGas ?? trade?.gasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n });\n\n // Estimated total gas fee, including refunded fees (medium)\n const { amount, valueInCurrency, usd } = calcTotalGasFee({\n approvalGasLimit: approval?.gasLimit,\n resetApprovalGasLimit: resetApproval?.gasLimit,\n tradeGasLimit: trade?.gasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n });\n\n // Max gas fee (high), used to disable submission of the transaction\n const {\n amount: amountMax,\n valueInCurrency: valueInCurrencyMax,\n usd: usdMax,\n } = calcTotalGasFee({\n approvalGasLimit: approval?.gasLimit,\n resetApprovalGasLimit: resetApproval?.gasLimit,\n tradeGasLimit: trade?.gasLimit,\n l1GasFeesInHexWei,\n feePerGasInDecGwei: maxFeePerGasInDecGwei,\n nativeToDisplayCurrencyExchangeRate,\n nativeToUsdExchangeRate,\n });\n\n return {\n effective: {\n amount: amountEffective,\n valueInCurrency: valueInCurrencyEffective,\n usd: usdEffective,\n },\n total: {\n amount,\n valueInCurrency,\n usd,\n },\n max: {\n amount: amountMax,\n valueInCurrency: valueInCurrencyMax,\n usd: usdMax,\n },\n };\n};\n\n/**\n * Calculates the total estimated network fees for the bridge transaction\n *\n * @param gasFee - The gas fee for the bridge transaction\n * @param gasFee.total - The fee to display to the user. If not available, this is equal to the gasLimit (total)\n * @param relayerFee - The relayer fee paid to bridge providers\n * @returns The total estimated network fee for the bridge transaction, including the relayer fee paid to bridge providers\n */\nexport const calcTotalEstimatedNetworkFee = (\n { total: gasFeeToDisplay }: ReturnType<typeof calcEstimatedAndMaxTotalGasFee>,\n relayerFee: ReturnType<typeof calcRelayerFee>,\n) => {\n return {\n amount: new BigNumber(gasFeeToDisplay?.amount ?? '0')\n .plus(relayerFee.amount)\n .toString(),\n valueInCurrency: gasFeeToDisplay?.valueInCurrency\n ? new BigNumber(gasFeeToDisplay.valueInCurrency)\n .plus(relayerFee.valueInCurrency ?? '0')\n .toString()\n : null,\n usd: gasFeeToDisplay?.usd\n ? new BigNumber(gasFeeToDisplay.usd)\n .plus(relayerFee.usd ?? '0')\n .toString()\n : null,\n };\n};\n\nexport const calcTotalMaxNetworkFee = (\n gasFee: ReturnType<typeof calcEstimatedAndMaxTotalGasFee>,\n relayerFee: ReturnType<typeof calcRelayerFee>,\n) => {\n return {\n amount: new BigNumber(gasFee.max.amount).plus(relayerFee.amount).toString(),\n valueInCurrency: gasFee.max.valueInCurrency\n ? new BigNumber(gasFee.max.valueInCurrency)\n .plus(relayerFee.valueInCurrency ?? '0')\n .toString()\n : null,\n usd: gasFee.max.usd\n ? new BigNumber(gasFee.max.usd).plus(relayerFee.usd ?? '0').toString()\n : null,\n };\n};\n\n// Gas is included for some swap quotes and this is the value displayed in the client\nexport const calcIncludedTxFees = (\n { gasIncluded, gasIncluded7702, srcAsset, feeData: { txFee } }: Quote,\n srcTokenExchangeRate: ExchangeRate,\n destTokenExchangeRate: ExchangeRate,\n) => {\n if (!txFee || !(gasIncluded || gasIncluded7702)) {\n return null;\n }\n // Use exchange rate of the token that is being used to pay for the transaction\n const { exchangeRate, usdExchangeRate } =\n txFee.asset.assetId === srcAsset.assetId\n ? srcTokenExchangeRate\n : destTokenExchangeRate;\n const normalizedTxFeeAmount = calcTokenAmount(\n txFee.amount,\n txFee.asset.decimals,\n );\n\n return {\n amount: normalizedTxFeeAmount.toString(),\n valueInCurrency: exchangeRate\n ? normalizedTxFeeAmount.times(exchangeRate).toString()\n : null,\n usd: usdExchangeRate\n ? normalizedTxFeeAmount.times(usdExchangeRate).toString()\n : null,\n };\n};\n\nexport const calcAdjustedReturn = (\n toTokenAmount: ReturnType<typeof calcToAmount>,\n totalEstimatedNetworkFee: ReturnType<typeof calcTotalEstimatedNetworkFee>,\n { feeData: { txFee }, destAsset: { assetId: destAssetId } }: Quote,\n) => {\n // If gas is included and is taken from the dest token, don't subtract network fee from return\n if (txFee?.asset?.assetId === destAssetId) {\n return {\n valueInCurrency: toTokenAmount.valueInCurrency,\n usd: toTokenAmount.usd,\n };\n }\n return {\n valueInCurrency:\n toTokenAmount.valueInCurrency && totalEstimatedNetworkFee.valueInCurrency\n ? new BigNumber(toTokenAmount.valueInCurrency)\n .minus(totalEstimatedNetworkFee.valueInCurrency)\n .toString()\n : null,\n usd:\n toTokenAmount.usd && totalEstimatedNetworkFee.usd\n ? new BigNumber(toTokenAmount.usd)\n .minus(totalEstimatedNetworkFee.usd)\n .toString()\n : null,\n };\n};\n\nexport const calcSwapRate = (sentAmount: string, destTokenAmount: string) =>\n new BigNumber(destTokenAmount).div(sentAmount).toString();\n\nexport const calcCost = (\n adjustedReturn: ReturnType<typeof calcAdjustedReturn>,\n sentAmount: ReturnType<typeof calcSentAmount>,\n) => ({\n valueInCurrency:\n adjustedReturn.valueInCurrency && sentAmount.valueInCurrency\n ? new BigNumber(sentAmount.valueInCurrency)\n .minus(adjustedReturn.valueInCurrency)\n .toString()\n : null,\n usd:\n adjustedReturn.usd && sentAmount.usd\n ? new BigNumber(sentAmount.usd).minus(adjustedReturn.usd).toString()\n : null,\n});\n\n/**\n * Calculates the slippage absolute value percentage based on the adjusted return and sent amount.\n *\n * @param adjustedReturn - Adjusted return value\n * @param sentAmount - Sent amount value\n * @returns the slippage in percentage\n */\nexport const calcSlippagePercentage = (\n adjustedReturn: ReturnType<typeof calcAdjustedReturn>,\n sentAmount: ReturnType<typeof calcSentAmount>,\n): string | null => {\n const cost = calcCost(adjustedReturn, sentAmount);\n\n if (cost.valueInCurrency && sentAmount.valueInCurrency) {\n return new BigNumber(cost.valueInCurrency)\n .div(sentAmount.valueInCurrency)\n .times(100)\n .abs()\n .toString();\n }\n\n if (cost.usd && sentAmount.usd) {\n return new BigNumber(cost.usd)\n .div(sentAmount.usd)\n .times(100)\n .abs()\n .toString();\n }\n\n return null;\n};\n\nexport const formatEtaInMinutes = (\n estimatedProcessingTimeInSeconds: number,\n) => {\n if (estimatedProcessingTimeInSeconds < 60) {\n return `< 1`;\n }\n return (estimatedProcessingTimeInSeconds / 60).toFixed();\n};\n\nexport const sortQuotes = (\n quotes: QuoteResponse[],\n featureId: FeatureId | null,\n) => {\n // Sort perps quotes by increasing estimated processing time (fastest first)\n if (featureId === FeatureId.PERPS) {\n return quotes.sort((a, b) => {\n return (\n a.estimatedProcessingTimeInSeconds - b.estimatedProcessingTimeInSeconds\n );\n });\n }\n return quotes;\n};\n"]}
|
package/dist/utils/quote.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import type { BridgeAsset, ExchangeRate, GenericQuoteRequest, L1GasFees, Quote, QuoteMetadata, QuoteResponse, NonEvmFees, TxData } from "../types.cjs";
|
|
3
|
-
import { FeatureId } from "
|
|
3
|
+
import { FeatureId } from "../types.cjs";
|
|
4
4
|
export declare const isValidQuoteRequest: (partialRequest: Partial<GenericQuoteRequest>, requireAmount?: boolean) => partialRequest is GenericQuoteRequest;
|
|
5
5
|
export declare const isValidBatchSellQuoteRequest: (quoteRequests: Partial<GenericQuoteRequest>[], requireAmount?: boolean) => quoteRequests is GenericQuoteRequest[];
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.cts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,MAAM,EACP,qBAAiB;
|
|
1
|
+
{"version":3,"file":"quote.d.cts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,MAAM,EACP,qBAAiB;AAClB,OAAO,EAAE,SAAS,EAAE,qBAAiB;AAGrC,eAAO,MAAM,mBAAmB,mBACd,QAAQ,mBAAmB,CAAC,mEA4D7C,CAAC;AAEF,eAAO,MAAM,4BAA4B,kBACxB,QAAQ,mBAAmB,CAAC,EAAE,oEAGwB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,aAAa,CAAC,OAAO,CAAC,WACD,CAAC;AAOhE,eAAO,MAAM,yBAAyB,gBACvB,aAAa,GAAG,UAAU,qCACJ,YAAY;;;;CAahD,CAAC;AAEF,eAAO,MAAM,YAAY,oBACN,MAAM,aACZ,WAAW,qCACa,YAAY;;;;CAehD,CAAC;AAEF,eAAO,MAAM,cAAc,kDACsB,KAAK,qCACjB,YAAY;;;;CA2BhD,CAAC;AAEF,eAAO,MAAM,aAAa,WAChB,MAAM,SACP,WAAW,qCACiB,YAAY;;;;;;;;;;;;;;CAchD,CAAC;AAEF,eAAO,MAAM,cAAc,kBACV,cAAc,MAAM,EAAE,MAAM,CAAC,qCACT,YAAY;;;;CAwBhD,CAAC;AA2CF,eAAO,MAAM,8BAA8B;iBAO5B,cAAc,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;;;qBAGrC,aAAa,CAAC,QAAQ,CA6DxC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,+BACX,WAAW,qCAAqC,CAAC,cACjE,WAAW,qBAAqB,CAAC;;;;CAiB9C,CAAC;AAEF,eAAO,MAAM,sBAAsB,WACzB,WAAW,qCAAqC,CAAC,cAC7C,WAAW,qBAAqB,CAAC;;;;CAa9C,CAAC;AAGF,eAAO,MAAM,kBAAkB,mEACmC,KAAK,wBAC/C,YAAY,yBACX,YAAY;;;;QAwBpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,kBACd,WAAW,mBAAmB,CAAC,4BACpB,WAAW,mCAAmC,CAAC,+DACZ,KAAK;;;CAuBnE,CAAC;AAEF,eAAO,MAAM,YAAY,eAAgB,MAAM,mBAAmB,MAAM,WACb,CAAC;AAE5D,eAAO,MAAM,QAAQ,mBACH,WAAW,yBAAyB,CAAC,cACzC,WAAW,qBAAqB,CAAC;;;CAY7C,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,mBACjB,WAAW,yBAAyB,CAAC,cACzC,WAAW,qBAAqB,CAAC,KAC5C,MAAM,GAAG,IAoBX,CAAC;AAEF,eAAO,MAAM,kBAAkB,qCACK,MAAM,WAMzC,CAAC;AAEF,eAAO,MAAM,UAAU,WACb,aAAa,EAAE,aACZ,SAAS,GAAG,IAAI,oBAW5B,CAAC"}
|
package/dist/utils/quote.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import type { BridgeAsset, ExchangeRate, GenericQuoteRequest, L1GasFees, Quote, QuoteMetadata, QuoteResponse, NonEvmFees, TxData } from "../types.mjs";
|
|
3
|
-
import { FeatureId } from "
|
|
3
|
+
import { FeatureId } from "../types.mjs";
|
|
4
4
|
export declare const isValidQuoteRequest: (partialRequest: Partial<GenericQuoteRequest>, requireAmount?: boolean) => partialRequest is GenericQuoteRequest;
|
|
5
5
|
export declare const isValidBatchSellQuoteRequest: (quoteRequests: Partial<GenericQuoteRequest>[], requireAmount?: boolean) => quoteRequests is GenericQuoteRequest[];
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.mts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,MAAM,EACP,qBAAiB;
|
|
1
|
+
{"version":3,"file":"quote.d.mts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,MAAM,EACP,qBAAiB;AAClB,OAAO,EAAE,SAAS,EAAE,qBAAiB;AAGrC,eAAO,MAAM,mBAAmB,mBACd,QAAQ,mBAAmB,CAAC,mEA4D7C,CAAC;AAEF,eAAO,MAAM,4BAA4B,kBACxB,QAAQ,mBAAmB,CAAC,EAAE,oEAGwB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,aAAa,CAAC,OAAO,CAAC,WACD,CAAC;AAOhE,eAAO,MAAM,yBAAyB,gBACvB,aAAa,GAAG,UAAU,qCACJ,YAAY;;;;CAahD,CAAC;AAEF,eAAO,MAAM,YAAY,oBACN,MAAM,aACZ,WAAW,qCACa,YAAY;;;;CAehD,CAAC;AAEF,eAAO,MAAM,cAAc,kDACsB,KAAK,qCACjB,YAAY;;;;CA2BhD,CAAC;AA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2
|
import { convertHexToDecimal, toHex, weiHexToGweiDec } from "@metamask/controller-utils";
|
|
3
3
|
import { BigNumber } from "bignumber.js";
|
|
4
|
+
import { FeatureId } from "../types.mjs";
|
|
4
5
|
import { isNativeAddress, isNonEvmChainId } from "./bridge.mjs";
|
|
5
|
-
import { FeatureId } from "./validators.mjs";
|
|
6
6
|
export const isValidQuoteRequest = (partialRequest, requireAmount = true) => {
|
|
7
7
|
const stringFields = [
|
|
8
8
|
'srcTokenAddress',
|