# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.5.0]

### Added

- Add `fetchVaults`, which reads `GET /v1/vaults` for the environment's vault catalog including `current_apy`, and is exposed as the `MoneyAccountApiDataService:fetchVaults` action. Export `VaultsResponse`, `VaultSummary`, and `MoneyAccountApiDataServiceFetchVaultsAction` ([#11633](https://github.com/MetaMask/core/pull/11633))

### Changed

- Bump `@metamask/utils` from `^12.0.1` to `^12.0.2` ([#11474](https://github.com/MetaMask/core/pull/11474))
- Bump `@tanstack/query-core` from `^5.103.2` to `^5.107.1` ([#11645](https://github.com/MetaMask/core/pull/11645))

## [2.4.0]

### Added

- Add `fetchVaultShareValuations`, which reads `GET /v1/positions/:address/vault-share-valuations` for up to 50 transaction hashes and is exposed as the `MoneyAccountApiDataService:fetchVaultShareValuations` action. Export `VaultShareValuationsResponse`, `VaultShareValuation`, `VaultShareValuationResult`, `VaultShareValuationsOptions`, `VAULT_SHARE_VALUATIONS_MAX_TX_HASHES`, and `MoneyAccountApiDataServiceFetchVaultShareValuationsAction` ([#11433](https://github.com/MetaMask/core/pull/11433))
  - Unused valuation fields accept `null`, and `type` and `source` are plain strings, so new values do not require a client release.

## [2.3.1]

### Changed

- Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))

### Fixed

- Validate VBA SIWE challenge messages against the expected Money Account template before signing, rejecting a message whose domain, URI, address, statement, version, chain ID, nonce, or timestamps do not match ([#11112](https://github.com/MetaMask/core/pull/11112))

## [2.3.0]

### Added

- Add SIWE-authenticated `fetchVbaTransfers` and `MoneyAccountApiDataService:fetchVbaTransfers` to read current VBA transfers for a wallet, with wallet-scoped in-memory sessions ([#11012](https://github.com/MetaMask/core/pull/11012))
- Add support for Node.js 26 ([#10981](https://github.com/MetaMask/core/pull/10981))

## [2.2.0]

### Added

- Add `MoneyAccountApiHttpError`, a subclass of `HttpError` that carries a sanitized `responseBody` (hex addresses redacted, truncated to 1000 characters) and allowlisted diagnostic `responseHeaders` ([#10822](https://github.com/MetaMask/core/pull/10822))

### Changed

- Non-2xx responses from every endpoint now throw `MoneyAccountApiHttpError` instead of a plain `HttpError` ([#10822](https://github.com/MetaMask/core/pull/10822))

## [2.1.0]

### Added

- Add `fetchVaultRate`, which reads a vault's current Accountant exchange rate from `GET /v1/vaults/:address/rate` and is exposed as the `MoneyAccountApiDataService:fetchVaultRate` action. Export `VaultRateResponse`, `VaultRateOptions`, and `MoneyAccountApiDataServiceFetchVaultRateAction` ([#10504](https://github.com/MetaMask/core/pull/10504))

### Changed

- Response validation now tolerates unknown fields returned by the Money Account API instead of throwing `MoneyAccountApiResponseValidationError`, so additive backend changes no longer break clients ([#10538](https://github.com/MetaMask/core/pull/10538))
- Bump `@tanstack/query-core` from `^5.89.0` to `^5.103.2` ([#10511](https://github.com/MetaMask/core/pull/10511))

## [2.0.0]

### Added

- Add optional `fresh` option to `fetchPositions` that cancels in-flight reads, fetches with a zero stale time, invalidates the result for subsequent reads, and sends `Cache-Control: no-cache` so the Money API skips its Nest response cache when supported ([#10455](https://github.com/MetaMask/core/pull/10455))
- Accept optional additive `musd_balance_updated_at` on the positions `balance` summary ([#10455](https://github.com/MetaMask/core/pull/10455))
- Accept vault metadata on each position returned by `fetchPositions`: `chain_id`, `vault_key`, `name`, `asset_symbol`, and `asset_decimals` ([#10500](https://github.com/MetaMask/core/pull/10500))
- Accept multi-asset balance fields `by_asset` and `total_balance_usd` on the positions `balance` summary, and export `AssetBalance` ([#10500](https://github.com/MetaMask/core/pull/10500))

### Changed

- **BREAKING:** `effective_apy` on a vault position is now `string | null`. `null` means the position has been invested for fewer than 28 days, and is distinct from a rate of zero ([#10500](https://github.com/MetaMask/core/pull/10500))
- Bump `@metamask/utils` from `^11.12.0` to `^12.0.0` ([#10192](https://github.com/MetaMask/core/pull/10192))
- Bump `@tanstack/query-core` from `^5.62.16` to `^5.89.0` ([#9324](https://github.com/MetaMask/core/pull/9324))
- Bump `@metamask/base-data-service` from `^2.0.0` to `^2.1.0` ([#10502](https://github.com/MetaMask/core/pull/10502))

## [1.0.0]

### Changed

- **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536))
  - This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions.
- **BREAKING:** Bump minimum Node.js version to 22 ([#9976](https://github.com/MetaMask/core/pull/9976))
- **BREAKING:** Bump TypeScript target to ES2022 ([#10019](https://github.com/MetaMask/core/pull/10019))
  - This package now ships ES2022 code, requiring a compatible modern environment or bundler configuration to consume.
- Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
- Bump `@metamask/base-data-service` from `^1.0.0` to `^2.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))
- Bump `@metamask/controller-utils` from `^12.3.0` to `^13.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))
- Bump `@metamask/messenger` from `^2.0.0` to `^3.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))

## [0.4.1]

### Changed

- Bump `@metamask/superstruct` from `^3.1.0` to `^3.4.1` ([#9754](https://github.com/MetaMask/core/pull/9754))
- Bump `@tanstack/query-core` from `^4.43.0` to `^5.62.16` ([#9712](https://github.com/MetaMask/core/pull/9712))
- Bump `@metamask/base-data-service` from `^0.1.3` to `^1.0.0` ([#9972](https://github.com/MetaMask/core/pull/9972))

## [0.4.0]

### Changed

- Add best-effort profile JWT authentication to Money Account API requests, falling back to unauthenticated requests when a token is unavailable ([#9661](https://github.com/MetaMask/core/pull/9661))

## [0.3.0]

### Added

- Add optional `trace` callback to `MoneyAccountApiDataService` constructor for network request tracing ([#9451](https://github.com/MetaMask/core/pull/9451))
  - All HTTP calls (`fetchPositions`, `fetchInterest`, `fetchHistory`, `fetchRateHistory`) emit best-effort backdated traces with `startTime`, `success`, and `errorName` attributes
  - Tracing is isolated from fetch/retry logic; trace failures do not impact queries

## [0.2.0]

### Added

- Add optional nullable `balance` field to the positions response (`musd_balance`, `vmusd_value_in_musd`, `total_balance`), matching the Money Account API contract. Export `PositionBalance` type. ([#9554](https://github.com/MetaMask/core/pull/9554))

## [0.1.0]

### Added

- Add `MoneyAccountApiDataService` data service ([#9402](https://github.com/MetaMask/core/pull/9402))
  - Fetch user vault positions from the Money Account API (`fetchPositions`)
  - Fetch interest earned over a time window (`fetchInterest`)
  - Fetch cursor-paginated cash-flow history (`fetchHistory`)
  - Fetch vault exchange-rate time series (`fetchRateHistory`)

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@2.5.0...HEAD
[2.5.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@2.4.0...@metamask/money-account-api-data-service@2.5.0
[2.4.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@2.3.1...@metamask/money-account-api-data-service@2.4.0
[2.3.1]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@2.3.0...@metamask/money-account-api-data-service@2.3.1
[2.3.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@2.2.0...@metamask/money-account-api-data-service@2.3.0
[2.2.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@2.1.0...@metamask/money-account-api-data-service@2.2.0
[2.1.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@2.0.0...@metamask/money-account-api-data-service@2.1.0
[2.0.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@1.0.0...@metamask/money-account-api-data-service@2.0.0
[1.0.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@0.4.1...@metamask/money-account-api-data-service@1.0.0
[0.4.1]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@0.4.0...@metamask/money-account-api-data-service@0.4.1
[0.4.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@0.3.0...@metamask/money-account-api-data-service@0.4.0
[0.3.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@0.2.0...@metamask/money-account-api-data-service@0.3.0
[0.2.0]: https://github.com/MetaMask/core/compare/@metamask/money-account-api-data-service@0.1.0...@metamask/money-account-api-data-service@0.2.0
[0.1.0]: https://github.com/MetaMask/core/releases/tag/@metamask/money-account-api-data-service@0.1.0
