@olympex-io/olympex-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/errors/base-error.ts","../src/errors/graphql-error.ts","../src/errors/network-error.ts","../src/errors/redact.ts","../src/client/request-signing.ts","../src/client/graphql-client.ts","../src/errors/config-error.ts","../src/fees/validation.ts","../src/fees/constants.ts","../src/config/backend-url.ts","../src/methods/account.ts","../src/methods/get-version.ts","../src/errors/domain-error.ts","../src/client/domain-response.ts","../src/fees/defaults.ts","../src/fees/serialize.ts","../src/graphql/operations.ts","../src/methods/quote.ts","../src/methods/support-chain.ts","../src/methods/swap.ts","../src/methods/tx-status.ts","../src/config/initialize.ts","../src/logging/console-logger.ts","../src/errors/not-implemented-error.ts"],"sourcesContent":["export { initialize } from './config/initialize.js';\nexport { createConsoleLogger } from './logging/console-logger.js';\nexport { getVersion } from './methods/get-version.js';\nexport { createAccount } from './methods/account.js';\nexport { OlympexSdkError } from './errors/base-error.js';\nexport { OlympexConfigError } from './errors/config-error.js';\nexport { OlympexDomainError } from './errors/domain-error.js';\nexport { OlympexGraphQLError } from './errors/graphql-error.js';\nexport { OlympexNetworkError } from './errors/network-error.js';\nexport { OlympexNotImplementedError } from './errors/not-implemented-error.js';\nexport type {\n CreateAccountInput,\n CreateAccountOptions,\n CreateAccountResponse,\n CrossChainQuote,\n CrossChainQuoteInput,\n CrossChainRouteAsset,\n CrossChainRouteAssetPair,\n CrossChainSwap,\n CrossChainSwapInput,\n DataFeeTransaction,\n FeeOptions,\n GasMultiplier,\n InitializeOptions,\n LogLevel,\n OlympexClient,\n OlympexLogger,\n QuoteDex,\n QuoteMarket,\n QuoteOrderBy,\n QuoteRequest,\n QuoteResult,\n QuoteRoute,\n QuoteSubRoute,\n SingleChainQuote,\n SingleChainQuoteInput,\n SingleChainSwap,\n SingleChainSwapInput,\n SwapRequest,\n SwapResult,\n TxStatus,\n TxStatusInput,\n} from './types/public.js';\n","/**\n * Base error for all SDK-thrown failures. Subclasses map to specific failure modes.\n *\n * @remarks Every SDK error exposes a stable `code` string and optional `metadata`.\n * Catch by `instanceof` or compare `error.code` for transport-agnostic handling.\n * See {@link OlympexConfigError}, {@link OlympexDomainError}, {@link OlympexGraphQLError},\n * {@link OlympexNetworkError}, and {@link OlympexNotImplementedError}.\n *\n * @example\n * ```ts\n * import {\n * OlympexSdkError,\n * OlympexConfigError,\n * OlympexDomainError,\n * } from '@olympex-io/olympex-sdk';\n *\n * try {\n * await client.quote({ mode: 'single-chain', params: { ... } });\n * } catch (error) {\n * if (error instanceof OlympexConfigError) {\n * console.error('Invalid input:', error.code, error.message);\n * } else if (error instanceof OlympexDomainError) {\n * console.error('Backend rejected:', error.code, error.metadata);\n * } else if (error instanceof OlympexSdkError) {\n * console.error('SDK error:', error.code);\n * }\n * }\n * ```\n */\nexport class OlympexSdkError extends Error {\n readonly code: string;\n readonly metadata: Record<string, unknown> | undefined;\n\n constructor(message: string, code = 'OLYMPEX_SDK_ERROR', metadata?: Record<string, unknown>) {\n super(message);\n this.name = new.target.name;\n this.code = code;\n this.metadata = metadata;\n }\n}\n","import { OlympexSdkError } from './base-error.js';\n\n/**\n * Thrown when the GraphQL response contains an `errors[]` array on an otherwise successful HTTP 200.\n *\n * @remarks Extends {@link OlympexSdkError}. Distinct from {@link OlympexNetworkError} — the\n * transport succeeded but the GraphQL layer reported execution or validation failures.\n *\n * @see docs/errors.md\n */\nexport class OlympexGraphQLError extends OlympexSdkError {\n constructor(message: string, metadata?: Record<string, unknown>) {\n super(message, 'OLYMPEX_GRAPHQL_ERROR', metadata);\n }\n}\n","import { OlympexSdkError } from './base-error.js';\n\n/**\n * Thrown on network failures: timeouts, fetch errors, or non-2xx HTTP responses.\n *\n * @remarks Extends {@link OlympexSdkError}. Retry logic should consider exponential backoff;\n * inspect `error.metadata` for status codes when available.\n *\n * @see docs/errors.md\n */\nexport class OlympexNetworkError extends OlympexSdkError {\n constructor(message: string, metadata?: Record<string, unknown>) {\n super(message, 'OLYMPEX_NETWORK_ERROR', metadata);\n }\n}\n","const SENSITIVE_KEY_PATTERN = /api[-_]?key|authorization|cookie|token|secret|password/i;\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function redact<T extends Record<string, unknown>>(value: T): T;\nexport function redact(value: unknown): unknown;\nexport function redact(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => redact(item));\n }\n\n if (!isPlainObject(value)) {\n return value;\n }\n\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [\n key,\n SENSITIVE_KEY_PATTERN.test(key) ? '<REDACTED>' : redact(entry),\n ]),\n );\n}\n","import crypto from 'crypto';\n\nexport interface BuildSignedHeadersInput {\n readonly apiKey: string;\n readonly apiSecret: string;\n readonly passphrase: string;\n readonly body: string;\n readonly timestamp?: string;\n readonly nonce?: string;\n}\n\nexport interface SignedHeaders {\n readonly 'x-api-key-id': string;\n readonly 'x-value-info': string;\n readonly 'x-passphrase': string;\n readonly 'x-signature': string;\n}\n\ninterface SignInput {\n readonly message: string;\n readonly secret: string;\n}\n\n// TODO: esto está duplicado en accounts.ts \"repositorio de backend\" evaluar de movelor a un paquete shared npm\nexport function generateBodySignature(body: string): string {\n const hashBuffer = crypto.createHash('sha256').update(body).digest();\n return hashBuffer.toString('base64url');\n}\n\n// TODO: esto está duplicado en accounts.ts \"repositorio de backend\" evaluar de movelor a un paquete shared npm\nfunction getTimestamp(): string {\n return Math.floor(Date.now() / 1000).toString();\n}\n\n// TODO: esto está duplicado en accounts.ts \"repositorio de backend\" evaluar de movelor a un paquete shared npm\nfunction generateNonce(): string {\n return crypto.randomBytes(12).toString('hex');\n}\n\n// TODO: esto está duplicado en accounts.ts \"repositorio de backend\" evaluar de movelor a un paquete shared npm\nfunction sign({ message, secret }: SignInput): string {\n return crypto.createHmac('sha256', secret).update(message).digest('hex');\n}\n\nexport function buildSignedHeaders({\n apiKey,\n apiSecret,\n passphrase,\n body,\n timestamp,\n nonce,\n}: BuildSignedHeadersInput): SignedHeaders {\n const bodyHash = generateBodySignature(body);\n const resolvedTimestamp = timestamp ?? getTimestamp();\n const resolvedNonce = nonce ?? generateNonce();\n const message = `${resolvedTimestamp}\\n${resolvedNonce}\\n${bodyHash}`;\n const headerData = Buffer.from(message).toString('base64');\n\n return {\n 'x-api-key-id': apiKey,\n 'x-value-info': headerData,\n 'x-passphrase': passphrase,\n 'x-signature': sign({ message, secret: apiSecret }),\n };\n}\n","import { OlympexGraphQLError } from '../errors/graphql-error.js';\nimport { OlympexNetworkError } from '../errors/network-error.js';\nimport { redact } from '../errors/redact.js';\nimport type { OlympexLogger } from '../types/public.js';\nimport { buildSignedHeaders } from './request-signing.js';\n\ninterface GraphQLErrorPayload {\n readonly message: string;\n readonly extensions?: Record<string, unknown>;\n readonly path?: readonly (string | number)[];\n}\n\ninterface GraphQLResponse<TData> {\n readonly data?: TData;\n readonly errors?: readonly GraphQLErrorPayload[];\n}\n\nexport interface GraphQLClientOptions {\n readonly apiKey: string;\n readonly apiSecret: string;\n readonly passphrase: string;\n readonly endpoint: string;\n readonly headers?: Record<string, string> | undefined;\n readonly logger?: OlympexLogger | undefined;\n readonly timeoutMs: number;\n}\n\nexport class OlympexGraphQLClient {\n private readonly apiKey: string;\n private readonly apiSecret: string;\n private readonly passphrase: string;\n private readonly endpoint: string;\n private readonly headers: Record<string, string>;\n private readonly logger: OlympexLogger | undefined;\n private readonly timeoutMs: number;\n\n constructor(options: GraphQLClientOptions) {\n this.apiKey = options.apiKey;\n this.apiSecret = options.apiSecret;\n this.passphrase = options.passphrase;\n this.endpoint = options.endpoint;\n this.headers = options.headers ?? {};\n this.logger = options.logger;\n this.timeoutMs = options.timeoutMs;\n }\n\n async request<TData, TVariables extends object>(\n document: string,\n variables: TVariables,\n ): Promise<TData> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n\n try {\n this.logger?.log(\n 'debug',\n 'Sending Olympex GraphQL request',\n redact({\n endpoint: this.endpoint,\n variables,\n }),\n );\n\n const bodyToFetch = JSON.stringify({ query: document, variables });\n const signedHeaders = buildSignedHeaders({\n apiKey: this.apiKey,\n apiSecret: this.apiSecret,\n body: bodyToFetch,\n passphrase: this.passphrase,\n });\n\n const response = await fetch(this.endpoint, {\n body: bodyToFetch,\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n ...this.headers,\n ...signedHeaders,\n },\n method: 'POST',\n signal: controller.signal,\n });\n\n let body: GraphQLResponse<TData>;\n try {\n body = (await response.json()) as GraphQLResponse<TData>;\n } catch {\n this.logger?.log(\n 'error',\n 'Olympex GraphQL response was not valid JSON',\n redact({\n contentType: response.headers.get('content-type') ?? undefined,\n endpoint: this.endpoint,\n status: response.status,\n }),\n );\n throw new OlympexNetworkError('GraphQL response was not valid JSON', {\n contentType: response.headers.get('content-type') ?? undefined,\n status: response.status,\n statusText: response.statusText,\n });\n }\n\n if (!response.ok) {\n this.logger?.log(\n 'error',\n 'Olympex GraphQL request failed with HTTP status',\n redact({\n endpoint: this.endpoint,\n status: response.status,\n statusText: response.statusText,\n }),\n );\n throw new OlympexNetworkError(`GraphQL request failed with status ${response.status}`, {\n status: response.status,\n statusText: response.statusText,\n });\n }\n\n if (body?.errors?.length) {\n const firstError = body.errors[0];\n this.logger?.log(\n 'warn',\n 'Olympex GraphQL response contains errors',\n redact({\n endpoint: this.endpoint,\n errorCount: body.errors.length,\n extensions: firstError?.extensions,\n firstMessage: firstError?.message,\n }),\n );\n throw new OlympexGraphQLError(body.errors[0]?.message ?? 'GraphQL request failed', {\n errors: body.errors.map((error) => ({\n extensions: error.extensions,\n message: error.message,\n path: error.path,\n })),\n });\n }\n\n if (!body?.data) {\n throw new OlympexGraphQLError('GraphQL response did not include data');\n }\n\n return body.data;\n } catch (error) {\n if (error instanceof OlympexGraphQLError || error instanceof OlympexNetworkError) {\n throw error;\n }\n\n const errorName = error instanceof Error ? error.name : 'UnknownError';\n const errorMessage = error instanceof Error ? error.message : 'Unknown network error';\n this.logger?.log(\n 'error',\n 'Olympex GraphQL network failure',\n redact({\n endpoint: this.endpoint,\n errorMessage,\n errorName,\n }),\n );\n throw new OlympexNetworkError(errorMessage);\n } finally {\n clearTimeout(timeout);\n }\n }\n}\n","import { OlympexSdkError } from './base-error.js';\n\n/**\n * Thrown when SDK configuration or caller input fails local validation before a network call.\n *\n * @remarks Extends {@link OlympexSdkError}. Safe to catch by `instanceof` or `error.code`\n * (`OLYMPEX_CONFIG_ERROR`). Examples: empty `apiKey`, invalid `OLYMPEX_BACKEND_URL`, invalid\n * {@link FeeOptions.feeBps | feeBps}.\n *\n * @see docs/errors.md\n */\nexport class OlympexConfigError extends OlympexSdkError {\n constructor(message: string, metadata?: Record<string, unknown>) {\n super(message, 'OLYMPEX_CONFIG_ERROR', metadata);\n }\n}\n","import { isAddress } from 'ethers';\nimport { OlympexConfigError } from '../errors/config-error.js';\nimport type { FeeOptions } from '../types/public.js';\nimport { FEE_BPS_MAX, FEE_BPS_MIN } from './constants.js';\n\nexport function validateFeeOptions(fees: FeeOptions | undefined): void {\n if (!fees) {\n return;\n }\n\n if (fees.feeBps !== undefined) {\n if (!Number.isFinite(fees.feeBps) || fees.feeBps < FEE_BPS_MIN || fees.feeBps > FEE_BPS_MAX) {\n throw new OlympexConfigError(`feeBps must be between ${FEE_BPS_MIN} and ${FEE_BPS_MAX}`);\n }\n }\n\n if (fees.feeRecipient !== undefined && !isAddress(fees.feeRecipient)) {\n throw new OlympexConfigError('feeRecipient must be a valid Ethereum address');\n }\n}\n","export const FEE_BPS_MIN = 0;\nexport const FEE_BPS_MAX = 100;\n","import { OlympexConfigError } from '../errors/config-error.js';\n\nexport const DEFAULT_BACKEND_URL = 'https://back.olympex.io/graphql';\n\nconst BACKEND_URL_ENV = 'OLYMPEX_BACKEND_URL';\nconst GRAPHQL_PATH = '/graphql';\n\nfunction readBackendUrlEnv(): string | undefined {\n const raw = process.env[BACKEND_URL_ENV];\n if (raw === undefined) {\n return undefined;\n }\n\n const trimmed = raw.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction validateBackendUrl(url: string): URL {\n let parsed: URL;\n\n try {\n parsed = new URL(url);\n } catch {\n throw new OlympexConfigError(`Invalid ${BACKEND_URL_ENV}: ${url}`);\n }\n\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new OlympexConfigError(`Invalid ${BACKEND_URL_ENV}: ${url}`);\n }\n\n if (parsed.search || parsed.hash) {\n throw new OlympexConfigError(`Invalid ${BACKEND_URL_ENV}: ${url}`);\n }\n\n const pathname = parsed.pathname.replace(/\\/$/, '') || '/';\n if (pathname !== '/' && pathname !== GRAPHQL_PATH) {\n throw new OlympexConfigError(`Invalid ${BACKEND_URL_ENV}: ${url}`);\n }\n\n return parsed;\n}\n\nexport function normalizeBase(baseUrl: string): string {\n return baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;\n}\n\nfunction toGraphqlEndpoint(url: string): string {\n const parsed = validateBackendUrl(url);\n const pathname = parsed.pathname.replace(/\\/$/, '') || '/';\n\n if (pathname === GRAPHQL_PATH) {\n return `${parsed.origin}${GRAPHQL_PATH}`;\n }\n\n return `${parsed.origin}${GRAPHQL_PATH}`;\n}\n\nexport function resolveBackendBaseUrl(): string {\n const configured = readBackendUrlEnv();\n const candidate = configured ?? DEFAULT_BACKEND_URL;\n return toGraphqlEndpoint(candidate);\n}\n\nexport function getGraphqlEndpoint(): string {\n return normalizeBase(resolveBackendBaseUrl());\n}\n\nexport function getRestBaseUrl(): string {\n const graphqlEndpoint = normalizeBase(resolveBackendBaseUrl());\n\n if (graphqlEndpoint.endsWith(GRAPHQL_PATH)) {\n return graphqlEndpoint.slice(0, -GRAPHQL_PATH.length);\n }\n\n return graphqlEndpoint;\n}\n","import { getRestBaseUrl } from '../config/backend-url.js';\nimport { OlympexConfigError } from '../errors/config-error.js';\nimport { OlympexNetworkError } from '../errors/network-error.js';\nimport type { CreateAccountOptions, CreateAccountResponse } from '../types/public.js';\n\nconst CREATE_ACCOUNT_PATH = '/api/v1/accounts';\n\ninterface CredentialsPayload {\n readonly apiKey: string;\n readonly secretKey: string;\n}\n\nfunction extractCredentials(payload: unknown): CreateAccountResponse | null {\n if (!payload || typeof payload !== 'object') {\n return null;\n }\n\n const directPayload = payload as Record<string, unknown>;\n const candidatePayloads: unknown[] = [directPayload];\n\n if (directPayload.data !== undefined) {\n candidatePayloads.push(directPayload.data);\n }\n\n for (const candidate of candidatePayloads) {\n if (!candidate || typeof candidate !== 'object') {\n continue;\n }\n\n const values = candidate as Partial<CredentialsPayload>;\n if (typeof values.apiKey === 'string' && typeof values.secretKey === 'string') {\n return {\n apiKey: values.apiKey,\n secretKey: values.secretKey,\n };\n }\n }\n\n return null;\n}\n\nfunction parseResponseMessage(payload: unknown): string | undefined {\n if (!payload || typeof payload !== 'object') {\n return undefined;\n }\n\n const maybeMessage = (payload as { message?: unknown }).message;\n return typeof maybeMessage === 'string' ? maybeMessage : undefined;\n}\n\n/**\n * Creates API credentials via public REST onboarding.\n *\n * @remarks Server-side only. Does not require {@link initialize}. Store returned `secretKey`\n * securely; it is shown once by the backend. Backend routing is resolved from\n * `OLYMPEX_BACKEND_URL` at call time.\n * @param options - {@link CreateAccountOptions} with onboarding fields.\n * @returns Fresh {@link CreateAccountResponse} credentials for subsequent {@link initialize}.\n * @throws {OlympexConfigError} When `name` or `password` is empty, or `OLYMPEX_BACKEND_URL` is invalid.\n * @throws {OlympexNetworkError} When REST onboarding fails or omits credentials.\n *\n * @see docs/authentication.md\n */\nexport async function createAccount({\n name,\n password,\n}: CreateAccountOptions): Promise<CreateAccountResponse> {\n const normalizedName = name.trim();\n const normalizedPassword = password.trim();\n\n if (!normalizedName) {\n throw new OlympexConfigError('name is required');\n }\n\n if (!normalizedPassword) {\n throw new OlympexConfigError('password is required');\n }\n\n const endpoint = `${getRestBaseUrl()}${CREATE_ACCOUNT_PATH}`;\n\n const response = await fetch(endpoint, {\n body: JSON.stringify({ name: normalizedName, password: normalizedPassword }),\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n },\n method: 'POST',\n });\n\n let responseBody: unknown;\n try {\n responseBody = await response.json();\n } catch {\n throw new OlympexNetworkError('createAccount response was not valid JSON', {\n contentType: response.headers.get('content-type') ?? undefined,\n endpoint,\n status: response.status,\n statusText: response.statusText,\n });\n }\n\n if (!response.ok) {\n throw new OlympexNetworkError(`createAccount request failed with status ${response.status}`, {\n endpoint,\n responseMessage: parseResponseMessage(responseBody),\n status: response.status,\n statusText: response.statusText,\n });\n }\n\n // TODO: tenemos el control tanto del código del SDK como del backend por lo que podemos\n // hacer que el SDK sepa como extraer las credenciales de la respuesta sin tener una\n // función tna verbosa de manera innecesaria\n const credentials = extractCredentials(responseBody);\n if (!credentials) {\n throw new OlympexNetworkError('createAccount response did not include credentials', {\n endpoint,\n status: response.status,\n });\n }\n\n return credentials;\n}\n","const VERSION = '0.0.0';\n\n/**\n * Returns the SDK package version string (standalone export).\n *\n * @remarks Prefer {@link OlympexClient.getVersion} on an initialized client for the same value.\n * @returns Semantic version of the installed SDK (e.g. `'0.0.0'`).\n *\n * @see docs/getting-started.md\n */\nexport function getVersion(): string {\n return VERSION;\n}\n","import { OlympexSdkError } from './base-error.js';\n\n/**\n * Thrown when the backend returns a domain-level `success: false` response.\n *\n * @remarks Extends {@link OlympexSdkError}. The HTTP request succeeded but the payload\n * indicates a business-rule or validation failure. Inspect `error.message` and `error.metadata`\n * for backend-provided context.\n *\n * @see docs/errors.md\n */\nexport class OlympexDomainError extends OlympexSdkError {\n constructor(message: string, metadata?: Record<string, unknown>) {\n super(message, 'OLYMPEX_DOMAIN_ERROR', metadata);\n }\n}\n","import { OlympexDomainError } from '../errors/domain-error.js';\n\ninterface DomainResponse {\n readonly code?: number;\n readonly message?: string;\n readonly success?: boolean;\n}\n\nexport function requireSuccessfulDomainResponse<TResponse extends DomainResponse>(\n response: TResponse | null | undefined,\n payloadName: string,\n): TResponse {\n if (response === null || response === undefined) {\n throw new OlympexDomainError(`Missing ${payloadName} response`);\n }\n\n if (response.success === false) {\n throw new OlympexDomainError(response.message ?? `${payloadName} failed`, {\n code: response.code,\n success: response.success,\n });\n }\n\n return response;\n}\n\nexport function requirePayload<TPayload>(\n payload: TPayload | null | undefined,\n payloadName: string,\n): TPayload {\n if (payload === null || payload === undefined) {\n throw new OlympexDomainError(`Missing ${payloadName} payload`);\n }\n\n return payload;\n}\n","import type { FeeOptions } from '../types/public.js';\n\nexport function resolveFeeOptions(\n callFees: FeeOptions | undefined,\n clientDefaultFees: FeeOptions | undefined,\n): FeeOptions | undefined {\n if (!callFees && !clientDefaultFees) {\n return undefined;\n }\n\n return {\n ...clientDefaultFees,\n ...callFees,\n };\n}\n","import type { FeeOptions } from '../types/public.js';\n\nexport function serializeFeeOptions(\n fees: FeeOptions | undefined,\n): Record<string, number | string> | undefined {\n if (!fees) {\n return undefined;\n }\n\n const serialized: Record<string, number | string> = {};\n\n if (fees.feeBps !== undefined) {\n serialized.feeBps = fees.feeBps;\n }\n\n if (fees.feeRecipient !== undefined) {\n serialized.feeRecipient = fees.feeRecipient;\n }\n\n return Object.keys(serialized).length > 0 ? serialized : undefined;\n}\n\nexport function mergeParamsWithFees<T extends Record<string, unknown>>(\n params: T,\n fees: FeeOptions | undefined,\n): T {\n const serialized = serializeFeeOptions(fees);\n\n if (!serialized) {\n return params;\n }\n\n return {\n ...params,\n ...serialized,\n };\n}\n","export const GET_ENABLED_CHAINS = /* GraphQL */ `\n query GetEnabledChains {\n getEnabledChains {\n chainIds\n }\n }\n`;\n\nexport const GET_QUOTE = /* GraphQL */ `\n query GetQuote($getQuoteParams: QuoteInput!) {\n getQuote(params: $getQuoteParams) {\n outAmount\n estimatedGas\n aggregatorId\n aggregatorOrder\n market {\n dexName\n swapAmount\n dexImageURL\n }\n routes {\n percentage\n subRoutes {\n from\n to\n dexes {\n name\n percentage\n }\n }\n }\n dataFeeTransaction {\n effectiveGasPrice\n nativePrice\n transactionFee\n transactionFeeInUSD\n tokenPrice\n transactionFeeInTokenIn\n valueToApprove\n }\n gasMultiplier\n }\n }\n`;\n\nexport const GET_QUOTE_SWAP = /* GraphQL */ `\n mutation GetQuoteSwap($getQuoteSwapParams: QuoteSwapInput!) {\n getQuoteSwap(params: $getQuoteSwapParams) {\n code\n message\n quoteSwap {\n data\n estimatedGas\n minOutAmount\n outAmount\n value\n approveTransaction\n }\n success\n }\n }\n`;\n\nexport const GET_CROSS_CHAIN_QUOTE = /* GraphQL */ `\n query GetCrossChainQuote($params: CrossChainQuoteInput!) {\n getCrossChainQuote(params: $params) {\n code\n message\n success\n crossChainQuote {\n aggregatorId\n estimatedGas\n estimatedTime\n estimateCostInUSD\n fromTokenAmount\n toTokenAmount\n minimumReceived\n bridgeInfo {\n icon\n displayName\n }\n middlewareRoute {\n chainFrom {\n fromAsset {\n address\n decimals\n symbol\n }\n toAsset {\n address\n decimals\n symbol\n }\n }\n chainTo {\n fromAsset {\n address\n decimals\n symbol\n }\n toAsset {\n address\n decimals\n symbol\n }\n }\n }\n }\n }\n }\n`;\n\nexport const GET_CROSS_CHAIN_SWAP = /* GraphQL */ `\n mutation GetCrossChainSwap($params: CrossChainSwapInput!) {\n getCrossChainSwap(params: $params) {\n code\n message\n success\n crossChainSwap {\n calldata\n value\n approveTransaction\n dexHash\n }\n }\n }\n`;\n\nexport const GET_CROSS_CHAIN_TX_STATUS = /* GraphQL */ `\n query GetCrossChainTxStatus($hash: String!, $chainId: String!, $dexHash: String!) {\n getCrossChainTxStatus(txHash: $hash, chainId: $chainId, dexHash: $dexHash) {\n message\n success\n txStatus {\n toChainId\n fromChainId\n detailStatus\n status\n }\n }\n }\n`;\n","import type { OlympexGraphQLClient } from '../client/graphql-client.js';\nimport { requirePayload, requireSuccessfulDomainResponse } from '../client/domain-response.js';\nimport { redact } from '../errors/redact.js';\nimport { resolveFeeOptions } from '../fees/defaults.js';\nimport { mergeParamsWithFees } from '../fees/serialize.js';\nimport { validateFeeOptions } from '../fees/validation.js';\nimport type { FeeOptions, OlympexLogger } from '../types/public.js';\nimport { GET_CROSS_CHAIN_QUOTE, GET_QUOTE } from '../graphql/operations.js';\nimport type {\n CrossChainQuote,\n QuoteRequest,\n QuoteResult,\n SingleChainQuote,\n} from '../types/public.js';\n\ninterface SingleChainQuoteData {\n readonly getQuote?: SingleChainQuote | null;\n}\n\ninterface CrossChainQuoteData {\n readonly getCrossChainQuote?: {\n readonly code: number;\n readonly message: string;\n readonly success: boolean;\n readonly crossChainQuote?: CrossChainQuote | null;\n } | null;\n}\n\nexport function createQuoteMethod(\n graphqlClient: OlympexGraphQLClient,\n defaultFees: FeeOptions | undefined,\n logger?: OlympexLogger,\n) {\n return async function quote(input: QuoteRequest): Promise<QuoteResult> {\n const fees = resolveFeeOptions(input.fees, defaultFees);\n validateFeeOptions(fees);\n\n if (input.mode === 'single-chain') {\n logger?.log(\n 'info',\n 'Olympex quote requested',\n redact({\n chainId: input.params.chainId,\n mode: 'single-chain',\n }),\n );\n\n const data = await graphqlClient.request<SingleChainQuoteData, Record<string, unknown>>(\n GET_QUOTE,\n {\n getQuoteParams: mergeParamsWithFees(input.params, fees),\n },\n );\n\n return {\n mode: 'single-chain',\n quote: requirePayload(data.getQuote, 'getQuote'),\n };\n }\n\n logger?.log(\n 'info',\n 'Olympex quote requested',\n redact({\n fromChainId: input.params.fromChainId,\n mode: 'cross-chain',\n toChainId: input.params.toChainId,\n }),\n );\n\n const data = await graphqlClient.request<CrossChainQuoteData, Record<string, unknown>>(\n GET_CROSS_CHAIN_QUOTE,\n {\n params: mergeParamsWithFees(input.params, fees),\n },\n );\n const response = requireSuccessfulDomainResponse(data.getCrossChainQuote, 'getCrossChainQuote');\n\n return {\n mode: 'cross-chain',\n quote: requirePayload(response.crossChainQuote, 'crossChainQuote'),\n };\n };\n}\n","import type { OlympexGraphQLClient } from '../client/graphql-client.js';\nimport { requirePayload } from '../client/domain-response.js';\nimport { GET_ENABLED_CHAINS } from '../graphql/operations.js';\n\ninterface EnabledChainsData {\n readonly getEnabledChains?: {\n readonly chainIds: readonly string[];\n } | null;\n}\n\nexport function createSupportChainMethod(graphqlClient: OlympexGraphQLClient) {\n return async function supportChain(chainId: string | number): Promise<boolean> {\n const data = await graphqlClient.request<EnabledChainsData, Record<string, never>>(\n GET_ENABLED_CHAINS,\n {},\n );\n const enabledChains = requirePayload(data.getEnabledChains, 'getEnabledChains');\n\n return enabledChains.chainIds.includes(String(chainId));\n };\n}\n","import type { OlympexGraphQLClient } from '../client/graphql-client.js';\nimport { requirePayload, requireSuccessfulDomainResponse } from '../client/domain-response.js';\nimport { redact } from '../errors/redact.js';\nimport { resolveFeeOptions } from '../fees/defaults.js';\nimport { mergeParamsWithFees } from '../fees/serialize.js';\nimport { validateFeeOptions } from '../fees/validation.js';\nimport type { FeeOptions, OlympexLogger } from '../types/public.js';\nimport { GET_CROSS_CHAIN_SWAP, GET_QUOTE_SWAP } from '../graphql/operations.js';\nimport type { CrossChainSwap, SingleChainSwap, SwapRequest, SwapResult } from '../types/public.js';\n\ninterface SingleChainSwapData {\n readonly getQuoteSwap?: {\n readonly code: number;\n readonly message: string;\n readonly quoteSwap?: SingleChainSwap | null;\n readonly success: boolean;\n } | null;\n}\n\ninterface CrossChainSwapData {\n readonly getCrossChainSwap?: {\n readonly code: number;\n readonly message: string;\n readonly success: boolean;\n readonly crossChainSwap?: CrossChainSwap | null;\n } | null;\n}\n\nexport function createSwapMethod(\n graphqlClient: OlympexGraphQLClient,\n defaultFees: FeeOptions | undefined,\n logger?: OlympexLogger,\n) {\n return async function swap(input: SwapRequest): Promise<SwapResult> {\n const fees = resolveFeeOptions(input.fees, defaultFees);\n validateFeeOptions(fees);\n\n if (input.mode === 'single-chain') {\n logger?.log(\n 'info',\n 'Olympex swap requested',\n redact({\n chainId: input.params.chainId,\n mode: 'single-chain',\n }),\n );\n\n const data = await graphqlClient.request<SingleChainSwapData, Record<string, unknown>>(\n GET_QUOTE_SWAP,\n {\n getQuoteSwapParams: mergeParamsWithFees(input.params, fees),\n },\n );\n const response = requireSuccessfulDomainResponse(data.getQuoteSwap, 'getQuoteSwap');\n\n return {\n mode: 'single-chain',\n swap: requirePayload(response.quoteSwap, 'quoteSwap'),\n };\n }\n\n logger?.log(\n 'info',\n 'Olympex swap requested',\n redact({\n fromChainId: input.params.fromChainId,\n mode: 'cross-chain',\n toChainId: input.params.toChainId,\n }),\n );\n\n const data = await graphqlClient.request<CrossChainSwapData, Record<string, unknown>>(\n GET_CROSS_CHAIN_SWAP,\n {\n params: mergeParamsWithFees(input.params, fees),\n },\n );\n const response = requireSuccessfulDomainResponse(data.getCrossChainSwap, 'getCrossChainSwap');\n\n return {\n mode: 'cross-chain',\n swap: requirePayload(response.crossChainSwap, 'crossChainSwap'),\n };\n };\n}\n","import type { OlympexGraphQLClient } from '../client/graphql-client.js';\nimport { requirePayload, requireSuccessfulDomainResponse } from '../client/domain-response.js';\nimport { GET_CROSS_CHAIN_TX_STATUS } from '../graphql/operations.js';\nimport type { TxStatus, TxStatusInput } from '../types/public.js';\n\ninterface TxStatusData {\n readonly getCrossChainTxStatus?: {\n readonly message: string;\n readonly success: boolean;\n readonly txStatus?: TxStatus | null;\n } | null;\n}\n\nexport function createTxStatusMethod(graphqlClient: OlympexGraphQLClient) {\n return async function txStatus(input: TxStatusInput): Promise<TxStatus> {\n const data = await graphqlClient.request<TxStatusData, TxStatusInput>(\n GET_CROSS_CHAIN_TX_STATUS,\n input,\n );\n const response = requireSuccessfulDomainResponse(\n data.getCrossChainTxStatus,\n 'getCrossChainTxStatus',\n );\n\n return requirePayload(response.txStatus, 'txStatus');\n };\n}\n","import { OlympexGraphQLClient } from '../client/graphql-client.js';\nimport { OlympexConfigError } from '../errors/config-error.js';\nimport { validateFeeOptions } from '../fees/validation.js';\nimport { createAccount } from '../methods/account.js';\nimport { getVersion } from '../methods/get-version.js';\nimport { createQuoteMethod } from '../methods/quote.js';\nimport { createSupportChainMethod } from '../methods/support-chain.js';\nimport { createSwapMethod } from '../methods/swap.js';\nimport { createTxStatusMethod } from '../methods/tx-status.js';\nimport type { InitializeOptions, OlympexClient } from '../types/public.js';\nimport { getGraphqlEndpoint } from './backend-url.js';\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\n/**\n * Creates an {@link OlympexClient} bound to an API key.\n *\n * @remarks Logging is silent-by-default unless {@link InitializeOptions.logger} is provided.\n * Fee defaults in `defaultFees` are validated locally then forwarded to the backend.\n * Backend routing is resolved from `OLYMPEX_BACKEND_URL` at call time.\n * @param options - {@link InitializeOptions} configuration.\n * @returns Configured {@link OlympexClient} ready for quote, swap, and status calls.\n * @throws {OlympexConfigError} When auth credentials are empty, `OLYMPEX_BACKEND_URL` is invalid, or `defaultFees` fail validation.\n *\n * @example Minimal bootstrap\n * ```ts\n * import { initialize } from '@olympex-io/olympex-sdk';\n *\n * const client = initialize({\n * apiKey: process.env.OLYMPEX_API_KEY!,\n * apiSecret: process.env.OLYMPEX_API_SECRET!,\n * passphrase: process.env.OLYMPEX_PASSPHRASE!,\n * });\n * ```\n *\n * @example With opt-in console logging\n * ```ts\n * import { initialize, createConsoleLogger } from '@olympex-io/olympex-sdk';\n *\n * const client = initialize({\n * apiKey: process.env.OLYMPEX_API_KEY!,\n * apiSecret: process.env.OLYMPEX_API_SECRET!,\n * passphrase: process.env.OLYMPEX_PASSPHRASE!,\n * logger: createConsoleLogger({ minLevel: 'debug' }),\n * });\n * ```\n *\n * @see docs/getting-started.md\n */\nexport function initialize(options: InitializeOptions): OlympexClient {\n const apiKey = options.apiKey.trim();\n const apiSecret = options.apiSecret.trim();\n const passphrase = options.passphrase.trim();\n\n if (!apiKey) {\n throw new OlympexConfigError('apiKey is required');\n }\n\n if (!apiSecret) {\n throw new OlympexConfigError('apiSecret is required');\n }\n\n if (!passphrase) {\n throw new OlympexConfigError('passphrase is required');\n }\n\n validateFeeOptions(options.defaultFees);\n\n const graphqlClient = new OlympexGraphQLClient({\n apiKey,\n apiSecret,\n endpoint: getGraphqlEndpoint(),\n headers: options.headers,\n logger: options.logger,\n passphrase,\n timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n });\n\n return {\n apiKey,\n createAccount,\n getVersion,\n quote: createQuoteMethod(graphqlClient, options.defaultFees, options.logger),\n supportChain: createSupportChainMethod(graphqlClient),\n swap: createSwapMethod(graphqlClient, options.defaultFees, options.logger),\n txStatus: createTxStatusMethod(graphqlClient),\n };\n}\n","import type { LogLevel, OlympexLogger } from '../types/public.js';\n\nconst LEVEL_RANK: Record<LogLevel, number> = {\n debug: 10,\n info: 20,\n warn: 30,\n error: 40,\n};\n\n/**\n * Options for {@link createConsoleLogger}.\n *\n * @property minLevel - Minimum {@link LogLevel} to emit; defaults to `'info'`.\n */\nexport interface CreateConsoleLoggerOptions {\n readonly minLevel?: LogLevel;\n}\n\n/**\n * Returns a safe {@link OlympexLogger} that writes to `console` at the configured minimum level.\n *\n * @remarks Implementations never throw. Messages below `minLevel` are filtered out.\n * @param options - Optional {@link CreateConsoleLoggerOptions}; `minLevel` defaults to `'info'`.\n * @returns Frozen {@link OlympexLogger} suitable for {@link InitializeOptions.logger}.\n *\n * @example\n * ```ts\n * import { createConsoleLogger } from '@olympex-io/olympex-sdk';\n *\n * const logger = createConsoleLogger({ minLevel: 'warn' });\n * logger.log('info', 'filtered out');\n * logger.log('warn', 'visible', { requestId: 'abc' });\n * ```\n *\n * @see docs/logging.md\n */\nexport function createConsoleLogger(options: CreateConsoleLoggerOptions = {}): OlympexLogger {\n const minRank = LEVEL_RANK[options.minLevel ?? 'info'];\n\n const target = (level: LogLevel): ((...args: unknown[]) => void) => {\n const method = globalThis.console[level];\n return typeof method === 'function'\n ? method.bind(globalThis.console)\n : globalThis.console.log.bind(globalThis.console);\n };\n\n return Object.freeze({\n log(level: LogLevel, message: string, metadata?: Record<string, unknown>) {\n if (LEVEL_RANK[level] < minRank) {\n return;\n }\n\n try {\n const write = target(level);\n if (metadata === undefined) {\n write(message);\n } else {\n write(message, metadata);\n }\n } catch {\n /* logging must never throw */\n }\n },\n });\n}\n","import { OlympexSdkError } from './base-error.js';\n\n/**\n * Thrown when a public method is not yet backed by a live backend contract.\n *\n * @remarks Extends {@link OlympexSdkError}. Use when exposing explicitly unsupported\n * temporary paths while backend contracts are still in progress.\n *\n * @see docs/errors.md\n */\nexport class OlympexNotImplementedError extends OlympexSdkError {\n constructor(message: string, metadata?: Record<string, unknown>) {\n super(message, 'OLYMPEX_NOT_IMPLEMENTED', metadata);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,OAAO,qBAAqB,UAAoC;AAC3F,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AACvB,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;;;AC7BO,IAAM,sBAAN,cAAkC,gBAAgB;AAAA,EACvD,YAAY,SAAiB,UAAoC;AAC/D,UAAM,SAAS,yBAAyB,QAAQ;AAAA,EAClD;AACF;;;ACJO,IAAM,sBAAN,cAAkC,gBAAgB;AAAA,EACvD,YAAY,SAAiB,UAAoC;AAC/D,UAAM,SAAS,yBAAyB,QAAQ;AAAA,EAClD;AACF;;;ACdA,IAAM,wBAAwB;AAE9B,SAAS,cAAc,OAAkD;AACvE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAIO,SAAS,OAAO,OAAyB;AAC9C,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC;AAAA,EACzC;AAEA,MAAI,CAAC,cAAc,KAAK,GAAG;AACzB,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