import type { DataServiceCacheUpdatedEvent, DataServiceGranularCacheUpdatedEvent, DataServiceInvalidateQueriesAction } from '@metamask/base-data-service'; import { BaseDataService } from '@metamask/base-data-service'; import type { CreateServicePolicyOptions, TraceContext, TraceRequest } from '@metamask/controller-utils'; import type { Messenger } from '@metamask/messenger'; import type { QueryClientConfig } from '@tanstack/query-core'; import { Env } from './constants.js'; import type { MoneyAccountApiDataServiceMethodActions } from './money-account-api-data-service-method-action-types.js'; import type { HistoryResponse, InterestResponse, PositionResponse, RateHistoryResponse, VaultRateResponse, VaultShareValuationsResponse, VaultsResponse, VbaTransfersResponse } from './response.types.js'; import type { HistoryOptions, InterestOptions, RateHistoryOptions, FetchPositionsOptions, VaultRateOptions, VaultShareValuationsOptions, FetchVbaTransfersOptions } from './types.js'; /** * The name of the {@link MoneyAccountApiDataService}, used to namespace the * service's actions and events. */ export declare const serviceName = "MoneyAccountApiDataService"; export declare const TRACES: { readonly POSITIONS_API: 'Money Account API Fetch Positions'; readonly INTEREST_API: 'Money Account API Fetch Interest'; readonly HISTORY_API: 'Money Account API Fetch History'; readonly RATE_HISTORY_API: 'Money Account API Fetch Rate History'; readonly VAULT_RATE_API: 'Money Account API Fetch Vault Rate'; readonly VAULTS_API: 'Money Account API Fetch Vaults'; readonly VAULT_SHARE_VALUATIONS_API: 'Money Account API Fetch Vault Share Valuations'; }; export type MoneyAccountApiDataServiceTraceName = (typeof TRACES)[keyof typeof TRACES]; export type MoneyAccountApiDataServiceTraceRequest = Omit & { name: MoneyAccountApiDataServiceTraceName; startTime?: number; }; export type MoneyAccountApiDataServiceTraceCallback = (request: MoneyAccountApiDataServiceTraceRequest, fn?: (context?: TraceContext) => ReturnType) => Promise; /** * Invalidates cached queries for {@link MoneyAccountApiDataService}. */ export type MoneyAccountApiDataServiceInvalidateQueriesAction = DataServiceInvalidateQueriesAction; /** * Actions that {@link MoneyAccountApiDataService} exposes to other consumers. */ export type MoneyAccountApiDataServiceActions = MoneyAccountApiDataServiceMethodActions | MoneyAccountApiDataServiceInvalidateQueriesAction; /** * Actions from other messengers that {@link MoneyAccountApiDataService} calls. */ type AuthenticationControllerGetBearerTokenAction = { type: 'AuthenticationController:getBearerToken'; handler: (entropySourceId?: string) => Promise; }; type KeyringControllerSignPersonalMessageAction = { type: 'KeyringController:signPersonalMessage'; handler: (messageParams: { data: string; from: string; }) => Promise; }; type AllowedActions = AuthenticationControllerGetBearerTokenAction | KeyringControllerSignPersonalMessageAction; /** * Published when {@link MoneyAccountApiDataService}'s cache is updated. */ export type MoneyAccountApiDataServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent; /** * Published when a key within {@link MoneyAccountApiDataService}'s cache is * updated. */ export type MoneyAccountApiDataServiceGranularCacheUpdatedEvent = DataServiceGranularCacheUpdatedEvent; /** * Events that {@link MoneyAccountApiDataService} exposes to other consumers. */ export type MoneyAccountApiDataServiceEvents = MoneyAccountApiDataServiceCacheUpdatedEvent | MoneyAccountApiDataServiceGranularCacheUpdatedEvent; /** * Events from other messengers that {@link MoneyAccountApiDataService} * subscribes to. */ type AllowedEvents = never; /** * The messenger which is restricted to actions and events accessed by * {@link MoneyAccountApiDataService}. */ export type MoneyAccountApiDataServiceMessenger = Messenger; export type MoneyAccountApiDataServiceOptions = { messenger: MoneyAccountApiDataServiceMessenger; env?: Env; queryClientConfig?: QueryClientConfig; policyOptions?: CreateServicePolicyOptions; trace?: MoneyAccountApiDataServiceTraceCallback; }; /** * Data service responsible for fetching positions, interest, cash-flow * history, vault rate history, and the current vault exchange rate from the * Money Account APY Tracking API. */ export declare class MoneyAccountApiDataService extends BaseDataService { #private; /** * Constructs a new MoneyAccountApiDataService. * * @param options - The constructor arguments. * @param options.messenger - The messenger suited for this service. * @param options.env - The target environment. Defaults to production. * @param options.queryClientConfig - Configuration for the underlying * TanStack Query client. * @param options.policyOptions - Options to pass to `createServicePolicy`. * @param options.trace - Optional callback to trace network requests. */ constructor({ messenger, env, queryClientConfig, policyOptions, trace, }: MoneyAccountApiDataServiceOptions); /** * Fetches the current vault positions for a given user address. * * @param address - The user's Ethereum address. * @param options - Optional fetch options. * @param options.fresh - When true, cancels in-flight reads, fetches with a * zero stale time, invalidates the result for subsequent reads, and asks the * Money API to skip its Nest response cache with `Cache-Control: no-cache`. * @returns The position response containing vault positions and an optional * `balance` summary (`null` when the API balance path is unavailable). */ fetchPositions(address: string, { fresh }?: FetchPositionsOptions): Promise; /** * Fetches the interest earned for a given address and vault over a * specified time window. * * @param address - The user's Ethereum address. * @param options - Options specifying vault, window, and optional chain ID. * @returns The interest response. */ fetchInterest(address: string, options: InterestOptions): Promise; /** * Fetches cursor-paginated cash-flow history for a given address. * Uses `fetchInfiniteQuery` for proper TanStack Query pagination semantics. * * When paginating, consumers must re-pass the same filter options * (`vaultAddress`, `chainId`, `limit`) alongside `cursor` on every page * request. This ensures the query key matches the original infinite query * and that the HTTP request includes the correct filters. * * @param address - The user's Ethereum address. * @param options - Optional filtering and pagination options. * @returns The history response containing cash-flow entries for the requested page. */ fetchHistory(address: string, options?: HistoryOptions): Promise; /** * Fetches the exchange-rate time series for a given vault. * * @param vaultAddress - The vault's Ethereum address. * @param options - Optional range and chain ID filters. * @returns The rate history response. */ fetchRateHistory(vaultAddress: string, options?: RateHistoryOptions): Promise; /** * Fetches the current Accountant exchange rate for a vault. * * The server returns 404 when the vault is not in the deployment registry * or has no indexed rate yet. * * @param vaultAddress - The vault's Ethereum address. * @param options - Optional chain ID filter. Omitted requests use the API default. * @returns The current vault rate response. */ fetchVaultRate(vaultAddress: string, options?: VaultRateOptions): Promise; /** * Fetches the environment's vault catalog, including each vault's current * APY. * * @returns The vault catalog response. */ fetchVaults(): Promise; /** * Batch-values vault share movements in past transactions. Each result * reports the shares moved and what they were worth in the vault's * underlying asset at that block. Unknown transactions come back with * `found: false` instead of failing the batch. * * @param address - The user's Ethereum address. * @param options - Transaction hashes to value and an optional chain ID. * @param options.txHashes - Transaction hashes. At most 50 distinct hashes * after lowercasing and de-duplication. * @param options.chainId - Chain ID of the transactions. Omitted requests use * the API default (Monad, 143). * @returns One result per requested hash, in request order. * @throws An `Error` before any request when `txHashes` is empty or contains * more than 50 distinct hashes. */ fetchVaultShareValuations(address: string, { txHashes, chainId }: VaultShareValuationsOptions): Promise; /** * Fetches current VBA transfers for the wallet authenticated via SIWE. * * @param options - Fetch options, including the wallet address to authenticate. * @returns Current transfers belonging to the authenticated wallet. */ fetchVbaTransfers(options: FetchVbaTransfersOptions): Promise; } export {}; //# sourceMappingURL=money-account-api-data-service.d.ts.map