Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@
},
"packages/bridge-controller/src/utils/metrics/types.ts": {
"@typescript-eslint/naming-convention": {
"count": 81
"count": 83
}
},
"packages/bridge-controller/src/utils/quote-fees.ts": {
Expand Down
5 changes: 5 additions & 0 deletions packages/bridge-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `has_gas_included_quote` property to `QuoteFetchData` type and compute it in `QuotesReceived` event to indicate if any received quote has gas included ([#7611](https://github.com/MetaMask/core/pull/7611))
- Add optional `usd_balance_source` property to `QuotesReceived` event and `getQuotesReceivedProperties` utility to allow clients to pass the source token balance in USD ([#7611](https://github.com/MetaMask/core/pull/7611))

## [64.4.1]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Array [
"error_message": "error_message",
"gas_included": false,
"gas_included_7702": false,
"has_gas_included_quote": false,
"initial_load_time_all_quotes": 0,
"is_hardware_wallet": false,
"price_impact": 0,
Expand Down Expand Up @@ -141,6 +142,7 @@ Array [
"error_message": "Failed to submit tx",
"gas_included": false,
"gas_included_7702": false,
"has_gas_included_quote": false,
"initial_load_time_all_quotes": 0,
"is_hardware_wallet": false,
"price_impact": 12,
Expand Down Expand Up @@ -219,6 +221,7 @@ Array [
"chain_id_source": "eip155:1",
"custom_slippage": false,
"gas_included": false,
"has_gas_included_quote": false,
"initial_load_time_all_quotes": 0,
"is_hardware_wallet": false,
"price_impact": 6,
Expand Down Expand Up @@ -248,6 +251,7 @@ Array [
"chain_id_source": "eip155:1",
"custom_slippage": false,
"gas_included": false,
"has_gas_included_quote": false,
"initial_load_time_all_quotes": 0,
"is_hardware_wallet": false,
"price_impact": 6,
Expand Down Expand Up @@ -349,6 +353,7 @@ Array [
"custom_slippage": false,
"gas_included": false,
"gas_included_7702": false,
"has_gas_included_quote": false,
"initial_load_time_all_quotes": 0,
"is_best_quote": true,
"is_hardware_wallet": false,
Expand Down Expand Up @@ -390,6 +395,7 @@ Array [
"custom_slippage": false,
"gas_included": false,
"gas_included_7702": false,
"has_gas_included_quote": false,
"initial_load_time_all_quotes": 0,
"is_hardware_wallet": false,
"price_impact": 0,
Expand All @@ -402,6 +408,7 @@ Array [
"swap_type": "crosschain",
"token_address_destination": null,
"token_address_source": "eip155:1/slip44:60",
"usd_balance_source": 0,
"usd_quoted_gas": 0,
"usd_quoted_return": 100,
"warnings": Array [
Expand Down Expand Up @@ -478,6 +485,7 @@ Array [
"custom_slippage": true,
"gas_included": false,
"gas_included_7702": false,
"has_gas_included_quote": false,
"initial_load_time_all_quotes": 11000,
"is_hardware_wallet": false,
"price_impact": 0,
Expand All @@ -493,6 +501,7 @@ Array [
"swap_type": "crosschain",
"token_address_destination": "eip155:10/erc20:0x123",
"token_address_source": "eip155:1/slip44:60",
"usd_balance_source": 0,
"usd_quoted_gas": 0,
"usd_quoted_return": 100,
"warnings": Array [
Expand Down
3 changes: 3 additions & 0 deletions packages/bridge-controller/src/bridge-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ describe('BridgeController', function () {
provider: 'provider_bridge',
best_quote_provider: 'provider_bridge2',
can_submit: true,
usd_balance_source: 0,
},
);

Expand Down Expand Up @@ -2366,6 +2367,7 @@ describe('BridgeController', function () {
provider: 'provider_bridge',
best_quote_provider: 'provider_bridge2',
can_submit: true,
usd_balance_source: 0,
},
);
expect(messengerMock.call.mock.calls).toMatchSnapshot();
Expand Down Expand Up @@ -2669,6 +2671,7 @@ describe('BridgeController', function () {
provider: 'provider_bridge',
best_quote_provider: 'provider_bridge2',
can_submit: true,
usd_balance_source: 0,
},
);
expect(trackMetaMetricsFn).toHaveBeenCalledTimes(0);
Expand Down
3 changes: 3 additions & 0 deletions packages/bridge-controller/src/bridge-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,9 @@ export class BridgeController extends StaticIntervalPollingController<BridgePoll
formatProviderLabel(quote),
),
initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,
has_gas_included_quote: this.state.quotes.some(
({ quote }) => quote.gasIncluded,
),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ describe('properties', () => {
"price_impact": 0,
"provider": "bridge1_bridge1",
"quoted_time_minutes": 1,
"usd_balance_source": 0,
"usd_quoted_gas": 0,
"usd_quoted_return": 0,
"warnings": Array [],
Expand Down
2 changes: 2 additions & 0 deletions packages/bridge-controller/src/utils/metrics/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export const getQuotesReceivedProperties = (
warnings: QuoteWarning[] = [],
isSubmittable: boolean = true,
recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>),
usdBalanceSource?: number,
) => {
const provider = activeQuote ? formatProviderLabel(activeQuote.quote) : '_';
return {
Expand All @@ -138,6 +139,7 @@ export const getQuotesReceivedProperties = (
: 0,
usd_quoted_gas: Number(activeQuote?.gasFee?.effective?.usd ?? 0),
usd_quoted_return: Number(activeQuote?.toTokenAmount?.usd ?? 0),
usd_balance_source: usdBalanceSource ?? 0,
best_quote_provider: recommendedQuote
? formatProviderLabel(recommendedQuote.quote)
: provider,
Expand Down
2 changes: 2 additions & 0 deletions packages/bridge-controller/src/utils/metrics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type QuoteFetchData = {
quotes_list: `${string}_${string}`[];
initial_load_time_all_quotes: number;
price_impact: number;
has_gas_included_quote: boolean;
};

export type TradeData = {
Expand Down Expand Up @@ -117,6 +118,7 @@ export type RequiredEventContextFromClient = {
best_quote_provider: QuoteFetchData['best_quote_provider'];
price_impact: QuoteFetchData['price_impact'];
can_submit: QuoteFetchData['can_submit'];
usd_balance_source?: number;
};
[UnifiedSwapBridgeEventName.QuotesError]: Pick<
RequestMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,7 @@ Array [
"price_impact": 0,
"provider": "lifi_across",
"quoted_time_minutes": 0.25,
"usd_balance_source": 0,
"usd_quoted_gas": 2.5778,
"usd_quoted_return": 0.134214,
"warnings": Array [
Expand Down
Loading