Skip to content
Open
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
7 changes: 7 additions & 0 deletions packages/ramps-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `RampsController:getQuoteWithFees`, which returns the best on-ramp quote with its fees reconciled to the resolved provider ([#10238](https://github.com/MetaMask/core/pull/10238))
- When the resolved provider is Transak Native, the returned quote's `providerFee`/`networkFee`/`totalFees` reflect the native buy quote's total fee: the aggregator `networkFee` stays on the network line and the remainder goes to the provider fee, so the breakdown survives and the total is unchanged. A non-native provider, a failed native lookup, or an unusable native fee returns the aggregator quote unchanged.
- The native lookup uses the stateless `TransakService:getBuyQuote`, so it does not write the shared native buy-quote state used by Unified Buy.

### Changed

- Add an optional fee-exclusion argument to native Transak buy quotes while preserving fee exclusion as the default. ([#9317](https://github.com/MetaMask/core/pull/9317))
- Add `bignumber.js` as a dependency, used by `getQuoteWithFees` for fee reconciliation ([#10238](https://github.com/MetaMask/core/pull/10238))
- Bump `@metamask/profile-sync-controller` from `^32.0.0` to `^32.1.1` ([#10184](https://github.com/MetaMask/core/pull/10184), [#10220](https://github.com/MetaMask/core/pull/10220))

## [22.0.0]
Expand Down
1 change: 1 addition & 0 deletions packages/ramps-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@metamask/messenger": "^3.0.0",
"@metamask/profile-sync-controller": "^32.1.1",
"@metamask/remote-feature-flag-controller": "^7.0.0",
"bignumber.js": "^9.1.2",
"fast-deep-equal": "^3.1.3"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,51 @@ export type RampsControllerGetQuotesAction = {
handler: RampsController['getQuotes'];
};

/**
* Fetches the best on-ramp quote for a request and, when the resolved
* provider is Transak Native, reconciles its fees to match what Transak
* Native actually charges.
*
* The aggregator `/quotes` estimate of Transak's fee does not match the
* native integration. When the resolved provider is Transak Native this
* fetches the native buy quote (an unauthenticated, API-key-only lookup, so
* it is safe at estimate time) and rewrites the returned quote's fee fields
* to its `totalFee`, keeping the aggregator's `networkFee` on the network
* line and placing the remainder in the provider fee so the breakdown
* survives and `providerFee + networkFee` still equals the native total. A
* non-native provider, a failed lookup, or an unusable native fee returns the
* aggregator quote unchanged.
*
* Consumers (e.g. `TransactionPayController`) call this instead of owning the
* provider check, asset-id parsing, and second native quote themselves.
*
* @param options - Quote options; see {@link getQuotes}, plus the fee mode.
* @param options.amount - Fiat amount for the quote.
* @param options.assetId - CAIP-19 asset id being bought.
* @param options.fiat - Optional fiat currency; defaults like {@link getQuotes}.
* @param options.paymentMethods - Optional payment method ids.
* @param options.walletAddress - Wallet address receiving the on-ramped asset.
* @param options.isFeeExcludedFromFiat - Whether Transak adds its fee on top
* of the fiat amount (`true`, fee-on-top) or carves it out (`false`). Must
* mirror the eventual checkout mode so the estimate equals the charge.
* Defaults to `true`.
* @param options.providers - See {@link getQuotes}.
* @param options.autoSelectProvider - See {@link getQuotes}.
* @param options.restrictToKnownOrNativeProviders - See {@link getQuotes}.
* @param options.preferredProviderIds - See {@link getQuotes}.
* @param options.region - See {@link getQuotes}.
* @param options.redirectUrl - See {@link getQuotes}.
* @param options.action - See {@link getQuotes}.
* @param options.forceRefresh - See {@link getQuotes}.
* @param options.ttl - See {@link getQuotes}.
* @returns The best quote with native-reconciled fees, or `undefined` when
* no quote is available.
*/
export type RampsControllerGetQuoteWithFeesAction = {
type: `RampsController:getQuoteWithFees`;
handler: RampsController['getQuoteWithFees'];
};

/**
* Adds or updates a V2 order in controller state.
* If an order with the same internal order code already exists, the incoming
Expand Down Expand Up @@ -848,6 +893,7 @@ export type RampsControllerMethodActions =
| RampsControllerGetPaymentMethodsForContextAction
| RampsControllerSetSelectedPaymentMethodAction
| RampsControllerGetQuotesAction
| RampsControllerGetQuoteWithFeesAction
| RampsControllerAddOrderAction
| RampsControllerRemoveOrderAction
| RampsControllerSyncOrdersWithUserStorageAction
Expand Down
Loading