diff --git a/packages/transaction-pay-controller/CHANGELOG.md b/packages/transaction-pay-controller/CHANGELOG.md index 2f68db2a6b8..26885faddbf 100644 --- a/packages/transaction-pay-controller/CHANGELOG.md +++ b/packages/transaction-pay-controller/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Read Relay provider fees directly from response ([#7098](https://github.com/MetaMask/core/pull/7098)) + ## [4.0.0] ### Added diff --git a/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.test.ts b/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.test.ts index 44245abf698..fba08ec8c4d 100644 --- a/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.test.ts +++ b/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.test.ts @@ -37,9 +37,6 @@ const QUOTE_REQUEST_MOCK: QuoteRequest = { const QUOTE_MOCK = { details: { - currencyIn: { - amountUsd: '2.34', - }, currencyOut: { amountFormatted: '1.0', amountUsd: '1.23', @@ -51,8 +48,8 @@ const QUOTE_MOCK = { timeEstimate: 300, }, fees: { - gas: { - amountUsd: '3.45', + relayer: { + amountUsd: '1.11', }, }, steps: [ diff --git a/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts b/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts index 2cfce4a9c9e..58eb8e75f75 100644 --- a/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts +++ b/packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts @@ -164,8 +164,7 @@ function normalizeQuote( fullRequest: PayStrategyGetQuotesRequest, ): TransactionPayQuote { const { messenger, transaction } = fullRequest; - const { details } = quote; - const { currencyIn, currencyOut } = details; + const { details, fees } = quote; const { usdToFiatRate } = getFiatRates(messenger, request); @@ -175,7 +174,7 @@ function normalizeQuote( ); const provider = getFiatValueFromUsd( - new BigNumber(currencyIn.amountUsd).minus(currencyOut.amountUsd), + new BigNumber(fees.relayer.amountUsd), usdToFiatRate, ); diff --git a/packages/transaction-pay-controller/src/strategy/relay/types.ts b/packages/transaction-pay-controller/src/strategy/relay/types.ts index a3a66616f3f..c0f581f1dae 100644 --- a/packages/transaction-pay-controller/src/strategy/relay/types.ts +++ b/packages/transaction-pay-controller/src/strategy/relay/types.ts @@ -2,9 +2,6 @@ import type { Hex } from '@metamask/utils'; export type RelayQuote = { details: { - currencyIn: { - amountUsd: string; - }; currencyOut: { amountFormatted: string; amountUsd: string; @@ -16,7 +13,7 @@ export type RelayQuote = { timeEstimate: number; }; fees: { - gas: { + relayer: { amountUsd: string; }; };