Skip to content

feat(money): add support for GET /v1/vaults/:address/rate - #10504

Merged
ffmcgee725 merged 2 commits into
mainfrom
jc/MUSD-1376
Sep 28, 2026
Merged

ffmcgee725 merged 2 commits into
mainfrom
jc/MUSD-1376

Conversation

@ffmcgee725

@ffmcgee725 ffmcgee725 commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Explanation

  • Add fetchVaultRate to @metamask/money-account-api-data-service so clients can read a vault's current Accountant exchange rate from GET /v1/vaults/:address/rate.
  • The method lowercases the vault address, sends optional chain_id, validates the response, and caches it for 5 minutes (the server TTL). It is exposed as MoneyAccountApiDataService:fetchVaultRate.
  • Additive exports: VaultRateResponse, VaultRateOptions, and MoneyAccountApiDataServiceFetchVaultRateAction.

Changelog

@metamask/money-account-api-data-service

[Unreleased]

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 (feat(money): add support for GET /v1/vaults/:address/rate #10504)

Test plan

  • yarn workspace @metamask/money-account-api-data-service run test --coverage (100% statements, branches, functions, lines)
  • yarn workspace @metamask/money-account-api-data-service run messenger-action-types:check
  • yarn workspace @metamask/money-account-api-data-service run changelog:validate
  • yarn oxlint packages/money-account-api-data-service

Note

Low Risk
Additive client API with no breaking changes; behavior mirrors existing fetch methods and is covered by tests.

Overview
Adds fetchVaultRate to @metamask/money-account-api-data-service so clients can read a vault’s current Accountant exchange rate from GET /v1/vaults/:address/rate, alongside existing rate-history support.

The method follows the same patterns as other Money Account API calls: lowercases the vault address, optional chain_id, profile JWT when available, superstruct validation, TanStack Query caching with a 5-minute stale time (VAULT_RATE_STALE_TIME_MS), tracing, and messenger exposure as MoneyAccountApiDataService:fetchVaultRate. New public types include VaultRateResponse, VaultRateOptions, and MoneyAccountApiDataServiceFetchVaultRateAction.

Tests cover auth headers, cache/dedup keyed by chain, 404 HttpError, malformed responses, and messenger invocation.

Reviewed by Cursor Bugbot for commit c422c50. Bugbot is set up for automated code reviews on this repo. Configure here.

@ffmcgee725
ffmcgee725 marked this pull request as ready for review September 28, 2026 11:24
@ffmcgee725
ffmcgee725 requested review from a team as code owners September 28, 2026 11:24
@ffmcgee725
ffmcgee725 added this pull request to stack #10540 September 28, 2026 15:35
Matt561
Matt561 previously approved these changes Sep 28, 2026
indexer_lag_seconds: number(),
});

export const VaultRateResponseStruct = object({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use type (if available) here just in case new properties are added to the response later?

Suggested change
export const VaultRateResponseStruct = object({
export const VaultRateResponseStruct = type({

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do that in here, which is meant to be merged right afterwards and released at the same time #10538
👍🏾

@ffmcgee725
ffmcgee725 added this pull request to the merge queue Sep 28, 2026
Merged via the queue into main with commit ae42a89 Sep 28, 2026
60 checks passed
@ffmcgee725
ffmcgee725 deleted the jc/MUSD-1376 branch September 28, 2026 19:01
@ffmcgee725 ffmcgee725 mentioned this pull request Sep 28, 2026
pull Bot pushed a commit to Reality2byte/core that referenced this pull request Sep 29, 2026
## @metamask/money-account-api-data-service

## [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`
([MetaMask#10504](MetaMask#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
([MetaMask#10538](MetaMask#10538))
- Bump `@tanstack/query-core` from `^5.89.0` to `^5.103.2`
([MetaMask#10511](MetaMask#10511))

## @metamask/money-account-balance-service

## [3.1.1]

### Changed

- Bump `@metamask/money-account-api-data-service` from `^2.0.0` to
`^2.1.0` ([MetaMask#10544](MetaMask#10544))

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants