@dimes-dot-fi/sdk 1.0.3 → 1.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.
Files changed (45) hide show
  1. package/README.md +15 -0
  2. package/dist/{dimes-client-C8wtMofm.d.cts → aliases-CXfmUrAb.d.cts} +12 -126
  3. package/dist/{dimes-client-C8wtMofm.d.ts → aliases-CXfmUrAb.d.ts} +12 -126
  4. package/dist/{chunk-BRANC7OH.mjs → chunk-EI5V5Z6G.mjs} +2 -2
  5. package/dist/{chunk-JGK55KDX.cjs → chunk-JWAPH4GD.cjs} +5 -5
  6. package/dist/{chunk-JGK55KDX.cjs.map → chunk-JWAPH4GD.cjs.map} +1 -1
  7. package/dist/{chunk-LQ5LLBR6.mjs → chunk-S65RABUT.mjs} +3 -2
  8. package/dist/{chunk-LQ5LLBR6.mjs.map → chunk-S65RABUT.mjs.map} +1 -1
  9. package/dist/{chunk-XXTTXLCT.cjs → chunk-UUE4HG2H.cjs} +3 -2
  10. package/dist/chunk-UUE4HG2H.cjs.map +1 -0
  11. package/dist/chunk-YUCGNELT.mjs +22 -0
  12. package/dist/chunk-YUCGNELT.mjs.map +1 -0
  13. package/dist/chunk-ZK56XS4X.cjs +22 -0
  14. package/dist/chunk-ZK56XS4X.cjs.map +1 -0
  15. package/dist/contract/index.cjs +13 -13
  16. package/dist/contract/index.d.cts +3 -2
  17. package/dist/contract/index.d.ts +3 -2
  18. package/dist/contract/index.mjs +1 -1
  19. package/dist/dimes-client-DfRPwGRk.d.ts +128 -0
  20. package/dist/dimes-client-Tfh-DX2h.d.cts +128 -0
  21. package/dist/{dimes-error-DJTpDU75.d.ts → dimes-error-CfbcQlUB.d.ts} +1 -1
  22. package/dist/{dimes-error-BfhINan2.d.cts → dimes-error-CrKY79nQ.d.cts} +1 -1
  23. package/dist/index.cjs +11 -7
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +7 -5
  26. package/dist/index.d.ts +7 -5
  27. package/dist/index.mjs +7 -3
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/{quote-CH01NmnL.d.cts → quote-BB2YieGk.d.ts} +2 -1
  30. package/dist/{quote-_6hQton4.d.ts → quote-DqF3MEbh.d.cts} +2 -1
  31. package/dist/react/index.cjs +4 -4
  32. package/dist/react/index.d.cts +3 -2
  33. package/dist/react/index.d.ts +3 -2
  34. package/dist/react/index.mjs +2 -2
  35. package/dist/types-B7_dC7HC.d.ts +42 -0
  36. package/dist/types-C9X_jp99.d.cts +42 -0
  37. package/dist/ws/index.cjs +133 -0
  38. package/dist/ws/index.cjs.map +1 -0
  39. package/dist/ws/index.d.cts +35 -0
  40. package/dist/ws/index.d.ts +35 -0
  41. package/dist/ws/index.mjs +133 -0
  42. package/dist/ws/index.mjs.map +1 -0
  43. package/package.json +13 -2
  44. package/dist/chunk-XXTTXLCT.cjs.map +0 -1
  45. /package/dist/{chunk-BRANC7OH.mjs.map → chunk-EI5V5Z6G.mjs.map} +0 -0
@@ -219,7 +219,8 @@ var friendlyByCode = {
219
219
  }
220
220
  return "Leverage is too high for the current price. Reduce leverage.";
221
221
  },
222
- quote_hard_exit_too_close: "Hard-exit is too close to entry. Reduce leverage.",
222
+ quote_trading_window_closing: "Trading window is closing. Reduce leverage.",
223
+ quote_hard_exit_too_close: "Trading window is closing. Reduce leverage.",
223
224
  quote_liquidation_not_viable: (params) => {
224
225
  const tolerance = formatBpsPct(getParam(params, "minTolerancePctBps"));
225
226
  return tolerance ? `Liquidation price is too close to entry (minimum buffer ${tolerance}). Reduce leverage.` : "Liquidation price is not viable at this leverage. Reduce leverage.";
@@ -309,4 +310,4 @@ var DimesContractError = class extends DimesError {
309
310
 
310
311
 
311
312
  exports.resolveFriendlyMessage = resolveFriendlyMessage; exports.formatErrorMessage = formatErrorMessage; exports.DimesError = DimesError; exports.DimesApiError = DimesApiError; exports.DimesContractError = DimesContractError;
312
- //# sourceMappingURL=chunk-XXTTXLCT.cjs.map
313
+ //# sourceMappingURL=chunk-UUE4HG2H.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-UUE4HG2H.cjs","../src/utils/parse.ts","../src/utils/format.ts","../src/errors/error-messages.ts","../src/errors/dimes-error.ts"],"names":[],"mappings":"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","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-UUE4HG2H.cjs","sourcesContent":[null,"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 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\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_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_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"]}
@@ -0,0 +1,22 @@
1
+ // src/ws/types.ts
2
+ var positionEventTypes = [
3
+ "position.cancelled",
4
+ "position.close_requested",
5
+ "position.closed",
6
+ "position.created",
7
+ "position.force_unwound",
8
+ "position.liquidated",
9
+ "position.opened",
10
+ "position.opening",
11
+ "position.reverted",
12
+ "position.settled"
13
+ ];
14
+ var notificationCodes = {
15
+ orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING"
16
+ };
17
+
18
+ export {
19
+ positionEventTypes,
20
+ notificationCodes
21
+ };
22
+ //# sourceMappingURL=chunk-YUCGNELT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ws/types.ts"],"sourcesContent":["import type { 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.reverted\",\n \"position.settled\",\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 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} 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;AACF;AAwCO,IAAM,oBAAoB;AAAA,EAC/B,0BAA0B;AAC5B;","names":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/ws/types.ts
2
+ var positionEventTypes = [
3
+ "position.cancelled",
4
+ "position.close_requested",
5
+ "position.closed",
6
+ "position.created",
7
+ "position.force_unwound",
8
+ "position.liquidated",
9
+ "position.opened",
10
+ "position.opening",
11
+ "position.reverted",
12
+ "position.settled"
13
+ ];
14
+ var notificationCodes = {
15
+ orderFulfillmentRetrying: "ORDER_FULFILLMENT_RETRYING"
16
+ };
17
+
18
+
19
+
20
+
21
+ exports.positionEventTypes = positionEventTypes; exports.notificationCodes = notificationCodes;
22
+ //# sourceMappingURL=chunk-ZK56XS4X.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-ZK56XS4X.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,mBAAA;AAAA,EACA;AACF,CAAA;AAwCO,IAAM,kBAAA,EAAoB;AAAA,EAC/B,wBAAA,EAA0B;AAC5B,CAAA;ADvCA;AACA;AACE;AACA;AACF,+FAAC","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-ZK56XS4X.cjs","sourcesContent":[null,"import type { 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.reverted\",\n \"position.settled\",\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 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} 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(); } } 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 _chunkXXTTXLCTcjs = require('../chunk-XXTTXLCT.cjs');
4
+ var _chunkUUE4HG2Hcjs = require('../chunk-UUE4HG2H.cjs');
5
5
 
6
6
  // src/contract/vault-abi.json
7
7
  var vault_abi_default = {
@@ -411,7 +411,7 @@ var _viem = require('viem');
411
411
  function toHex(value) {
412
412
  if (!_viem.isHex.call(void 0, value)) {
413
413
  const HEX_PREVIEW_LENGTH = 10;
414
- throw new (0, _chunkXXTTXLCTcjs.DimesError)(
414
+ throw new (0, _chunkUUE4HG2Hcjs.DimesError)(
415
415
  "invalid_hex",
416
416
  `Expected hex string starting with 0x, got: ${value.slice(0, HEX_PREVIEW_LENGTH)}`
417
417
  );
@@ -420,7 +420,7 @@ function toHex(value) {
420
420
  }
421
421
  function toAddress(value) {
422
422
  if (!_viem.isAddress.call(void 0, value)) {
423
- throw new (0, _chunkXXTTXLCTcjs.DimesError)("invalid_address", `Invalid EVM address: ${value}`);
423
+ throw new (0, _chunkUUE4HG2Hcjs.DimesError)("invalid_address", `Invalid EVM address: ${value}`);
424
424
  }
425
425
  return _viem.getAddress.call(void 0, value);
426
426
  }
@@ -522,7 +522,7 @@ async function verifyOfferSignature(client, offer, userAddress) {
522
522
  const recoveredSigner = await recoverCreatePositionSigner(offer, userAddress);
523
523
  const expectedSigner = _viem.getAddress.call(void 0, info.polygonSignerAddress);
524
524
  if (recoveredSigner !== expectedSigner) {
525
- throw new (0, _chunkXXTTXLCTcjs.DimesContractError)(
525
+ throw new (0, _chunkUUE4HG2Hcjs.DimesContractError)(
526
526
  "invalid_signer",
527
527
  `Recovered signer ${recoveredSigner} does not match expected authority ${expectedSigner}`
528
528
  );
@@ -613,12 +613,12 @@ function firstLine(s) {
613
613
  }
614
614
  function formatContractError(err) {
615
615
  if (!err) {
616
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)("unknown", "Transaction failed.");
616
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)("unknown", "Transaction failed.");
617
617
  }
618
618
  if (err instanceof _viem.BaseError) {
619
619
  const rejected = err.walk((e) => e instanceof _viem.UserRejectedRequestError);
620
620
  if (rejected) {
621
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)("UserRejected", "Transaction rejected in wallet.");
621
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)("UserRejected", "Transaction rejected in wallet.");
622
622
  }
623
623
  const reverted = err.walk(
624
624
  (e) => e instanceof _viem.ContractFunctionRevertedError
@@ -629,12 +629,12 @@ function formatContractError(err) {
629
629
  if (errorName) {
630
630
  const fmt = friendlyByErrorName[errorName];
631
631
  const message = fmt ? fmt(args) : humanizeName(errorName);
632
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)(errorName, message);
632
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)(errorName, message);
633
633
  }
634
634
  const raw = reverted.raw;
635
635
  const selector = raw && raw.length >= HEX_SELECTOR_LENGTH ? raw.slice(0, HEX_SELECTOR_LENGTH) : void 0;
636
636
  const selectorMessage = selector ? friendlyBySelector[selector] : void 0;
637
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)(
637
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)(
638
638
  _nullishCoalesce(selector, () => ( "unknown_revert")),
639
639
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
640
640
  _nullishCoalesce(_nullishCoalesce(selectorMessage, () => ( reverted.shortMessage)), () => ( "Contract reverted."))
@@ -642,17 +642,17 @@ function formatContractError(err) {
642
642
  }
643
643
  const exec = err.walk((e) => e instanceof _viem.ContractFunctionExecutionError);
644
644
  if (_optionalChain([exec, 'optionalAccess', _5 => _5.shortMessage])) {
645
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)("execution_error", firstLine(exec.shortMessage));
645
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)("execution_error", firstLine(exec.shortMessage));
646
646
  }
647
647
  if (err.shortMessage) {
648
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)("base_error", firstLine(err.shortMessage));
648
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)("base_error", firstLine(err.shortMessage));
649
649
  }
650
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)("base_error", firstLine(err.message));
650
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)("base_error", firstLine(err.message));
651
651
  }
652
652
  if (err instanceof Error) {
653
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)("error", firstLine(err.message));
653
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)("error", firstLine(err.message));
654
654
  }
655
- return new (0, _chunkXXTTXLCTcjs.DimesContractError)("unknown", "Transaction failed.");
655
+ return new (0, _chunkUUE4HG2Hcjs.DimesContractError)("unknown", "Transaction failed.");
656
656
  }
657
657
 
658
658
 
@@ -1,7 +1,8 @@
1
1
  import { Abi, Address, Hex } from 'viem';
2
2
  export { Address, Hex } from 'viem';
3
- import { O as Offer, D as DimesClient } from '../dimes-client-C8wtMofm.cjs';
4
- import { a as DimesContractError } from '../dimes-error-BfhINan2.cjs';
3
+ import { O as Offer } from '../aliases-CXfmUrAb.cjs';
4
+ import { D as DimesClient } from '../dimes-client-Tfh-DX2h.cjs';
5
+ import { a as DimesContractError } from '../dimes-error-CrKY79nQ.cjs';
5
6
 
6
7
  declare const vaultAbi: Abi;
7
8
  declare const erc20Abi: readonly [{
@@ -1,7 +1,8 @@
1
1
  import { Abi, Address, Hex } from 'viem';
2
2
  export { Address, Hex } from 'viem';
3
- import { O as Offer, D as DimesClient } from '../dimes-client-C8wtMofm.js';
4
- import { a as DimesContractError } from '../dimes-error-DJTpDU75.js';
3
+ import { O as Offer } from '../aliases-CXfmUrAb.js';
4
+ import { D as DimesClient } from '../dimes-client-DfRPwGRk.js';
5
+ import { a as DimesContractError } from '../dimes-error-CfbcQlUB.js';
5
6
 
6
7
  declare const vaultAbi: Abi;
7
8
  declare const erc20Abi: readonly [{
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DimesContractError,
3
3
  DimesError
4
- } from "../chunk-LQ5LLBR6.mjs";
4
+ } from "../chunk-S65RABUT.mjs";
5
5
 
6
6
  // src/contract/vault-abi.json
7
7
  var vault_abi_default = {
@@ -0,0 +1,128 @@
1
+ import { M as Market, C as CreateOfferParams, O as Offer, P as Position, c as ContractInfo, e as CustomerLimit } from './aliases-CXfmUrAb.js';
2
+
3
+ declare const marketMovedCodes: Set<string>;
4
+ type QuoteHint = {
5
+ kind: "use-max-collateral";
6
+ maxCollateralUsd: number;
7
+ minCollateralUsd: number;
8
+ } | {
9
+ kind: "clamp-leverage";
10
+ maxLeverageBps?: number;
11
+ } | {
12
+ kind: "raise-leverage";
13
+ minLeverageBps: number;
14
+ } | {
15
+ kind: "raise-slippage";
16
+ currentSlippageBps: number;
17
+ maxSlippageBps: number;
18
+ } | {
19
+ kind: "market-full";
20
+ } | null;
21
+ type Params = Record<string, unknown> | null | undefined;
22
+ declare function quoteErrorHint(code: string | null, params: Params, context: {
23
+ leverageBps: number;
24
+ }): QuoteHint;
25
+ type CorrectedField = "collateral" | "leverage" | "slippage";
26
+ type HintAdjustment = {
27
+ field: "collateral";
28
+ fromValue: number;
29
+ toValue: number;
30
+ toLabel: string;
31
+ reason: "max-collateral";
32
+ } | {
33
+ field: "leverage";
34
+ fromValue: number;
35
+ toValue: number;
36
+ toLabel: string;
37
+ reason: "clamp-max" | "raise-min";
38
+ } | {
39
+ field: "slippage";
40
+ fromValue: number;
41
+ toValue: number;
42
+ toLabel: string;
43
+ reason: "raise-slippage";
44
+ } | null;
45
+ declare function hintAdjustment(hint: QuoteHint, current: {
46
+ collateralUsd: number;
47
+ leverageBps: number;
48
+ slippageBps: number;
49
+ }): HintAdjustment;
50
+
51
+ interface Paginated<T> {
52
+ data: T[];
53
+ hasMore: boolean;
54
+ }
55
+
56
+ interface AuthProvider {
57
+ getHeaders(): Promise<Record<string, string>>;
58
+ refresh?(): Promise<void>;
59
+ }
60
+ interface ApiKeyAuthOptions {
61
+ apiKey: string;
62
+ walletAddress: string;
63
+ baseUrl?: string;
64
+ fetch?: typeof globalThis.fetch;
65
+ }
66
+ declare class ApiKeyAuth implements AuthProvider {
67
+ private jwt;
68
+ private expiresAt;
69
+ private refreshPromise;
70
+ private readonly apiKey;
71
+ private readonly walletAddress;
72
+ private readonly baseUrl;
73
+ private readonly fetchFn;
74
+ constructor(options: ApiKeyAuthOptions);
75
+ getHeaders(): Promise<Record<string, string>>;
76
+ refresh(): Promise<void>;
77
+ private fetchToken;
78
+ }
79
+ interface JwtAuthOptions {
80
+ tokenUrl: string;
81
+ fetch?: typeof globalThis.fetch;
82
+ }
83
+ declare class JwtAuth implements AuthProvider {
84
+ private readonly fetchFn;
85
+ private readonly tokenUrl;
86
+ private jwt;
87
+ private expiresAt;
88
+ private refreshPromise;
89
+ constructor(options: JwtAuthOptions);
90
+ getHeaders(): Promise<Record<string, string>>;
91
+ refresh(): Promise<void>;
92
+ private fetchToken;
93
+ }
94
+
95
+ interface DimesClientOptions {
96
+ baseUrl?: string;
97
+ auth: AuthProvider;
98
+ fetch?: typeof globalThis.fetch;
99
+ maxRetries?: number;
100
+ maxRetryDelayMs?: number;
101
+ }
102
+ interface GetMarketsParams {
103
+ cursor?: string;
104
+ limit?: number;
105
+ category?: string;
106
+ status?: string;
107
+ provider?: "polymarket" | "kalshi";
108
+ }
109
+ interface GetPositionsParams {
110
+ cursor?: string;
111
+ limit?: number;
112
+ status?: "open" | "closed";
113
+ }
114
+ declare class DimesClient {
115
+ private readonly http;
116
+ constructor(options: DimesClientOptions);
117
+ getMarkets(params?: GetMarketsParams): Promise<Paginated<Market>>;
118
+ getMarket(ticker: string): Promise<Market>;
119
+ createDraftQuote(params: CreateOfferParams): Promise<Offer>;
120
+ promoteDraftQuote(draftId: string): Promise<Offer>;
121
+ createQuote(params: CreateOfferParams): Promise<Offer>;
122
+ getPositions(params?: GetPositionsParams): Promise<Position[]>;
123
+ cancelPosition(positionId: string): Promise<void>;
124
+ getContractInfo(): Promise<ContractInfo>;
125
+ getLimits(): Promise<CustomerLimit>;
126
+ }
127
+
128
+ export { ApiKeyAuth as A, type CorrectedField as C, DimesClient as D, type GetMarketsParams as G, type HintAdjustment as H, JwtAuth as J, type Paginated as P, type QuoteHint as Q, type ApiKeyAuthOptions as a, type AuthProvider as b, type DimesClientOptions as c, type GetPositionsParams as d, type JwtAuthOptions as e, hintAdjustment as h, marketMovedCodes as m, quoteErrorHint as q };
@@ -0,0 +1,128 @@
1
+ import { M as Market, C as CreateOfferParams, O as Offer, P as Position, c as ContractInfo, e as CustomerLimit } from './aliases-CXfmUrAb.cjs';
2
+
3
+ declare const marketMovedCodes: Set<string>;
4
+ type QuoteHint = {
5
+ kind: "use-max-collateral";
6
+ maxCollateralUsd: number;
7
+ minCollateralUsd: number;
8
+ } | {
9
+ kind: "clamp-leverage";
10
+ maxLeverageBps?: number;
11
+ } | {
12
+ kind: "raise-leverage";
13
+ minLeverageBps: number;
14
+ } | {
15
+ kind: "raise-slippage";
16
+ currentSlippageBps: number;
17
+ maxSlippageBps: number;
18
+ } | {
19
+ kind: "market-full";
20
+ } | null;
21
+ type Params = Record<string, unknown> | null | undefined;
22
+ declare function quoteErrorHint(code: string | null, params: Params, context: {
23
+ leverageBps: number;
24
+ }): QuoteHint;
25
+ type CorrectedField = "collateral" | "leverage" | "slippage";
26
+ type HintAdjustment = {
27
+ field: "collateral";
28
+ fromValue: number;
29
+ toValue: number;
30
+ toLabel: string;
31
+ reason: "max-collateral";
32
+ } | {
33
+ field: "leverage";
34
+ fromValue: number;
35
+ toValue: number;
36
+ toLabel: string;
37
+ reason: "clamp-max" | "raise-min";
38
+ } | {
39
+ field: "slippage";
40
+ fromValue: number;
41
+ toValue: number;
42
+ toLabel: string;
43
+ reason: "raise-slippage";
44
+ } | null;
45
+ declare function hintAdjustment(hint: QuoteHint, current: {
46
+ collateralUsd: number;
47
+ leverageBps: number;
48
+ slippageBps: number;
49
+ }): HintAdjustment;
50
+
51
+ interface Paginated<T> {
52
+ data: T[];
53
+ hasMore: boolean;
54
+ }
55
+
56
+ interface AuthProvider {
57
+ getHeaders(): Promise<Record<string, string>>;
58
+ refresh?(): Promise<void>;
59
+ }
60
+ interface ApiKeyAuthOptions {
61
+ apiKey: string;
62
+ walletAddress: string;
63
+ baseUrl?: string;
64
+ fetch?: typeof globalThis.fetch;
65
+ }
66
+ declare class ApiKeyAuth implements AuthProvider {
67
+ private jwt;
68
+ private expiresAt;
69
+ private refreshPromise;
70
+ private readonly apiKey;
71
+ private readonly walletAddress;
72
+ private readonly baseUrl;
73
+ private readonly fetchFn;
74
+ constructor(options: ApiKeyAuthOptions);
75
+ getHeaders(): Promise<Record<string, string>>;
76
+ refresh(): Promise<void>;
77
+ private fetchToken;
78
+ }
79
+ interface JwtAuthOptions {
80
+ tokenUrl: string;
81
+ fetch?: typeof globalThis.fetch;
82
+ }
83
+ declare class JwtAuth implements AuthProvider {
84
+ private readonly fetchFn;
85
+ private readonly tokenUrl;
86
+ private jwt;
87
+ private expiresAt;
88
+ private refreshPromise;
89
+ constructor(options: JwtAuthOptions);
90
+ getHeaders(): Promise<Record<string, string>>;
91
+ refresh(): Promise<void>;
92
+ private fetchToken;
93
+ }
94
+
95
+ interface DimesClientOptions {
96
+ baseUrl?: string;
97
+ auth: AuthProvider;
98
+ fetch?: typeof globalThis.fetch;
99
+ maxRetries?: number;
100
+ maxRetryDelayMs?: number;
101
+ }
102
+ interface GetMarketsParams {
103
+ cursor?: string;
104
+ limit?: number;
105
+ category?: string;
106
+ status?: string;
107
+ provider?: "polymarket" | "kalshi";
108
+ }
109
+ interface GetPositionsParams {
110
+ cursor?: string;
111
+ limit?: number;
112
+ status?: "open" | "closed";
113
+ }
114
+ declare class DimesClient {
115
+ private readonly http;
116
+ constructor(options: DimesClientOptions);
117
+ getMarkets(params?: GetMarketsParams): Promise<Paginated<Market>>;
118
+ getMarket(ticker: string): Promise<Market>;
119
+ createDraftQuote(params: CreateOfferParams): Promise<Offer>;
120
+ promoteDraftQuote(draftId: string): Promise<Offer>;
121
+ createQuote(params: CreateOfferParams): Promise<Offer>;
122
+ getPositions(params?: GetPositionsParams): Promise<Position[]>;
123
+ cancelPosition(positionId: string): Promise<void>;
124
+ getContractInfo(): Promise<ContractInfo>;
125
+ getLimits(): Promise<CustomerLimit>;
126
+ }
127
+
128
+ export { ApiKeyAuth as A, type CorrectedField as C, DimesClient as D, type GetMarketsParams as G, type HintAdjustment as H, JwtAuth as J, type Paginated as P, type QuoteHint as Q, type ApiKeyAuthOptions as a, type AuthProvider as b, type DimesClientOptions as c, type GetPositionsParams as d, type JwtAuthOptions as e, hintAdjustment as h, marketMovedCodes as m, quoteErrorHint as q };
@@ -1,4 +1,4 @@
1
- import { Q as QuoteHint } from './dimes-client-C8wtMofm.js';
1
+ import { Q as QuoteHint } from './dimes-client-DfRPwGRk.js';
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-C8wtMofm.cjs';
1
+ import { Q as QuoteHint } from './dimes-client-Tfh-DX2h.cjs';
2
2
 
3
3
  declare class DimesError extends Error {
4
4
  readonly code: string;
package/dist/index.cjs CHANGED
@@ -4,14 +4,17 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkJGK55KDXcjs = require('./chunk-JGK55KDX.cjs');
7
+ var _chunkJWAPH4GDcjs = require('./chunk-JWAPH4GD.cjs');
8
8
 
9
9
 
10
10
 
11
11
 
12
12
 
13
13
 
14
- var _chunkXXTTXLCTcjs = require('./chunk-XXTTXLCT.cjs');
14
+ var _chunkUUE4HG2Hcjs = require('./chunk-UUE4HG2H.cjs');
15
+
16
+
17
+ var _chunkZK56XS4Xcjs = require('./chunk-ZK56XS4X.cjs');
15
18
 
16
19
  // src/client/dimes-client.ts
17
20
  var _humps = require('humps');
@@ -53,10 +56,10 @@ async function throwFromResponse(response) {
53
56
  }
54
57
  const code = _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _ => _.error, 'optionalAccess', _2 => _2.code]), () => ( "unknown_error"));
55
58
  const type = _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _3 => _3.error, 'optionalAccess', _4 => _4.type]), () => ( null));
56
- const message = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _5 => _5.error, 'optionalAccess', _6 => _6.message]), () => ( code)), () => ( rawBody)), () => ( `API error ${response.status}`));
59
+ const message = _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _5 => _5.error, 'optionalAccess', _6 => _6.message]), () => ( `API error ${response.status}`));
57
60
  const rawParams = _optionalChain([parsed, 'optionalAccess', _7 => _7.error, 'optionalAccess', _8 => _8.params]);
58
61
  const params = rawParams ? _humps.camelizeKeys.call(void 0, rawParams) : null;
59
- throw new (0, _chunkXXTTXLCTcjs.DimesApiError)({ status: response.status, code, type, message, params });
62
+ throw new (0, _chunkUUE4HG2Hcjs.DimesApiError)({ status: response.status, code, type, message, params });
60
63
  }
61
64
  var HttpClient = class {
62
65
 
@@ -225,7 +228,7 @@ var ApiKeyAuth = (_class = class {
225
228
  });
226
229
  if (!response.ok) {
227
230
  const text = await response.text();
228
- throw new (0, _chunkXXTTXLCTcjs.DimesError)("auth_token_failed", `Failed to obtain auth token (${response.status}): ${text}`);
231
+ throw new (0, _chunkUUE4HG2Hcjs.DimesError)("auth_token_failed", `Failed to obtain auth token (${response.status}): ${text}`);
229
232
  }
230
233
  const data = await response.json();
231
234
  this.jwt = data.token;
@@ -265,7 +268,7 @@ var JwtAuth = (_class2 = class {
265
268
  const response = await this.fetchFn(this.tokenUrl);
266
269
  if (!response.ok) {
267
270
  const text = await response.text();
268
- throw new (0, _chunkXXTTXLCTcjs.DimesError)(
271
+ throw new (0, _chunkUUE4HG2Hcjs.DimesError)(
269
272
  "auth_token_failed",
270
273
  `Failed to fetch token from ${this.tokenUrl} (${response.status}): ${text}`
271
274
  );
@@ -304,5 +307,6 @@ function leverageMaxBps(lev, side) {
304
307
 
305
308
 
306
309
 
307
- exports.ApiKeyAuth = ApiKeyAuth; exports.DimesApiError = _chunkXXTTXLCTcjs.DimesApiError; exports.DimesClient = DimesClient; exports.DimesContractError = _chunkXXTTXLCTcjs.DimesContractError; exports.DimesError = _chunkXXTTXLCTcjs.DimesError; exports.JwtAuth = JwtAuth; exports.buildQuoteParams = _chunkJGK55KDXcjs.buildQuoteParams; exports.executeQuote = _chunkJGK55KDXcjs.executeQuote; exports.formatErrorMessage = _chunkXXTTXLCTcjs.formatErrorMessage; exports.hintAdjustment = _chunkJGK55KDXcjs.hintAdjustment; exports.isClosedPosition = isClosedPosition; exports.isOpenPosition = isOpenPosition; exports.leverageMaxBps = leverageMaxBps; exports.marketMovedCodes = _chunkJGK55KDXcjs.marketMovedCodes; exports.quoteErrorHint = _chunkJGK55KDXcjs.quoteErrorHint; exports.resolveFriendlyMessage = _chunkXXTTXLCTcjs.resolveFriendlyMessage;
310
+
311
+ exports.ApiKeyAuth = ApiKeyAuth; exports.DimesApiError = _chunkUUE4HG2Hcjs.DimesApiError; exports.DimesClient = DimesClient; exports.DimesContractError = _chunkUUE4HG2Hcjs.DimesContractError; exports.DimesError = _chunkUUE4HG2Hcjs.DimesError; exports.JwtAuth = JwtAuth; exports.buildQuoteParams = _chunkJWAPH4GDcjs.buildQuoteParams; exports.executeQuote = _chunkJWAPH4GDcjs.executeQuote; exports.formatErrorMessage = _chunkUUE4HG2Hcjs.formatErrorMessage; exports.hintAdjustment = _chunkJWAPH4GDcjs.hintAdjustment; exports.isClosedPosition = isClosedPosition; exports.isOpenPosition = isOpenPosition; exports.leverageMaxBps = leverageMaxBps; exports.marketMovedCodes = _chunkJWAPH4GDcjs.marketMovedCodes; exports.positionEventTypes = _chunkZK56XS4Xcjs.positionEventTypes; exports.quoteErrorHint = _chunkJWAPH4GDcjs.quoteErrorHint; exports.resolveFriendlyMessage = _chunkUUE4HG2Hcjs.resolveFriendlyMessage;
308
312
  //# sourceMappingURL=index.cjs.map