@dimes-dot-fi/sdk 1.0.0 → 1.0.6

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 +236 -0
  2. package/dist/{dimes-client-BLIAuK4M.d.cts → aliases-CXfmUrAb.d.cts} +12 -119
  3. package/dist/{dimes-client-BLIAuK4M.d.ts → aliases-CXfmUrAb.d.ts} +12 -119
  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-MSD7A3XX.cjs +18 -0
  8. package/dist/chunk-MSD7A3XX.cjs.map +1 -0
  9. package/dist/{chunk-LQ5LLBR6.mjs → chunk-S65RABUT.mjs} +3 -2
  10. package/dist/{chunk-LQ5LLBR6.mjs.map → chunk-S65RABUT.mjs.map} +1 -1
  11. package/dist/{chunk-XXTTXLCT.cjs → chunk-UUE4HG2H.cjs} +3 -2
  12. package/dist/chunk-UUE4HG2H.cjs.map +1 -0
  13. package/dist/chunk-XWRROLKW.mjs +18 -0
  14. package/dist/chunk-XWRROLKW.mjs.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-BtDMi3Kv.d.ts → dimes-error-CfbcQlUB.d.ts} +1 -1
  22. package/dist/{dimes-error-DxzsfQo6.d.cts → dimes-error-CrKY79nQ.d.cts} +1 -1
  23. package/dist/index.cjs +50 -13
  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 +44 -7
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/{quote-ByZJRoPf.d.cts → quote-BB2YieGk.d.ts} +2 -1
  30. package/dist/{quote-CgmTKnIZ.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-C2WfUBLu.d.cts +18 -0
  36. package/dist/types-oz2d_Nyk.d.ts +18 -0
  37. package/dist/ws/index.cjs +115 -0
  38. package/dist/ws/index.cjs.map +1 -0
  39. package/dist/ws/index.d.cts +32 -0
  40. package/dist/ws/index.d.ts +32 -0
  41. package/dist/ws/index.mjs +115 -0
  42. package/dist/ws/index.mjs.map +1 -0
  43. package/package.json +17 -3
  44. package/dist/chunk-XXTTXLCT.cjs.map +0 -1
  45. /package/dist/{chunk-BRANC7OH.mjs.map → chunk-EI5V5Z6G.mjs.map} +0 -0
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+ <p align="center">
2
+ <strong>@dimes-dot-fi/sdk</strong>
3
+ </p>
4
+
5
+ <p align="center">
6
+ TypeScript SDK for building on <a href="https://dimes.fi">Dimes Multiply</a> — leveraged prediction markets.
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@dimes-dot-fi/sdk"><img src="https://img.shields.io/npm/v/@dimes-dot-fi/sdk.svg" alt="npm version"></a>
11
+ <a href="https://www.npmjs.com/package/@dimes-dot-fi/sdk"><img src="https://img.shields.io/npm/dm/@dimes-dot-fi/sdk.svg" alt="npm downloads"></a>
12
+ <a href="https://github.com/nicktids"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license"></a>
13
+ <a href="https://docs.dimes.fi"><img src="https://img.shields.io/badge/docs-dimes.fi-black.svg" alt="docs"></a>
14
+ </p>
15
+
16
+ ---
17
+
18
+ Dimes Multiply is a middle-layer protocol that lets trading terminals, wallets, and apps offer up to 10x leveraged exposure on prediction markets (Polymarket) without building internal leverage infrastructure. This SDK gives you a type-safe TypeScript client for the Multiply API, a quote engine with auto-correction, React hooks, and viem-compatible on-chain transaction builders.
19
+
20
+ ## Features
21
+
22
+ - **Full API client** — typed methods for markets, quotes, positions, and contract info with automatic camelCase conversion
23
+ - **Quote engine** — `executeQuote()` handles the draft → promote flow, retries on market-moved errors, and auto-corrects leverage/collateral/slippage
24
+ - **React hooks** — `useMarkets()`, `usePositions()`, `useQuote()`, `useContractInfo()`, and more — works with your existing TanStack Query setup
25
+ - **On-chain builders** — viem-compatible transaction data for `createPosition`, `approve`, and `requestClose`
26
+ - **Signature verification** — verify quote signatures against the contract-info endpoint with per-client caching
27
+ - **Auth management** — `ApiKeyAuth` auto-obtains and refreshes JWTs; `JwtAuth` for static or dynamic tokens
28
+ - **Error handling** — typed `DimesApiError` with friendly messages, structured hints, and programmatic correction suggestions
29
+ - **Tree-shakeable** — three entry points, ESM + CJS, zero runtime dependencies beyond `humps`
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ npm install @dimes-dot-fi/sdk
35
+ ```
36
+
37
+ ## Entry Points
38
+
39
+ | Import | What | Peer deps |
40
+ |--------|------|-----------|
41
+ | `@dimes-dot-fi/sdk` | Client, quote engine, errors, types | — |
42
+ | `@dimes-dot-fi/sdk/react` | React hooks + provider | `react`, `@tanstack/react-query` |
43
+ | `@dimes-dot-fi/sdk/contract` | Tx builders, signature verification | `viem` |
44
+
45
+ ## Quick Start
46
+
47
+ ### Client setup
48
+
49
+ Your backend holds the Dimes API key and exposes an endpoint that generates JWTs for your users (see [Authentication](https://docs.dimes.fi/for-developers/authentication)). Point `JwtAuth` at that endpoint — it fetches, caches, and auto-refreshes tokens:
50
+
51
+ ```typescript
52
+ import { DimesClient, JwtAuth } from "@dimes-dot-fi/sdk";
53
+
54
+ const client = new DimesClient({
55
+ auth: new JwtAuth({
56
+ tokenUrl: "https://your-backend.com/api/dimes-token",
57
+ }),
58
+ });
59
+ ```
60
+
61
+ For server-side (Node.js) where you hold the API key directly:
62
+
63
+ ```typescript
64
+ import { DimesClient, ApiKeyAuth } from "@dimes-dot-fi/sdk";
65
+
66
+ const client = new DimesClient({
67
+ auth: new ApiKeyAuth({
68
+ apiKey: process.env.DIMES_API_KEY,
69
+ walletAddress: "0x1234...abcd",
70
+ }),
71
+ });
72
+ ```
73
+
74
+ ### Browse markets
75
+
76
+ ```typescript
77
+ const { data: markets } = await client.getMarkets();
78
+ const market = await client.getMarket("will-btc-hit-100k-2026");
79
+
80
+ console.log(market.leverage.maxBps); // 100000 (10x)
81
+ ```
82
+
83
+ ### Execute a quote
84
+
85
+ ```typescript
86
+ import { executeQuote } from "@dimes-dot-fi/sdk";
87
+
88
+ const result = await executeQuote(client, {
89
+ marketTicker: "will-btc-hit-100k-2026",
90
+ side: "yes",
91
+ collateralUsd: 25,
92
+ leverageBps: 50000, // 5x
93
+ slippageBps: 300,
94
+ });
95
+
96
+ console.log(result.offer.entryPriceUsd);
97
+ console.log(result.corrections); // auto-applied adjustments, if any
98
+ ```
99
+
100
+ `executeQuote` handles the full lifecycle: creates a draft quote, promotes it, retries on market-moved errors, and auto-corrects parameters when the API suggests adjustments. Hook into each stage:
101
+
102
+ ```typescript
103
+ const result = await executeQuote(client, params, {
104
+ onDraftReady: (draft) => showPreview(draft),
105
+ onMarketMoved: (event) => showRetryNotice(event.retryCount),
106
+ onCorrection: (adj) => showAdjustment(adj.field, adj.toLabel),
107
+ maxRetries: 3,
108
+ });
109
+ ```
110
+
111
+ ### Open a position on-chain
112
+
113
+ ```typescript
114
+ import { buildCreatePositionTx, buildApproveTx, verifyOfferSignature } from "@dimes-dot-fi/sdk/contract";
115
+
116
+ // Verify the quote signature
117
+ await verifyOfferSignature(client, result.offer, userAddress);
118
+
119
+ // Build viem-compatible transactions
120
+ const approveTx = buildApproveTx(usdcAddress, vaultAddress, amount);
121
+ const createTx = buildCreatePositionTx(result.offer);
122
+
123
+ await walletClient.writeContract(approveTx);
124
+ await walletClient.writeContract(createTx);
125
+ ```
126
+
127
+ ### Close a position
128
+
129
+ ```typescript
130
+ import { buildRequestCloseTx } from "@dimes-dot-fi/sdk/contract";
131
+
132
+ const closeTx = buildRequestCloseTx(vaultAddress, positionKey);
133
+ await walletClient.writeContract(closeTx);
134
+ ```
135
+
136
+ ## React
137
+
138
+ ```tsx
139
+ import { DimesClient, JwtAuth } from "@dimes-dot-fi/sdk";
140
+ import { DimesProvider } from "@dimes-dot-fi/sdk/react";
141
+
142
+ const client = new DimesClient({
143
+ auth: new JwtAuth({ tokenUrl: "https://your-backend.com/api/dimes-token" }),
144
+ });
145
+
146
+ function App() {
147
+ return (
148
+ <QueryClientProvider client={queryClient}>
149
+ <DimesProvider client={client}>
150
+ <YourApp />
151
+ </DimesProvider>
152
+ </QueryClientProvider>
153
+ );
154
+ }
155
+ ```
156
+
157
+ All hooks accept optional `queryOptions` for full control over caching, polling, and `queryClient` selection:
158
+
159
+ ```tsx
160
+ import { useMarkets, usePositions, useQuote, useContractInfo } from "@dimes-dot-fi/sdk/react";
161
+
162
+ function Dashboard() {
163
+ const { data: markets } = useMarkets();
164
+ const { data: positions } = usePositions({ status: "open" });
165
+ const { data: contractInfo } = useContractInfo(); // cached, staleTime: Infinity
166
+ const { state, execute, reset } = useQuote();
167
+
168
+ // state.phase: "idle" | "loading-draft" | "draft-ready" | "promoting" | "promoted" | "error"
169
+ }
170
+ ```
171
+
172
+ ## Error Handling
173
+
174
+ ```typescript
175
+ import { DimesApiError, formatErrorMessage, quoteErrorHint, hintAdjustment } from "@dimes-dot-fi/sdk";
176
+
177
+ try {
178
+ await executeQuote(client, params);
179
+ } catch (err) {
180
+ if (err instanceof DimesApiError) {
181
+ // User-friendly message for any error code
182
+ console.log(formatErrorMessage(err.code, err.params));
183
+
184
+ // Programmatic correction hints for leverage/collateral/slippage errors
185
+ const hint = quoteErrorHint(err.code, err.params, { leverageBps: params.leverageBps });
186
+ const adj = hintAdjustment(hint, params);
187
+ if (adj) {
188
+ console.log(`Suggestion: adjust ${adj.field} to ${adj.toLabel}`);
189
+ }
190
+ }
191
+ }
192
+ ```
193
+
194
+ The SDK's HTTP client automatically retries on 429 (rate limit) with `Retry-After` support and refreshes auth on 401.
195
+
196
+ ## Sandbox
197
+
198
+ ```typescript
199
+ const client = new DimesClient({
200
+ baseUrl: "https://api-sandbox.dimes.fi",
201
+ auth: new ApiKeyAuth({
202
+ apiKey: "dm_sbx_skey_...",
203
+ walletAddress: "0x...",
204
+ }),
205
+ });
206
+ ```
207
+
208
+ Same API, same contracts, fake USDC. Get a sandbox key via the [Telegram link on dimes.fi](https://dimes.fi).
209
+
210
+ ## API Method Reference
211
+
212
+ | Endpoint | Method | React Hook |
213
+ |----------|--------|------------|
214
+ | `GET /markets` | `client.getMarkets()` | `useMarkets()` |
215
+ | `GET /markets/:ticker` | `client.getMarket(ticker)` | `useMarket(ticker)` |
216
+ | `GET /contract-info` | `client.getContractInfo()` | `useContractInfo()` |
217
+ | `GET /positions` | `client.getPositions()` | `usePositions()` |
218
+ | `GET /limits` | `client.getLimits()` | `useLimits()` |
219
+ | `POST /draft-quotes` | `client.createDraftQuote()` | — |
220
+ | `POST /promoted-quotes/:id` | `client.promoteDraftQuote()` | — |
221
+ | `POST /quotes` | `client.createQuote()` | — |
222
+ | Draft → Promote (full flow) | `executeQuote()` | `useQuote()` |
223
+ | Cancel position | `client.cancelPosition()` | `useCancelPosition()` |
224
+
225
+ ## Documentation
226
+
227
+ - [**Quickstart**](https://docs.dimes.fi/for-developers/quickstart) — end-to-end in 6 steps
228
+ - [**SDK Installation**](https://docs.dimes.fi/for-developers/sdk-installation) — setup, auth, and peer deps
229
+ - [**API Reference**](https://docs.dimes.fi/for-developers/api-reference) — full endpoint documentation
230
+ - [**Error Handling**](https://docs.dimes.fi/for-developers/error-handling) — error codes and structured hints
231
+ - [**On-Chain Integration**](https://docs.dimes.fi/for-developers/on-chain-integration) — wallet patterns and contract ABIs
232
+ - [**UI Guidelines**](https://docs.dimes.fi/for-developers/ui-guidelines) — leverage sliders, quote flow, position cards
233
+
234
+ ## License
235
+
236
+ MIT
@@ -418,6 +418,11 @@ interface components {
418
418
  origination_leverage_bps: number;
419
419
  };
420
420
  CustomerPositionCurrent: {
421
+ /**
422
+ * @description Current book-value leverage in basis points (20000 = 2x)
423
+ * @example 18000
424
+ */
425
+ book_leverage_bps: number;
421
426
  /**
422
427
  * @description Current collateral formatted as USD
423
428
  * @example 2.50
@@ -439,6 +444,7 @@ interface components {
439
444
  */
440
445
  effective_collateral_usd_pips: string;
441
446
  /**
447
+ * @deprecated Use book_leverage_bps instead
442
448
  * @description Current leverage in basis points
443
449
  * @example 18000
444
450
  */
@@ -453,6 +459,11 @@ interface components {
453
459
  * @example 5500
454
460
  */
455
461
  mark_price_usd_pips: string;
462
+ /**
463
+ * @description Current market-value leverage in basis points, computed from the live oracle price. Null when the position is insolvent (equity <= 0).
464
+ * @example 19500
465
+ */
466
+ market_leverage_bps: number | null;
456
467
  /**
457
468
  * @description Unrealized PnL net of all fees (origination + pending lifetime) as return on equity in basis points
458
469
  * @example 1800
@@ -1120,122 +1131,4 @@ declare function isOpenPosition(p: Position): p is OpenPosition;
1120
1131
  declare function isClosedPosition(p: Position): p is ClosedPosition;
1121
1132
  declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
1122
1133
 
1123
- declare const marketMovedCodes: Set<string>;
1124
- type QuoteHint = {
1125
- kind: "use-max-collateral";
1126
- maxCollateralUsd: number;
1127
- minCollateralUsd: number;
1128
- } | {
1129
- kind: "clamp-leverage";
1130
- maxLeverageBps?: number;
1131
- } | {
1132
- kind: "raise-leverage";
1133
- minLeverageBps: number;
1134
- } | {
1135
- kind: "raise-slippage";
1136
- currentSlippageBps: number;
1137
- maxSlippageBps: number;
1138
- } | {
1139
- kind: "market-full";
1140
- } | null;
1141
- type Params = Record<string, unknown> | null | undefined;
1142
- declare function quoteErrorHint(code: string | null, params: Params, context: {
1143
- leverageBps: number;
1144
- }): QuoteHint;
1145
- type CorrectedField = "collateral" | "leverage" | "slippage";
1146
- type HintAdjustment = {
1147
- field: "collateral";
1148
- fromValue: number;
1149
- toValue: number;
1150
- toLabel: string;
1151
- reason: "max-collateral";
1152
- } | {
1153
- field: "leverage";
1154
- fromValue: number;
1155
- toValue: number;
1156
- toLabel: string;
1157
- reason: "clamp-max" | "raise-min";
1158
- } | {
1159
- field: "slippage";
1160
- fromValue: number;
1161
- toValue: number;
1162
- toLabel: string;
1163
- reason: "raise-slippage";
1164
- } | null;
1165
- declare function hintAdjustment(hint: QuoteHint, current: {
1166
- collateralUsd: number;
1167
- leverageBps: number;
1168
- slippageBps: number;
1169
- }): HintAdjustment;
1170
-
1171
- interface Paginated<T> {
1172
- data: T[];
1173
- hasMore: boolean;
1174
- }
1175
-
1176
- interface AuthProvider {
1177
- getHeaders(): Promise<Record<string, string>>;
1178
- refresh?(): Promise<void>;
1179
- }
1180
- interface ApiKeyAuthOptions {
1181
- apiKey: string;
1182
- walletAddress: string;
1183
- baseUrl?: string;
1184
- fetch?: typeof globalThis.fetch;
1185
- }
1186
- declare class ApiKeyAuth implements AuthProvider {
1187
- private jwt;
1188
- private expiresAt;
1189
- private refreshPromise;
1190
- private readonly apiKey;
1191
- private readonly walletAddress;
1192
- private readonly baseUrl;
1193
- private readonly fetchFn;
1194
- constructor(options: ApiKeyAuthOptions);
1195
- getHeaders(): Promise<Record<string, string>>;
1196
- refresh(): Promise<void>;
1197
- private fetchToken;
1198
- }
1199
- interface JwtAuthOptions {
1200
- token: string | (() => Promise<string>);
1201
- }
1202
- declare class JwtAuth implements AuthProvider {
1203
- private readonly tokenOrFn;
1204
- constructor(options: JwtAuthOptions);
1205
- getHeaders(): Promise<Record<string, string>>;
1206
- }
1207
-
1208
- interface DimesClientOptions {
1209
- baseUrl?: string;
1210
- auth: AuthProvider;
1211
- fetch?: typeof globalThis.fetch;
1212
- maxRetries?: number;
1213
- maxRetryDelayMs?: number;
1214
- }
1215
- interface GetMarketsParams {
1216
- cursor?: string;
1217
- limit?: number;
1218
- category?: string;
1219
- status?: string;
1220
- provider?: "polymarket" | "kalshi";
1221
- }
1222
- interface GetPositionsParams {
1223
- cursor?: string;
1224
- limit?: number;
1225
- status?: "open" | "closed";
1226
- }
1227
- declare class DimesClient {
1228
- private readonly http;
1229
- constructor(options: DimesClientOptions);
1230
- getMarkets(params?: GetMarketsParams): Promise<Paginated<Market>>;
1231
- getMarket(ticker: string): Promise<Market>;
1232
- createDraftQuote(params: CreateOfferParams): Promise<Offer>;
1233
- promoteDraftQuote(draftId: string): Promise<Offer>;
1234
- createQuote(params: CreateOfferParams): Promise<Offer>;
1235
- getPositions(params?: GetPositionsParams): Promise<Position[]>;
1236
- cancelPosition(positionId: string): Promise<void>;
1237
- getContractInfo(): Promise<ContractInfo>;
1238
- getLimits(): Promise<CustomerLimit>;
1239
- }
1240
-
1241
- export { ApiKeyAuth as A, type PositionUnwindList as B, type CreateOfferParams as C, DimesClient as D, hintAdjustment as E, isClosedPosition as F, type GetMarketsParams as G, type HintAdjustment as H, isOpenPosition as I, JwtAuth as J, leverageMaxBps as K, marketMovedCodes as L, type Market as M, quoteErrorHint as N, type Offer as O, type Paginated as P, type QuoteHint as Q, type ApiKeyAuthOptions as a, type AuthProvider as b, type CamelizeKeys as c, type ClosedPosition as d, type ContractInfo as e, type CorrectedField as f, type CreateTokenResult as g, type CustomerLimit as h, type DimesClientOptions as i, type GetPositionsParams as j, type JwtAuthOptions as k, type MarketFees as l, type MarketLeverage as m, type MarketPrices as n, type OpenPosition as o, type OriginationTier as p, type Position as q, type PositionClosedFees as r, type PositionCurrent as s, type PositionEntry as t, type PositionFailure as u, type PositionOpenFees as v, type PositionResult as w, type PositionRisk as x, type PositionTiming as y, type PositionUnwind as z };
1134
+ export { type CreateOfferParams as C, type Market as M, type Offer as O, type Position as P, type CamelizeKeys as a, type ClosedPosition as b, type ContractInfo as c, type CreateTokenResult as d, type CustomerLimit as e, type MarketFees as f, type MarketLeverage as g, type MarketPrices as h, type OpenPosition as i, type OriginationTier as j, type PositionClosedFees as k, type PositionCurrent as l, type PositionEntry as m, type PositionFailure as n, type PositionOpenFees as o, type PositionResult as p, type PositionRisk as q, type PositionTiming as r, type PositionUnwind as s, type PositionUnwindList as t, isClosedPosition as u, isOpenPosition as v, leverageMaxBps as w };
@@ -418,6 +418,11 @@ interface components {
418
418
  origination_leverage_bps: number;
419
419
  };
420
420
  CustomerPositionCurrent: {
421
+ /**
422
+ * @description Current book-value leverage in basis points (20000 = 2x)
423
+ * @example 18000
424
+ */
425
+ book_leverage_bps: number;
421
426
  /**
422
427
  * @description Current collateral formatted as USD
423
428
  * @example 2.50
@@ -439,6 +444,7 @@ interface components {
439
444
  */
440
445
  effective_collateral_usd_pips: string;
441
446
  /**
447
+ * @deprecated Use book_leverage_bps instead
442
448
  * @description Current leverage in basis points
443
449
  * @example 18000
444
450
  */
@@ -453,6 +459,11 @@ interface components {
453
459
  * @example 5500
454
460
  */
455
461
  mark_price_usd_pips: string;
462
+ /**
463
+ * @description Current market-value leverage in basis points, computed from the live oracle price. Null when the position is insolvent (equity <= 0).
464
+ * @example 19500
465
+ */
466
+ market_leverage_bps: number | null;
456
467
  /**
457
468
  * @description Unrealized PnL net of all fees (origination + pending lifetime) as return on equity in basis points
458
469
  * @example 1800
@@ -1120,122 +1131,4 @@ declare function isOpenPosition(p: Position): p is OpenPosition;
1120
1131
  declare function isClosedPosition(p: Position): p is ClosedPosition;
1121
1132
  declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
1122
1133
 
1123
- declare const marketMovedCodes: Set<string>;
1124
- type QuoteHint = {
1125
- kind: "use-max-collateral";
1126
- maxCollateralUsd: number;
1127
- minCollateralUsd: number;
1128
- } | {
1129
- kind: "clamp-leverage";
1130
- maxLeverageBps?: number;
1131
- } | {
1132
- kind: "raise-leverage";
1133
- minLeverageBps: number;
1134
- } | {
1135
- kind: "raise-slippage";
1136
- currentSlippageBps: number;
1137
- maxSlippageBps: number;
1138
- } | {
1139
- kind: "market-full";
1140
- } | null;
1141
- type Params = Record<string, unknown> | null | undefined;
1142
- declare function quoteErrorHint(code: string | null, params: Params, context: {
1143
- leverageBps: number;
1144
- }): QuoteHint;
1145
- type CorrectedField = "collateral" | "leverage" | "slippage";
1146
- type HintAdjustment = {
1147
- field: "collateral";
1148
- fromValue: number;
1149
- toValue: number;
1150
- toLabel: string;
1151
- reason: "max-collateral";
1152
- } | {
1153
- field: "leverage";
1154
- fromValue: number;
1155
- toValue: number;
1156
- toLabel: string;
1157
- reason: "clamp-max" | "raise-min";
1158
- } | {
1159
- field: "slippage";
1160
- fromValue: number;
1161
- toValue: number;
1162
- toLabel: string;
1163
- reason: "raise-slippage";
1164
- } | null;
1165
- declare function hintAdjustment(hint: QuoteHint, current: {
1166
- collateralUsd: number;
1167
- leverageBps: number;
1168
- slippageBps: number;
1169
- }): HintAdjustment;
1170
-
1171
- interface Paginated<T> {
1172
- data: T[];
1173
- hasMore: boolean;
1174
- }
1175
-
1176
- interface AuthProvider {
1177
- getHeaders(): Promise<Record<string, string>>;
1178
- refresh?(): Promise<void>;
1179
- }
1180
- interface ApiKeyAuthOptions {
1181
- apiKey: string;
1182
- walletAddress: string;
1183
- baseUrl?: string;
1184
- fetch?: typeof globalThis.fetch;
1185
- }
1186
- declare class ApiKeyAuth implements AuthProvider {
1187
- private jwt;
1188
- private expiresAt;
1189
- private refreshPromise;
1190
- private readonly apiKey;
1191
- private readonly walletAddress;
1192
- private readonly baseUrl;
1193
- private readonly fetchFn;
1194
- constructor(options: ApiKeyAuthOptions);
1195
- getHeaders(): Promise<Record<string, string>>;
1196
- refresh(): Promise<void>;
1197
- private fetchToken;
1198
- }
1199
- interface JwtAuthOptions {
1200
- token: string | (() => Promise<string>);
1201
- }
1202
- declare class JwtAuth implements AuthProvider {
1203
- private readonly tokenOrFn;
1204
- constructor(options: JwtAuthOptions);
1205
- getHeaders(): Promise<Record<string, string>>;
1206
- }
1207
-
1208
- interface DimesClientOptions {
1209
- baseUrl?: string;
1210
- auth: AuthProvider;
1211
- fetch?: typeof globalThis.fetch;
1212
- maxRetries?: number;
1213
- maxRetryDelayMs?: number;
1214
- }
1215
- interface GetMarketsParams {
1216
- cursor?: string;
1217
- limit?: number;
1218
- category?: string;
1219
- status?: string;
1220
- provider?: "polymarket" | "kalshi";
1221
- }
1222
- interface GetPositionsParams {
1223
- cursor?: string;
1224
- limit?: number;
1225
- status?: "open" | "closed";
1226
- }
1227
- declare class DimesClient {
1228
- private readonly http;
1229
- constructor(options: DimesClientOptions);
1230
- getMarkets(params?: GetMarketsParams): Promise<Paginated<Market>>;
1231
- getMarket(ticker: string): Promise<Market>;
1232
- createDraftQuote(params: CreateOfferParams): Promise<Offer>;
1233
- promoteDraftQuote(draftId: string): Promise<Offer>;
1234
- createQuote(params: CreateOfferParams): Promise<Offer>;
1235
- getPositions(params?: GetPositionsParams): Promise<Position[]>;
1236
- cancelPosition(positionId: string): Promise<void>;
1237
- getContractInfo(): Promise<ContractInfo>;
1238
- getLimits(): Promise<CustomerLimit>;
1239
- }
1240
-
1241
- export { ApiKeyAuth as A, type PositionUnwindList as B, type CreateOfferParams as C, DimesClient as D, hintAdjustment as E, isClosedPosition as F, type GetMarketsParams as G, type HintAdjustment as H, isOpenPosition as I, JwtAuth as J, leverageMaxBps as K, marketMovedCodes as L, type Market as M, quoteErrorHint as N, type Offer as O, type Paginated as P, type QuoteHint as Q, type ApiKeyAuthOptions as a, type AuthProvider as b, type CamelizeKeys as c, type ClosedPosition as d, type ContractInfo as e, type CorrectedField as f, type CreateTokenResult as g, type CustomerLimit as h, type DimesClientOptions as i, type GetPositionsParams as j, type JwtAuthOptions as k, type MarketFees as l, type MarketLeverage as m, type MarketPrices as n, type OpenPosition as o, type OriginationTier as p, type Position as q, type PositionClosedFees as r, type PositionCurrent as s, type PositionEntry as t, type PositionFailure as u, type PositionOpenFees as v, type PositionResult as w, type PositionRisk as x, type PositionTiming as y, type PositionUnwind as z };
1134
+ export { type CreateOfferParams as C, type Market as M, type Offer as O, type Position as P, type CamelizeKeys as a, type ClosedPosition as b, type ContractInfo as c, type CreateTokenResult as d, type CustomerLimit as e, type MarketFees as f, type MarketLeverage as g, type MarketPrices as h, type OpenPosition as i, type OriginationTier as j, type PositionClosedFees as k, type PositionCurrent as l, type PositionEntry as m, type PositionFailure as n, type PositionOpenFees as o, type PositionResult as p, type PositionRisk as q, type PositionTiming as r, type PositionUnwind as s, type PositionUnwindList as t, isClosedPosition as u, isOpenPosition as v, leverageMaxBps as w };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DimesApiError,
3
3
  DimesError
4
- } from "./chunk-LQ5LLBR6.mjs";
4
+ } from "./chunk-S65RABUT.mjs";
5
5
 
6
6
  // src/quote/build-quote-params.ts
7
7
  var DEFAULT_LEVERAGE_STEP_BPS = 2500;
@@ -280,4 +280,4 @@ export {
280
280
  hintAdjustment,
281
281
  executeQuote
282
282
  };
283
- //# sourceMappingURL=chunk-BRANC7OH.mjs.map
283
+ //# sourceMappingURL=chunk-EI5V5Z6G.mjs.map
@@ -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/quote/build-quote-params.ts
7
7
  var DEFAULT_LEVERAGE_STEP_BPS = 2500;
@@ -183,7 +183,7 @@ function hintAdjustment(hint, current) {
183
183
  // src/quote/quote.ts
184
184
  var DEFAULT_MAX_RETRIES = 3;
185
185
  function isMarketMovedError(err) {
186
- return err instanceof _chunkXXTTXLCTcjs.DimesApiError && marketMovedCodes.has(err.code);
186
+ return err instanceof _chunkUUE4HG2Hcjs.DimesApiError && marketMovedCodes.has(err.code);
187
187
  }
188
188
  function applyAdjustment(params, adj, currentParams) {
189
189
  switch (adj.field) {
@@ -209,7 +209,7 @@ function handleMarketMoved(err, attempt, maxRetries) {
209
209
  return isMarketMovedError(err) && attempt < maxRetries;
210
210
  }
211
211
  function handleCorrection(err, currentParams) {
212
- if (!(err instanceof _chunkXXTTXLCTcjs.DimesApiError)) {
212
+ if (!(err instanceof _chunkUUE4HG2Hcjs.DimesApiError)) {
213
213
  return null;
214
214
  }
215
215
  const hint = quoteErrorHint(err.code, err.params, {
@@ -270,7 +270,7 @@ async function executeQuote(client, params, options) {
270
270
  throw err;
271
271
  }
272
272
  }
273
- throw new (0, _chunkXXTTXLCTcjs.DimesError)("market_moved_retries_exhausted", "Exhausted market-moved retries");
273
+ throw new (0, _chunkUUE4HG2Hcjs.DimesError)("market_moved_retries_exhausted", "Exhausted market-moved retries");
274
274
  }
275
275
 
276
276
 
@@ -280,4 +280,4 @@ async function executeQuote(client, params, options) {
280
280
 
281
281
 
282
282
  exports.buildQuoteParams = buildQuoteParams; exports.marketMovedCodes = marketMovedCodes; exports.quoteErrorHint = quoteErrorHint; exports.hintAdjustment = hintAdjustment; exports.executeQuote = executeQuote;
283
- //# sourceMappingURL=chunk-JGK55KDX.cjs.map
283
+ //# sourceMappingURL=chunk-JWAPH4GD.cjs.map