From 64d96e1b238035eb5dca2c4c4acfcb4888d3efe7 Mon Sep 17 00:00:00 2001 From: Matthew Walsh Date: Sun, 9 Nov 2025 21:41:05 +0000 Subject: [PATCH 1/2] Simplify relay fees --- .../src/strategy/relay/relay-quotes.test.ts | 7 ++----- .../src/strategy/relay/relay-quotes.ts | 5 ++--- .../transaction-pay-controller/src/strategy/relay/types.ts | 5 +---- 3 files changed, 5 insertions(+), 12 deletions(-) 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; }; }; From b91a4ca49b4b04904b54898d0a97e0c3eb20e310 Mon Sep 17 00:00:00 2001 From: Matthew Walsh Date: Sun, 9 Nov 2025 21:45:52 +0000 Subject: [PATCH 2/2] Update changelog --- packages/transaction-pay-controller/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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