@dimes-dot-fi/sdk 2.2.0 → 2.4.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.
Files changed (48) hide show
  1. package/dist/{aliases-RwEPSZoO.d.cts → aliases-Dne14KBa.d.cts} +40 -16
  2. package/dist/{aliases-RwEPSZoO.d.ts → aliases-Dne14KBa.d.ts} +40 -16
  3. package/dist/{chunk-5VHDXPRV.mjs → chunk-7SGBJTUW.mjs} +2 -2
  4. package/dist/{chunk-7SAMK7CS.cjs → chunk-IZI65LZF.cjs} +5 -5
  5. package/dist/{chunk-7SAMK7CS.cjs.map → chunk-IZI65LZF.cjs.map} +1 -1
  6. package/dist/{chunk-72LTVPD2.cjs → chunk-KNGEIWFR.cjs} +6 -2
  7. package/dist/chunk-KNGEIWFR.cjs.map +1 -0
  8. package/dist/{chunk-PZCBUVPD.mjs → chunk-LXZAXWLO.mjs} +6 -2
  9. package/dist/{chunk-PZCBUVPD.mjs.map → chunk-LXZAXWLO.mjs.map} +1 -1
  10. package/dist/{chunk-T67Z74J3.mjs → chunk-Q34TMZ5J.mjs} +2 -2
  11. package/dist/{chunk-PK2PRTQW.mjs → chunk-TYR33WJW.mjs} +9 -4
  12. package/dist/chunk-TYR33WJW.mjs.map +1 -0
  13. package/dist/{chunk-FAW2C5AM.cjs → chunk-UPNJRN65.cjs} +4 -4
  14. package/dist/{chunk-FAW2C5AM.cjs.map → chunk-UPNJRN65.cjs.map} +1 -1
  15. package/dist/{chunk-53U53KZ2.cjs → chunk-UYDXDYEP.cjs} +9 -4
  16. package/dist/chunk-UYDXDYEP.cjs.map +1 -0
  17. package/dist/contract/index.cjs +13 -13
  18. package/dist/contract/index.d.cts +3 -3
  19. package/dist/contract/index.d.ts +3 -3
  20. package/dist/contract/index.mjs +1 -1
  21. package/dist/{dimes-client-CK7WmY0g.d.cts → dimes-client-D9tohawC.d.cts} +1 -1
  22. package/dist/{dimes-client-BLTd5GkU.d.ts → dimes-client-DJ1d_p31.d.ts} +1 -1
  23. package/dist/{dimes-error-CU1Ob_ed.d.cts → dimes-error-E9yPAZb-.d.cts} +1 -1
  24. package/dist/{dimes-error-DBT1WPVq.d.ts → dimes-error-hSoOierP.d.ts} +1 -1
  25. package/dist/index.cjs +9 -9
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +7 -7
  28. package/dist/index.d.ts +7 -7
  29. package/dist/index.mjs +5 -5
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/{quote-D34eTxx3.d.ts → quote-D4QunMtN.d.ts} +2 -2
  32. package/dist/{quote-CPl9ceZ3.d.cts → quote-sWguOcoJ.d.cts} +2 -2
  33. package/dist/react/index.cjs +11 -11
  34. package/dist/react/index.d.cts +4 -4
  35. package/dist/react/index.d.ts +4 -4
  36. package/dist/react/index.mjs +4 -4
  37. package/dist/{types-Bf10ReSH.d.ts → types-BHU4Qq7e.d.ts} +6 -3
  38. package/dist/{types-CL4jY3Gp.d.cts → types-Bvj_WDbX.d.cts} +6 -3
  39. package/dist/ws/index.cjs +3 -3
  40. package/dist/ws/index.d.cts +3 -3
  41. package/dist/ws/index.d.ts +3 -3
  42. package/dist/ws/index.mjs +2 -2
  43. package/package.json +1 -1
  44. package/dist/chunk-53U53KZ2.cjs.map +0 -1
  45. package/dist/chunk-72LTVPD2.cjs.map +0 -1
  46. package/dist/chunk-PK2PRTQW.mjs.map +0 -1
  47. /package/dist/{chunk-5VHDXPRV.mjs.map → chunk-7SGBJTUW.mjs.map} +0 -0
  48. /package/dist/{chunk-T67Z74J3.mjs.map → chunk-Q34TMZ5J.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/parse.ts","../src/utils/format.ts","../src/errors/error-messages.ts","../src/errors/dimes-error.ts"],"sourcesContent":["export type Params = Record<string, unknown> | null;\n\nexport function asNumber(value: unknown): number | null {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n if (typeof value === \"string\" && value.trim() !== \"\") {\n const parsed = Number(value);\n if (Number.isFinite(parsed)) {\n return parsed;\n }\n }\n return null;\n}\n\nexport function asBigInt(value: unknown): bigint | null {\n if (typeof value === \"bigint\") {\n return value;\n }\n if (typeof value === \"string\" && /^-?\\d+$/.test(value.trim())) {\n return BigInt(value.trim());\n }\n if (typeof value === \"number\" && Number.isInteger(value)) {\n return BigInt(value);\n }\n return null;\n}\n\nexport function getParam(params: Params, key: string): unknown {\n return params ? params[key] : undefined;\n}\n","import { asNumber, asBigInt } from \"./parse\";\n\nconst BPS_PER_UNIT = 10_000;\nconst BPS_PER_PCT = 100;\nconst FRACTION_TO_PCT = 100;\nconst PIPS_PER_USD = 1_000_000n;\nconst ROUNDING_OFFSET = 5_000n;\nconst CENTS_DIVISOR = 10_000n;\nconst CENTS_PAD = 2;\n\nexport function formatLeverage(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n / BPS_PER_UNIT).toLocaleString(undefined, { maximumFractionDigits: 2 })}x`;\n}\n\nexport function formatBpsPct(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n / BPS_PER_PCT).toLocaleString(undefined, { maximumFractionDigits: 2 })}%`;\n}\n\nexport function formatFractionPct(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n * FRACTION_TO_PCT).toLocaleString(undefined, { maximumFractionDigits: 1 })}%`;\n}\n\nexport function formatPipsUsd(value: unknown): string | null {\n const big = asBigInt(value);\n if (big === null) {\n return null;\n }\n const negative = big < 0n;\n const absUnits = negative ? -big : big;\n const whole = absUnits / PIPS_PER_USD;\n const frac = absUnits % PIPS_PER_USD;\n const cents = (frac + ROUNDING_OFFSET) / CENTS_DIVISOR;\n const formatted = `$${whole.toLocaleString()}.${cents.toString().padStart(CENTS_PAD, \"0\")}`;\n return negative ? `-${formatted}` : formatted;\n}\n","import { formatLeverage, formatBpsPct, formatFractionPct, formatPipsUsd } from \"../utils/format\";\nimport { type Params, getParam } from \"../utils/parse\";\n\ntype FriendlyEntry = string | ((params: Params) => string);\n\nconst minFillBpsMaxForMessage = 5_000;\n\nconst friendlyByCode: Record<string, FriendlyEntry> = {\n invalid_evm_address: \"Invalid EVM address.\",\n invalid_solana_address: \"Invalid Solana address.\",\n invalid_string_for_chain_address: \"Invalid wallet address for the selected chain.\",\n invalid_wallet_address: \"Invalid wallet address.\",\n customer_auth_invalid_wallet_address: \"Invalid wallet address.\",\n\n unauthorized: \"Session expired. Please reconnect your wallet.\",\n forbidden: \"You do not have access to this resource.\",\n\n array_out_of_bounds: \"Internal indexing error. Please try again.\",\n batch_compute_not_available: \"Cached pricing is temporarily unavailable. Try again shortly.\",\n internal_server_error: \"Something went wrong on our side. Please try again.\",\n unexpected_error: \"Something went wrong. Please try again.\",\n provider_not_available: \"Upstream provider is unavailable. Try again shortly.\",\n request_already_in_progress: \"A previous request is still in flight. Wait for it to complete and try again.\",\n math_error: \"A numeric calculation failed. Please try again.\",\n invalid_number: \"Invalid numeric value in request.\",\n invalid_message: \"Received an invalid upstream message.\",\n invalid_filter_combination: \"That combination of filters is not supported.\",\n\n cancel_position_delay_not_elapsed: \"Cancel delay has not elapsed yet. Try again shortly.\",\n cancel_position_transaction_failed: \"Cancel transaction failed on-chain.\",\n cancel_position_not_found: \"Position not found.\",\n cancel_position_not_in_created_state: \"This position can only be cancelled before it has filled.\",\n cancel_position_not_on_polygon: \"Cancel is only supported for Polygon positions.\",\n customer_cancel_position_evm_only: \"Cancel is only supported for EVM positions.\",\n customer_cancel_position_not_cancellable: \"This position can no longer be cancelled.\",\n customer_cancel_position_not_owner: \"You do not own this position.\",\n customer_cancel_position_not_found: \"Position not found.\",\n\n circuit_breaker_price_divergence_tripped: \"Trading is temporarily paused due to price divergence. Try again shortly.\",\n\n customer_market_not_found: \"Market not found.\",\n customer_position_not_found: \"Position not found.\",\n customer_position_transactions_not_found: \"Position not found.\",\n\n close_position_transaction_failed: \"Close transaction failed on-chain.\",\n close_position_transaction_not_found: \"Close transaction not found.\",\n finalize_close_transaction_failed: \"Finalising the close transaction failed.\",\n close_no_open_position_transaction: \"No open transaction found for this position.\",\n close_no_request_close_transaction: \"No close request found for this position.\",\n close_polymarket_order_failed: \"Polymarket close order failed.\",\n close_polymarket_order_retry_failed: \"Polymarket close order failed after retries.\",\n close_position_already_closed: \"This position is already closed.\",\n close_position_has_no_tokens: \"This position has no tokens to close.\",\n close_position_not_found: \"Position not found.\",\n close_position_not_originated: \"Position has not been originated yet — nothing to close.\",\n\n exchange_order_submission_locked: \"Order submission is temporarily locked. Try again shortly.\",\n\n quote_partner_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `Partner position limit reached. Remaining capacity: ${available}.`\n : \"Partner position limit reached. Try a smaller size.\";\n },\n quote_user_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `You have reached your position limit on this market. Remaining capacity: ${available}.`\n : \"You have reached your position limit on this market.\";\n },\n quote_market_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `This market has reached its open-interest cap. Remaining capacity: ${available}.`\n : \"This market has reached its open-interest cap. Try a smaller size or another market.\";\n },\n quote_global_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `Global position limit reached. Remaining capacity: ${available}.`\n : \"Global position limit reached. Try again shortly.\";\n },\n quote_side_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `This side of the market is at its position limit. Remaining capacity: ${available}.`\n : \"This side of the market is at its position limit. Try the other side or a smaller size.\";\n },\n quote_side_capacity_exceeded: (params) => {\n const maxCollateral = formatPipsUsd(getParam(params, \"maxSupportedCollateralUsdPips\"));\n return maxCollateral\n ? `Not enough capacity on this side of the market. Max supported collateral at this size: ${maxCollateral}.`\n : \"Not enough capacity on this side of the market for that size.\";\n },\n quote_position_limit_exceeded: \"Position limit reached for this request.\",\n\n quote_insufficient_liquidity: \"Not enough liquidity on the order book to fill this size.\",\n quote_slippage_too_high: (params) => {\n const max = formatBpsPct(getParam(params, \"maxSlippageBps\"));\n const current = formatBpsPct(getParam(params, \"currentSlippageBps\"));\n if (max && current) {\n return `Required slippage ${current} exceeds your tolerance (${max}). Reduce size or raise tolerance.`;\n }\n if (max) {\n return `Required slippage exceeds your tolerance (${max}). Reduce size or raise tolerance.`;\n }\n return \"Price would move too far to fill this order. Reduce size or raise your slippage tolerance.\";\n },\n quote_event_not_started: \"This event has not started yet. Trading opens at the scheduled start time.\",\n quote_entry_bid_depth_too_low: \"Order book depth on the entry side is too thin to open this position safely.\",\n quote_entry_capacity_exceeded: \"Entry size exceeds the market's available capacity.\",\n quote_entry_depth_too_low: \"Order book depth is too thin to open this position safely.\",\n quote_entry_spread_too_wide: \"Bid/ask spread is too wide to open right now. Try again shortly.\",\n quote_entry_order_book_stale: \"Order book data is stale. Refresh and try again.\",\n quote_entry_price_stale: \"Price data is stale. Refresh and try again.\",\n quote_entry_crypto_price_stale: \"Crypto price data is stale. Refresh and try again.\",\n quote_entry_sport_data_stale: \"Sport event data is stale. Refresh and try again.\",\n quote_entry_volume_too_low: \"Recent traded volume on this market is too low to open new positions.\",\n quote_entry_top_holder_too_high: \"A single trader holds too much of this market. Opening here is restricted.\",\n quote_entry_price_out_of_range: \"Current price is outside the range we can open at. Try again shortly.\",\n quote_entry_exit_drop_too_high: \"Exit liquidity is too thin to safely open this size.\",\n quote_entry_market_too_elapsed: (params) => {\n const elapsed = formatFractionPct(getParam(params, \"pctElapsed\"));\n const max = formatFractionPct(getParam(params, \"maxPctElapsed\"));\n if (elapsed && max) {\n return `Market is ${elapsed} elapsed (max ${max}). Too close to resolution to open new positions.`;\n }\n return \"Market is too close to resolution to open new positions.\";\n },\n quote_entry_excluded_market_type: \"This market type is not supported for leveraged positions.\",\n quote_entry_excluded_sport: \"This sport is not supported for leveraged positions.\",\n quote_price_too_low: \"Underlying price is too low to open a leveraged position.\",\n quote_open_interest_unavailable: \"Open-interest data is unavailable right now. Try again shortly.\",\n\n quote_leverage_below_minimum: (params) => {\n const min = formatLeverage(getParam(params, \"minLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (min && current) {\n return `Leverage ${current} is below the minimum allowed (${min}).`;\n }\n if (min) {\n return `Leverage is below the minimum allowed (${min}).`;\n }\n return \"Leverage is below the minimum allowed for this market.\";\n },\n quote_leverage_exceeds_maximum: (params) => {\n const max = formatLeverage(getParam(params, \"maxLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (max && current) {\n return `Leverage ${current} is above the maximum allowed (${max}).`;\n }\n if (max) {\n return `Leverage is above the maximum allowed (${max}).`;\n }\n return \"Leverage is above the maximum allowed for this market.\";\n },\n quote_leverage_exceeds_collateral_floor: (params) => {\n const min = formatPipsUsd(getParam(params, \"minCollateralUsdPips\"));\n const current = formatPipsUsd(getParam(params, \"currentCollateralUsdPips\"));\n if (min && current) {\n return `Collateral ${current} is below the minimum ${min} required at this leverage. Raise collateral to at least ${min}.`;\n }\n if (min) {\n return `Collateral is below the minimum ${min} required at this leverage. Raise collateral to at least ${min}.`;\n }\n return \"Collateral is below the minimum required at this leverage. Raise collateral.\";\n },\n quote_leverage_exceeds_model_max: (params) => {\n const max = formatLeverage(getParam(params, \"maxLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (max && current) {\n return `Leverage ${current} exceeds the risk-model limit (${max}) for this market.`;\n }\n if (max) {\n return `Leverage exceeds the risk-model limit (${max}) for this market.`;\n }\n return \"Leverage exceeds the risk-model limit for this market.\";\n },\n quote_leverage_too_high_for_price: (params) => {\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n const max = formatLeverage(getParam(params, \"maxAcceptableLeverageBps\"));\n if (current && max) {\n return `Leverage ${current} is too high for the current price. Maximum is ${max}.`;\n }\n if (current) {\n return `Leverage ${current} is too high for the current price. Reduce leverage.`;\n }\n return \"Leverage is too high for the current price. Reduce leverage.\";\n },\n quote_trading_window_closing: \"Trading window is closing. Reduce leverage.\",\n quote_hard_exit_too_close: \"Trading window is closing. Reduce leverage.\",\n quote_liquidation_not_viable: (params) => {\n const tolerance = formatBpsPct(getParam(params, \"minTolerancePctBps\"));\n return tolerance\n ? `Liquidation price is too close to entry (minimum buffer ${tolerance}). Reduce leverage.`\n : \"Liquidation price is not viable at this leverage. Reduce leverage.\";\n },\n\n quote_min_fill_bps_requires_fak: \"Partial-fill request was malformed. Please re-quote.\",\n quote_min_fill_bps_out_of_range: \"Minimum fill must be between 20% and 50%.\",\n quote_min_fill_bps_step_invalid: \"Minimum fill must be set in 5% steps.\",\n quote_min_fill_bps_below_floor: (params) => {\n const floorRaw = getParam(params, \"floorMinFillBps\");\n const floorPct = formatBpsPct(floorRaw);\n const limit = getParam(params, \"boundBy\") === \"notional\" ? \"minimum order size\" : \"minimum collateral\";\n const floorBeyondMax = typeof floorRaw === \"number\" && floorRaw > minFillBpsMaxForMessage;\n if (floorBeyondMax || !floorPct) {\n return `This trade is too small for a partial fill without falling below the ${limit}. Increase your trade size, or turn off partial fill to open atomically.`;\n }\n return `This trade is too small for that minimum fill — a partial fill could fall below the ${limit}. Raise the minimum fill to at least ${floorPct}, or increase your trade size.`;\n },\n quote_fak_order_type_disabled: \"Partial fills are temporarily unavailable. Turn off partial fill to continue.\",\n\n quote_market_not_active: \"Market is not active.\",\n quote_market_not_eligible: \"Market is not eligible for leveraged trading.\",\n quote_market_not_ready: \"Market is not ready yet. Try again shortly.\",\n quote_market_not_found: \"Market not found.\",\n quote_market_risk_too_high: \"Market risk is too high right now. Try again later.\",\n quote_market_unsupported_category: \"This market category is not supported.\",\n quote_market_no_prices: \"No price data available for this market.\",\n quote_market_missing_polymarket_condition_id: \"This market is missing required Polymarket data.\",\n\n quote_polymarket_market_closed: \"This Polymarket market is closed and not accepting new positions.\",\n quote_polymarket_market_inactive: \"This Polymarket market is inactive and not accepting new positions.\",\n quote_polymarket_market_not_accepting_orders:\n \"Polymarket is not accepting orders on this market right now. Try again shortly or pick another market.\",\n quote_polymarket_missing_token: \"This Polymarket market is missing a tradable outcome token.\",\n quote_invalid_polymarket_wallet_address: \"Invalid Polymarket wallet address.\",\n quote_invalid_kalshi_wallet_address: \"Invalid Kalshi wallet address.\",\n\n kalshi_quote_market_closed: \"This Kalshi market is closed.\",\n\n quote_draft_not_found: \"This quote has expired or does not exist. Please request a new quote.\",\n\n quote_twap_data_stale: \"Reference price (TWAP) is stale. Try again shortly.\",\n quote_twap_data_unavailable: \"Reference price (TWAP) is unavailable for this market.\",\n quote_revision_required: \"Quote needs to be refreshed before submitting.\",\n quote_price_provider_not_found: \"No price provider configured for this market.\",\n\n notional_selector_insufficient_liquidity: \"Not enough liquidity at the selected size.\",\n\n evm_gas_price_circuit_breaker: \"EVM gas price is too high — trading is temporarily paused.\",\n evm_gas_price_spike: \"EVM gas price spiked. Try again shortly.\",\n evm_simulation_failed: \"Transaction simulation failed. The transaction would revert on-chain.\",\n evm_receipt_timeout: \"Transaction confirmation timed out. Check status before retrying.\",\n evm_transaction_failed: \"EVM transaction failed.\",\n\n position_transition_conflicting_operation: \"Another operation on this position is in progress. Try again shortly.\",\n position_transition_invalid_state: \"Position is not in a state that allows this action.\",\n\n quote_creation_disabled: \"Quote creation is temporarily disabled. Try again shortly.\",\n};\n\nfunction humanizeCode(code: string): string {\n const spaced = code.replace(/_/g, \" \");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nexport function resolveFriendlyMessage(code: string, params: Params): string | null {\n const entry = friendlyByCode[code];\n if (entry === undefined) {\n return null;\n }\n return typeof entry === \"function\" ? entry(params) : entry;\n}\n\nexport function formatErrorMessage(code: string, params: Params): string {\n return resolveFriendlyMessage(code, params) ?? humanizeCode(code);\n}\n","import type { QuoteHint } from \"../quote/quote-error-hints\";\nimport { resolveFriendlyMessage } from \"./error-messages\";\n\nexport class DimesError extends Error {\n public readonly code: string;\n\n constructor(code: string, message: string) {\n super(message);\n this.name = \"DimesError\";\n this.code = code;\n }\n}\n\nexport class DimesApiError extends DimesError {\n public readonly status: number;\n\n public readonly type: string | null;\n\n public readonly rawMessage: string;\n\n public readonly params: Record<string, unknown> | null;\n\n public readonly hint: QuoteHint | null;\n\n constructor(options: {\n status: number;\n code: string;\n type: string | null;\n message: string;\n params: Record<string, unknown> | null;\n hint?: QuoteHint | null;\n }) {\n const friendly = resolveFriendlyMessage(options.code, options.params) ?? options.message;\n super(options.code, friendly);\n this.name = \"DimesApiError\";\n this.status = options.status;\n this.type = options.type;\n this.rawMessage = options.message;\n this.params = options.params;\n this.hint = options.hint ?? null;\n }\n}\n\nexport class DimesContractError extends DimesError {\n constructor(code: string, message: string) {\n super(code, message);\n this.name = \"DimesContractError\";\n }\n}\n"],"mappings":";AAEO,SAAS,SAAS,OAA+B;AACtD,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG;AACvD,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI;AACpD,UAAM,SAAS,OAAO,KAAK;AAC3B,QAAI,OAAO,SAAS,MAAM,GAAG;AAC3B,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,SAAS,OAA+B;AACtD,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,YAAY,UAAU,KAAK,MAAM,KAAK,CAAC,GAAG;AAC7D,WAAO,OAAO,MAAM,KAAK,CAAC;AAAA,EAC5B;AACA,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,GAAG;AACxD,WAAO,OAAO,KAAK;AAAA,EACrB;AACA,SAAO;AACT;AAEO,SAAS,SAAS,QAAgB,KAAsB;AAC7D,SAAO,SAAS,OAAO,GAAG,IAAI;AAChC;;;AC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nB,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/utils/parse.ts","../src/utils/format.ts","../src/errors/error-messages.ts","../src/errors/dimes-error.ts"],"sourcesContent":["export type Params = Record<string, unknown> | null;\n\nexport function asNumber(value: unknown): number | null {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n if (typeof value === \"string\" && value.trim() !== \"\") {\n const parsed = Number(value);\n if (Number.isFinite(parsed)) {\n return parsed;\n }\n }\n return null;\n}\n\nexport function asBigInt(value: unknown): bigint | null {\n if (typeof value === \"bigint\") {\n return value;\n }\n if (typeof value === \"string\" && /^-?\\d+$/.test(value.trim())) {\n return BigInt(value.trim());\n }\n if (typeof value === \"number\" && Number.isInteger(value)) {\n return BigInt(value);\n }\n return null;\n}\n\nexport function getParam(params: Params, key: string): unknown {\n return params ? params[key] : undefined;\n}\n","import { asNumber, asBigInt } from \"./parse\";\n\nconst BPS_PER_UNIT = 10_000;\nconst BPS_PER_PCT = 100;\nconst FRACTION_TO_PCT = 100;\nconst PIPS_PER_USD = 1_000_000n;\nconst ROUNDING_OFFSET = 5_000n;\nconst CENTS_DIVISOR = 10_000n;\nconst CENTS_PAD = 2;\n\nexport function formatLeverage(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n / BPS_PER_UNIT).toLocaleString(undefined, { maximumFractionDigits: 2 })}x`;\n}\n\nexport function formatBpsPct(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n / BPS_PER_PCT).toLocaleString(undefined, { maximumFractionDigits: 2 })}%`;\n}\n\nexport function formatFractionPct(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n * FRACTION_TO_PCT).toLocaleString(undefined, { maximumFractionDigits: 1 })}%`;\n}\n\nexport function formatPipsUsd(value: unknown): string | null {\n const big = asBigInt(value);\n if (big === null) {\n return null;\n }\n const negative = big < 0n;\n const absUnits = negative ? -big : big;\n const whole = absUnits / PIPS_PER_USD;\n const frac = absUnits % PIPS_PER_USD;\n const cents = (frac + ROUNDING_OFFSET) / CENTS_DIVISOR;\n const formatted = `$${whole.toLocaleString()}.${cents.toString().padStart(CENTS_PAD, \"0\")}`;\n return negative ? `-${formatted}` : formatted;\n}\n","import { formatLeverage, formatBpsPct, formatFractionPct, formatPipsUsd } from \"../utils/format\";\nimport { type Params, getParam } from \"../utils/parse\";\n\ntype FriendlyEntry = string | ((params: Params) => string);\n\nconst minFillBpsMaxForMessage = 5_000;\n\nconst friendlyByCode: Record<string, FriendlyEntry> = {\n invalid_evm_address: \"Invalid EVM address.\",\n invalid_solana_address: \"Invalid Solana address.\",\n invalid_string_for_chain_address: \"Invalid wallet address for the selected chain.\",\n invalid_wallet_address: \"Invalid wallet address.\",\n customer_auth_invalid_wallet_address: \"Invalid wallet address.\",\n\n unauthorized: \"Session expired. Please reconnect your wallet.\",\n forbidden: \"You do not have access to this resource.\",\n\n array_out_of_bounds: \"Internal indexing error. Please try again.\",\n batch_compute_not_available: \"Cached pricing is temporarily unavailable. Try again shortly.\",\n internal_server_error: \"Something went wrong on our side. Please try again.\",\n unexpected_error: \"Something went wrong. Please try again.\",\n provider_not_available: \"Upstream provider is unavailable. Try again shortly.\",\n request_already_in_progress: \"A previous request is still in flight. Wait for it to complete and try again.\",\n math_error: \"A numeric calculation failed. Please try again.\",\n invalid_number: \"Invalid numeric value in request.\",\n invalid_message: \"Received an invalid upstream message.\",\n invalid_filter_combination: \"That combination of filters is not supported.\",\n\n cancel_position_delay_not_elapsed: \"Cancel delay has not elapsed yet. Try again shortly.\",\n cancel_position_transaction_failed: \"Cancel transaction failed on-chain.\",\n cancel_position_not_found: \"Position not found.\",\n cancel_position_not_in_created_state: \"This position can only be cancelled before it has filled.\",\n cancel_position_not_on_polygon: \"Cancel is only supported for Polygon positions.\",\n customer_cancel_position_evm_only: \"Cancel is only supported for EVM positions.\",\n customer_cancel_position_not_cancellable: \"This position can no longer be cancelled.\",\n customer_cancel_position_not_owner: \"You do not own this position.\",\n customer_cancel_position_not_found: \"Position not found.\",\n\n circuit_breaker_price_divergence_tripped: \"Trading is temporarily paused due to price divergence. Try again shortly.\",\n\n customer_market_not_found: \"Market not found.\",\n customer_position_not_found: \"Position not found.\",\n customer_position_transactions_not_found: \"Position not found.\",\n\n close_position_transaction_failed: \"Close transaction failed on-chain.\",\n close_position_transaction_not_found: \"Close transaction not found.\",\n finalize_close_transaction_failed: \"Finalising the close transaction failed.\",\n close_no_open_position_transaction: \"No open transaction found for this position.\",\n close_no_request_close_transaction: \"No close request found for this position.\",\n close_polymarket_order_failed: \"Polymarket close order failed.\",\n close_polymarket_order_retry_failed: \"Polymarket close order failed after retries.\",\n close_position_already_closed: \"This position is already closed.\",\n close_position_has_no_tokens: \"This position has no tokens to close.\",\n close_position_not_found: \"Position not found.\",\n close_position_not_originated: \"Position has not been originated yet — nothing to close.\",\n\n exchange_order_submission_locked: \"Order submission is temporarily locked. Try again shortly.\",\n\n quote_partner_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `Partner position limit reached. Remaining capacity: ${available}.`\n : \"Partner position limit reached. Try a smaller size.\";\n },\n quote_user_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `You have reached your position limit on this market. Remaining capacity: ${available}.`\n : \"You have reached your position limit on this market.\";\n },\n quote_market_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `This market has reached its open-interest cap. Remaining capacity: ${available}.`\n : \"This market has reached its open-interest cap. Try a smaller size or another market.\";\n },\n quote_global_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `Global position limit reached. Remaining capacity: ${available}.`\n : \"Global position limit reached. Try again shortly.\";\n },\n quote_side_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `This side of the market is at its position limit. Remaining capacity: ${available}.`\n : \"This side of the market is at its position limit. Try the other side or a smaller size.\";\n },\n quote_side_capacity_exceeded: (params) => {\n const maxCollateral = formatPipsUsd(getParam(params, \"maxSupportedCollateralUsdPips\"));\n return maxCollateral\n ? `Not enough capacity on this side of the market. Max supported collateral at this size: ${maxCollateral}.`\n : \"Not enough capacity on this side of the market for that size.\";\n },\n quote_position_limit_exceeded: \"Position limit reached for this request.\",\n\n quote_insufficient_liquidity: \"Not enough liquidity on the order book to fill this size.\",\n quote_slippage_too_high: (params) => {\n const max = formatBpsPct(getParam(params, \"maxSlippageBps\"));\n const current = formatBpsPct(getParam(params, \"currentSlippageBps\"));\n if (max && current) {\n return `Required slippage ${current} exceeds your tolerance (${max}). Reduce size or raise tolerance.`;\n }\n if (max) {\n return `Required slippage exceeds your tolerance (${max}). Reduce size or raise tolerance.`;\n }\n return \"Price would move too far to fill this order. Reduce size or raise your slippage tolerance.\";\n },\n quote_event_not_started: \"This event has not started yet. Trading opens at the scheduled start time.\",\n quote_entry_bid_depth_too_low: \"Order book depth on the entry side is too thin to open this position safely.\",\n quote_entry_capacity_exceeded: \"Entry size exceeds the market's available capacity.\",\n quote_entry_depth_too_low: \"Order book depth is too thin to open this position safely.\",\n quote_entry_spread_too_wide: \"Bid/ask spread is too wide to open right now. Try again shortly.\",\n quote_entry_order_book_stale: \"Order book data is stale. Refresh and try again.\",\n quote_entry_price_stale: \"Price data is stale. Refresh and try again.\",\n quote_entry_crypto_price_stale: \"Crypto price data is stale. Refresh and try again.\",\n quote_entry_sport_data_stale: \"Sport event data is stale. Refresh and try again.\",\n quote_entry_volume_too_low: \"Recent traded volume on this market is too low to open new positions.\",\n quote_entry_top_holder_too_high: \"A single trader holds too much of this market. Opening here is restricted.\",\n quote_entry_price_out_of_range: \"Current price is outside the range we can open at. Try again shortly.\",\n quote_entry_exit_drop_too_high: \"Exit liquidity is too thin to safely open this size.\",\n quote_entry_market_too_elapsed: (params) => {\n const elapsed = formatFractionPct(getParam(params, \"pctElapsed\"));\n const max = formatFractionPct(getParam(params, \"maxPctElapsed\"));\n if (elapsed && max) {\n return `Market is ${elapsed} elapsed (max ${max}). Too close to resolution to open new positions.`;\n }\n return \"Market is too close to resolution to open new positions.\";\n },\n quote_entry_excluded_market_type: \"This market type is not supported for leveraged positions.\",\n quote_entry_excluded_sport: \"This sport is not supported for leveraged positions.\",\n quote_price_too_low: \"Underlying price is too low to open a leveraged position.\",\n quote_open_interest_unavailable: \"Open-interest data is unavailable right now. Try again shortly.\",\n\n quote_leverage_below_minimum: (params) => {\n const min = formatLeverage(getParam(params, \"minLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (min && current) {\n return `Leverage ${current} is below the minimum allowed (${min}).`;\n }\n if (min) {\n return `Leverage is below the minimum allowed (${min}).`;\n }\n return \"Leverage is below the minimum allowed for this market.\";\n },\n quote_leverage_exceeds_maximum: (params) => {\n const max = formatLeverage(getParam(params, \"maxLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (max && current) {\n return `Leverage ${current} is above the maximum allowed (${max}).`;\n }\n if (max) {\n return `Leverage is above the maximum allowed (${max}).`;\n }\n return \"Leverage is above the maximum allowed for this market.\";\n },\n quote_leverage_exceeds_collateral_floor: (params) => {\n const min = formatPipsUsd(getParam(params, \"minCollateralUsdPips\"));\n const current = formatPipsUsd(getParam(params, \"currentCollateralUsdPips\"));\n if (min && current) {\n return `Collateral ${current} is below the minimum ${min} required at this leverage. Raise collateral to at least ${min}.`;\n }\n if (min) {\n return `Collateral is below the minimum ${min} required at this leverage. Raise collateral to at least ${min}.`;\n }\n return \"Collateral is below the minimum required at this leverage. Raise collateral.\";\n },\n quote_leverage_exceeds_model_max: (params) => {\n const max = formatLeverage(getParam(params, \"maxLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (max && current) {\n return `Leverage ${current} exceeds the risk-model limit (${max}) for this market.`;\n }\n if (max) {\n return `Leverage exceeds the risk-model limit (${max}) for this market.`;\n }\n return \"Leverage exceeds the risk-model limit for this market.\";\n },\n quote_leverage_too_high_for_price: (params) => {\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n const max = formatLeverage(getParam(params, \"maxAcceptableLeverageBps\"));\n if (current && max) {\n return `Leverage ${current} is too high for the current price. Maximum is ${max}.`;\n }\n if (current) {\n return `Leverage ${current} is too high for the current price. Reduce leverage.`;\n }\n return \"Leverage is too high for the current price. Reduce leverage.\";\n },\n quote_trading_window_closing: \"Trading window is closing. Reduce leverage.\",\n quote_hard_exit_too_close: \"Trading window is closing. Reduce leverage.\",\n quote_liquidation_not_viable: (params) => {\n const tolerance = formatBpsPct(getParam(params, \"minTolerancePctBps\"));\n return tolerance\n ? `Liquidation price is too close to entry (minimum buffer ${tolerance}). Reduce leverage.`\n : \"Liquidation price is not viable at this leverage. Reduce leverage.\";\n },\n\n quote_min_fill_bps_requires_fak: \"Partial-fill request was malformed. Please re-quote.\",\n quote_min_fill_bps_out_of_range: \"Minimum fill must be between 20% and 50%.\",\n quote_min_fill_bps_step_invalid: \"Minimum fill must be set in 5% steps.\",\n quote_min_fill_bps_below_floor: (params) => {\n const floorRaw = getParam(params, \"floorMinFillBps\");\n const floorPct = formatBpsPct(floorRaw);\n const limit = getParam(params, \"boundBy\") === \"notional\" ? \"minimum order size\" : \"minimum collateral\";\n const floorBeyondMax = typeof floorRaw === \"number\" && floorRaw > minFillBpsMaxForMessage;\n if (floorBeyondMax || !floorPct) {\n return `This trade is too small for a partial fill without falling below the ${limit}. Increase your trade size, or turn off partial fill to open atomically.`;\n }\n return `This trade is too small for that minimum fill — a partial fill could fall below the ${limit}. Raise the minimum fill to at least ${floorPct}, or increase your trade size.`;\n },\n quote_fak_order_type_disabled: \"Partial fills are temporarily unavailable. Turn off partial fill to continue.\",\n\n quote_market_not_active: \"Market is not active.\",\n quote_market_not_eligible: \"Market is not eligible for leveraged trading.\",\n quote_market_not_ready: \"Market is not ready yet. Try again shortly.\",\n quote_market_not_found: \"Market not found.\",\n quote_market_risk_too_high: \"Market risk is too high right now. Try again later.\",\n quote_market_unsupported_category: \"This market category is not supported.\",\n quote_market_unsupported_crypto_asset: \"This market's underlying asset is not supported.\",\n quote_market_no_prices: \"No price data available for this market.\",\n quote_market_missing_polymarket_condition_id: \"This market is missing required Polymarket data.\",\n\n quote_polymarket_market_closed: \"This Polymarket market is closed and not accepting new positions.\",\n quote_polymarket_market_inactive: \"This Polymarket market is inactive and not accepting new positions.\",\n quote_polymarket_market_not_accepting_orders:\n \"Polymarket is not accepting orders on this market right now. Try again shortly or pick another market.\",\n quote_polymarket_missing_token: \"This Polymarket market is missing a tradable outcome token.\",\n quote_invalid_polymarket_wallet_address: \"Invalid Polymarket wallet address.\",\n quote_invalid_kalshi_wallet_address: \"Invalid Kalshi wallet address.\",\n\n kalshi_quote_market_closed: \"This Kalshi market is closed.\",\n\n quote_draft_not_found: \"This quote has expired or does not exist. Please request a new quote.\",\n\n quote_twap_data_stale: \"Reference price (TWAP) is stale. Try again shortly.\",\n quote_twap_data_unavailable: \"Reference price (TWAP) is unavailable for this market.\",\n quote_revision_required: \"Quote needs to be refreshed before submitting.\",\n quote_price_provider_not_found: \"No price provider configured for this market.\",\n\n notional_selector_insufficient_liquidity: \"Not enough liquidity to fill an order of this size. Try a smaller size.\",\n notional_selector_below_min_notional:\n \"This side of the market doesn't have enough liquidity to support the minimum position size right now.\",\n notional_selector_empty_order_book:\n \"This side of the market has no available liquidity right now. Try again shortly.\",\n notional_selector_pregame_insufficient_liquidity:\n \"This market doesn't yet have enough pre-game liquidity to support a position. \" +\n \"Try again closer to the event start.\",\n\n evm_gas_price_circuit_breaker: \"EVM gas price is too high — trading is temporarily paused.\",\n evm_gas_price_spike: \"EVM gas price spiked. Try again shortly.\",\n evm_simulation_failed: \"Transaction simulation failed. The transaction would revert on-chain.\",\n evm_receipt_timeout: \"Transaction confirmation timed out. Check status before retrying.\",\n evm_transaction_failed: \"EVM transaction failed.\",\n\n position_transition_conflicting_operation: \"Another operation on this position is in progress. Try again shortly.\",\n position_transition_invalid_state: \"Position is not in a state that allows this action.\",\n\n quote_creation_disabled: \"Quote creation is temporarily disabled. Try again shortly.\",\n};\n\nfunction humanizeCode(code: string): string {\n const spaced = code.replace(/_/g, \" \");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nexport function resolveFriendlyMessage(code: string, params: Params): string | null {\n const entry = friendlyByCode[code];\n if (entry === undefined) {\n return null;\n }\n return typeof entry === \"function\" ? entry(params) : entry;\n}\n\nexport function formatErrorMessage(code: string, params: Params): string {\n return resolveFriendlyMessage(code, params) ?? humanizeCode(code);\n}\n","import type { QuoteHint } from \"../quote/quote-error-hints\";\nimport { resolveFriendlyMessage } from \"./error-messages\";\n\nexport class DimesError extends Error {\n public readonly code: string;\n\n constructor(code: string, message: string) {\n super(message);\n this.name = \"DimesError\";\n this.code = code;\n }\n}\n\nexport class DimesApiError extends DimesError {\n public readonly status: number;\n\n public readonly type: string | null;\n\n public readonly rawMessage: string;\n\n public readonly params: Record<string, unknown> | null;\n\n public readonly hint: QuoteHint | null;\n\n constructor(options: {\n status: number;\n code: string;\n type: string | null;\n message: string;\n params: Record<string, unknown> | null;\n hint?: QuoteHint | null;\n }) {\n const friendly = resolveFriendlyMessage(options.code, options.params) ?? options.message;\n super(options.code, friendly);\n this.name = \"DimesApiError\";\n this.status = options.status;\n this.type = options.type;\n this.rawMessage = options.message;\n this.params = options.params;\n this.hint = options.hint ?? null;\n }\n}\n\nexport class DimesContractError extends DimesError {\n constructor(code: string, message: string) {\n super(code, message);\n this.name = \"DimesContractError\";\n }\n}\n"],"mappings":";AAEO,SAAS,SAAS,OAA+B;AACtD,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG;AACvD,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAA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AEhB,YAAY,MAAc,SAAiB;AACzC,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,WAAW;AAAA,EAC5B;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEhB,YAAY,SAOT;AACD,UAAM,WAAW,uBAAuB,QAAQ,MAAM,QAAQ,MAAM,KAAK,QAAQ;AACjF,UAAM,QAAQ,MAAM,QAAQ;AAC5B,SAAK,OAAO;AACZ,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,QAAQ;AACpB,SAAK,aAAa,QAAQ;AAC1B,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,QAAQ,QAAQ;AAAA,EAC9B;AACF;AAEO,IAAM,qBAAN,cAAiC,WAAW;AAAA,EACjD,YAAY,MAAc,SAAiB;AACzC,UAAM,MAAM,OAAO;AACnB,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DimesApiError,
3
3
  DimesError
4
- } from "./chunk-PZCBUVPD.mjs";
4
+ } from "./chunk-LXZAXWLO.mjs";
5
5
 
6
6
  // src/quote/build-quote-params.ts
7
7
  var DEFAULT_LEVERAGE_STEP_BPS = 2500;
@@ -327,4 +327,4 @@ export {
327
327
  isMarketMovedError,
328
328
  executeQuote
329
329
  };
330
- //# sourceMappingURL=chunk-T67Z74J3.mjs.map
330
+ //# sourceMappingURL=chunk-Q34TMZ5J.mjs.map
@@ -13,15 +13,20 @@ var positionEventTypes = [
13
13
  "position.partial_closed",
14
14
  "position.partial_close_aborted",
15
15
  "position.reverted",
16
- "position.settled"
16
+ "position.settled",
17
+ "position.settlement_state_changed"
17
18
  ];
18
19
  var marketEventTypes = [
19
20
  "market.discovered",
20
21
  "market.eligibility_changed",
21
- "market.max_leverage_changed"
22
+ "market.max_leverage_changed",
23
+ "market.settlement_state_changed"
22
24
  ];
23
25
  var notificationCodes = {
24
- orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING"
26
+ orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING",
27
+ partialOpenProgress: "PARTIAL_OPEN_PROGRESS",
28
+ partialOpenFloorMissed: "PARTIAL_OPEN_FLOOR_MISSED",
29
+ orderFulfillmentFailed: "ORDER_FULFILLMENT_FAILED"
25
30
  };
26
31
 
27
32
  export {
@@ -29,4 +34,4 @@ export {
29
34
  marketEventTypes,
30
35
  notificationCodes
31
36
  };
32
- //# sourceMappingURL=chunk-PK2PRTQW.mjs.map
37
+ //# sourceMappingURL=chunk-TYR33WJW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ws/types.ts"],"sourcesContent":["import type { Market, MarketLeverage, MarketPolymarket, Position } from \"../types\";\n\nexport const positionEventTypes = [\n \"position.cancelled\",\n \"position.close_requested\",\n \"position.closed\",\n \"position.created\",\n \"position.force_unwound\",\n \"position.liquidated\",\n \"position.opened\",\n \"position.opening\",\n \"position.partial_close_requested\",\n \"position.partial_close_initiated\",\n \"position.partial_closed\",\n \"position.partial_close_aborted\",\n \"position.reverted\",\n \"position.settled\",\n \"position.settlement_state_changed\",\n] as const;\n\nexport type PositionEventType = (typeof positionEventTypes)[number];\n\nexport interface PositionEventEnvelope {\n id: string;\n type: PositionEventType;\n created_at: string;\n data: Record<string, unknown>;\n}\n\nexport interface PositionEvent {\n id: string;\n type: PositionEventType;\n createdAt: string;\n data: Position;\n}\n\nexport const marketEventTypes = [\n \"market.discovered\",\n \"market.eligibility_changed\",\n \"market.max_leverage_changed\",\n \"market.settlement_state_changed\",\n] as const;\n\nexport type MarketEventType = (typeof marketEventTypes)[number];\n\nexport type MarketDelta = Pick<Market, \"id\"> & {\n polymarket: MarketPolymarket;\n leverage?: MarketLeverage;\n} & Partial<Omit<Market, \"id\" | \"leverage\">>;\n\nexport interface MarketEventEnvelope {\n id: string;\n type: MarketEventType;\n created_at: string;\n data: Record<string, unknown>[];\n}\n\nexport interface MarketEvent {\n id: string;\n type: MarketEventType;\n createdAt: string;\n data: Market[] | MarketDelta[];\n}\n\nexport interface NotificationEventEnvelope {\n id: string;\n type: \"notification\";\n created_at: string;\n data: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n };\n}\n\nexport interface NotificationEvent {\n id: string;\n type: \"notification\";\n createdAt: string;\n data: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n };\n}\n\nexport const notificationCodes = {\n orderFulfillmentRetrying: \"ORDER_FULFILLMENT_RETRYING\",\n partialOpenProgress: \"PARTIAL_OPEN_PROGRESS\",\n partialOpenFloorMissed: \"PARTIAL_OPEN_FLOOR_MISSED\",\n orderFulfillmentFailed: \"ORDER_FULFILLMENT_FAILED\",\n} as const;\n\nexport type NotificationCode = (typeof notificationCodes)[keyof typeof notificationCodes];\n"],"mappings":";AAEO,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAkBO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA6CO,IAAM,oBAAoB;AAAA,EAC/B,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,wBAAwB;AAC1B;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
2
2
 
3
3
 
4
- var _chunk53U53KZ2cjs = require('./chunk-53U53KZ2.cjs');
4
+ var _chunkUYDXDYEPcjs = require('./chunk-UYDXDYEP.cjs');
5
5
 
6
6
  // src/ws/position-socket.ts
7
7
  var _humps = require('humps');
@@ -63,7 +63,7 @@ var PositionSocket = (_class = class {
63
63
  cb(err);
64
64
  }
65
65
  });
66
- for (const eventType of _chunk53U53KZ2cjs.positionEventTypes) {
66
+ for (const eventType of _chunkUYDXDYEPcjs.positionEventTypes) {
67
67
  this.socket.on(eventType, (envelope) => {
68
68
  const event = camelizeEnvelope(envelope);
69
69
  this.emit(eventType, event);
@@ -185,7 +185,7 @@ var MarketSocket = (_class2 = class {
185
185
  cb(err);
186
186
  }
187
187
  });
188
- for (const eventType of _chunk53U53KZ2cjs.marketEventTypes) {
188
+ for (const eventType of _chunkUYDXDYEPcjs.marketEventTypes) {
189
189
  this.socket.on(eventType, (envelope) => {
190
190
  const event = camelizeEnvelope2(envelope);
191
191
  this.emit(eventType, event);
@@ -237,4 +237,4 @@ var MarketSocket = (_class2 = class {
237
237
 
238
238
 
239
239
  exports.PositionSocket = PositionSocket; exports.MarketSocket = MarketSocket;
240
- //# sourceMappingURL=chunk-FAW2C5AM.cjs.map
240
+ //# sourceMappingURL=chunk-UPNJRN65.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-FAW2C5AM.cjs","../src/ws/position-socket.ts","../src/ws/market-socket.ts"],"names":["io","camelizeEnvelope"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8BAA6B;AAC7B,kDAAgC;AAqBhC,IAAM,YAAA,EAAc,0CAAA;AAEpB,SAAS,gBAAA,CAAiB,QAAA,EAAgD;AACxE,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,QAAA,CAAS,EAAA;AAA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uB,EAAA;AACJ,IAAA;AACf,MAAA;AACF,IAAA;AAEa,oBAAA;AAEC,IAAA;AACF,IAAA;AACV,MAAA;AACF,IAAA;AAEiB,IAAA;AACA,IAAA;AACD,MAAA;AACD,MAAA;AACC,MAAA;AACd,MAAA;AACA,MAAA;AACD,IAAA;AAEc,IAAA;AACF,MAAA;AACN,QAAA;AACL,MAAA;AACD,IAAA;AAEc,IAAA;AACF,MAAA;AACN,QAAA;AACL,MAAA;AACD,IAAA;AAEc,IAAA;AACF,MAAA;AACH,QAAA;AACR,MAAA;AACD,IAAA;AAEU,IAAA;AACM,MAAA;AACCA,QAAAA;AACJ,QAAA;AACA,QAAA;AACX,MAAA;AACH,IAAA;AACF,EAAA;AAE0B,EAAA;AACX,oBAAA;AACC,IAAA;AAChB,EAAA;AAEO,EAAA;AACW,IAAA;AACH,IAAA;AACf,EAAA;AAEuE,EAAA;AACtD,IAAA;AACL,IAAA;AACF,MAAA;AACD,MAAA;AACP,IAAA;AACU,IAAA;AACO,IAAA;AACnB,EAAA;AAEqD,EAAA;AAC9C,IAAA;AACa,IAAA;AACpB,EAAA;AAEwD,EAAA;AACjD,IAAA;AACa,IAAA;AACpB,EAAA;AAE8C,EAAA;AACvC,IAAA;AACa,IAAA;AACpB,EAAA;AAEqD,EAAA;AAClC,IAAA;AACP,IAAA;AACR,MAAA;AACF,IAAA;AACiB,IAAA;AACR,MAAA;AACT,IAAA;AACF,EAAA;AACF;AFuFsB;AACA;AACA;AACA;AACA","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-FAW2C5AM.cjs","sourcesContent":[null,"import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Position } from \"../types\";\nimport {\n positionEventTypes,\n type NotificationEvent,\n type NotificationEventEnvelope,\n type PositionEvent,\n type PositionEventEnvelope,\n type PositionEventType,\n} from \"./types\";\n\nexport interface PositionSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: PositionEvent) => void;\ntype NotificationCallback = (event: NotificationEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/user-positions\";\n\nfunction camelizeEnvelope(envelope: PositionEventEnvelope): PositionEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: camelizeKeys(envelope.data) as unknown as Position,\n };\n}\n\nexport class PositionSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n private readonly notificationListeners = new Set<NotificationCallback>();\n\n constructor(options: PositionSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of positionEventTypes) {\n this.socket.on(eventType, (envelope: PositionEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n\n this.socket.on(\"notification\", (envelope: NotificationEventEnvelope) => {\n const event: NotificationEvent = {\n id: envelope.id,\n type: \"notification\",\n createdAt: envelope.created_at,\n data: envelope.data,\n };\n for (const cb of this.notificationListeners) {\n cb(event);\n }\n });\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: PositionEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n public onNotification(cb: NotificationCallback): () => void {\n this.notificationListeners.add(cb);\n return () => this.notificationListeners.delete(cb);\n }\n\n private emit(event: string, data: PositionEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n","import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Market } from \"../types\";\nimport {\n marketEventTypes,\n type MarketDelta,\n type MarketEvent,\n type MarketEventEnvelope,\n type MarketEventType,\n} from \"./types\";\n\nexport interface MarketSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: MarketEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/user-markets\";\n\nfunction camelizeEnvelope(envelope: MarketEventEnvelope): MarketEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: envelope.data.map((item) => camelizeKeys(item)) as unknown as Market[] | MarketDelta[],\n };\n}\n\nexport class MarketSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n constructor(options: MarketSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of marketEventTypes) {\n this.socket.on(eventType, (envelope: MarketEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: MarketEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n private emit(event: string, data: MarketEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-UPNJRN65.cjs","../src/ws/position-socket.ts","../src/ws/market-socket.ts"],"names":["io","camelizeEnvelope"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8BAA6B;AAC7B,kDAAgC;AAqBhC,IAAM,YAAA,EAAc,0CAAA;AAEpB,SAAS,gBAAA,CAAiB,QAAA,EAAgD;AACxE,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,QAAA,CAAS,EAAA;AAAA,IACb,IAAA,EAAM,QAAA,CAAS,IAAA;AAAA,IACf,SAAA,EAAW,QAAA,CAAS,UAAA;AAAA,IACpB,IAAA,EAAM,iCAAA,QAAa,CAAS,IAAI;AAAA,EAClC,CAAA;AACF;AAEO,IAAM,eAAA,YAAN,MAAqB;AAAA,iBAClB,OAAA,EAAwB,KAAA;AAAA,EAEf;AAAA,EAEA;AAAA,kBAEA,eAAA,kBAAiB,IAAI,GAAA,CAAgC,EAAA;AAAA,kBAErD,iBAAA,kBAAmB,IAAI,GAAA,CAAwB,EAAA;AAAA,kBAE/C,oBAAA,kBAAsB,IAAI,GAAA,CAAwB,EAAA;AAAA,kBAElD,eAAA,kBAAiB,IAAI,GAAA,CAAmB,EAAA;AAAA,kBAExC,sBAAA,kBAAwB,IAAI,GAAA,CAA0B,EAAA;AAAA,EAEvE,WAAA,CAAY,OAAA,EAAgC;AAC1C,IAAA,IAAA,CAAK,QAAA,mBAAU,OAAA,CAAQ,OAAA,UAAW,wBAAA;AAClC,IAAA,IAAA,CAAK,SAAA,EAAW,OAAA,CAAQ,QAAA;AAAA,EAC1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B,EAAA;AAEwD,EAAA;AACjD,IAAA;AACa,IAAA;AACpB,EAAA;AAE8C,EAAA;AACvC,IAAA;AACa,IAAA;AACpB,EAAA;AAEqD,EAAA;AAClC,IAAA;AACP,IAAA;AACR,MAAA;AACF,IAAA;AACiB,IAAA;AACR,MAAA;AACT,IAAA;AACF,EAAA;AACF;AFuFsB;AACA;AACA;AACA;AACA","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-UPNJRN65.cjs","sourcesContent":[null,"import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Position } from \"../types\";\nimport {\n positionEventTypes,\n type NotificationEvent,\n type NotificationEventEnvelope,\n type PositionEvent,\n type PositionEventEnvelope,\n type PositionEventType,\n} from \"./types\";\n\nexport interface PositionSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: PositionEvent) => void;\ntype NotificationCallback = (event: NotificationEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/user-positions\";\n\nfunction camelizeEnvelope(envelope: PositionEventEnvelope): PositionEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: camelizeKeys(envelope.data) as unknown as Position,\n };\n}\n\nexport class PositionSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n private readonly notificationListeners = new Set<NotificationCallback>();\n\n constructor(options: PositionSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of positionEventTypes) {\n this.socket.on(eventType, (envelope: PositionEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n\n this.socket.on(\"notification\", (envelope: NotificationEventEnvelope) => {\n const event: NotificationEvent = {\n id: envelope.id,\n type: \"notification\",\n createdAt: envelope.created_at,\n data: envelope.data,\n };\n for (const cb of this.notificationListeners) {\n cb(event);\n }\n });\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: PositionEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n public onNotification(cb: NotificationCallback): () => void {\n this.notificationListeners.add(cb);\n return () => this.notificationListeners.delete(cb);\n }\n\n private emit(event: string, data: PositionEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n","import { camelizeKeys } from \"humps\";\nimport { io, type Socket } from \"socket.io-client\";\nimport type { Market } from \"../types\";\nimport {\n marketEventTypes,\n type MarketDelta,\n type MarketEvent,\n type MarketEventEnvelope,\n type MarketEventType,\n} from \"./types\";\n\nexport interface MarketSocketOptions {\n baseUrl?: string;\n getToken: () => string | null;\n}\n\ntype EventCallback = (event: MarketEvent) => void;\ntype ConnectionCallback = () => void;\ntype ErrorCallback = (error: unknown) => void;\n\nconst wsNamespace = \"/v1/ws/prediction-markets/user-markets\";\n\nfunction camelizeEnvelope(envelope: MarketEventEnvelope): MarketEvent {\n return {\n id: envelope.id,\n type: envelope.type,\n createdAt: envelope.created_at,\n data: envelope.data.map((item) => camelizeKeys(item)) as unknown as Market[] | MarketDelta[],\n };\n}\n\nexport class MarketSocket {\n private socket: Socket | null = null;\n\n private readonly baseUrl: string;\n\n private readonly getToken: () => string | null;\n\n private readonly eventListeners = new Map<string, Set<EventCallback>>();\n\n private readonly connectListeners = new Set<ConnectionCallback>();\n\n private readonly disconnectListeners = new Set<ConnectionCallback>();\n\n private readonly errorListeners = new Set<ErrorCallback>();\n\n constructor(options: MarketSocketOptions) {\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.getToken = options.getToken;\n }\n\n public get connected(): boolean {\n return this.socket?.connected ?? false;\n }\n\n public connect(): void {\n if (this.socket?.connected) {\n return;\n }\n\n this.socket?.disconnect();\n\n const token = this.getToken();\n if (!token) {\n return;\n }\n\n const getToken = this.getToken;\n this.socket = io(`${this.baseUrl}${wsNamespace}`, {\n auth: (cb) => cb({ token: getToken() }),\n transports: [\"websocket\"],\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 30000,\n });\n\n this.socket.on(\"connect\", () => {\n for (const cb of this.connectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"disconnect\", () => {\n for (const cb of this.disconnectListeners) {\n cb();\n }\n });\n\n this.socket.on(\"error\", (err: unknown) => {\n for (const cb of this.errorListeners) {\n cb(err);\n }\n });\n\n for (const eventType of marketEventTypes) {\n this.socket.on(eventType, (envelope: MarketEventEnvelope) => {\n const event = camelizeEnvelope(envelope);\n this.emit(eventType, event);\n this.emit(\"*\", event);\n });\n }\n }\n\n public disconnect(): void {\n this.socket?.disconnect();\n this.socket = null;\n }\n\n public reconnectWithToken(): void {\n this.disconnect();\n this.connect();\n }\n\n public on(event: MarketEventType | \"*\", cb: EventCallback): () => void {\n let set = this.eventListeners.get(event);\n if (!set) {\n set = new Set();\n this.eventListeners.set(event, set);\n }\n set.add(cb);\n return () => set.delete(cb);\n }\n\n public onConnect(cb: ConnectionCallback): () => void {\n this.connectListeners.add(cb);\n return () => this.connectListeners.delete(cb);\n }\n\n public onDisconnect(cb: ConnectionCallback): () => void {\n this.disconnectListeners.add(cb);\n return () => this.disconnectListeners.delete(cb);\n }\n\n public onError(cb: ErrorCallback): () => void {\n this.errorListeners.add(cb);\n return () => this.errorListeners.delete(cb);\n }\n\n private emit(event: string, data: MarketEvent): void {\n const set = this.eventListeners.get(event);\n if (!set) {\n return;\n }\n for (const cb of set) {\n cb(data);\n }\n }\n}\n"]}
@@ -13,15 +13,20 @@ var positionEventTypes = [
13
13
  "position.partial_closed",
14
14
  "position.partial_close_aborted",
15
15
  "position.reverted",
16
- "position.settled"
16
+ "position.settled",
17
+ "position.settlement_state_changed"
17
18
  ];
18
19
  var marketEventTypes = [
19
20
  "market.discovered",
20
21
  "market.eligibility_changed",
21
- "market.max_leverage_changed"
22
+ "market.max_leverage_changed",
23
+ "market.settlement_state_changed"
22
24
  ];
23
25
  var notificationCodes = {
24
- orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING"
26
+ orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING",
27
+ partialOpenProgress: "PARTIAL_OPEN_PROGRESS",
28
+ partialOpenFloorMissed: "PARTIAL_OPEN_FLOOR_MISSED",
29
+ orderFulfillmentFailed: "ORDER_FULFILLMENT_FAILED"
25
30
  };
26
31
 
27
32
 
@@ -29,4 +34,4 @@ var notificationCodes = {
29
34
 
30
35
 
31
36
  exports.positionEventTypes = positionEventTypes; exports.marketEventTypes = marketEventTypes; exports.notificationCodes = notificationCodes;
32
- //# sourceMappingURL=chunk-53U53KZ2.cjs.map
37
+ //# sourceMappingURL=chunk-UYDXDYEP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-UYDXDYEP.cjs","../src/ws/types.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,mBAAA,EAAqB;AAAA,EAChC,oBAAA;AAAA,EACA,0BAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,wBAAA;AAAA,EACA,qBAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kCAAA;AAAA,EACA,kCAAA;AAAA,EACA,yBAAA;AAAA,EACA,gCAAA;AAAA,EACA,mBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA;AAkBO,IAAM,iBAAA,EAAmB;AAAA,EAC9B,mBAAA;AAAA,EACA,4BAAA;AAAA,EACA,6BAAA;AAAA,EACA;AACF,CAAA;AA6CO,IAAM,kBAAA,EAAoB;AAAA,EAC/B,wBAAA,EAA0B,4BAAA;AAAA,EAC1B,mBAAA,EAAqB,uBAAA;AAAA,EACrB,sBAAA,EAAwB,2BAAA;AAAA,EACxB,sBAAA,EAAwB;AAC1B,CAAA;AD7DA;AACA;AACE;AACA;AACA;AACF,4IAAC","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-UYDXDYEP.cjs","sourcesContent":[null,"import type { Market, MarketLeverage, MarketPolymarket, Position } from \"../types\";\n\nexport const positionEventTypes = [\n \"position.cancelled\",\n \"position.close_requested\",\n \"position.closed\",\n \"position.created\",\n \"position.force_unwound\",\n \"position.liquidated\",\n \"position.opened\",\n \"position.opening\",\n \"position.partial_close_requested\",\n \"position.partial_close_initiated\",\n \"position.partial_closed\",\n \"position.partial_close_aborted\",\n \"position.reverted\",\n \"position.settled\",\n \"position.settlement_state_changed\",\n] as const;\n\nexport type PositionEventType = (typeof positionEventTypes)[number];\n\nexport interface PositionEventEnvelope {\n id: string;\n type: PositionEventType;\n created_at: string;\n data: Record<string, unknown>;\n}\n\nexport interface PositionEvent {\n id: string;\n type: PositionEventType;\n createdAt: string;\n data: Position;\n}\n\nexport const marketEventTypes = [\n \"market.discovered\",\n \"market.eligibility_changed\",\n \"market.max_leverage_changed\",\n \"market.settlement_state_changed\",\n] as const;\n\nexport type MarketEventType = (typeof marketEventTypes)[number];\n\nexport type MarketDelta = Pick<Market, \"id\"> & {\n polymarket: MarketPolymarket;\n leverage?: MarketLeverage;\n} & Partial<Omit<Market, \"id\" | \"leverage\">>;\n\nexport interface MarketEventEnvelope {\n id: string;\n type: MarketEventType;\n created_at: string;\n data: Record<string, unknown>[];\n}\n\nexport interface MarketEvent {\n id: string;\n type: MarketEventType;\n createdAt: string;\n data: Market[] | MarketDelta[];\n}\n\nexport interface NotificationEventEnvelope {\n id: string;\n type: \"notification\";\n created_at: string;\n data: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n };\n}\n\nexport interface NotificationEvent {\n id: string;\n type: \"notification\";\n createdAt: string;\n data: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n };\n}\n\nexport const notificationCodes = {\n orderFulfillmentRetrying: \"ORDER_FULFILLMENT_RETRYING\",\n partialOpenProgress: \"PARTIAL_OPEN_PROGRESS\",\n partialOpenFloorMissed: \"PARTIAL_OPEN_FLOOR_MISSED\",\n orderFulfillmentFailed: \"ORDER_FULFILLMENT_FAILED\",\n} as const;\n\nexport type NotificationCode = (typeof notificationCodes)[keyof typeof notificationCodes];\n"]}
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunk72LTVPD2cjs = require('../chunk-72LTVPD2.cjs');
4
+ var _chunkKNGEIWFRcjs = require('../chunk-KNGEIWFR.cjs');
5
5
 
6
6
  // src/contract/vault-abi.json
7
7
  var vault_abi_default = {
@@ -5598,7 +5598,7 @@ var _viem = require('viem');
5598
5598
  function toHex(value) {
5599
5599
  if (!_viem.isHex.call(void 0, value)) {
5600
5600
  const HEX_PREVIEW_LENGTH = 10;
5601
- throw new (0, _chunk72LTVPD2cjs.DimesError)(
5601
+ throw new (0, _chunkKNGEIWFRcjs.DimesError)(
5602
5602
  "invalid_hex",
5603
5603
  `Expected hex string starting with 0x, got: ${value.slice(0, HEX_PREVIEW_LENGTH)}`
5604
5604
  );
@@ -5607,7 +5607,7 @@ function toHex(value) {
5607
5607
  }
5608
5608
  function toAddress(value) {
5609
5609
  if (!_viem.isAddress.call(void 0, value)) {
5610
- throw new (0, _chunk72LTVPD2cjs.DimesError)("invalid_address", `Invalid EVM address: ${value}`);
5610
+ throw new (0, _chunkKNGEIWFRcjs.DimesError)("invalid_address", `Invalid EVM address: ${value}`);
5611
5611
  }
5612
5612
  return _viem.getAddress.call(void 0, value);
5613
5613
  }
@@ -5902,7 +5902,7 @@ async function assertQuoteSigner(quote, userAddress, expectedSigner) {
5902
5902
  const recoveredSigner = await recoverCreatePositionSigner(quote, userAddress);
5903
5903
  const expected = _viem.getAddress.call(void 0, expectedSigner);
5904
5904
  if (recoveredSigner !== expected) {
5905
- throw new (0, _chunk72LTVPD2cjs.DimesContractError)(
5905
+ throw new (0, _chunkKNGEIWFRcjs.DimesContractError)(
5906
5906
  "invalid_signer",
5907
5907
  `Recovered signer ${recoveredSigner} does not match expected authority ${expected}`
5908
5908
  );
@@ -6025,12 +6025,12 @@ function firstLine(s) {
6025
6025
  }
6026
6026
  function formatContractError(err) {
6027
6027
  if (!err) {
6028
- return new (0, _chunk72LTVPD2cjs.DimesContractError)("unknown", "Transaction failed.");
6028
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)("unknown", "Transaction failed.");
6029
6029
  }
6030
6030
  if (err instanceof _viem.BaseError) {
6031
6031
  const rejected = err.walk((e) => e instanceof _viem.UserRejectedRequestError);
6032
6032
  if (rejected) {
6033
- return new (0, _chunk72LTVPD2cjs.DimesContractError)("UserRejected", "Transaction rejected in wallet.");
6033
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)("UserRejected", "Transaction rejected in wallet.");
6034
6034
  }
6035
6035
  const reverted = err.walk(
6036
6036
  (e) => e instanceof _viem.ContractFunctionRevertedError
@@ -6041,12 +6041,12 @@ function formatContractError(err) {
6041
6041
  if (errorName) {
6042
6042
  const fmt = friendlyByErrorName[errorName];
6043
6043
  const message = fmt ? fmt(args) : humanizeName(errorName);
6044
- return new (0, _chunk72LTVPD2cjs.DimesContractError)(errorName, message);
6044
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)(errorName, message);
6045
6045
  }
6046
6046
  const raw = reverted.raw;
6047
6047
  const selector = raw && raw.length >= HEX_SELECTOR_LENGTH ? raw.slice(0, HEX_SELECTOR_LENGTH) : void 0;
6048
6048
  const selectorMessage = selector ? friendlyBySelector[selector] : void 0;
6049
- return new (0, _chunk72LTVPD2cjs.DimesContractError)(
6049
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)(
6050
6050
  _nullishCoalesce(selector, () => ( "unknown_revert")),
6051
6051
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
6052
6052
  _nullishCoalesce(_nullishCoalesce(selectorMessage, () => ( reverted.shortMessage)), () => ( "Contract reverted."))
@@ -6054,17 +6054,17 @@ function formatContractError(err) {
6054
6054
  }
6055
6055
  const exec = err.walk((e) => e instanceof _viem.ContractFunctionExecutionError);
6056
6056
  if (_optionalChain([exec, 'optionalAccess', _5 => _5.shortMessage])) {
6057
- return new (0, _chunk72LTVPD2cjs.DimesContractError)("execution_error", firstLine(exec.shortMessage));
6057
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)("execution_error", firstLine(exec.shortMessage));
6058
6058
  }
6059
6059
  if (err.shortMessage) {
6060
- return new (0, _chunk72LTVPD2cjs.DimesContractError)("base_error", firstLine(err.shortMessage));
6060
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)("base_error", firstLine(err.shortMessage));
6061
6061
  }
6062
- return new (0, _chunk72LTVPD2cjs.DimesContractError)("base_error", firstLine(err.message));
6062
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)("base_error", firstLine(err.message));
6063
6063
  }
6064
6064
  if (err instanceof Error) {
6065
- return new (0, _chunk72LTVPD2cjs.DimesContractError)("error", firstLine(err.message));
6065
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)("error", firstLine(err.message));
6066
6066
  }
6067
- return new (0, _chunk72LTVPD2cjs.DimesContractError)("unknown", "Transaction failed.");
6067
+ return new (0, _chunkKNGEIWFRcjs.DimesContractError)("unknown", "Transaction failed.");
6068
6068
  }
6069
6069
 
6070
6070
 
@@ -1,8 +1,8 @@
1
1
  import { Abi, Address, Hex } from 'viem';
2
2
  export { Address, Hex } from 'viem';
3
- import { Q as Quote, e as ContractInfo } from '../aliases-RwEPSZoO.cjs';
4
- import { D as DimesClient } from '../dimes-client-CK7WmY0g.cjs';
5
- import { D as DimesContractError } from '../dimes-error-CU1Ob_ed.cjs';
3
+ import { Q as Quote, e as ContractInfo } from '../aliases-Dne14KBa.cjs';
4
+ import { D as DimesClient } from '../dimes-client-D9tohawC.cjs';
5
+ import { D as DimesContractError } from '../dimes-error-E9yPAZb-.cjs';
6
6
 
7
7
  declare const vaultAbi: Abi;
8
8
  declare const erc20Abi: readonly [{
@@ -1,8 +1,8 @@
1
1
  import { Abi, Address, Hex } from 'viem';
2
2
  export { Address, Hex } from 'viem';
3
- import { Q as Quote, e as ContractInfo } from '../aliases-RwEPSZoO.js';
4
- import { D as DimesClient } from '../dimes-client-BLTd5GkU.js';
5
- import { D as DimesContractError } from '../dimes-error-DBT1WPVq.js';
3
+ import { Q as Quote, e as ContractInfo } from '../aliases-Dne14KBa.js';
4
+ import { D as DimesClient } from '../dimes-client-DJ1d_p31.js';
5
+ import { D as DimesContractError } from '../dimes-error-hSoOierP.js';
6
6
 
7
7
  declare const vaultAbi: Abi;
8
8
  declare const erc20Abi: readonly [{
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DimesContractError,
3
3
  DimesError
4
- } from "../chunk-PZCBUVPD.mjs";
4
+ } from "../chunk-LXZAXWLO.mjs";
5
5
 
6
6
  // src/contract/vault-abi.json
7
7
  var vault_abi_default = {
@@ -1,4 +1,4 @@
1
- import { M as Market, C as CreateQuoteParams, Q as Quote, P as Position, c as PositionTransactions, d as PositionPartialCloseList, e as ContractInfo, f as CustomerLimit, F as FeeRates, g as FeeReportParams, h as FeeReport } from './aliases-RwEPSZoO.cjs';
1
+ import { M as Market, C as CreateQuoteParams, Q as Quote, P as Position, c as PositionTransactions, d as PositionPartialCloseList, e as ContractInfo, f as CustomerLimit, F as FeeRates, g as FeeReportParams, h as FeeReport } from './aliases-Dne14KBa.cjs';
2
2
 
3
3
  declare const marketMovedCodes: Set<string>;
4
4
  type QuoteHint = {
@@ -1,4 +1,4 @@
1
- import { M as Market, C as CreateQuoteParams, Q as Quote, P as Position, c as PositionTransactions, d as PositionPartialCloseList, e as ContractInfo, f as CustomerLimit, F as FeeRates, g as FeeReportParams, h as FeeReport } from './aliases-RwEPSZoO.js';
1
+ import { M as Market, C as CreateQuoteParams, Q as Quote, P as Position, c as PositionTransactions, d as PositionPartialCloseList, e as ContractInfo, f as CustomerLimit, F as FeeRates, g as FeeReportParams, h as FeeReport } from './aliases-Dne14KBa.js';
2
2
 
3
3
  declare const marketMovedCodes: Set<string>;
4
4
  type QuoteHint = {
@@ -1,4 +1,4 @@
1
- import { Q as QuoteHint } from './dimes-client-CK7WmY0g.cjs';
1
+ import { Q as QuoteHint } from './dimes-client-D9tohawC.cjs';
2
2
 
3
3
  declare class DimesError extends Error {
4
4
  readonly code: string;
@@ -1,4 +1,4 @@
1
- import { Q as QuoteHint } from './dimes-client-BLTd5GkU.js';
1
+ import { Q as QuoteHint } from './dimes-client-DJ1d_p31.js';
2
2
 
3
3
  declare class DimesError extends Error {
4
4
  readonly code: string;
package/dist/index.cjs CHANGED
@@ -5,17 +5,17 @@
5
5
 
6
6
 
7
7
 
8
- var _chunk7SAMK7CScjs = require('./chunk-7SAMK7CS.cjs');
8
+ var _chunkIZI65LZFcjs = require('./chunk-IZI65LZF.cjs');
9
9
 
10
10
 
11
11
 
12
12
 
13
13
 
14
14
 
15
- var _chunk72LTVPD2cjs = require('./chunk-72LTVPD2.cjs');
15
+ var _chunkKNGEIWFRcjs = require('./chunk-KNGEIWFR.cjs');
16
16
 
17
17
 
18
- var _chunk53U53KZ2cjs = require('./chunk-53U53KZ2.cjs');
18
+ var _chunkUYDXDYEPcjs = require('./chunk-UYDXDYEP.cjs');
19
19
 
20
20
  // src/client/dimes-client.ts
21
21
  var _humps = require('humps');
@@ -60,7 +60,7 @@ async function throwFromResponse(response) {
60
60
  const message = _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _5 => _5.error, 'optionalAccess', _6 => _6.message]), () => ( `API error ${response.status}`));
61
61
  const rawParams = _optionalChain([parsed, 'optionalAccess', _7 => _7.error, 'optionalAccess', _8 => _8.params]);
62
62
  const params = rawParams ? _humps.camelizeKeys.call(void 0, rawParams) : null;
63
- throw new (0, _chunk72LTVPD2cjs.DimesApiError)({ status: response.status, code, type, message, params });
63
+ throw new (0, _chunkKNGEIWFRcjs.DimesApiError)({ status: response.status, code, type, message, params });
64
64
  }
65
65
  var HttpClient = class {
66
66
 
@@ -280,7 +280,7 @@ var ApiKeyAuth = (_class = class {
280
280
  });
281
281
  if (!response.ok) {
282
282
  const text = await response.text();
283
- throw new (0, _chunk72LTVPD2cjs.DimesError)("auth_token_failed", `Failed to obtain auth token (${response.status}): ${text}`);
283
+ throw new (0, _chunkKNGEIWFRcjs.DimesError)("auth_token_failed", `Failed to obtain auth token (${response.status}): ${text}`);
284
284
  }
285
285
  const data = await response.json();
286
286
  this.jwt = data.token;
@@ -323,7 +323,7 @@ var JwtAuth = (_class2 = class {
323
323
  const response = await this.fetchFn(this.tokenUrl);
324
324
  if (!response.ok) {
325
325
  const text = await response.text();
326
- throw new (0, _chunk72LTVPD2cjs.DimesError)(
326
+ throw new (0, _chunkKNGEIWFRcjs.DimesError)(
327
327
  "auth_token_failed",
328
328
  `Failed to fetch token from ${this.tokenUrl} (${response.status}): ${text}`
329
329
  );
@@ -382,14 +382,14 @@ function rejectionReasonText(code) {
382
382
  if (!code) {
383
383
  return "Not eligible for new positions";
384
384
  }
385
- const stripped = code.replace(/^quote_/i, "").replaceAll("_", " ").toLowerCase();
385
+ const stripped = code.replace(/^quote_/i, "").replace(/^notional_selector_/i, "").replaceAll("_", " ").toLowerCase();
386
386
  return stripped.charAt(0).toUpperCase() + stripped.slice(1);
387
387
  }
388
388
  function rejectionReasonShort(code) {
389
389
  if (!code) {
390
390
  return "unavailable";
391
391
  }
392
- const stripped = code.replace(/^quote_/i, "").replace(/_exceeded$/i, "").replace(/_too_(low|high)$/i, "").replaceAll("_", " ").toLowerCase();
392
+ const stripped = code.replace(/^quote_/i, "").replace(/^notional_selector_/i, "").replace(/_exceeded$/i, "").replace(/_too_(low|high)$/i, "").replaceAll("_", " ").toLowerCase();
393
393
  return stripped;
394
394
  }
395
395
 
@@ -630,5 +630,5 @@ function clampCloseTokenUnits(value, min, max) {
630
630
 
631
631
 
632
632
 
633
- exports.ApiKeyAuth = ApiKeyAuth; exports.DimesApiError = _chunk72LTVPD2cjs.DimesApiError; exports.DimesClient = DimesClient; exports.DimesContractError = _chunk72LTVPD2cjs.DimesContractError; exports.DimesError = _chunk72LTVPD2cjs.DimesError; exports.JwtAuth = JwtAuth; exports.buildQuoteParams = _chunk7SAMK7CScjs.buildQuoteParams; exports.clampCloseTokenUnits = clampCloseTokenUnits; exports.closeTokenUnitsForPct = closeTokenUnitsForPct; exports.computeMaxGain = computeMaxGain; exports.computeOriginationFeeUsdcUnits = computeOriginationFeeUsdcUnits; exports.computePolymarketTradingFee = computePolymarketTradingFee; exports.defaultSide = defaultSide; exports.estimateLiquidationPrice = estimateLiquidationPrice; exports.executeQuote = _chunk7SAMK7CScjs.executeQuote; exports.expectedPositionTokenUnits = expectedPositionTokenUnits; exports.fallbackMinPartialCloseTokenUnits = fallbackMinPartialCloseTokenUnits; exports.formatErrorMessage = _chunk72LTVPD2cjs.formatErrorMessage; exports.getOriginationFeeBreakdown = getOriginationFeeBreakdown; exports.getSidedEligibility = getSidedEligibility; exports.hintAdjustment = _chunk7SAMK7CScjs.hintAdjustment; exports.isClosedPosition = isClosedPosition; exports.isFullyClosed = isFullyClosed; exports.isFullyOpen = isFullyOpen; exports.isMarketMovedError = _chunk7SAMK7CScjs.isMarketMovedError; exports.isOpenPosition = isOpenPosition; exports.leverageMaxBps = leverageMaxBps; exports.marketMovedCodes = _chunk7SAMK7CScjs.marketMovedCodes; exports.maxLeverageBpsAtNotional = maxLeverageBpsAtNotional; exports.maxViableLeverageBpsForCollateral = maxViableLeverageBpsForCollateral; exports.partialCloseMinFractionBps = partialCloseMinFractionBps; exports.partialCloseMinTokens = partialCloseMinTokens; exports.pctBpsForCloseTokenUnits = pctBpsForCloseTokenUnits; exports.positionEventTypes = _chunk53U53KZ2cjs.positionEventTypes; exports.quoteErrorHint = _chunk7SAMK7CScjs.quoteErrorHint; exports.rejectionReasonShort = rejectionReasonShort; exports.rejectionReasonText = rejectionReasonText; exports.resolveFriendlyMessage = _chunk72LTVPD2cjs.resolveFriendlyMessage; exports.resolveOriginationFeeBps = resolveOriginationFeeBps; exports.resolveProtocolOriginationFeeBps = resolveProtocolOriginationFeeBps; exports.tokenUnitsPerToken = tokenUnitsPerToken;
633
+ exports.ApiKeyAuth = ApiKeyAuth; exports.DimesApiError = _chunkKNGEIWFRcjs.DimesApiError; exports.DimesClient = DimesClient; exports.DimesContractError = _chunkKNGEIWFRcjs.DimesContractError; exports.DimesError = _chunkKNGEIWFRcjs.DimesError; exports.JwtAuth = JwtAuth; exports.buildQuoteParams = _chunkIZI65LZFcjs.buildQuoteParams; exports.clampCloseTokenUnits = clampCloseTokenUnits; exports.closeTokenUnitsForPct = closeTokenUnitsForPct; exports.computeMaxGain = computeMaxGain; exports.computeOriginationFeeUsdcUnits = computeOriginationFeeUsdcUnits; exports.computePolymarketTradingFee = computePolymarketTradingFee; exports.defaultSide = defaultSide; exports.estimateLiquidationPrice = estimateLiquidationPrice; exports.executeQuote = _chunkIZI65LZFcjs.executeQuote; exports.expectedPositionTokenUnits = expectedPositionTokenUnits; exports.fallbackMinPartialCloseTokenUnits = fallbackMinPartialCloseTokenUnits; exports.formatErrorMessage = _chunkKNGEIWFRcjs.formatErrorMessage; exports.getOriginationFeeBreakdown = getOriginationFeeBreakdown; exports.getSidedEligibility = getSidedEligibility; exports.hintAdjustment = _chunkIZI65LZFcjs.hintAdjustment; exports.isClosedPosition = isClosedPosition; exports.isFullyClosed = isFullyClosed; exports.isFullyOpen = isFullyOpen; exports.isMarketMovedError = _chunkIZI65LZFcjs.isMarketMovedError; exports.isOpenPosition = isOpenPosition; exports.leverageMaxBps = leverageMaxBps; exports.marketMovedCodes = _chunkIZI65LZFcjs.marketMovedCodes; exports.maxLeverageBpsAtNotional = maxLeverageBpsAtNotional; exports.maxViableLeverageBpsForCollateral = maxViableLeverageBpsForCollateral; exports.partialCloseMinFractionBps = partialCloseMinFractionBps; exports.partialCloseMinTokens = partialCloseMinTokens; exports.pctBpsForCloseTokenUnits = pctBpsForCloseTokenUnits; exports.positionEventTypes = _chunkUYDXDYEPcjs.positionEventTypes; exports.quoteErrorHint = _chunkIZI65LZFcjs.quoteErrorHint; exports.rejectionReasonShort = rejectionReasonShort; exports.rejectionReasonText = rejectionReasonText; exports.resolveFriendlyMessage = _chunkKNGEIWFRcjs.resolveFriendlyMessage; exports.resolveOriginationFeeBps = resolveOriginationFeeBps; exports.resolveProtocolOriginationFeeBps = resolveProtocolOriginationFeeBps; exports.tokenUnitsPerToken = tokenUnitsPerToken;
634
634
  //# sourceMappingURL=index.cjs.map