var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _MarketDataService_deps;
import { v4 as uuidv4 } from "uuid";
import { PerpsMeasurementName } from "../constants/performanceMetrics.mjs";
import { PERPS_CONSTANTS } from "../constants/perpsConfig.mjs";
import { PERPS_ERROR_CODES } from "../perpsErrorCodes.mjs";
import { PerpsTraceNames, PerpsTraceOperations } from "../types/index.mjs";
import { ensureError } from "../utils/errorUtils.mjs";
/**
 * MarketDataService
 *
 * Handles all read-only data-fetching operations for the Perps controller.
 * This service is stateless and delegates to the provider.
 * The controller is responsible for tracing and state management.
 *
 * Instance-based service with constructor injection of platform dependencies.
 */
export class MarketDataService {
    /**
     * Create a new MarketDataService instance
     *
     * @param deps - Platform dependencies for logging, metrics, etc.
     */
    constructor(deps) {
        _MarketDataService_deps.set(this, void 0);
        __classPrivateFieldSet(this, _MarketDataService_deps, deps, "f");
    }
    /**
     * Get current positions
     * Handles full orchestration: tracing, error logging, state management, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getPositions(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.GetPositions,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                },
            });
            const positions = await provider.getPositions(params);
            // Update state on success (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.lastUpdateTimestamp = Date.now();
                    state.lastError = null;
                });
            }
            traceData = { success: true };
            return positions;
        }
        catch (error) {
            const errorMessage = error instanceof Error
                ? error.message
                : PERPS_ERROR_CODES.POSITIONS_FAILED;
            // Update error state (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.lastError = errorMessage;
                    state.lastUpdateTimestamp = Date.now();
                });
            }
            traceData = {
                success: false,
                error: errorMessage,
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.GetPositions,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get order fills for a specific user or order
     * Handles full orchestration: tracing, error logging, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getOrderFills(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.OrderFillsFetch,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                },
            });
            const result = await provider.getOrderFills(params);
            traceData = { success: true };
            return result;
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getOrderFills'), {
                tags: {
                    feature: PERPS_CONSTANTS.FeatureName,
                    provider: context.tracingContext.provider,
                    network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                },
                context: {
                    name: context.errorContext.controller,
                    data: {
                        method: context.errorContext.method,
                        params,
                    },
                },
            });
            traceData = {
                success: false,
                error: error instanceof Error ? error.message : 'Unknown error',
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.OrderFillsFetch,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get historical user orders (order lifecycle)
     * Handles full orchestration: tracing, error logging, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getOrders(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.OrdersFetch,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                },
            });
            const result = await provider.getOrders(params);
            traceData = { success: true };
            return result;
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getOrders'), {
                tags: {
                    feature: PERPS_CONSTANTS.FeatureName,
                    provider: context.tracingContext.provider,
                    network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                },
                context: {
                    name: context.errorContext.controller,
                    data: {
                        method: context.errorContext.method,
                        params,
                    },
                },
            });
            traceData = {
                success: false,
                error: error instanceof Error ? error.message : 'Unknown error',
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.OrdersFetch,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get current open orders
     * Handles full orchestration: tracing, error logging, performance measurement, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getOpenOrders(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        const startTime = __classPrivateFieldGet(this, _MarketDataService_deps, "f").performance.now();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.OrdersFetch,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                },
            });
            const result = await provider.getOpenOrders(params);
            const completionDuration = __classPrivateFieldGet(this, _MarketDataService_deps, "f").performance.now() - startTime;
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.setMeasurement(PerpsMeasurementName.PerpsGetOpenOrdersOperation, completionDuration, 'millisecond');
            traceData = { success: true };
            return result;
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getOpenOrders'), {
                tags: {
                    feature: PERPS_CONSTANTS.FeatureName,
                    provider: context.tracingContext.provider,
                    network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                },
                context: {
                    name: context.errorContext.controller,
                    data: {
                        method: context.errorContext.method,
                        params,
                    },
                },
            });
            traceData = {
                success: false,
                error: error instanceof Error ? error.message : 'Unknown error',
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.OrdersFetch,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get funding rates
     * Handles full orchestration: tracing, error logging, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getFunding(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.FundingFetch,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                },
            });
            const result = await provider.getFunding(params);
            traceData = { success: true };
            return result;
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getFunding'), {
                tags: {
                    feature: PERPS_CONSTANTS.FeatureName,
                    provider: context.tracingContext.provider,
                    network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                },
                context: {
                    name: context.errorContext.controller,
                    data: {
                        method: context.errorContext.method,
                        params,
                    },
                },
            });
            traceData = {
                success: false,
                error: error instanceof Error ? error.message : 'Unknown error',
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.FundingFetch,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get account state
     * Handles full orchestration: tracing, error logging, state management, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getAccountState(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.GetAccountState,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                    source: params?.source ?? 'unknown',
                },
            });
            const accountState = await provider.getAccountState(params);
            // Safety check for accountState
            if (!accountState) {
                const error = new Error('Failed to get account state: received null/undefined response');
                __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getAccountState'), {
                    tags: {
                        feature: PERPS_CONSTANTS.FeatureName,
                        provider: context.tracingContext.provider,
                        network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                    },
                    context: {
                        name: context.errorContext.controller,
                        data: {
                            method: context.errorContext.method,
                            operation: 'nullAccountStateCheck',
                        },
                    },
                });
                throw error;
            }
            // Update state on success (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.accountState = accountState;
                    state.lastUpdateTimestamp = Date.now();
                    state.lastError = null;
                });
            }
            traceData = { success: true };
            return accountState;
        }
        catch (error) {
            const errorMessage = error instanceof Error ? error.message : 'Account state fetch failed';
            // Update error state (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.lastError = errorMessage;
                    state.lastUpdateTimestamp = Date.now();
                });
            }
            traceData = {
                success: false,
                error: errorMessage,
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.GetAccountState,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get historical portfolio data
     * Handles full orchestration: tracing, error logging, state management, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getHistoricalPortfolio(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.GetHistoricalPortfolio,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                },
            });
            if (!provider.getHistoricalPortfolio) {
                throw new Error('Historical portfolio not supported by provider');
            }
            const result = await provider.getHistoricalPortfolio(params);
            traceData = { success: true };
            return result;
        }
        catch (error) {
            const errorMessage = error instanceof Error
                ? error.message
                : 'Failed to get historical portfolio';
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getHistoricalPortfolio'), {
                tags: {
                    feature: PERPS_CONSTANTS.FeatureName,
                    provider: context.tracingContext.provider,
                    network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                },
                context: {
                    name: context.errorContext.controller,
                    data: {
                        method: context.errorContext.method,
                        params,
                    },
                },
            });
            // Update error state (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.lastError = errorMessage;
                    state.lastUpdateTimestamp = Date.now();
                });
            }
            traceData = {
                success: false,
                error: errorMessage,
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.GetHistoricalPortfolio,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get available markets
     * Handles full orchestration: tracing, error logging, state management, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getMarkets(options) {
        const { provider, params, context } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.GetMarkets,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                    ...(params?.symbols && {
                        symbolCount: String(params.symbols.length),
                    }),
                    ...(params?.dex !== undefined && { dex: params.dex }),
                },
            });
            const markets = await provider.getMarkets(params);
            // Clear any previous errors on successful call (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.lastError = null;
                    state.lastUpdateTimestamp = Date.now();
                });
            }
            traceData = { success: true };
            return markets;
        }
        catch (error) {
            const errorMessage = error instanceof Error
                ? error.message
                : PERPS_ERROR_CODES.MARKETS_FAILED;
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getMarkets'), {
                tags: {
                    feature: PERPS_CONSTANTS.FeatureName,
                    provider: context.tracingContext.provider,
                    network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                },
                context: {
                    name: context.errorContext.controller,
                    data: {
                        method: context.errorContext.method,
                        params,
                    },
                },
            });
            // Update error state (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.lastError = errorMessage;
                    state.lastUpdateTimestamp = Date.now();
                });
            }
            traceData = {
                success: false,
                error: errorMessage,
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.GetMarkets,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Get available DEXs (HIP-3 support required)
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getAvailableDexs(options) {
        const { provider, params } = options;
        try {
            if (!provider.getAvailableDexs) {
                throw new Error('Provider does not support HIP-3 DEXs');
            }
            return await provider.getAvailableDexs(params);
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getAvailableDexs'), {
                context: {
                    name: 'MarketDataService.getAvailableDexs',
                    data: { params },
                },
            });
            throw error;
        }
    }
    /**
     * Fetch historical candle data for charting
     * Handles full orchestration: tracing, error logging, state management, and provider delegation
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.symbol - The trading pair symbol.
     * @param options.interval - The candle interval period.
     * @param options.limit - Maximum number of items to fetch.
     * @param options.endTime - End timestamp in milliseconds.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async fetchHistoricalCandles(options) {
        const { provider, symbol, interval, limit = 100, endTime, context, } = options;
        const traceId = uuidv4();
        let traceData;
        try {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.trace({
                name: PerpsTraceNames.FetchHistoricalCandles,
                id: traceId,
                op: PerpsTraceOperations.Operation,
                tags: {
                    provider: context.tracingContext.provider,
                    isTestnet: String(context.tracingContext.isTestnet),
                    symbol,
                    interval,
                },
            });
            // Check if provider supports historical candles via clientService
            const hyperLiquidProvider = provider;
            if (!hyperLiquidProvider.clientService?.fetchHistoricalCandles) {
                throw new Error('Historical candles not supported by provider');
            }
            const result = await hyperLiquidProvider.clientService.fetchHistoricalCandles({
                symbol,
                interval,
                limit,
                endTime,
            });
            traceData = { success: true };
            return result;
        }
        catch (error) {
            const errorMessage = error instanceof Error
                ? error.message
                : 'Failed to fetch historical candles';
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.fetchHistoricalCandles'), {
                tags: {
                    feature: PERPS_CONSTANTS.FeatureName,
                    provider: context.tracingContext.provider,
                    network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',
                },
                context: {
                    name: context.errorContext.controller,
                    data: {
                        method: context.errorContext.method,
                        symbol,
                        interval,
                        limit,
                        endTime,
                    },
                },
            });
            // Update error state (if stateManager is provided)
            if (context.stateManager) {
                context.stateManager.update((state) => {
                    state.lastError = errorMessage;
                    state.lastUpdateTimestamp = Date.now();
                });
            }
            traceData = {
                success: false,
                error: errorMessage,
            };
            throw error;
        }
        finally {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").tracer.endTrace({
                name: PerpsTraceNames.FetchHistoricalCandles,
                id: traceId,
                data: traceData,
            });
        }
    }
    /**
     * Calculate liquidation price for a position
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async calculateLiquidationPrice(options) {
        const { provider, params } = options;
        try {
            return await provider.calculateLiquidationPrice(params);
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.calculateLiquidationPrice'), {
                context: {
                    name: 'MarketDataService.calculateLiquidationPrice',
                    data: { params },
                },
            });
            throw error;
        }
    }
    /**
     * Calculate maintenance margin for a position
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async calculateMaintenanceMargin(options) {
        const { provider, params } = options;
        try {
            return await provider.calculateMaintenanceMargin(params);
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.calculateMaintenanceMargin'), {
                context: {
                    name: 'MarketDataService.calculateMaintenanceMargin',
                    data: { params },
                },
            });
            throw error;
        }
    }
    /**
     * Get maximum leverage for an asset
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.asset - The asset identifier.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async getMaxLeverage(options) {
        const { provider, asset } = options;
        try {
            return await provider.getMaxLeverage(asset);
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.getMaxLeverage'), {
                context: {
                    name: 'MarketDataService.getMaxLeverage',
                    data: { asset },
                },
            });
            throw error;
        }
    }
    /**
     * Calculate fees for an order
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async calculateFees(options) {
        const { provider, params } = options;
        try {
            return await provider.calculateFees(params);
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.calculateFees'), {
                context: {
                    name: 'MarketDataService.calculateFees',
                    data: { params },
                },
            });
            throw error;
        }
    }
    /**
     * Validate an order before placement
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async validateOrder(options) {
        const { provider, params } = options;
        try {
            return await provider.validateOrder(params);
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.validateOrder'), {
                context: {
                    name: 'MarketDataService.validateOrder',
                    data: { params },
                },
            });
            throw error;
        }
    }
    /**
     * Validate a position close request
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.params - The operation parameters.
     * @param options.context - The service context for dependencies.
     * @returns The result of the operation.
     */
    async validateClosePosition(options) {
        const { provider, params } = options;
        try {
            return await provider.validateClosePosition(params);
        }
        catch (error) {
            __classPrivateFieldGet(this, _MarketDataService_deps, "f").logger.error(ensureError(error, 'MarketDataService.validateClosePosition'), {
                context: {
                    name: 'MarketDataService.validateClosePosition',
                    data: { params },
                },
            });
            throw error;
        }
    }
    /**
     * Get supported withdrawal routes (synchronous)
     * Note: This method doesn't log errors to avoid needing context for a synchronous getter
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @returns The result of the operation.
     */
    getWithdrawalRoutes(options) {
        const { provider } = options;
        try {
            return provider.getWithdrawalRoutes();
        }
        catch {
            // Silent fail - withdrawal routes are not critical
            return [];
        }
    }
    /**
     * Get block explorer URL (synchronous)
     *
     * @param options - The configuration options.
     * @param options.provider - The perps provider instance.
     * @param options.address - The wallet address.
     * @returns The result of the operation.
     */
    getBlockExplorerUrl(options) {
        const { provider, address } = options;
        return provider.getBlockExplorerUrl(address);
    }
}
_MarketDataService_deps = new WeakMap();
//# sourceMappingURL=MarketDataService.mjs.map