@dimes-dot-fi/sdk 1.0.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.
- package/dist/chunk-BRANC7OH.mjs +283 -0
- package/dist/chunk-BRANC7OH.mjs.map +1 -0
- package/dist/chunk-JGK55KDX.cjs +283 -0
- package/dist/chunk-JGK55KDX.cjs.map +1 -0
- package/dist/chunk-LQ5LLBR6.mjs +312 -0
- package/dist/chunk-LQ5LLBR6.mjs.map +1 -0
- package/dist/chunk-XXTTXLCT.cjs +312 -0
- package/dist/chunk-XXTTXLCT.cjs.map +1 -0
- package/dist/contract/index.cjs +670 -0
- package/dist/contract/index.cjs.map +1 -0
- package/dist/contract/index.d.cts +83 -0
- package/dist/contract/index.d.ts +83 -0
- package/dist/contract/index.mjs +670 -0
- package/dist/contract/index.mjs.map +1 -0
- package/dist/dimes-client-BLIAuK4M.d.cts +1241 -0
- package/dist/dimes-client-BLIAuK4M.d.ts +1241 -0
- package/dist/dimes-error-BtDMi3Kv.d.ts +26 -0
- package/dist/dimes-error-DxzsfQo6.d.cts +26 -0
- package/dist/index.cjs +275 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.mjs +275 -0
- package/dist/index.mjs.map +1 -0
- package/dist/quote-ByZJRoPf.d.cts +29 -0
- package/dist/quote-CgmTKnIZ.d.ts +29 -0
- package/dist/react/index.cjs +166 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +41 -0
- package/dist/react/index.d.ts +41 -0
- package/dist/react/index.mjs +166 -0
- package/dist/react/index.mjs.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Q as QuoteHint } from './dimes-client-BLIAuK4M.js';
|
|
2
|
+
|
|
3
|
+
declare class DimesError extends Error {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
constructor(code: string, message: string);
|
|
6
|
+
}
|
|
7
|
+
declare class DimesApiError extends DimesError {
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly type: string | null;
|
|
10
|
+
readonly rawMessage: string;
|
|
11
|
+
readonly params: Record<string, unknown> | null;
|
|
12
|
+
readonly hint: QuoteHint | null;
|
|
13
|
+
constructor(options: {
|
|
14
|
+
status: number;
|
|
15
|
+
code: string;
|
|
16
|
+
type: string | null;
|
|
17
|
+
message: string;
|
|
18
|
+
params: Record<string, unknown> | null;
|
|
19
|
+
hint?: QuoteHint | null;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
declare class DimesContractError extends DimesError {
|
|
23
|
+
constructor(code: string, message: string);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { DimesApiError as D, DimesContractError as a, DimesError as b };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Q as QuoteHint } from './dimes-client-BLIAuK4M.cjs';
|
|
2
|
+
|
|
3
|
+
declare class DimesError extends Error {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
constructor(code: string, message: string);
|
|
6
|
+
}
|
|
7
|
+
declare class DimesApiError extends DimesError {
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly type: string | null;
|
|
10
|
+
readonly rawMessage: string;
|
|
11
|
+
readonly params: Record<string, unknown> | null;
|
|
12
|
+
readonly hint: QuoteHint | null;
|
|
13
|
+
constructor(options: {
|
|
14
|
+
status: number;
|
|
15
|
+
code: string;
|
|
16
|
+
type: string | null;
|
|
17
|
+
message: string;
|
|
18
|
+
params: Record<string, unknown> | null;
|
|
19
|
+
hint?: QuoteHint | null;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
declare class DimesContractError extends DimesError {
|
|
23
|
+
constructor(code: string, message: string);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { DimesApiError as D, DimesContractError as a, DimesError as b };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
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;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkJGK55KDXcjs = require('./chunk-JGK55KDX.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkXXTTXLCTcjs = require('./chunk-XXTTXLCT.cjs');
|
|
15
|
+
|
|
16
|
+
// src/client/dimes-client.ts
|
|
17
|
+
var _humps = require('humps');
|
|
18
|
+
|
|
19
|
+
// src/client/http.ts
|
|
20
|
+
|
|
21
|
+
var HTTP_UNAUTHORIZED = 401;
|
|
22
|
+
var HTTP_TOO_MANY_REQUESTS = 429;
|
|
23
|
+
var DEFAULT_MAX_RETRIES = 3;
|
|
24
|
+
var DEFAULT_MAX_RETRY_DELAY_MS = 6e4;
|
|
25
|
+
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
26
|
+
var BACKOFF_FACTOR = 2;
|
|
27
|
+
var MS_PER_SECOND = 1e3;
|
|
28
|
+
function sleep(ms) {
|
|
29
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
30
|
+
}
|
|
31
|
+
function parseRetryAfterMs(header, attempt) {
|
|
32
|
+
const fallbackMs = DEFAULT_RETRY_DELAY_MS * BACKOFF_FACTOR ** attempt;
|
|
33
|
+
if (!header) {
|
|
34
|
+
return fallbackMs;
|
|
35
|
+
}
|
|
36
|
+
const seconds = Number(header);
|
|
37
|
+
if (!Number.isNaN(seconds) && seconds >= 0) {
|
|
38
|
+
return seconds * MS_PER_SECOND;
|
|
39
|
+
}
|
|
40
|
+
const dateMs = Date.parse(header);
|
|
41
|
+
if (!Number.isNaN(dateMs)) {
|
|
42
|
+
return Math.max(0, dateMs - Date.now());
|
|
43
|
+
}
|
|
44
|
+
return fallbackMs;
|
|
45
|
+
}
|
|
46
|
+
async function throwFromResponse(response) {
|
|
47
|
+
const rawBody = await response.text();
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = rawBody ? JSON.parse(rawBody) : null;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
parsed = null;
|
|
53
|
+
}
|
|
54
|
+
const code = _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _ => _.error, 'optionalAccess', _2 => _2.code]), () => ( "unknown_error"));
|
|
55
|
+
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}`));
|
|
57
|
+
const rawParams = _optionalChain([parsed, 'optionalAccess', _7 => _7.error, 'optionalAccess', _8 => _8.params]);
|
|
58
|
+
const params = rawParams ? _humps.camelizeKeys.call(void 0, rawParams) : null;
|
|
59
|
+
throw new (0, _chunkXXTTXLCTcjs.DimesApiError)({ status: response.status, code, type, message, params });
|
|
60
|
+
}
|
|
61
|
+
var HttpClient = class {
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
constructor(options) {
|
|
68
|
+
this.baseUrl = options.baseUrl;
|
|
69
|
+
this.auth = options.auth;
|
|
70
|
+
this.fetchFn = _nullishCoalesce(options.fetch, () => ( globalThis.fetch.bind(globalThis)));
|
|
71
|
+
this.maxRetries = _nullishCoalesce(options.maxRetries, () => ( DEFAULT_MAX_RETRIES));
|
|
72
|
+
this.maxRetryDelayMs = _nullishCoalesce(options.maxRetryDelayMs, () => ( DEFAULT_MAX_RETRY_DELAY_MS));
|
|
73
|
+
}
|
|
74
|
+
async request(path, options) {
|
|
75
|
+
const authHeaders = await this.auth.getHeaders();
|
|
76
|
+
const headers = {
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
...authHeaders,
|
|
79
|
+
..._optionalChain([options, 'optionalAccess', _9 => _9.headers])
|
|
80
|
+
};
|
|
81
|
+
let response = await this.fetchFn(`${this.baseUrl}${path}`, {
|
|
82
|
+
...options,
|
|
83
|
+
headers
|
|
84
|
+
});
|
|
85
|
+
if (response.status === HTTP_UNAUTHORIZED && this.auth.refresh) {
|
|
86
|
+
await this.auth.refresh();
|
|
87
|
+
const retryHeaders = await this.auth.getHeaders();
|
|
88
|
+
response = await this.fetchFn(`${this.baseUrl}${path}`, {
|
|
89
|
+
...options,
|
|
90
|
+
headers: { ...headers, ...retryHeaders }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
for (let attempt = 0; response.status === HTTP_TOO_MANY_REQUESTS && attempt < this.maxRetries; attempt++) {
|
|
94
|
+
const delayMs = parseRetryAfterMs(response.headers.get("retry-after"), attempt);
|
|
95
|
+
if (delayMs > this.maxRetryDelayMs) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
await sleep(delayMs);
|
|
99
|
+
const freshAuth = await this.auth.getHeaders();
|
|
100
|
+
response = await this.fetchFn(`${this.baseUrl}${path}`, {
|
|
101
|
+
...options,
|
|
102
|
+
headers: { ...headers, ...freshAuth }
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (!response.ok) {
|
|
106
|
+
await throwFromResponse(response);
|
|
107
|
+
}
|
|
108
|
+
return _humps.camelizeKeys.call(void 0, await response.json());
|
|
109
|
+
}
|
|
110
|
+
async requestList(path, options) {
|
|
111
|
+
const result = await this.request(path, options);
|
|
112
|
+
return result.data;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/client/dimes-client.ts
|
|
117
|
+
function buildQueryFromEntries(entries) {
|
|
118
|
+
const filtered = entries.filter(([, v]) => v !== void 0 && v !== null);
|
|
119
|
+
if (filtered.length === 0) {
|
|
120
|
+
return "";
|
|
121
|
+
}
|
|
122
|
+
const search = new URLSearchParams();
|
|
123
|
+
for (const [key, value] of filtered) {
|
|
124
|
+
search.set(
|
|
125
|
+
key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`),
|
|
126
|
+
String(value)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return `?${search.toString()}`;
|
|
130
|
+
}
|
|
131
|
+
var DimesClient = class {
|
|
132
|
+
|
|
133
|
+
constructor(options) {
|
|
134
|
+
this.http = new HttpClient({
|
|
135
|
+
baseUrl: _nullishCoalesce(options.baseUrl, () => ( "https://api.dimes.fi")),
|
|
136
|
+
auth: options.auth,
|
|
137
|
+
fetch: options.fetch,
|
|
138
|
+
maxRetries: options.maxRetries,
|
|
139
|
+
maxRetryDelayMs: options.maxRetryDelayMs
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async getMarkets(params) {
|
|
143
|
+
const query = params ? buildQueryFromEntries(Object.entries(params)) : "";
|
|
144
|
+
return this.http.request(`/v1/prediction-markets/markets${query}`);
|
|
145
|
+
}
|
|
146
|
+
async getMarket(ticker) {
|
|
147
|
+
return this.http.request(`/v1/prediction-markets/markets/${encodeURIComponent(ticker)}`);
|
|
148
|
+
}
|
|
149
|
+
async createDraftQuote(params) {
|
|
150
|
+
return this.http.request("/v1/prediction-markets/draft-quotes", {
|
|
151
|
+
method: "POST",
|
|
152
|
+
body: JSON.stringify(_humps.decamelizeKeys.call(void 0, params))
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async promoteDraftQuote(draftId) {
|
|
156
|
+
return this.http.request(`/v1/prediction-markets/promoted-quotes/${encodeURIComponent(draftId)}`, {
|
|
157
|
+
method: "POST"
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
async createQuote(params) {
|
|
161
|
+
return this.http.request("/v1/prediction-markets/quotes", {
|
|
162
|
+
method: "POST",
|
|
163
|
+
body: JSON.stringify(_humps.decamelizeKeys.call(void 0, params))
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async getPositions(params) {
|
|
167
|
+
const query = params ? buildQueryFromEntries(Object.entries(params)) : "";
|
|
168
|
+
return this.http.requestList(`/v1/prediction-markets/positions${query}`);
|
|
169
|
+
}
|
|
170
|
+
async cancelPosition(positionId) {
|
|
171
|
+
await this.http.request(`/v1/prediction-markets/positions/${encodeURIComponent(positionId)}/cancel`, {
|
|
172
|
+
method: "POST"
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async getContractInfo() {
|
|
176
|
+
return this.http.request("/v1/prediction-markets/contract-info");
|
|
177
|
+
}
|
|
178
|
+
async getLimits() {
|
|
179
|
+
return this.http.request("/v1/prediction-markets/limits");
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/client/auth.ts
|
|
184
|
+
var ApiKeyAuth = (_class = class {
|
|
185
|
+
__init() {this.jwt = null}
|
|
186
|
+
__init2() {this.expiresAt = 0}
|
|
187
|
+
__init3() {this.refreshPromise = null}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
193
|
+
this.apiKey = options.apiKey;
|
|
194
|
+
this.walletAddress = options.walletAddress;
|
|
195
|
+
this.baseUrl = _nullishCoalesce(options.baseUrl, () => ( "https://api.dimes.fi"));
|
|
196
|
+
this.fetchFn = _nullishCoalesce(options.fetch, () => ( globalThis.fetch.bind(globalThis)));
|
|
197
|
+
}
|
|
198
|
+
async getHeaders() {
|
|
199
|
+
const TOKEN_EXPIRY_BUFFER_MS = 3e4;
|
|
200
|
+
if (!this.jwt || Date.now() >= this.expiresAt - TOKEN_EXPIRY_BUFFER_MS) {
|
|
201
|
+
await this.refresh();
|
|
202
|
+
}
|
|
203
|
+
return { Authorization: `Bearer ${this.jwt}` };
|
|
204
|
+
}
|
|
205
|
+
async refresh() {
|
|
206
|
+
if (this.refreshPromise) {
|
|
207
|
+
await this.refreshPromise;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
this.refreshPromise = this.fetchToken();
|
|
211
|
+
try {
|
|
212
|
+
await this.refreshPromise;
|
|
213
|
+
} finally {
|
|
214
|
+
this.refreshPromise = null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async fetchToken() {
|
|
218
|
+
const response = await this.fetchFn(`${this.baseUrl}/v1/prediction-markets/tokens`, {
|
|
219
|
+
method: "POST",
|
|
220
|
+
headers: {
|
|
221
|
+
"Content-Type": "application/json",
|
|
222
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
223
|
+
},
|
|
224
|
+
body: JSON.stringify({ wallet_address: this.walletAddress })
|
|
225
|
+
});
|
|
226
|
+
if (!response.ok) {
|
|
227
|
+
const text = await response.text();
|
|
228
|
+
throw new (0, _chunkXXTTXLCTcjs.DimesError)("auth_token_failed", `Failed to obtain auth token (${response.status}): ${text}`);
|
|
229
|
+
}
|
|
230
|
+
const data = await response.json();
|
|
231
|
+
this.jwt = data.token;
|
|
232
|
+
this.expiresAt = new Date(data.expires_at).getTime();
|
|
233
|
+
}
|
|
234
|
+
}, _class);
|
|
235
|
+
var JwtAuth = class {
|
|
236
|
+
|
|
237
|
+
constructor(options) {
|
|
238
|
+
this.tokenOrFn = options.token;
|
|
239
|
+
}
|
|
240
|
+
async getHeaders() {
|
|
241
|
+
const token = typeof this.tokenOrFn === "function" ? await this.tokenOrFn() : this.tokenOrFn;
|
|
242
|
+
return { Authorization: `Bearer ${token}` };
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// src/types/aliases.ts
|
|
247
|
+
function isOpenPosition(p) {
|
|
248
|
+
return "current" in p;
|
|
249
|
+
}
|
|
250
|
+
function isClosedPosition(p) {
|
|
251
|
+
return "result" in p;
|
|
252
|
+
}
|
|
253
|
+
function leverageMaxBps(lev, side) {
|
|
254
|
+
const perSide = side === "yes" ? lev.maxYesBps : lev.maxNoBps;
|
|
255
|
+
return _nullishCoalesce(_nullishCoalesce(perSide, () => ( lev.maxBps)), () => ( lev.minBps));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
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;
|
|
275
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/index.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;AACsB,MAAA;AACxB,IAAA;AACF,EAAA;AAE0C,EAAA;AAC4C,IAAA;AAC1E,MAAA;AACC,MAAA;AACS,QAAA;AACoB,QAAA;AACtC,MAAA;AAC2D,MAAA;AAC5D,IAAA;AAEiB,IAAA;AACiB,MAAA;AACkD,MAAA;AACrF,IAAA;AAEkC,IAAA;AAClB,IAAA;AACmC,IAAA;AACrD,EAAA;AACF;AAM6C;AAC1B,EAAA;AAEoB,EAAA;AACV,IAAA;AAC3B,EAAA;AAE2D,EAAA;AAC0B,IAAA;AACzC,IAAA;AAC5C,EAAA;AACF;AHiJ4F;AACA;AI3L7B;AACzC,EAAA;AACtB;AAEmE;AAC9C,EAAA;AACrB;AAEgF;AACzB,EAAA;AAEjB,EAAA;AACtC;AJ0L4F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/alexemery/bl/dimes-sdk/dist/index.cjs","sourcesContent":[null,"import { decamelizeKeys } from \"humps\";\nimport type { ContractInfo, CreateOfferParams, Market, Offer, Position, Paginated, CustomerLimit } from \"../types\";\nimport type { AuthProvider } from \"./auth\";\nimport { HttpClient } from \"./http\";\n\nexport interface DimesClientOptions {\n baseUrl?: string;\n auth: AuthProvider;\n fetch?: typeof globalThis.fetch;\n maxRetries?: number;\n maxRetryDelayMs?: number;\n}\n\nexport interface GetMarketsParams {\n cursor?: string;\n limit?: number;\n category?: string;\n status?: string;\n provider?: \"polymarket\" | \"kalshi\";\n}\n\nexport interface GetPositionsParams {\n cursor?: string;\n limit?: number;\n status?: \"open\" | \"closed\";\n}\n\nfunction buildQueryFromEntries(entries: [string, unknown][]): string {\n const filtered = entries.filter(([, v]) => v !== undefined && v !== null);\n if (filtered.length === 0) {\n return \"\";\n }\n\n const search = new URLSearchParams();\n for (const [key, value] of filtered) {\n search.set(\n key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`),\n String(value),\n );\n }\n\n return `?${search.toString()}`;\n}\n\nexport class DimesClient {\n private readonly http: HttpClient;\n\n constructor(options: DimesClientOptions) {\n this.http = new HttpClient({\n baseUrl: options.baseUrl ?? \"https://api.dimes.fi\",\n auth: options.auth,\n fetch: options.fetch,\n maxRetries: options.maxRetries,\n maxRetryDelayMs: options.maxRetryDelayMs,\n });\n }\n\n public async getMarkets(params?: GetMarketsParams): Promise<Paginated<Market>> {\n const query = params ? buildQueryFromEntries(Object.entries(params)) : \"\";\n return this.http.request<Paginated<Market>>(`/v1/prediction-markets/markets${query}`);\n }\n\n public async getMarket(ticker: string): Promise<Market> {\n return this.http.request<Market>(`/v1/prediction-markets/markets/${encodeURIComponent(ticker)}`);\n }\n\n public async createDraftQuote(params: CreateOfferParams): Promise<Offer> {\n return this.http.request<Offer>(\"/v1/prediction-markets/draft-quotes\", {\n method: \"POST\",\n body: JSON.stringify(decamelizeKeys(params)),\n });\n }\n\n public async promoteDraftQuote(draftId: string): Promise<Offer> {\n return this.http.request<Offer>(`/v1/prediction-markets/promoted-quotes/${encodeURIComponent(draftId)}`, {\n method: \"POST\",\n });\n }\n\n public async createQuote(params: CreateOfferParams): Promise<Offer> {\n return this.http.request<Offer>(\"/v1/prediction-markets/quotes\", {\n method: \"POST\",\n body: JSON.stringify(decamelizeKeys(params)),\n });\n }\n\n public async getPositions(params?: GetPositionsParams): Promise<Position[]> {\n const query = params ? buildQueryFromEntries(Object.entries(params)) : \"\";\n return this.http.requestList<Position>(`/v1/prediction-markets/positions${query}`);\n }\n\n public async cancelPosition(positionId: string): Promise<void> {\n await this.http.request<unknown>(`/v1/prediction-markets/positions/${encodeURIComponent(positionId)}/cancel`, {\n method: \"POST\",\n });\n }\n\n public async getContractInfo(): Promise<ContractInfo> {\n return this.http.request<ContractInfo>(\"/v1/prediction-markets/contract-info\");\n }\n\n public async getLimits(): Promise<CustomerLimit> {\n return this.http.request<CustomerLimit>(\"/v1/prediction-markets/limits\");\n }\n}\n","import { camelizeKeys, type Camelized } from \"humps\";\nimport { DimesApiError } from \"../errors/dimes-error\";\nimport type { AuthProvider } from \"./auth\";\n\nexport type { Camelized };\n\ninterface ApiErrorBody {\n error?: {\n type?: string;\n code?: string;\n message?: string;\n params?: Record<string, unknown>;\n };\n}\n\nconst HTTP_UNAUTHORIZED = 401;\nconst HTTP_TOO_MANY_REQUESTS = 429;\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_MAX_RETRY_DELAY_MS = 60_000;\nconst DEFAULT_RETRY_DELAY_MS = 1000;\nconst BACKOFF_FACTOR = 2;\nconst MS_PER_SECOND = 1000;\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction parseRetryAfterMs(header: string | null, attempt: number): number {\n const fallbackMs = DEFAULT_RETRY_DELAY_MS * BACKOFF_FACTOR ** attempt;\n if (!header) {\n return fallbackMs;\n }\n\n const seconds = Number(header);\n if (!Number.isNaN(seconds) && seconds >= 0) {\n return seconds * MS_PER_SECOND;\n }\n\n const dateMs = Date.parse(header);\n if (!Number.isNaN(dateMs)) {\n return Math.max(0, dateMs - Date.now());\n }\n\n return fallbackMs;\n}\n\n// eslint-disable-next-line complexity\nasync function throwFromResponse(response: Response): Promise<never> {\n const rawBody = await response.text();\n let parsed: ApiErrorBody | null;\n try {\n parsed = rawBody ? (JSON.parse(rawBody) as ApiErrorBody) : null;\n } catch {\n parsed = null;\n }\n\n const code = parsed?.error?.code ?? \"unknown_error\";\n const type = parsed?.error?.type ?? null;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const message = parsed?.error?.message ?? code ?? rawBody ?? `API error ${response.status}`;\n const rawParams = parsed?.error?.params;\n const params = rawParams ? (camelizeKeys(rawParams) as Record<string, unknown>) : null;\n\n throw new DimesApiError({ status: response.status, code, type, message, params });\n}\n\nexport interface HttpClientOptions {\n baseUrl: string;\n auth: AuthProvider;\n fetch?: typeof globalThis.fetch;\n maxRetries?: number;\n maxRetryDelayMs?: number;\n}\n\nexport class HttpClient {\n private readonly baseUrl: string;\n\n private readonly auth: AuthProvider;\n\n private readonly fetchFn: typeof globalThis.fetch;\n\n private readonly maxRetries: number;\n\n private readonly maxRetryDelayMs: number;\n\n constructor(options: HttpClientOptions) {\n this.baseUrl = options.baseUrl;\n this.auth = options.auth;\n this.fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);\n this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;\n this.maxRetryDelayMs = options.maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS;\n }\n\n public async request<T>(path: string, options?: RequestInit): Promise<T> {\n const authHeaders = await this.auth.getHeaders();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...authHeaders,\n ...(options?.headers as Record<string, string> | undefined),\n };\n\n let response = await this.fetchFn(`${this.baseUrl}${path}`, {\n ...options,\n headers,\n });\n\n if (response.status === HTTP_UNAUTHORIZED && this.auth.refresh) {\n await this.auth.refresh();\n const retryHeaders = await this.auth.getHeaders();\n response = await this.fetchFn(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...headers, ...retryHeaders },\n });\n }\n\n for (let attempt = 0; response.status === HTTP_TOO_MANY_REQUESTS && attempt < this.maxRetries; attempt++) {\n const delayMs = parseRetryAfterMs(response.headers.get(\"retry-after\"), attempt);\n if (delayMs > this.maxRetryDelayMs) {\n break;\n }\n await sleep(delayMs);\n const freshAuth = await this.auth.getHeaders();\n response = await this.fetchFn(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...headers, ...freshAuth },\n });\n }\n\n if (!response.ok) {\n await throwFromResponse(response);\n }\n\n return camelizeKeys(await response.json()) as T;\n }\n\n public async requestList<T>(path: string, options?: RequestInit): Promise<T[]> {\n const result = await this.request<{ data: T[] }>(path, options);\n return result.data;\n }\n}\n","import { DimesError } from \"../errors/dimes-error\";\n\nexport interface AuthProvider {\n getHeaders(): Promise<Record<string, string>>;\n refresh?(): Promise<void>;\n}\n\ninterface TokenResponse {\n token: string;\n expires_at: string;\n}\n\nexport interface ApiKeyAuthOptions {\n apiKey: string;\n walletAddress: string;\n baseUrl?: string;\n fetch?: typeof globalThis.fetch;\n}\n\nexport class ApiKeyAuth implements AuthProvider {\n private jwt: string | null = null;\n\n private expiresAt = 0;\n\n private refreshPromise: Promise<void> | null = null;\n\n private readonly apiKey: string;\n\n private readonly walletAddress: string;\n\n private readonly baseUrl: string;\n\n private readonly fetchFn: typeof globalThis.fetch;\n\n constructor(options: ApiKeyAuthOptions) {\n this.apiKey = options.apiKey;\n this.walletAddress = options.walletAddress;\n this.baseUrl = options.baseUrl ?? \"https://api.dimes.fi\";\n this.fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n public async getHeaders(): Promise<Record<string, string>> {\n const TOKEN_EXPIRY_BUFFER_MS = 30_000;\n if (!this.jwt || Date.now() >= this.expiresAt - TOKEN_EXPIRY_BUFFER_MS) {\n await this.refresh();\n }\n return { Authorization: `Bearer ${this.jwt}` };\n }\n\n public async refresh(): Promise<void> {\n if (this.refreshPromise) {\n await this.refreshPromise;\n return;\n }\n\n this.refreshPromise = this.fetchToken();\n try {\n await this.refreshPromise;\n } finally {\n this.refreshPromise = null;\n }\n }\n\n private async fetchToken(): Promise<void> {\n const response = await this.fetchFn(`${this.baseUrl}/v1/prediction-markets/tokens`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n },\n body: JSON.stringify({ wallet_address: this.walletAddress }),\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new DimesError(\"auth_token_failed\", `Failed to obtain auth token (${response.status}): ${text}`);\n }\n\n const data = (await response.json()) as TokenResponse;\n this.jwt = data.token;\n this.expiresAt = new Date(data.expires_at).getTime();\n }\n}\n\nexport interface JwtAuthOptions {\n token: string | (() => Promise<string>);\n}\n\nexport class JwtAuth implements AuthProvider {\n private readonly tokenOrFn: string | (() => Promise<string>);\n\n constructor(options: JwtAuthOptions) {\n this.tokenOrFn = options.token;\n }\n\n public async getHeaders(): Promise<Record<string, string>> {\n const token = typeof this.tokenOrFn === \"function\" ? await this.tokenOrFn() : this.tokenOrFn;\n return { Authorization: `Bearer ${token}` };\n }\n}\n","import type { CamelizeKeys } from \"./camelize\";\nimport type { components } from \"./generated\";\n\ntype Raw = components[\"schemas\"];\n\nexport type Market = CamelizeKeys<Raw[\"CustomerMarket\"]>;\n\nexport type MarketLeverage = CamelizeKeys<Raw[\"CustomerLeverage\"]>;\n\nexport type MarketFees = CamelizeKeys<Raw[\"CustomerFees\"]>;\n\nexport type MarketPrices = CamelizeKeys<Raw[\"CustomerMarketPrices\"]>;\n\nexport type OriginationTier = CamelizeKeys<Raw[\"CustomerOriginationTier\"]>;\n\nexport type Offer = CamelizeKeys<Raw[\"ApiCustomerOffer\"]>;\n\nexport type OpenPosition = CamelizeKeys<Raw[\"CustomerOpenPosition\"]>;\n\nexport type ClosedPosition = CamelizeKeys<Raw[\"CustomerClosedPosition\"]>;\n\nexport type Position = OpenPosition | ClosedPosition;\n\nexport type PositionEntry = CamelizeKeys<Raw[\"CustomerPositionEntry\"]>;\n\nexport type PositionCurrent = CamelizeKeys<Raw[\"CustomerPositionCurrent\"]>;\n\nexport type PositionRisk = CamelizeKeys<Raw[\"CustomerPositionRisk\"]>;\n\nexport type PositionOpenFees = CamelizeKeys<Raw[\"CustomerPositionOpenFees\"]>;\n\nexport type PositionClosedFees = CamelizeKeys<Raw[\"CustomerPositionClosedFees\"]>;\n\nexport type PositionResult = CamelizeKeys<Raw[\"CustomerPositionResult\"]>;\n\nexport type PositionTiming = CamelizeKeys<Raw[\"CustomerPositionTiming\"]>;\n\nexport type PositionFailure = CamelizeKeys<Raw[\"CustomerPositionFailure\"]>;\n\nexport type PositionUnwind = CamelizeKeys<Raw[\"CustomerPositionUnwind\"]>;\n\nexport type PositionUnwindList = CamelizeKeys<Raw[\"CustomerPositionUnwindList\"]>;\n\nexport type ContractInfo = CamelizeKeys<Raw[\"CustomerContractInfo\"]>;\n\nexport type CustomerLimit = CamelizeKeys<Raw[\"CustomerLimit\"]>;\n\nexport type CreateTokenResult = CamelizeKeys<Raw[\"CreateTokenResult\"]>;\n\nexport interface CreateOfferParams {\n marketTicker: string;\n effectiveSide: \"yes\" | \"no\";\n leverageBps: number;\n notionalAmountUsdPips: string;\n slippageBps: number;\n pmProvider?: \"polymarket\" | \"kalshi\";\n}\n\nexport function isOpenPosition(p: Position): p is OpenPosition {\n return \"current\" in p;\n}\n\nexport function isClosedPosition(p: Position): p is ClosedPosition {\n return \"result\" in p;\n}\n\nexport function leverageMaxBps(lev: MarketLeverage, side: \"yes\" | \"no\"): number {\n const perSide = side === \"yes\" ? lev.maxYesBps : lev.maxNoBps;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n return perSide ?? lev.maxBps ?? lev.minBps;\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { C as CreateOfferParams, O as Offer } from './dimes-client-BLIAuK4M.cjs';
|
|
2
|
+
export { A as ApiKeyAuth, a as ApiKeyAuthOptions, b as AuthProvider, c as CamelizeKeys, d as ClosedPosition, e as ContractInfo, f as CorrectedField, g as CreateTokenResult, h as CustomerLimit, D as DimesClient, i as DimesClientOptions, G as GetMarketsParams, j as GetPositionsParams, H as HintAdjustment, J as JwtAuth, k as JwtAuthOptions, M as Market, l as MarketFees, m as MarketLeverage, n as MarketPrices, o as OpenPosition, p as OriginationTier, P as Paginated, q as Position, r as PositionClosedFees, s as PositionCurrent, t as PositionEntry, u as PositionFailure, v as PositionOpenFees, w as PositionResult, x as PositionRisk, y as PositionTiming, z as PositionUnwind, B as PositionUnwindList, Q as QuoteHint, E as hintAdjustment, F as isClosedPosition, I as isOpenPosition, K as leverageMaxBps, L as marketMovedCodes, N as quoteErrorHint } from './dimes-client-BLIAuK4M.cjs';
|
|
3
|
+
export { D as DimesApiError, a as DimesContractError, b as DimesError } from './dimes-error-DxzsfQo6.cjs';
|
|
4
|
+
import { Q as QuoteParams, a as QuoteOptions, b as QuoteResult } from './quote-ByZJRoPf.cjs';
|
|
5
|
+
export { M as MarketMovedEvent, S as Side } from './quote-ByZJRoPf.cjs';
|
|
6
|
+
|
|
7
|
+
type Params = Record<string, unknown> | null;
|
|
8
|
+
|
|
9
|
+
declare function resolveFriendlyMessage(code: string, params: Params): string | null;
|
|
10
|
+
declare function formatErrorMessage(code: string, params: Params): string;
|
|
11
|
+
|
|
12
|
+
interface QuoteClient {
|
|
13
|
+
createDraftQuote(params: CreateOfferParams): Promise<Offer>;
|
|
14
|
+
promoteDraftQuote(draftId: string): Promise<Offer>;
|
|
15
|
+
createQuote(params: CreateOfferParams): Promise<Offer>;
|
|
16
|
+
}
|
|
17
|
+
declare function executeQuote(client: QuoteClient, params: QuoteParams, options?: QuoteOptions): Promise<QuoteResult>;
|
|
18
|
+
|
|
19
|
+
declare function buildQuoteParams(params: QuoteParams, stepBps?: number): CreateOfferParams;
|
|
20
|
+
|
|
21
|
+
export { CreateOfferParams, Offer, QuoteOptions, QuoteParams, QuoteResult, buildQuoteParams, executeQuote, formatErrorMessage, resolveFriendlyMessage };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { C as CreateOfferParams, O as Offer } from './dimes-client-BLIAuK4M.js';
|
|
2
|
+
export { A as ApiKeyAuth, a as ApiKeyAuthOptions, b as AuthProvider, c as CamelizeKeys, d as ClosedPosition, e as ContractInfo, f as CorrectedField, g as CreateTokenResult, h as CustomerLimit, D as DimesClient, i as DimesClientOptions, G as GetMarketsParams, j as GetPositionsParams, H as HintAdjustment, J as JwtAuth, k as JwtAuthOptions, M as Market, l as MarketFees, m as MarketLeverage, n as MarketPrices, o as OpenPosition, p as OriginationTier, P as Paginated, q as Position, r as PositionClosedFees, s as PositionCurrent, t as PositionEntry, u as PositionFailure, v as PositionOpenFees, w as PositionResult, x as PositionRisk, y as PositionTiming, z as PositionUnwind, B as PositionUnwindList, Q as QuoteHint, E as hintAdjustment, F as isClosedPosition, I as isOpenPosition, K as leverageMaxBps, L as marketMovedCodes, N as quoteErrorHint } from './dimes-client-BLIAuK4M.js';
|
|
3
|
+
export { D as DimesApiError, a as DimesContractError, b as DimesError } from './dimes-error-BtDMi3Kv.js';
|
|
4
|
+
import { Q as QuoteParams, a as QuoteOptions, b as QuoteResult } from './quote-CgmTKnIZ.js';
|
|
5
|
+
export { M as MarketMovedEvent, S as Side } from './quote-CgmTKnIZ.js';
|
|
6
|
+
|
|
7
|
+
type Params = Record<string, unknown> | null;
|
|
8
|
+
|
|
9
|
+
declare function resolveFriendlyMessage(code: string, params: Params): string | null;
|
|
10
|
+
declare function formatErrorMessage(code: string, params: Params): string;
|
|
11
|
+
|
|
12
|
+
interface QuoteClient {
|
|
13
|
+
createDraftQuote(params: CreateOfferParams): Promise<Offer>;
|
|
14
|
+
promoteDraftQuote(draftId: string): Promise<Offer>;
|
|
15
|
+
createQuote(params: CreateOfferParams): Promise<Offer>;
|
|
16
|
+
}
|
|
17
|
+
declare function executeQuote(client: QuoteClient, params: QuoteParams, options?: QuoteOptions): Promise<QuoteResult>;
|
|
18
|
+
|
|
19
|
+
declare function buildQuoteParams(params: QuoteParams, stepBps?: number): CreateOfferParams;
|
|
20
|
+
|
|
21
|
+
export { CreateOfferParams, Offer, QuoteOptions, QuoteParams, QuoteResult, buildQuoteParams, executeQuote, formatErrorMessage, resolveFriendlyMessage };
|