meteora-api 0.0.0 → 0.2.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/README.md +14 -0
- package/dist/index.cjs +3817 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6702 -0
- package/dist/index.d.mts +6702 -0
- package/dist/index.mjs +3807 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +28 -9
- package/index.js +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3807 @@
|
|
|
1
|
+
//#region generated/damm-v1/core/bodySerializer.gen.ts
|
|
2
|
+
const jsonBodySerializer$4 = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region generated/damm-v1/core/serverSentEvents.gen.ts
|
|
5
|
+
function createSseClient$4({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
6
|
+
let lastEventId;
|
|
7
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
8
|
+
const createStream = async function* () {
|
|
9
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
10
|
+
let attempt = 0;
|
|
11
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
12
|
+
while (true) {
|
|
13
|
+
if (signal.aborted) break;
|
|
14
|
+
attempt++;
|
|
15
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
16
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
17
|
+
try {
|
|
18
|
+
const requestInit = {
|
|
19
|
+
redirect: "follow",
|
|
20
|
+
...options,
|
|
21
|
+
body: options.serializedBody,
|
|
22
|
+
headers,
|
|
23
|
+
signal
|
|
24
|
+
};
|
|
25
|
+
let request = new Request(url, requestInit);
|
|
26
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
27
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
28
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
29
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
30
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
31
|
+
let buffer = "";
|
|
32
|
+
const abortHandler = () => {
|
|
33
|
+
try {
|
|
34
|
+
reader.cancel();
|
|
35
|
+
} catch {}
|
|
36
|
+
};
|
|
37
|
+
signal.addEventListener("abort", abortHandler);
|
|
38
|
+
try {
|
|
39
|
+
while (true) {
|
|
40
|
+
const { done, value } = await reader.read();
|
|
41
|
+
if (done) break;
|
|
42
|
+
buffer += value;
|
|
43
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
44
|
+
const chunks = buffer.split("\n\n");
|
|
45
|
+
buffer = chunks.pop() ?? "";
|
|
46
|
+
for (const chunk of chunks) {
|
|
47
|
+
const lines = chunk.split("\n");
|
|
48
|
+
const dataLines = [];
|
|
49
|
+
let eventName;
|
|
50
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
51
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
52
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
53
|
+
else if (line.startsWith("retry:")) {
|
|
54
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
55
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
56
|
+
}
|
|
57
|
+
let data;
|
|
58
|
+
let parsedJson = false;
|
|
59
|
+
if (dataLines.length) {
|
|
60
|
+
const rawData = dataLines.join("\n");
|
|
61
|
+
try {
|
|
62
|
+
data = JSON.parse(rawData);
|
|
63
|
+
parsedJson = true;
|
|
64
|
+
} catch {
|
|
65
|
+
data = rawData;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (parsedJson) {
|
|
69
|
+
if (responseValidator) await responseValidator(data);
|
|
70
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
71
|
+
}
|
|
72
|
+
onSseEvent?.({
|
|
73
|
+
data,
|
|
74
|
+
event: eventName,
|
|
75
|
+
id: lastEventId,
|
|
76
|
+
retry: retryDelay
|
|
77
|
+
});
|
|
78
|
+
if (dataLines.length) yield data;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} finally {
|
|
82
|
+
signal.removeEventListener("abort", abortHandler);
|
|
83
|
+
reader.releaseLock();
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
onSseError?.(error);
|
|
88
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
89
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
90
|
+
await sleep(backoff);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return { stream: createStream() };
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region generated/damm-v1/core/pathSerializer.gen.ts
|
|
98
|
+
const separatorArrayExplode$4 = (style) => {
|
|
99
|
+
switch (style) {
|
|
100
|
+
case "label": return ".";
|
|
101
|
+
case "matrix": return ";";
|
|
102
|
+
case "simple": return ",";
|
|
103
|
+
default: return "&";
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const separatorArrayNoExplode$4 = (style) => {
|
|
107
|
+
switch (style) {
|
|
108
|
+
case "form": return ",";
|
|
109
|
+
case "pipeDelimited": return "|";
|
|
110
|
+
case "spaceDelimited": return "%20";
|
|
111
|
+
default: return ",";
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const separatorObjectExplode$4 = (style) => {
|
|
115
|
+
switch (style) {
|
|
116
|
+
case "label": return ".";
|
|
117
|
+
case "matrix": return ";";
|
|
118
|
+
case "simple": return ",";
|
|
119
|
+
default: return "&";
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const serializeArrayParam$4 = ({ allowReserved, explode, name, style, value }) => {
|
|
123
|
+
if (!explode) {
|
|
124
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode$4(style));
|
|
125
|
+
switch (style) {
|
|
126
|
+
case "label": return `.${joinedValues}`;
|
|
127
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
128
|
+
case "simple": return joinedValues;
|
|
129
|
+
default: return `${name}=${joinedValues}`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const separator = separatorArrayExplode$4(style);
|
|
133
|
+
const joinedValues = value.map((v) => {
|
|
134
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
135
|
+
return serializePrimitiveParam$4({
|
|
136
|
+
allowReserved,
|
|
137
|
+
name,
|
|
138
|
+
value: v
|
|
139
|
+
});
|
|
140
|
+
}).join(separator);
|
|
141
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
142
|
+
};
|
|
143
|
+
const serializePrimitiveParam$4 = ({ allowReserved, name, value }) => {
|
|
144
|
+
if (value === void 0 || value === null) return "";
|
|
145
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
146
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
147
|
+
};
|
|
148
|
+
const serializeObjectParam$4 = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
149
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
150
|
+
if (style !== "deepObject" && !explode) {
|
|
151
|
+
let values = [];
|
|
152
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
153
|
+
values = [
|
|
154
|
+
...values,
|
|
155
|
+
key,
|
|
156
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
157
|
+
];
|
|
158
|
+
});
|
|
159
|
+
const joinedValues = values.join(",");
|
|
160
|
+
switch (style) {
|
|
161
|
+
case "form": return `${name}=${joinedValues}`;
|
|
162
|
+
case "label": return `.${joinedValues}`;
|
|
163
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
164
|
+
default: return joinedValues;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const separator = separatorObjectExplode$4(style);
|
|
168
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam$4({
|
|
169
|
+
allowReserved,
|
|
170
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
171
|
+
value: v
|
|
172
|
+
})).join(separator);
|
|
173
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
174
|
+
};
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region generated/damm-v1/core/utils.gen.ts
|
|
177
|
+
const PATH_PARAM_RE$4 = /\{[^{}]+\}/g;
|
|
178
|
+
const defaultPathSerializer$4 = ({ path, url: _url }) => {
|
|
179
|
+
let url = _url;
|
|
180
|
+
const matches = _url.match(PATH_PARAM_RE$4);
|
|
181
|
+
if (matches) for (const match of matches) {
|
|
182
|
+
let explode = false;
|
|
183
|
+
let name = match.substring(1, match.length - 1);
|
|
184
|
+
let style = "simple";
|
|
185
|
+
if (name.endsWith("*")) {
|
|
186
|
+
explode = true;
|
|
187
|
+
name = name.substring(0, name.length - 1);
|
|
188
|
+
}
|
|
189
|
+
if (name.startsWith(".")) {
|
|
190
|
+
name = name.substring(1);
|
|
191
|
+
style = "label";
|
|
192
|
+
} else if (name.startsWith(";")) {
|
|
193
|
+
name = name.substring(1);
|
|
194
|
+
style = "matrix";
|
|
195
|
+
}
|
|
196
|
+
const value = path[name];
|
|
197
|
+
if (value === void 0 || value === null) continue;
|
|
198
|
+
if (Array.isArray(value)) {
|
|
199
|
+
url = url.replace(match, serializeArrayParam$4({
|
|
200
|
+
explode,
|
|
201
|
+
name,
|
|
202
|
+
style,
|
|
203
|
+
value
|
|
204
|
+
}));
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (typeof value === "object") {
|
|
208
|
+
url = url.replace(match, serializeObjectParam$4({
|
|
209
|
+
explode,
|
|
210
|
+
name,
|
|
211
|
+
style,
|
|
212
|
+
value,
|
|
213
|
+
valueOnly: true
|
|
214
|
+
}));
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (style === "matrix") {
|
|
218
|
+
url = url.replace(match, `;${serializePrimitiveParam$4({
|
|
219
|
+
name,
|
|
220
|
+
value
|
|
221
|
+
})}`);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
225
|
+
url = url.replace(match, replaceValue);
|
|
226
|
+
}
|
|
227
|
+
return url;
|
|
228
|
+
};
|
|
229
|
+
const getUrl$4 = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
230
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
231
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
232
|
+
if (path) url = defaultPathSerializer$4({
|
|
233
|
+
path,
|
|
234
|
+
url
|
|
235
|
+
});
|
|
236
|
+
let search = query ? querySerializer(query) : "";
|
|
237
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
238
|
+
if (search) url += `?${search}`;
|
|
239
|
+
return url;
|
|
240
|
+
};
|
|
241
|
+
function getValidRequestBody$4(options) {
|
|
242
|
+
const hasBody = options.body !== void 0;
|
|
243
|
+
if (hasBody && options.bodySerializer) {
|
|
244
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
245
|
+
return options.body !== "" ? options.body : null;
|
|
246
|
+
}
|
|
247
|
+
if (hasBody) return options.body;
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region generated/damm-v1/core/auth.gen.ts
|
|
251
|
+
const getAuthToken$4 = async (auth, callback) => {
|
|
252
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
253
|
+
if (!token) return;
|
|
254
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
255
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
256
|
+
return token;
|
|
257
|
+
};
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region generated/damm-v1/client/utils.gen.ts
|
|
260
|
+
const createQuerySerializer$4 = ({ parameters = {}, ...args } = {}) => {
|
|
261
|
+
const querySerializer = (queryParams) => {
|
|
262
|
+
const search = [];
|
|
263
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
264
|
+
const value = queryParams[name];
|
|
265
|
+
if (value === void 0 || value === null) continue;
|
|
266
|
+
const options = parameters[name] || args;
|
|
267
|
+
if (Array.isArray(value)) {
|
|
268
|
+
const serializedArray = serializeArrayParam$4({
|
|
269
|
+
allowReserved: options.allowReserved,
|
|
270
|
+
explode: true,
|
|
271
|
+
name,
|
|
272
|
+
style: "form",
|
|
273
|
+
value,
|
|
274
|
+
...options.array
|
|
275
|
+
});
|
|
276
|
+
if (serializedArray) search.push(serializedArray);
|
|
277
|
+
} else if (typeof value === "object") {
|
|
278
|
+
const serializedObject = serializeObjectParam$4({
|
|
279
|
+
allowReserved: options.allowReserved,
|
|
280
|
+
explode: true,
|
|
281
|
+
name,
|
|
282
|
+
style: "deepObject",
|
|
283
|
+
value,
|
|
284
|
+
...options.object
|
|
285
|
+
});
|
|
286
|
+
if (serializedObject) search.push(serializedObject);
|
|
287
|
+
} else {
|
|
288
|
+
const serializedPrimitive = serializePrimitiveParam$4({
|
|
289
|
+
allowReserved: options.allowReserved,
|
|
290
|
+
name,
|
|
291
|
+
value
|
|
292
|
+
});
|
|
293
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return search.join("&");
|
|
297
|
+
};
|
|
298
|
+
return querySerializer;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Infers parseAs value from provided Content-Type header.
|
|
302
|
+
*/
|
|
303
|
+
const getParseAs$4 = (contentType) => {
|
|
304
|
+
if (!contentType) return "stream";
|
|
305
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
306
|
+
if (!cleanContent) return;
|
|
307
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
308
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
309
|
+
if ([
|
|
310
|
+
"application/",
|
|
311
|
+
"audio/",
|
|
312
|
+
"image/",
|
|
313
|
+
"video/"
|
|
314
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
315
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
316
|
+
};
|
|
317
|
+
const checkForExistence$4 = (options, name) => {
|
|
318
|
+
if (!name) return false;
|
|
319
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
320
|
+
return false;
|
|
321
|
+
};
|
|
322
|
+
async function setAuthParams$4(options) {
|
|
323
|
+
for (const auth of options.security ?? []) {
|
|
324
|
+
if (checkForExistence$4(options, auth.name)) continue;
|
|
325
|
+
const token = await getAuthToken$4(auth, options.auth);
|
|
326
|
+
if (!token) continue;
|
|
327
|
+
const name = auth.name ?? "Authorization";
|
|
328
|
+
switch (auth.in) {
|
|
329
|
+
case "query":
|
|
330
|
+
if (!options.query) options.query = {};
|
|
331
|
+
options.query[name] = token;
|
|
332
|
+
break;
|
|
333
|
+
case "cookie":
|
|
334
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
335
|
+
break;
|
|
336
|
+
default: options.headers.set(name, token);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const buildUrl$4 = (options) => getUrl$4({
|
|
341
|
+
baseUrl: options.baseUrl,
|
|
342
|
+
path: options.path,
|
|
343
|
+
query: options.query,
|
|
344
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer$4(options.querySerializer),
|
|
345
|
+
url: options.url
|
|
346
|
+
});
|
|
347
|
+
const mergeConfigs$4 = (a, b) => {
|
|
348
|
+
const config = {
|
|
349
|
+
...a,
|
|
350
|
+
...b
|
|
351
|
+
};
|
|
352
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
353
|
+
config.headers = mergeHeaders$4(a.headers, b.headers);
|
|
354
|
+
return config;
|
|
355
|
+
};
|
|
356
|
+
const headersEntries$4 = (headers) => {
|
|
357
|
+
const entries = [];
|
|
358
|
+
headers.forEach((value, key) => {
|
|
359
|
+
entries.push([key, value]);
|
|
360
|
+
});
|
|
361
|
+
return entries;
|
|
362
|
+
};
|
|
363
|
+
const mergeHeaders$4 = (...headers) => {
|
|
364
|
+
const mergedHeaders = new Headers();
|
|
365
|
+
for (const header of headers) {
|
|
366
|
+
if (!header) continue;
|
|
367
|
+
const iterator = header instanceof Headers ? headersEntries$4(header) : Object.entries(header);
|
|
368
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
369
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
370
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
371
|
+
}
|
|
372
|
+
return mergedHeaders;
|
|
373
|
+
};
|
|
374
|
+
var Interceptors$4 = class {
|
|
375
|
+
fns = [];
|
|
376
|
+
clear() {
|
|
377
|
+
this.fns = [];
|
|
378
|
+
}
|
|
379
|
+
eject(id) {
|
|
380
|
+
const index = this.getInterceptorIndex(id);
|
|
381
|
+
if (this.fns[index]) this.fns[index] = null;
|
|
382
|
+
}
|
|
383
|
+
exists(id) {
|
|
384
|
+
const index = this.getInterceptorIndex(id);
|
|
385
|
+
return Boolean(this.fns[index]);
|
|
386
|
+
}
|
|
387
|
+
getInterceptorIndex(id) {
|
|
388
|
+
if (typeof id === "number") return this.fns[id] ? id : -1;
|
|
389
|
+
return this.fns.indexOf(id);
|
|
390
|
+
}
|
|
391
|
+
update(id, fn) {
|
|
392
|
+
const index = this.getInterceptorIndex(id);
|
|
393
|
+
if (this.fns[index]) {
|
|
394
|
+
this.fns[index] = fn;
|
|
395
|
+
return id;
|
|
396
|
+
}
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
use(fn) {
|
|
400
|
+
this.fns.push(fn);
|
|
401
|
+
return this.fns.length - 1;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
const createInterceptors$4 = () => ({
|
|
405
|
+
error: new Interceptors$4(),
|
|
406
|
+
request: new Interceptors$4(),
|
|
407
|
+
response: new Interceptors$4()
|
|
408
|
+
});
|
|
409
|
+
const defaultQuerySerializer$4 = createQuerySerializer$4({
|
|
410
|
+
allowReserved: false,
|
|
411
|
+
array: {
|
|
412
|
+
explode: true,
|
|
413
|
+
style: "form"
|
|
414
|
+
},
|
|
415
|
+
object: {
|
|
416
|
+
explode: true,
|
|
417
|
+
style: "deepObject"
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
const defaultHeaders$4 = { "Content-Type": "application/json" };
|
|
421
|
+
const createConfig$4 = (override = {}) => ({
|
|
422
|
+
...jsonBodySerializer$4,
|
|
423
|
+
headers: defaultHeaders$4,
|
|
424
|
+
parseAs: "auto",
|
|
425
|
+
querySerializer: defaultQuerySerializer$4,
|
|
426
|
+
...override
|
|
427
|
+
});
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region generated/damm-v1/client/client.gen.ts
|
|
430
|
+
const createClient = (config = {}) => {
|
|
431
|
+
let _config = mergeConfigs$4(createConfig$4(), config);
|
|
432
|
+
const getConfig = () => ({ ..._config });
|
|
433
|
+
const setConfig = (config) => {
|
|
434
|
+
_config = mergeConfigs$4(_config, config);
|
|
435
|
+
return getConfig();
|
|
436
|
+
};
|
|
437
|
+
const interceptors = createInterceptors$4();
|
|
438
|
+
const beforeRequest = async (options) => {
|
|
439
|
+
const opts = {
|
|
440
|
+
..._config,
|
|
441
|
+
...options,
|
|
442
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
443
|
+
headers: mergeHeaders$4(_config.headers, options.headers),
|
|
444
|
+
serializedBody: void 0
|
|
445
|
+
};
|
|
446
|
+
if (opts.security) await setAuthParams$4(opts);
|
|
447
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
448
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
449
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
450
|
+
const resolvedOpts = opts;
|
|
451
|
+
return {
|
|
452
|
+
opts: resolvedOpts,
|
|
453
|
+
url: buildUrl$4(resolvedOpts)
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
const request = async (options) => {
|
|
457
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
458
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
459
|
+
let request;
|
|
460
|
+
let response;
|
|
461
|
+
try {
|
|
462
|
+
const { opts, url } = await beforeRequest(options);
|
|
463
|
+
const requestInit = {
|
|
464
|
+
redirect: "follow",
|
|
465
|
+
...opts,
|
|
466
|
+
body: getValidRequestBody$4(opts)
|
|
467
|
+
};
|
|
468
|
+
request = new Request(url, requestInit);
|
|
469
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
470
|
+
const _fetch = opts.fetch;
|
|
471
|
+
response = await _fetch(request);
|
|
472
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
473
|
+
const result = {
|
|
474
|
+
request,
|
|
475
|
+
response
|
|
476
|
+
};
|
|
477
|
+
if (response.ok) {
|
|
478
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs$4(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
479
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
480
|
+
let emptyData;
|
|
481
|
+
switch (parseAs) {
|
|
482
|
+
case "arrayBuffer":
|
|
483
|
+
case "blob":
|
|
484
|
+
case "text":
|
|
485
|
+
emptyData = await response[parseAs]();
|
|
486
|
+
break;
|
|
487
|
+
case "formData":
|
|
488
|
+
emptyData = new FormData();
|
|
489
|
+
break;
|
|
490
|
+
case "stream":
|
|
491
|
+
emptyData = response.body;
|
|
492
|
+
break;
|
|
493
|
+
default: emptyData = {};
|
|
494
|
+
}
|
|
495
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
496
|
+
data: emptyData,
|
|
497
|
+
...result
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
let data;
|
|
501
|
+
switch (parseAs) {
|
|
502
|
+
case "arrayBuffer":
|
|
503
|
+
case "blob":
|
|
504
|
+
case "formData":
|
|
505
|
+
case "text":
|
|
506
|
+
data = await response[parseAs]();
|
|
507
|
+
break;
|
|
508
|
+
case "json": {
|
|
509
|
+
const text = await response.text();
|
|
510
|
+
data = text ? JSON.parse(text) : {};
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
514
|
+
data: response.body,
|
|
515
|
+
...result
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
if (parseAs === "json") {
|
|
519
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
520
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
521
|
+
}
|
|
522
|
+
return opts.responseStyle === "data" ? data : {
|
|
523
|
+
data,
|
|
524
|
+
...result
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
const textError = await response.text();
|
|
528
|
+
let jsonError;
|
|
529
|
+
try {
|
|
530
|
+
jsonError = JSON.parse(textError);
|
|
531
|
+
} catch {}
|
|
532
|
+
throw jsonError ?? textError;
|
|
533
|
+
} catch (error) {
|
|
534
|
+
let finalError = error;
|
|
535
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
536
|
+
finalError = finalError || {};
|
|
537
|
+
if (throwOnError) throw finalError;
|
|
538
|
+
return responseStyle === "data" ? void 0 : {
|
|
539
|
+
error: finalError,
|
|
540
|
+
request,
|
|
541
|
+
response
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
const makeMethodFn = (method) => (options) => request({
|
|
546
|
+
...options,
|
|
547
|
+
method
|
|
548
|
+
});
|
|
549
|
+
const makeSseFn = (method) => async (options) => {
|
|
550
|
+
const { opts, url } = await beforeRequest(options);
|
|
551
|
+
return createSseClient$4({
|
|
552
|
+
...opts,
|
|
553
|
+
body: opts.body,
|
|
554
|
+
method,
|
|
555
|
+
onRequest: async (url, init) => {
|
|
556
|
+
let request = new Request(url, init);
|
|
557
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
558
|
+
return request;
|
|
559
|
+
},
|
|
560
|
+
serializedBody: getValidRequestBody$4(opts),
|
|
561
|
+
url
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
const _buildUrl = (options) => buildUrl$4({
|
|
565
|
+
..._config,
|
|
566
|
+
...options
|
|
567
|
+
});
|
|
568
|
+
return {
|
|
569
|
+
buildUrl: _buildUrl,
|
|
570
|
+
connect: makeMethodFn("CONNECT"),
|
|
571
|
+
delete: makeMethodFn("DELETE"),
|
|
572
|
+
get: makeMethodFn("GET"),
|
|
573
|
+
getConfig,
|
|
574
|
+
head: makeMethodFn("HEAD"),
|
|
575
|
+
interceptors,
|
|
576
|
+
options: makeMethodFn("OPTIONS"),
|
|
577
|
+
patch: makeMethodFn("PATCH"),
|
|
578
|
+
post: makeMethodFn("POST"),
|
|
579
|
+
put: makeMethodFn("PUT"),
|
|
580
|
+
request,
|
|
581
|
+
setConfig,
|
|
582
|
+
sse: {
|
|
583
|
+
connect: makeSseFn("CONNECT"),
|
|
584
|
+
delete: makeSseFn("DELETE"),
|
|
585
|
+
get: makeSseFn("GET"),
|
|
586
|
+
head: makeSseFn("HEAD"),
|
|
587
|
+
options: makeSseFn("OPTIONS"),
|
|
588
|
+
patch: makeSseFn("PATCH"),
|
|
589
|
+
post: makeSseFn("POST"),
|
|
590
|
+
put: makeSseFn("PUT"),
|
|
591
|
+
trace: makeSseFn("TRACE")
|
|
592
|
+
},
|
|
593
|
+
trace: makeMethodFn("TRACE")
|
|
594
|
+
};
|
|
595
|
+
};
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region generated/damm-v1/client.gen.ts
|
|
598
|
+
const client$4 = createClient(createConfig$4({ baseUrl: "https://damm-api.meteora.ag" }));
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region generated/damm-v1/sdk.gen.ts
|
|
601
|
+
var HeyApiClient$4 = class {
|
|
602
|
+
client;
|
|
603
|
+
constructor(args) {
|
|
604
|
+
this.client = args?.client ?? client$4;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
var HeyApiRegistry$4 = class {
|
|
608
|
+
defaultKey = "default";
|
|
609
|
+
instances = /* @__PURE__ */ new Map();
|
|
610
|
+
get(key) {
|
|
611
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
612
|
+
if (!instance) throw new Error(`No SDK client found. Create one with "new DammV1Api()" to fix this error.`);
|
|
613
|
+
return instance;
|
|
614
|
+
}
|
|
615
|
+
set(value, key) {
|
|
616
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
var AlphaVault = class extends HeyApiClient$4 {
|
|
620
|
+
/**
|
|
621
|
+
* Alpha Vaults
|
|
622
|
+
*/
|
|
623
|
+
getVaults(options) {
|
|
624
|
+
return (options?.client ?? this.client).get({
|
|
625
|
+
url: "/alpha-vault",
|
|
626
|
+
...options
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Alpha Vault Configs
|
|
631
|
+
*/
|
|
632
|
+
getAll(options) {
|
|
633
|
+
return (options?.client ?? this.client).get({
|
|
634
|
+
url: "/alpha-vault-configs",
|
|
635
|
+
...options
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
var Pools$2 = class extends HeyApiClient$4 {
|
|
640
|
+
/**
|
|
641
|
+
* Pools With Farms
|
|
642
|
+
*/
|
|
643
|
+
getPoolsWithFarm(options) {
|
|
644
|
+
return (options?.client ?? this.client).get({
|
|
645
|
+
url: "/farms",
|
|
646
|
+
...options
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Pool Configs
|
|
651
|
+
*/
|
|
652
|
+
getAllPoolConfigs(options) {
|
|
653
|
+
return (options?.client ?? this.client).get({
|
|
654
|
+
url: "/pool-configs",
|
|
655
|
+
...options
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Pools
|
|
660
|
+
*/
|
|
661
|
+
getPools(options) {
|
|
662
|
+
return (options?.client ?? this.client).get({
|
|
663
|
+
url: "/pools",
|
|
664
|
+
...options
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Pool Metrics
|
|
669
|
+
*/
|
|
670
|
+
getPoolsMetrics(options) {
|
|
671
|
+
return (options?.client ?? this.client).get({
|
|
672
|
+
url: "/pools-metrics",
|
|
673
|
+
...options
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Pool Search
|
|
678
|
+
*/
|
|
679
|
+
filterAndGetPoolInfo(options) {
|
|
680
|
+
return (options.client ?? this.client).get({
|
|
681
|
+
url: "/pools/search",
|
|
682
|
+
...options
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Pool Search Deprecated
|
|
687
|
+
*/
|
|
688
|
+
filterAndGetPoolInfoDeprecated(options) {
|
|
689
|
+
return (options.client ?? this.client).get({
|
|
690
|
+
url: "/pools/{version}",
|
|
691
|
+
...options
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Pools By A Vault LP
|
|
696
|
+
*/
|
|
697
|
+
getPoolsByAVaultLp(options) {
|
|
698
|
+
return (options.client ?? this.client).post({
|
|
699
|
+
url: "/pools_by_a_vault_lp",
|
|
700
|
+
...options,
|
|
701
|
+
headers: {
|
|
702
|
+
"Content-Type": "application/json",
|
|
703
|
+
...options.headers
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
var FeeConfigs = class extends HeyApiClient$4 {
|
|
709
|
+
/**
|
|
710
|
+
* Fee Configs
|
|
711
|
+
*/
|
|
712
|
+
getConfigAssociatedFeeConfigs(options) {
|
|
713
|
+
return (options.client ?? this.client).get({
|
|
714
|
+
url: "/fee-config/{config_address}",
|
|
715
|
+
...options
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
var DammV1Api = class DammV1Api extends HeyApiClient$4 {
|
|
720
|
+
static __registry = new HeyApiRegistry$4();
|
|
721
|
+
constructor(args) {
|
|
722
|
+
super(args);
|
|
723
|
+
DammV1Api.__registry.set(this, args?.key);
|
|
724
|
+
}
|
|
725
|
+
_alphaVault;
|
|
726
|
+
get alphaVault() {
|
|
727
|
+
return this._alphaVault ??= new AlphaVault({ client: this.client });
|
|
728
|
+
}
|
|
729
|
+
_pools;
|
|
730
|
+
get pools() {
|
|
731
|
+
return this._pools ??= new Pools$2({ client: this.client });
|
|
732
|
+
}
|
|
733
|
+
_feeConfigs;
|
|
734
|
+
get feeConfigs() {
|
|
735
|
+
return this._feeConfigs ??= new FeeConfigs({ client: this.client });
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region generated/damm-v2/core/bodySerializer.gen.ts
|
|
740
|
+
const jsonBodySerializer$3 = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
741
|
+
//#endregion
|
|
742
|
+
//#region generated/damm-v2/core/serverSentEvents.gen.ts
|
|
743
|
+
function createSseClient$3({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
744
|
+
let lastEventId;
|
|
745
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
746
|
+
const createStream = async function* () {
|
|
747
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
748
|
+
let attempt = 0;
|
|
749
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
750
|
+
while (true) {
|
|
751
|
+
if (signal.aborted) break;
|
|
752
|
+
attempt++;
|
|
753
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
754
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
755
|
+
try {
|
|
756
|
+
const requestInit = {
|
|
757
|
+
redirect: "follow",
|
|
758
|
+
...options,
|
|
759
|
+
body: options.serializedBody,
|
|
760
|
+
headers,
|
|
761
|
+
signal
|
|
762
|
+
};
|
|
763
|
+
let request = new Request(url, requestInit);
|
|
764
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
765
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
766
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
767
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
768
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
769
|
+
let buffer = "";
|
|
770
|
+
const abortHandler = () => {
|
|
771
|
+
try {
|
|
772
|
+
reader.cancel();
|
|
773
|
+
} catch {}
|
|
774
|
+
};
|
|
775
|
+
signal.addEventListener("abort", abortHandler);
|
|
776
|
+
try {
|
|
777
|
+
while (true) {
|
|
778
|
+
const { done, value } = await reader.read();
|
|
779
|
+
if (done) break;
|
|
780
|
+
buffer += value;
|
|
781
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
782
|
+
const chunks = buffer.split("\n\n");
|
|
783
|
+
buffer = chunks.pop() ?? "";
|
|
784
|
+
for (const chunk of chunks) {
|
|
785
|
+
const lines = chunk.split("\n");
|
|
786
|
+
const dataLines = [];
|
|
787
|
+
let eventName;
|
|
788
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
789
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
790
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
791
|
+
else if (line.startsWith("retry:")) {
|
|
792
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
793
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
794
|
+
}
|
|
795
|
+
let data;
|
|
796
|
+
let parsedJson = false;
|
|
797
|
+
if (dataLines.length) {
|
|
798
|
+
const rawData = dataLines.join("\n");
|
|
799
|
+
try {
|
|
800
|
+
data = JSON.parse(rawData);
|
|
801
|
+
parsedJson = true;
|
|
802
|
+
} catch {
|
|
803
|
+
data = rawData;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
if (parsedJson) {
|
|
807
|
+
if (responseValidator) await responseValidator(data);
|
|
808
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
809
|
+
}
|
|
810
|
+
onSseEvent?.({
|
|
811
|
+
data,
|
|
812
|
+
event: eventName,
|
|
813
|
+
id: lastEventId,
|
|
814
|
+
retry: retryDelay
|
|
815
|
+
});
|
|
816
|
+
if (dataLines.length) yield data;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
} finally {
|
|
820
|
+
signal.removeEventListener("abort", abortHandler);
|
|
821
|
+
reader.releaseLock();
|
|
822
|
+
}
|
|
823
|
+
break;
|
|
824
|
+
} catch (error) {
|
|
825
|
+
onSseError?.(error);
|
|
826
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
827
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
828
|
+
await sleep(backoff);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
return { stream: createStream() };
|
|
833
|
+
}
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region generated/damm-v2/core/pathSerializer.gen.ts
|
|
836
|
+
const separatorArrayExplode$3 = (style) => {
|
|
837
|
+
switch (style) {
|
|
838
|
+
case "label": return ".";
|
|
839
|
+
case "matrix": return ";";
|
|
840
|
+
case "simple": return ",";
|
|
841
|
+
default: return "&";
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
const separatorArrayNoExplode$3 = (style) => {
|
|
845
|
+
switch (style) {
|
|
846
|
+
case "form": return ",";
|
|
847
|
+
case "pipeDelimited": return "|";
|
|
848
|
+
case "spaceDelimited": return "%20";
|
|
849
|
+
default: return ",";
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
const separatorObjectExplode$3 = (style) => {
|
|
853
|
+
switch (style) {
|
|
854
|
+
case "label": return ".";
|
|
855
|
+
case "matrix": return ";";
|
|
856
|
+
case "simple": return ",";
|
|
857
|
+
default: return "&";
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
const serializeArrayParam$3 = ({ allowReserved, explode, name, style, value }) => {
|
|
861
|
+
if (!explode) {
|
|
862
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode$3(style));
|
|
863
|
+
switch (style) {
|
|
864
|
+
case "label": return `.${joinedValues}`;
|
|
865
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
866
|
+
case "simple": return joinedValues;
|
|
867
|
+
default: return `${name}=${joinedValues}`;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
const separator = separatorArrayExplode$3(style);
|
|
871
|
+
const joinedValues = value.map((v) => {
|
|
872
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
873
|
+
return serializePrimitiveParam$3({
|
|
874
|
+
allowReserved,
|
|
875
|
+
name,
|
|
876
|
+
value: v
|
|
877
|
+
});
|
|
878
|
+
}).join(separator);
|
|
879
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
880
|
+
};
|
|
881
|
+
const serializePrimitiveParam$3 = ({ allowReserved, name, value }) => {
|
|
882
|
+
if (value === void 0 || value === null) return "";
|
|
883
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
884
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
885
|
+
};
|
|
886
|
+
const serializeObjectParam$3 = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
887
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
888
|
+
if (style !== "deepObject" && !explode) {
|
|
889
|
+
let values = [];
|
|
890
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
891
|
+
values = [
|
|
892
|
+
...values,
|
|
893
|
+
key,
|
|
894
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
895
|
+
];
|
|
896
|
+
});
|
|
897
|
+
const joinedValues = values.join(",");
|
|
898
|
+
switch (style) {
|
|
899
|
+
case "form": return `${name}=${joinedValues}`;
|
|
900
|
+
case "label": return `.${joinedValues}`;
|
|
901
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
902
|
+
default: return joinedValues;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
const separator = separatorObjectExplode$3(style);
|
|
906
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam$3({
|
|
907
|
+
allowReserved,
|
|
908
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
909
|
+
value: v
|
|
910
|
+
})).join(separator);
|
|
911
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
912
|
+
};
|
|
913
|
+
//#endregion
|
|
914
|
+
//#region generated/damm-v2/core/utils.gen.ts
|
|
915
|
+
const PATH_PARAM_RE$3 = /\{[^{}]+\}/g;
|
|
916
|
+
const defaultPathSerializer$3 = ({ path, url: _url }) => {
|
|
917
|
+
let url = _url;
|
|
918
|
+
const matches = _url.match(PATH_PARAM_RE$3);
|
|
919
|
+
if (matches) for (const match of matches) {
|
|
920
|
+
let explode = false;
|
|
921
|
+
let name = match.substring(1, match.length - 1);
|
|
922
|
+
let style = "simple";
|
|
923
|
+
if (name.endsWith("*")) {
|
|
924
|
+
explode = true;
|
|
925
|
+
name = name.substring(0, name.length - 1);
|
|
926
|
+
}
|
|
927
|
+
if (name.startsWith(".")) {
|
|
928
|
+
name = name.substring(1);
|
|
929
|
+
style = "label";
|
|
930
|
+
} else if (name.startsWith(";")) {
|
|
931
|
+
name = name.substring(1);
|
|
932
|
+
style = "matrix";
|
|
933
|
+
}
|
|
934
|
+
const value = path[name];
|
|
935
|
+
if (value === void 0 || value === null) continue;
|
|
936
|
+
if (Array.isArray(value)) {
|
|
937
|
+
url = url.replace(match, serializeArrayParam$3({
|
|
938
|
+
explode,
|
|
939
|
+
name,
|
|
940
|
+
style,
|
|
941
|
+
value
|
|
942
|
+
}));
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
945
|
+
if (typeof value === "object") {
|
|
946
|
+
url = url.replace(match, serializeObjectParam$3({
|
|
947
|
+
explode,
|
|
948
|
+
name,
|
|
949
|
+
style,
|
|
950
|
+
value,
|
|
951
|
+
valueOnly: true
|
|
952
|
+
}));
|
|
953
|
+
continue;
|
|
954
|
+
}
|
|
955
|
+
if (style === "matrix") {
|
|
956
|
+
url = url.replace(match, `;${serializePrimitiveParam$3({
|
|
957
|
+
name,
|
|
958
|
+
value
|
|
959
|
+
})}`);
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
963
|
+
url = url.replace(match, replaceValue);
|
|
964
|
+
}
|
|
965
|
+
return url;
|
|
966
|
+
};
|
|
967
|
+
const getUrl$3 = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
968
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
969
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
970
|
+
if (path) url = defaultPathSerializer$3({
|
|
971
|
+
path,
|
|
972
|
+
url
|
|
973
|
+
});
|
|
974
|
+
let search = query ? querySerializer(query) : "";
|
|
975
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
976
|
+
if (search) url += `?${search}`;
|
|
977
|
+
return url;
|
|
978
|
+
};
|
|
979
|
+
function getValidRequestBody$3(options) {
|
|
980
|
+
const hasBody = options.body !== void 0;
|
|
981
|
+
if (hasBody && options.bodySerializer) {
|
|
982
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
983
|
+
return options.body !== "" ? options.body : null;
|
|
984
|
+
}
|
|
985
|
+
if (hasBody) return options.body;
|
|
986
|
+
}
|
|
987
|
+
//#endregion
|
|
988
|
+
//#region generated/damm-v2/core/auth.gen.ts
|
|
989
|
+
const getAuthToken$3 = async (auth, callback) => {
|
|
990
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
991
|
+
if (!token) return;
|
|
992
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
993
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
994
|
+
return token;
|
|
995
|
+
};
|
|
996
|
+
//#endregion
|
|
997
|
+
//#region generated/damm-v2/client/utils.gen.ts
|
|
998
|
+
const createQuerySerializer$3 = ({ parameters = {}, ...args } = {}) => {
|
|
999
|
+
const querySerializer = (queryParams) => {
|
|
1000
|
+
const search = [];
|
|
1001
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
1002
|
+
const value = queryParams[name];
|
|
1003
|
+
if (value === void 0 || value === null) continue;
|
|
1004
|
+
const options = parameters[name] || args;
|
|
1005
|
+
if (Array.isArray(value)) {
|
|
1006
|
+
const serializedArray = serializeArrayParam$3({
|
|
1007
|
+
allowReserved: options.allowReserved,
|
|
1008
|
+
explode: true,
|
|
1009
|
+
name,
|
|
1010
|
+
style: "form",
|
|
1011
|
+
value,
|
|
1012
|
+
...options.array
|
|
1013
|
+
});
|
|
1014
|
+
if (serializedArray) search.push(serializedArray);
|
|
1015
|
+
} else if (typeof value === "object") {
|
|
1016
|
+
const serializedObject = serializeObjectParam$3({
|
|
1017
|
+
allowReserved: options.allowReserved,
|
|
1018
|
+
explode: true,
|
|
1019
|
+
name,
|
|
1020
|
+
style: "deepObject",
|
|
1021
|
+
value,
|
|
1022
|
+
...options.object
|
|
1023
|
+
});
|
|
1024
|
+
if (serializedObject) search.push(serializedObject);
|
|
1025
|
+
} else {
|
|
1026
|
+
const serializedPrimitive = serializePrimitiveParam$3({
|
|
1027
|
+
allowReserved: options.allowReserved,
|
|
1028
|
+
name,
|
|
1029
|
+
value
|
|
1030
|
+
});
|
|
1031
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return search.join("&");
|
|
1035
|
+
};
|
|
1036
|
+
return querySerializer;
|
|
1037
|
+
};
|
|
1038
|
+
/**
|
|
1039
|
+
* Infers parseAs value from provided Content-Type header.
|
|
1040
|
+
*/
|
|
1041
|
+
const getParseAs$3 = (contentType) => {
|
|
1042
|
+
if (!contentType) return "stream";
|
|
1043
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
1044
|
+
if (!cleanContent) return;
|
|
1045
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
1046
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
1047
|
+
if ([
|
|
1048
|
+
"application/",
|
|
1049
|
+
"audio/",
|
|
1050
|
+
"image/",
|
|
1051
|
+
"video/"
|
|
1052
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
1053
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
1054
|
+
};
|
|
1055
|
+
const checkForExistence$3 = (options, name) => {
|
|
1056
|
+
if (!name) return false;
|
|
1057
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
1058
|
+
return false;
|
|
1059
|
+
};
|
|
1060
|
+
async function setAuthParams$3(options) {
|
|
1061
|
+
for (const auth of options.security ?? []) {
|
|
1062
|
+
if (checkForExistence$3(options, auth.name)) continue;
|
|
1063
|
+
const token = await getAuthToken$3(auth, options.auth);
|
|
1064
|
+
if (!token) continue;
|
|
1065
|
+
const name = auth.name ?? "Authorization";
|
|
1066
|
+
switch (auth.in) {
|
|
1067
|
+
case "query":
|
|
1068
|
+
if (!options.query) options.query = {};
|
|
1069
|
+
options.query[name] = token;
|
|
1070
|
+
break;
|
|
1071
|
+
case "cookie":
|
|
1072
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
1073
|
+
break;
|
|
1074
|
+
default: options.headers.set(name, token);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
const buildUrl$3 = (options) => getUrl$3({
|
|
1079
|
+
baseUrl: options.baseUrl,
|
|
1080
|
+
path: options.path,
|
|
1081
|
+
query: options.query,
|
|
1082
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer$3(options.querySerializer),
|
|
1083
|
+
url: options.url
|
|
1084
|
+
});
|
|
1085
|
+
const mergeConfigs$3 = (a, b) => {
|
|
1086
|
+
const config = {
|
|
1087
|
+
...a,
|
|
1088
|
+
...b
|
|
1089
|
+
};
|
|
1090
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
1091
|
+
config.headers = mergeHeaders$3(a.headers, b.headers);
|
|
1092
|
+
return config;
|
|
1093
|
+
};
|
|
1094
|
+
const headersEntries$3 = (headers) => {
|
|
1095
|
+
const entries = [];
|
|
1096
|
+
headers.forEach((value, key) => {
|
|
1097
|
+
entries.push([key, value]);
|
|
1098
|
+
});
|
|
1099
|
+
return entries;
|
|
1100
|
+
};
|
|
1101
|
+
const mergeHeaders$3 = (...headers) => {
|
|
1102
|
+
const mergedHeaders = new Headers();
|
|
1103
|
+
for (const header of headers) {
|
|
1104
|
+
if (!header) continue;
|
|
1105
|
+
const iterator = header instanceof Headers ? headersEntries$3(header) : Object.entries(header);
|
|
1106
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
1107
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
1108
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
1109
|
+
}
|
|
1110
|
+
return mergedHeaders;
|
|
1111
|
+
};
|
|
1112
|
+
var Interceptors$3 = class {
|
|
1113
|
+
fns = [];
|
|
1114
|
+
clear() {
|
|
1115
|
+
this.fns = [];
|
|
1116
|
+
}
|
|
1117
|
+
eject(id) {
|
|
1118
|
+
const index = this.getInterceptorIndex(id);
|
|
1119
|
+
if (this.fns[index]) this.fns[index] = null;
|
|
1120
|
+
}
|
|
1121
|
+
exists(id) {
|
|
1122
|
+
const index = this.getInterceptorIndex(id);
|
|
1123
|
+
return Boolean(this.fns[index]);
|
|
1124
|
+
}
|
|
1125
|
+
getInterceptorIndex(id) {
|
|
1126
|
+
if (typeof id === "number") return this.fns[id] ? id : -1;
|
|
1127
|
+
return this.fns.indexOf(id);
|
|
1128
|
+
}
|
|
1129
|
+
update(id, fn) {
|
|
1130
|
+
const index = this.getInterceptorIndex(id);
|
|
1131
|
+
if (this.fns[index]) {
|
|
1132
|
+
this.fns[index] = fn;
|
|
1133
|
+
return id;
|
|
1134
|
+
}
|
|
1135
|
+
return false;
|
|
1136
|
+
}
|
|
1137
|
+
use(fn) {
|
|
1138
|
+
this.fns.push(fn);
|
|
1139
|
+
return this.fns.length - 1;
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
const createInterceptors$3 = () => ({
|
|
1143
|
+
error: new Interceptors$3(),
|
|
1144
|
+
request: new Interceptors$3(),
|
|
1145
|
+
response: new Interceptors$3()
|
|
1146
|
+
});
|
|
1147
|
+
const defaultQuerySerializer$3 = createQuerySerializer$3({
|
|
1148
|
+
allowReserved: false,
|
|
1149
|
+
array: {
|
|
1150
|
+
explode: true,
|
|
1151
|
+
style: "form"
|
|
1152
|
+
},
|
|
1153
|
+
object: {
|
|
1154
|
+
explode: true,
|
|
1155
|
+
style: "deepObject"
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
const defaultHeaders$3 = { "Content-Type": "application/json" };
|
|
1159
|
+
const createConfig$3 = (override = {}) => ({
|
|
1160
|
+
...jsonBodySerializer$3,
|
|
1161
|
+
headers: defaultHeaders$3,
|
|
1162
|
+
parseAs: "auto",
|
|
1163
|
+
querySerializer: defaultQuerySerializer$3,
|
|
1164
|
+
...override
|
|
1165
|
+
});
|
|
1166
|
+
//#endregion
|
|
1167
|
+
//#region generated/damm-v2/client/client.gen.ts
|
|
1168
|
+
const createClient$1 = (config = {}) => {
|
|
1169
|
+
let _config = mergeConfigs$3(createConfig$3(), config);
|
|
1170
|
+
const getConfig = () => ({ ..._config });
|
|
1171
|
+
const setConfig = (config) => {
|
|
1172
|
+
_config = mergeConfigs$3(_config, config);
|
|
1173
|
+
return getConfig();
|
|
1174
|
+
};
|
|
1175
|
+
const interceptors = createInterceptors$3();
|
|
1176
|
+
const beforeRequest = async (options) => {
|
|
1177
|
+
const opts = {
|
|
1178
|
+
..._config,
|
|
1179
|
+
...options,
|
|
1180
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
1181
|
+
headers: mergeHeaders$3(_config.headers, options.headers),
|
|
1182
|
+
serializedBody: void 0
|
|
1183
|
+
};
|
|
1184
|
+
if (opts.security) await setAuthParams$3(opts);
|
|
1185
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
1186
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
1187
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
1188
|
+
const resolvedOpts = opts;
|
|
1189
|
+
return {
|
|
1190
|
+
opts: resolvedOpts,
|
|
1191
|
+
url: buildUrl$3(resolvedOpts)
|
|
1192
|
+
};
|
|
1193
|
+
};
|
|
1194
|
+
const request = async (options) => {
|
|
1195
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
1196
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
1197
|
+
let request;
|
|
1198
|
+
let response;
|
|
1199
|
+
try {
|
|
1200
|
+
const { opts, url } = await beforeRequest(options);
|
|
1201
|
+
const requestInit = {
|
|
1202
|
+
redirect: "follow",
|
|
1203
|
+
...opts,
|
|
1204
|
+
body: getValidRequestBody$3(opts)
|
|
1205
|
+
};
|
|
1206
|
+
request = new Request(url, requestInit);
|
|
1207
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
1208
|
+
const _fetch = opts.fetch;
|
|
1209
|
+
response = await _fetch(request);
|
|
1210
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
1211
|
+
const result = {
|
|
1212
|
+
request,
|
|
1213
|
+
response
|
|
1214
|
+
};
|
|
1215
|
+
if (response.ok) {
|
|
1216
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs$3(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
1217
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
1218
|
+
let emptyData;
|
|
1219
|
+
switch (parseAs) {
|
|
1220
|
+
case "arrayBuffer":
|
|
1221
|
+
case "blob":
|
|
1222
|
+
case "text":
|
|
1223
|
+
emptyData = await response[parseAs]();
|
|
1224
|
+
break;
|
|
1225
|
+
case "formData":
|
|
1226
|
+
emptyData = new FormData();
|
|
1227
|
+
break;
|
|
1228
|
+
case "stream":
|
|
1229
|
+
emptyData = response.body;
|
|
1230
|
+
break;
|
|
1231
|
+
default: emptyData = {};
|
|
1232
|
+
}
|
|
1233
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
1234
|
+
data: emptyData,
|
|
1235
|
+
...result
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
let data;
|
|
1239
|
+
switch (parseAs) {
|
|
1240
|
+
case "arrayBuffer":
|
|
1241
|
+
case "blob":
|
|
1242
|
+
case "formData":
|
|
1243
|
+
case "text":
|
|
1244
|
+
data = await response[parseAs]();
|
|
1245
|
+
break;
|
|
1246
|
+
case "json": {
|
|
1247
|
+
const text = await response.text();
|
|
1248
|
+
data = text ? JSON.parse(text) : {};
|
|
1249
|
+
break;
|
|
1250
|
+
}
|
|
1251
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
1252
|
+
data: response.body,
|
|
1253
|
+
...result
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
if (parseAs === "json") {
|
|
1257
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
1258
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
1259
|
+
}
|
|
1260
|
+
return opts.responseStyle === "data" ? data : {
|
|
1261
|
+
data,
|
|
1262
|
+
...result
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
const textError = await response.text();
|
|
1266
|
+
let jsonError;
|
|
1267
|
+
try {
|
|
1268
|
+
jsonError = JSON.parse(textError);
|
|
1269
|
+
} catch {}
|
|
1270
|
+
throw jsonError ?? textError;
|
|
1271
|
+
} catch (error) {
|
|
1272
|
+
let finalError = error;
|
|
1273
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
1274
|
+
finalError = finalError || {};
|
|
1275
|
+
if (throwOnError) throw finalError;
|
|
1276
|
+
return responseStyle === "data" ? void 0 : {
|
|
1277
|
+
error: finalError,
|
|
1278
|
+
request,
|
|
1279
|
+
response
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
const makeMethodFn = (method) => (options) => request({
|
|
1284
|
+
...options,
|
|
1285
|
+
method
|
|
1286
|
+
});
|
|
1287
|
+
const makeSseFn = (method) => async (options) => {
|
|
1288
|
+
const { opts, url } = await beforeRequest(options);
|
|
1289
|
+
return createSseClient$3({
|
|
1290
|
+
...opts,
|
|
1291
|
+
body: opts.body,
|
|
1292
|
+
method,
|
|
1293
|
+
onRequest: async (url, init) => {
|
|
1294
|
+
let request = new Request(url, init);
|
|
1295
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
1296
|
+
return request;
|
|
1297
|
+
},
|
|
1298
|
+
serializedBody: getValidRequestBody$3(opts),
|
|
1299
|
+
url
|
|
1300
|
+
});
|
|
1301
|
+
};
|
|
1302
|
+
const _buildUrl = (options) => buildUrl$3({
|
|
1303
|
+
..._config,
|
|
1304
|
+
...options
|
|
1305
|
+
});
|
|
1306
|
+
return {
|
|
1307
|
+
buildUrl: _buildUrl,
|
|
1308
|
+
connect: makeMethodFn("CONNECT"),
|
|
1309
|
+
delete: makeMethodFn("DELETE"),
|
|
1310
|
+
get: makeMethodFn("GET"),
|
|
1311
|
+
getConfig,
|
|
1312
|
+
head: makeMethodFn("HEAD"),
|
|
1313
|
+
interceptors,
|
|
1314
|
+
options: makeMethodFn("OPTIONS"),
|
|
1315
|
+
patch: makeMethodFn("PATCH"),
|
|
1316
|
+
post: makeMethodFn("POST"),
|
|
1317
|
+
put: makeMethodFn("PUT"),
|
|
1318
|
+
request,
|
|
1319
|
+
setConfig,
|
|
1320
|
+
sse: {
|
|
1321
|
+
connect: makeSseFn("CONNECT"),
|
|
1322
|
+
delete: makeSseFn("DELETE"),
|
|
1323
|
+
get: makeSseFn("GET"),
|
|
1324
|
+
head: makeSseFn("HEAD"),
|
|
1325
|
+
options: makeSseFn("OPTIONS"),
|
|
1326
|
+
patch: makeSseFn("PATCH"),
|
|
1327
|
+
post: makeSseFn("POST"),
|
|
1328
|
+
put: makeSseFn("PUT"),
|
|
1329
|
+
trace: makeSseFn("TRACE")
|
|
1330
|
+
},
|
|
1331
|
+
trace: makeMethodFn("TRACE")
|
|
1332
|
+
};
|
|
1333
|
+
};
|
|
1334
|
+
//#endregion
|
|
1335
|
+
//#region generated/damm-v2/client.gen.ts
|
|
1336
|
+
const client$3 = createClient$1(createConfig$3({ baseUrl: "https://damm-v2.datapi.meteora.ag" }));
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region generated/damm-v2/sdk.gen.ts
|
|
1339
|
+
var HeyApiClient$3 = class {
|
|
1340
|
+
client;
|
|
1341
|
+
constructor(args) {
|
|
1342
|
+
this.client = args?.client ?? client$3;
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
var HeyApiRegistry$3 = class {
|
|
1346
|
+
defaultKey = "default";
|
|
1347
|
+
instances = /* @__PURE__ */ new Map();
|
|
1348
|
+
get(key) {
|
|
1349
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
1350
|
+
if (!instance) throw new Error(`No SDK client found. Create one with "new DammV2Api()" to fix this error.`);
|
|
1351
|
+
return instance;
|
|
1352
|
+
}
|
|
1353
|
+
set(value, key) {
|
|
1354
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
var Pools$1 = class extends HeyApiClient$3 {
|
|
1358
|
+
/**
|
|
1359
|
+
* Pools
|
|
1360
|
+
*
|
|
1361
|
+
* Returns a paginated list of pools
|
|
1362
|
+
*/
|
|
1363
|
+
getPools(options) {
|
|
1364
|
+
return (options?.client ?? this.client).get({
|
|
1365
|
+
url: "/pools",
|
|
1366
|
+
...options
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Groups
|
|
1371
|
+
*
|
|
1372
|
+
* Returns a paginated list of pool groups
|
|
1373
|
+
*/
|
|
1374
|
+
getGroups(options) {
|
|
1375
|
+
return (options?.client ?? this.client).get({
|
|
1376
|
+
url: "/pools/groups",
|
|
1377
|
+
...options
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Group
|
|
1382
|
+
*
|
|
1383
|
+
* Returns a paginated list of pools that belong to a specific pool group
|
|
1384
|
+
*/
|
|
1385
|
+
getGroup(options) {
|
|
1386
|
+
return (options.client ?? this.client).get({
|
|
1387
|
+
url: "/pools/groups/{lexical_order_mints}",
|
|
1388
|
+
...options
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Pool
|
|
1393
|
+
*
|
|
1394
|
+
* Returns metadata and current state for a single pool
|
|
1395
|
+
*/
|
|
1396
|
+
getPool(options) {
|
|
1397
|
+
return (options.client ?? this.client).get({
|
|
1398
|
+
url: "/pools/{address}",
|
|
1399
|
+
...options
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* OHLCV
|
|
1404
|
+
*
|
|
1405
|
+
* Returns OHLCV candles for a single pool over a time range
|
|
1406
|
+
*
|
|
1407
|
+
* **Notes**
|
|
1408
|
+
* - If both `start_time` and `end_time` are provided, candles are returned in the range `[start_time, end_time]`
|
|
1409
|
+
* - If only one of `start_time` or `end_time` is provided, the missing bound is inferred using the selected `timeframe`
|
|
1410
|
+
* - If neither is provided, a default range is used based on `timeframe`
|
|
1411
|
+
*/
|
|
1412
|
+
getOhlcv(options) {
|
|
1413
|
+
return (options.client ?? this.client).get({
|
|
1414
|
+
url: "/pools/{address}/ohlcv",
|
|
1415
|
+
...options
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Historical Volume
|
|
1420
|
+
*
|
|
1421
|
+
* Returns historical volume for a pool aggregated into time buckets
|
|
1422
|
+
*
|
|
1423
|
+
* **Notes**
|
|
1424
|
+
* - If both `start_time` and `end_time` are provided, the result covers the range `[start_time, end_time]`
|
|
1425
|
+
* - If only one of `start_time` or `end_time` is provided, the missing bound is inferred using the selected `timeframe`
|
|
1426
|
+
* - If neither is provided, a default range is used based on `timeframe`
|
|
1427
|
+
*/
|
|
1428
|
+
getHistoricalVolume(options) {
|
|
1429
|
+
return (options.client ?? this.client).get({
|
|
1430
|
+
url: "/pools/{address}/volume/history",
|
|
1431
|
+
...options
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
var Stats$1 = class extends HeyApiClient$3 {
|
|
1436
|
+
/**
|
|
1437
|
+
* Protocol Overview
|
|
1438
|
+
*
|
|
1439
|
+
* Returns aggregated protocol-level metrics across all pools
|
|
1440
|
+
*/
|
|
1441
|
+
getProtocolOverview(options) {
|
|
1442
|
+
return (options?.client ?? this.client).get({
|
|
1443
|
+
url: "/stats/protocol_metrics",
|
|
1444
|
+
...options
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
var DammV2Api = class DammV2Api extends HeyApiClient$3 {
|
|
1449
|
+
static __registry = new HeyApiRegistry$3();
|
|
1450
|
+
constructor(args) {
|
|
1451
|
+
super(args);
|
|
1452
|
+
DammV2Api.__registry.set(this, args?.key);
|
|
1453
|
+
}
|
|
1454
|
+
_pools;
|
|
1455
|
+
get pools() {
|
|
1456
|
+
return this._pools ??= new Pools$1({ client: this.client });
|
|
1457
|
+
}
|
|
1458
|
+
_stats;
|
|
1459
|
+
get stats() {
|
|
1460
|
+
return this._stats ??= new Stats$1({ client: this.client });
|
|
1461
|
+
}
|
|
1462
|
+
};
|
|
1463
|
+
//#endregion
|
|
1464
|
+
//#region generated/dlmm/core/bodySerializer.gen.ts
|
|
1465
|
+
const jsonBodySerializer$2 = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
1466
|
+
//#endregion
|
|
1467
|
+
//#region generated/dlmm/core/serverSentEvents.gen.ts
|
|
1468
|
+
function createSseClient$2({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
1469
|
+
let lastEventId;
|
|
1470
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1471
|
+
const createStream = async function* () {
|
|
1472
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
1473
|
+
let attempt = 0;
|
|
1474
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
1475
|
+
while (true) {
|
|
1476
|
+
if (signal.aborted) break;
|
|
1477
|
+
attempt++;
|
|
1478
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
1479
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
1480
|
+
try {
|
|
1481
|
+
const requestInit = {
|
|
1482
|
+
redirect: "follow",
|
|
1483
|
+
...options,
|
|
1484
|
+
body: options.serializedBody,
|
|
1485
|
+
headers,
|
|
1486
|
+
signal
|
|
1487
|
+
};
|
|
1488
|
+
let request = new Request(url, requestInit);
|
|
1489
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
1490
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
1491
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
1492
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
1493
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
1494
|
+
let buffer = "";
|
|
1495
|
+
const abortHandler = () => {
|
|
1496
|
+
try {
|
|
1497
|
+
reader.cancel();
|
|
1498
|
+
} catch {}
|
|
1499
|
+
};
|
|
1500
|
+
signal.addEventListener("abort", abortHandler);
|
|
1501
|
+
try {
|
|
1502
|
+
while (true) {
|
|
1503
|
+
const { done, value } = await reader.read();
|
|
1504
|
+
if (done) break;
|
|
1505
|
+
buffer += value;
|
|
1506
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
1507
|
+
const chunks = buffer.split("\n\n");
|
|
1508
|
+
buffer = chunks.pop() ?? "";
|
|
1509
|
+
for (const chunk of chunks) {
|
|
1510
|
+
const lines = chunk.split("\n");
|
|
1511
|
+
const dataLines = [];
|
|
1512
|
+
let eventName;
|
|
1513
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
1514
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
1515
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
1516
|
+
else if (line.startsWith("retry:")) {
|
|
1517
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
1518
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
1519
|
+
}
|
|
1520
|
+
let data;
|
|
1521
|
+
let parsedJson = false;
|
|
1522
|
+
if (dataLines.length) {
|
|
1523
|
+
const rawData = dataLines.join("\n");
|
|
1524
|
+
try {
|
|
1525
|
+
data = JSON.parse(rawData);
|
|
1526
|
+
parsedJson = true;
|
|
1527
|
+
} catch {
|
|
1528
|
+
data = rawData;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
if (parsedJson) {
|
|
1532
|
+
if (responseValidator) await responseValidator(data);
|
|
1533
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
1534
|
+
}
|
|
1535
|
+
onSseEvent?.({
|
|
1536
|
+
data,
|
|
1537
|
+
event: eventName,
|
|
1538
|
+
id: lastEventId,
|
|
1539
|
+
retry: retryDelay
|
|
1540
|
+
});
|
|
1541
|
+
if (dataLines.length) yield data;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
} finally {
|
|
1545
|
+
signal.removeEventListener("abort", abortHandler);
|
|
1546
|
+
reader.releaseLock();
|
|
1547
|
+
}
|
|
1548
|
+
break;
|
|
1549
|
+
} catch (error) {
|
|
1550
|
+
onSseError?.(error);
|
|
1551
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
1552
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
1553
|
+
await sleep(backoff);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
return { stream: createStream() };
|
|
1558
|
+
}
|
|
1559
|
+
//#endregion
|
|
1560
|
+
//#region generated/dlmm/core/pathSerializer.gen.ts
|
|
1561
|
+
const separatorArrayExplode$2 = (style) => {
|
|
1562
|
+
switch (style) {
|
|
1563
|
+
case "label": return ".";
|
|
1564
|
+
case "matrix": return ";";
|
|
1565
|
+
case "simple": return ",";
|
|
1566
|
+
default: return "&";
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
const separatorArrayNoExplode$2 = (style) => {
|
|
1570
|
+
switch (style) {
|
|
1571
|
+
case "form": return ",";
|
|
1572
|
+
case "pipeDelimited": return "|";
|
|
1573
|
+
case "spaceDelimited": return "%20";
|
|
1574
|
+
default: return ",";
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
const separatorObjectExplode$2 = (style) => {
|
|
1578
|
+
switch (style) {
|
|
1579
|
+
case "label": return ".";
|
|
1580
|
+
case "matrix": return ";";
|
|
1581
|
+
case "simple": return ",";
|
|
1582
|
+
default: return "&";
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
const serializeArrayParam$2 = ({ allowReserved, explode, name, style, value }) => {
|
|
1586
|
+
if (!explode) {
|
|
1587
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode$2(style));
|
|
1588
|
+
switch (style) {
|
|
1589
|
+
case "label": return `.${joinedValues}`;
|
|
1590
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
1591
|
+
case "simple": return joinedValues;
|
|
1592
|
+
default: return `${name}=${joinedValues}`;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
const separator = separatorArrayExplode$2(style);
|
|
1596
|
+
const joinedValues = value.map((v) => {
|
|
1597
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
1598
|
+
return serializePrimitiveParam$2({
|
|
1599
|
+
allowReserved,
|
|
1600
|
+
name,
|
|
1601
|
+
value: v
|
|
1602
|
+
});
|
|
1603
|
+
}).join(separator);
|
|
1604
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
1605
|
+
};
|
|
1606
|
+
const serializePrimitiveParam$2 = ({ allowReserved, name, value }) => {
|
|
1607
|
+
if (value === void 0 || value === null) return "";
|
|
1608
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
1609
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
1610
|
+
};
|
|
1611
|
+
const serializeObjectParam$2 = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
1612
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
1613
|
+
if (style !== "deepObject" && !explode) {
|
|
1614
|
+
let values = [];
|
|
1615
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
1616
|
+
values = [
|
|
1617
|
+
...values,
|
|
1618
|
+
key,
|
|
1619
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
1620
|
+
];
|
|
1621
|
+
});
|
|
1622
|
+
const joinedValues = values.join(",");
|
|
1623
|
+
switch (style) {
|
|
1624
|
+
case "form": return `${name}=${joinedValues}`;
|
|
1625
|
+
case "label": return `.${joinedValues}`;
|
|
1626
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
1627
|
+
default: return joinedValues;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
const separator = separatorObjectExplode$2(style);
|
|
1631
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam$2({
|
|
1632
|
+
allowReserved,
|
|
1633
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
1634
|
+
value: v
|
|
1635
|
+
})).join(separator);
|
|
1636
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
1637
|
+
};
|
|
1638
|
+
//#endregion
|
|
1639
|
+
//#region generated/dlmm/core/utils.gen.ts
|
|
1640
|
+
const PATH_PARAM_RE$2 = /\{[^{}]+\}/g;
|
|
1641
|
+
const defaultPathSerializer$2 = ({ path, url: _url }) => {
|
|
1642
|
+
let url = _url;
|
|
1643
|
+
const matches = _url.match(PATH_PARAM_RE$2);
|
|
1644
|
+
if (matches) for (const match of matches) {
|
|
1645
|
+
let explode = false;
|
|
1646
|
+
let name = match.substring(1, match.length - 1);
|
|
1647
|
+
let style = "simple";
|
|
1648
|
+
if (name.endsWith("*")) {
|
|
1649
|
+
explode = true;
|
|
1650
|
+
name = name.substring(0, name.length - 1);
|
|
1651
|
+
}
|
|
1652
|
+
if (name.startsWith(".")) {
|
|
1653
|
+
name = name.substring(1);
|
|
1654
|
+
style = "label";
|
|
1655
|
+
} else if (name.startsWith(";")) {
|
|
1656
|
+
name = name.substring(1);
|
|
1657
|
+
style = "matrix";
|
|
1658
|
+
}
|
|
1659
|
+
const value = path[name];
|
|
1660
|
+
if (value === void 0 || value === null) continue;
|
|
1661
|
+
if (Array.isArray(value)) {
|
|
1662
|
+
url = url.replace(match, serializeArrayParam$2({
|
|
1663
|
+
explode,
|
|
1664
|
+
name,
|
|
1665
|
+
style,
|
|
1666
|
+
value
|
|
1667
|
+
}));
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
if (typeof value === "object") {
|
|
1671
|
+
url = url.replace(match, serializeObjectParam$2({
|
|
1672
|
+
explode,
|
|
1673
|
+
name,
|
|
1674
|
+
style,
|
|
1675
|
+
value,
|
|
1676
|
+
valueOnly: true
|
|
1677
|
+
}));
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
if (style === "matrix") {
|
|
1681
|
+
url = url.replace(match, `;${serializePrimitiveParam$2({
|
|
1682
|
+
name,
|
|
1683
|
+
value
|
|
1684
|
+
})}`);
|
|
1685
|
+
continue;
|
|
1686
|
+
}
|
|
1687
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
1688
|
+
url = url.replace(match, replaceValue);
|
|
1689
|
+
}
|
|
1690
|
+
return url;
|
|
1691
|
+
};
|
|
1692
|
+
const getUrl$2 = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
1693
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
1694
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
1695
|
+
if (path) url = defaultPathSerializer$2({
|
|
1696
|
+
path,
|
|
1697
|
+
url
|
|
1698
|
+
});
|
|
1699
|
+
let search = query ? querySerializer(query) : "";
|
|
1700
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
1701
|
+
if (search) url += `?${search}`;
|
|
1702
|
+
return url;
|
|
1703
|
+
};
|
|
1704
|
+
function getValidRequestBody$2(options) {
|
|
1705
|
+
const hasBody = options.body !== void 0;
|
|
1706
|
+
if (hasBody && options.bodySerializer) {
|
|
1707
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
1708
|
+
return options.body !== "" ? options.body : null;
|
|
1709
|
+
}
|
|
1710
|
+
if (hasBody) return options.body;
|
|
1711
|
+
}
|
|
1712
|
+
//#endregion
|
|
1713
|
+
//#region generated/dlmm/core/auth.gen.ts
|
|
1714
|
+
const getAuthToken$2 = async (auth, callback) => {
|
|
1715
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
1716
|
+
if (!token) return;
|
|
1717
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
1718
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
1719
|
+
return token;
|
|
1720
|
+
};
|
|
1721
|
+
//#endregion
|
|
1722
|
+
//#region generated/dlmm/client/utils.gen.ts
|
|
1723
|
+
const createQuerySerializer$2 = ({ parameters = {}, ...args } = {}) => {
|
|
1724
|
+
const querySerializer = (queryParams) => {
|
|
1725
|
+
const search = [];
|
|
1726
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
1727
|
+
const value = queryParams[name];
|
|
1728
|
+
if (value === void 0 || value === null) continue;
|
|
1729
|
+
const options = parameters[name] || args;
|
|
1730
|
+
if (Array.isArray(value)) {
|
|
1731
|
+
const serializedArray = serializeArrayParam$2({
|
|
1732
|
+
allowReserved: options.allowReserved,
|
|
1733
|
+
explode: true,
|
|
1734
|
+
name,
|
|
1735
|
+
style: "form",
|
|
1736
|
+
value,
|
|
1737
|
+
...options.array
|
|
1738
|
+
});
|
|
1739
|
+
if (serializedArray) search.push(serializedArray);
|
|
1740
|
+
} else if (typeof value === "object") {
|
|
1741
|
+
const serializedObject = serializeObjectParam$2({
|
|
1742
|
+
allowReserved: options.allowReserved,
|
|
1743
|
+
explode: true,
|
|
1744
|
+
name,
|
|
1745
|
+
style: "deepObject",
|
|
1746
|
+
value,
|
|
1747
|
+
...options.object
|
|
1748
|
+
});
|
|
1749
|
+
if (serializedObject) search.push(serializedObject);
|
|
1750
|
+
} else {
|
|
1751
|
+
const serializedPrimitive = serializePrimitiveParam$2({
|
|
1752
|
+
allowReserved: options.allowReserved,
|
|
1753
|
+
name,
|
|
1754
|
+
value
|
|
1755
|
+
});
|
|
1756
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
return search.join("&");
|
|
1760
|
+
};
|
|
1761
|
+
return querySerializer;
|
|
1762
|
+
};
|
|
1763
|
+
/**
|
|
1764
|
+
* Infers parseAs value from provided Content-Type header.
|
|
1765
|
+
*/
|
|
1766
|
+
const getParseAs$2 = (contentType) => {
|
|
1767
|
+
if (!contentType) return "stream";
|
|
1768
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
1769
|
+
if (!cleanContent) return;
|
|
1770
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
1771
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
1772
|
+
if ([
|
|
1773
|
+
"application/",
|
|
1774
|
+
"audio/",
|
|
1775
|
+
"image/",
|
|
1776
|
+
"video/"
|
|
1777
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
1778
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
1779
|
+
};
|
|
1780
|
+
const checkForExistence$2 = (options, name) => {
|
|
1781
|
+
if (!name) return false;
|
|
1782
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
1783
|
+
return false;
|
|
1784
|
+
};
|
|
1785
|
+
async function setAuthParams$2(options) {
|
|
1786
|
+
for (const auth of options.security ?? []) {
|
|
1787
|
+
if (checkForExistence$2(options, auth.name)) continue;
|
|
1788
|
+
const token = await getAuthToken$2(auth, options.auth);
|
|
1789
|
+
if (!token) continue;
|
|
1790
|
+
const name = auth.name ?? "Authorization";
|
|
1791
|
+
switch (auth.in) {
|
|
1792
|
+
case "query":
|
|
1793
|
+
if (!options.query) options.query = {};
|
|
1794
|
+
options.query[name] = token;
|
|
1795
|
+
break;
|
|
1796
|
+
case "cookie":
|
|
1797
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
1798
|
+
break;
|
|
1799
|
+
default: options.headers.set(name, token);
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
const buildUrl$2 = (options) => getUrl$2({
|
|
1804
|
+
baseUrl: options.baseUrl,
|
|
1805
|
+
path: options.path,
|
|
1806
|
+
query: options.query,
|
|
1807
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer$2(options.querySerializer),
|
|
1808
|
+
url: options.url
|
|
1809
|
+
});
|
|
1810
|
+
const mergeConfigs$2 = (a, b) => {
|
|
1811
|
+
const config = {
|
|
1812
|
+
...a,
|
|
1813
|
+
...b
|
|
1814
|
+
};
|
|
1815
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
1816
|
+
config.headers = mergeHeaders$2(a.headers, b.headers);
|
|
1817
|
+
return config;
|
|
1818
|
+
};
|
|
1819
|
+
const headersEntries$2 = (headers) => {
|
|
1820
|
+
const entries = [];
|
|
1821
|
+
headers.forEach((value, key) => {
|
|
1822
|
+
entries.push([key, value]);
|
|
1823
|
+
});
|
|
1824
|
+
return entries;
|
|
1825
|
+
};
|
|
1826
|
+
const mergeHeaders$2 = (...headers) => {
|
|
1827
|
+
const mergedHeaders = new Headers();
|
|
1828
|
+
for (const header of headers) {
|
|
1829
|
+
if (!header) continue;
|
|
1830
|
+
const iterator = header instanceof Headers ? headersEntries$2(header) : Object.entries(header);
|
|
1831
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
1832
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
1833
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
1834
|
+
}
|
|
1835
|
+
return mergedHeaders;
|
|
1836
|
+
};
|
|
1837
|
+
var Interceptors$2 = class {
|
|
1838
|
+
fns = [];
|
|
1839
|
+
clear() {
|
|
1840
|
+
this.fns = [];
|
|
1841
|
+
}
|
|
1842
|
+
eject(id) {
|
|
1843
|
+
const index = this.getInterceptorIndex(id);
|
|
1844
|
+
if (this.fns[index]) this.fns[index] = null;
|
|
1845
|
+
}
|
|
1846
|
+
exists(id) {
|
|
1847
|
+
const index = this.getInterceptorIndex(id);
|
|
1848
|
+
return Boolean(this.fns[index]);
|
|
1849
|
+
}
|
|
1850
|
+
getInterceptorIndex(id) {
|
|
1851
|
+
if (typeof id === "number") return this.fns[id] ? id : -1;
|
|
1852
|
+
return this.fns.indexOf(id);
|
|
1853
|
+
}
|
|
1854
|
+
update(id, fn) {
|
|
1855
|
+
const index = this.getInterceptorIndex(id);
|
|
1856
|
+
if (this.fns[index]) {
|
|
1857
|
+
this.fns[index] = fn;
|
|
1858
|
+
return id;
|
|
1859
|
+
}
|
|
1860
|
+
return false;
|
|
1861
|
+
}
|
|
1862
|
+
use(fn) {
|
|
1863
|
+
this.fns.push(fn);
|
|
1864
|
+
return this.fns.length - 1;
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
const createInterceptors$2 = () => ({
|
|
1868
|
+
error: new Interceptors$2(),
|
|
1869
|
+
request: new Interceptors$2(),
|
|
1870
|
+
response: new Interceptors$2()
|
|
1871
|
+
});
|
|
1872
|
+
const defaultQuerySerializer$2 = createQuerySerializer$2({
|
|
1873
|
+
allowReserved: false,
|
|
1874
|
+
array: {
|
|
1875
|
+
explode: true,
|
|
1876
|
+
style: "form"
|
|
1877
|
+
},
|
|
1878
|
+
object: {
|
|
1879
|
+
explode: true,
|
|
1880
|
+
style: "deepObject"
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
const defaultHeaders$2 = { "Content-Type": "application/json" };
|
|
1884
|
+
const createConfig$2 = (override = {}) => ({
|
|
1885
|
+
...jsonBodySerializer$2,
|
|
1886
|
+
headers: defaultHeaders$2,
|
|
1887
|
+
parseAs: "auto",
|
|
1888
|
+
querySerializer: defaultQuerySerializer$2,
|
|
1889
|
+
...override
|
|
1890
|
+
});
|
|
1891
|
+
//#endregion
|
|
1892
|
+
//#region generated/dlmm/client/client.gen.ts
|
|
1893
|
+
const createClient$2 = (config = {}) => {
|
|
1894
|
+
let _config = mergeConfigs$2(createConfig$2(), config);
|
|
1895
|
+
const getConfig = () => ({ ..._config });
|
|
1896
|
+
const setConfig = (config) => {
|
|
1897
|
+
_config = mergeConfigs$2(_config, config);
|
|
1898
|
+
return getConfig();
|
|
1899
|
+
};
|
|
1900
|
+
const interceptors = createInterceptors$2();
|
|
1901
|
+
const beforeRequest = async (options) => {
|
|
1902
|
+
const opts = {
|
|
1903
|
+
..._config,
|
|
1904
|
+
...options,
|
|
1905
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
1906
|
+
headers: mergeHeaders$2(_config.headers, options.headers),
|
|
1907
|
+
serializedBody: void 0
|
|
1908
|
+
};
|
|
1909
|
+
if (opts.security) await setAuthParams$2(opts);
|
|
1910
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
1911
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
1912
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
1913
|
+
const resolvedOpts = opts;
|
|
1914
|
+
return {
|
|
1915
|
+
opts: resolvedOpts,
|
|
1916
|
+
url: buildUrl$2(resolvedOpts)
|
|
1917
|
+
};
|
|
1918
|
+
};
|
|
1919
|
+
const request = async (options) => {
|
|
1920
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
1921
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
1922
|
+
let request;
|
|
1923
|
+
let response;
|
|
1924
|
+
try {
|
|
1925
|
+
const { opts, url } = await beforeRequest(options);
|
|
1926
|
+
const requestInit = {
|
|
1927
|
+
redirect: "follow",
|
|
1928
|
+
...opts,
|
|
1929
|
+
body: getValidRequestBody$2(opts)
|
|
1930
|
+
};
|
|
1931
|
+
request = new Request(url, requestInit);
|
|
1932
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
1933
|
+
const _fetch = opts.fetch;
|
|
1934
|
+
response = await _fetch(request);
|
|
1935
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
1936
|
+
const result = {
|
|
1937
|
+
request,
|
|
1938
|
+
response
|
|
1939
|
+
};
|
|
1940
|
+
if (response.ok) {
|
|
1941
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs$2(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
1942
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
1943
|
+
let emptyData;
|
|
1944
|
+
switch (parseAs) {
|
|
1945
|
+
case "arrayBuffer":
|
|
1946
|
+
case "blob":
|
|
1947
|
+
case "text":
|
|
1948
|
+
emptyData = await response[parseAs]();
|
|
1949
|
+
break;
|
|
1950
|
+
case "formData":
|
|
1951
|
+
emptyData = new FormData();
|
|
1952
|
+
break;
|
|
1953
|
+
case "stream":
|
|
1954
|
+
emptyData = response.body;
|
|
1955
|
+
break;
|
|
1956
|
+
default: emptyData = {};
|
|
1957
|
+
}
|
|
1958
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
1959
|
+
data: emptyData,
|
|
1960
|
+
...result
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
let data;
|
|
1964
|
+
switch (parseAs) {
|
|
1965
|
+
case "arrayBuffer":
|
|
1966
|
+
case "blob":
|
|
1967
|
+
case "formData":
|
|
1968
|
+
case "text":
|
|
1969
|
+
data = await response[parseAs]();
|
|
1970
|
+
break;
|
|
1971
|
+
case "json": {
|
|
1972
|
+
const text = await response.text();
|
|
1973
|
+
data = text ? JSON.parse(text) : {};
|
|
1974
|
+
break;
|
|
1975
|
+
}
|
|
1976
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
1977
|
+
data: response.body,
|
|
1978
|
+
...result
|
|
1979
|
+
};
|
|
1980
|
+
}
|
|
1981
|
+
if (parseAs === "json") {
|
|
1982
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
1983
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
1984
|
+
}
|
|
1985
|
+
return opts.responseStyle === "data" ? data : {
|
|
1986
|
+
data,
|
|
1987
|
+
...result
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
const textError = await response.text();
|
|
1991
|
+
let jsonError;
|
|
1992
|
+
try {
|
|
1993
|
+
jsonError = JSON.parse(textError);
|
|
1994
|
+
} catch {}
|
|
1995
|
+
throw jsonError ?? textError;
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
let finalError = error;
|
|
1998
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
1999
|
+
finalError = finalError || {};
|
|
2000
|
+
if (throwOnError) throw finalError;
|
|
2001
|
+
return responseStyle === "data" ? void 0 : {
|
|
2002
|
+
error: finalError,
|
|
2003
|
+
request,
|
|
2004
|
+
response
|
|
2005
|
+
};
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
const makeMethodFn = (method) => (options) => request({
|
|
2009
|
+
...options,
|
|
2010
|
+
method
|
|
2011
|
+
});
|
|
2012
|
+
const makeSseFn = (method) => async (options) => {
|
|
2013
|
+
const { opts, url } = await beforeRequest(options);
|
|
2014
|
+
return createSseClient$2({
|
|
2015
|
+
...opts,
|
|
2016
|
+
body: opts.body,
|
|
2017
|
+
method,
|
|
2018
|
+
onRequest: async (url, init) => {
|
|
2019
|
+
let request = new Request(url, init);
|
|
2020
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
2021
|
+
return request;
|
|
2022
|
+
},
|
|
2023
|
+
serializedBody: getValidRequestBody$2(opts),
|
|
2024
|
+
url
|
|
2025
|
+
});
|
|
2026
|
+
};
|
|
2027
|
+
const _buildUrl = (options) => buildUrl$2({
|
|
2028
|
+
..._config,
|
|
2029
|
+
...options
|
|
2030
|
+
});
|
|
2031
|
+
return {
|
|
2032
|
+
buildUrl: _buildUrl,
|
|
2033
|
+
connect: makeMethodFn("CONNECT"),
|
|
2034
|
+
delete: makeMethodFn("DELETE"),
|
|
2035
|
+
get: makeMethodFn("GET"),
|
|
2036
|
+
getConfig,
|
|
2037
|
+
head: makeMethodFn("HEAD"),
|
|
2038
|
+
interceptors,
|
|
2039
|
+
options: makeMethodFn("OPTIONS"),
|
|
2040
|
+
patch: makeMethodFn("PATCH"),
|
|
2041
|
+
post: makeMethodFn("POST"),
|
|
2042
|
+
put: makeMethodFn("PUT"),
|
|
2043
|
+
request,
|
|
2044
|
+
setConfig,
|
|
2045
|
+
sse: {
|
|
2046
|
+
connect: makeSseFn("CONNECT"),
|
|
2047
|
+
delete: makeSseFn("DELETE"),
|
|
2048
|
+
get: makeSseFn("GET"),
|
|
2049
|
+
head: makeSseFn("HEAD"),
|
|
2050
|
+
options: makeSseFn("OPTIONS"),
|
|
2051
|
+
patch: makeSseFn("PATCH"),
|
|
2052
|
+
post: makeSseFn("POST"),
|
|
2053
|
+
put: makeSseFn("PUT"),
|
|
2054
|
+
trace: makeSseFn("TRACE")
|
|
2055
|
+
},
|
|
2056
|
+
trace: makeMethodFn("TRACE")
|
|
2057
|
+
};
|
|
2058
|
+
};
|
|
2059
|
+
//#endregion
|
|
2060
|
+
//#region generated/dlmm/client.gen.ts
|
|
2061
|
+
const client$2 = createClient$2(createConfig$2({ baseUrl: "https://dlmm.datapi.meteora.ag" }));
|
|
2062
|
+
//#endregion
|
|
2063
|
+
//#region generated/dlmm/sdk.gen.ts
|
|
2064
|
+
var HeyApiClient$2 = class {
|
|
2065
|
+
client;
|
|
2066
|
+
constructor(args) {
|
|
2067
|
+
this.client = args?.client ?? client$2;
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
var HeyApiRegistry$2 = class {
|
|
2071
|
+
defaultKey = "default";
|
|
2072
|
+
instances = /* @__PURE__ */ new Map();
|
|
2073
|
+
get(key) {
|
|
2074
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
2075
|
+
if (!instance) throw new Error(`No SDK client found. Create one with "new DlmmApi()" to fix this error.`);
|
|
2076
|
+
return instance;
|
|
2077
|
+
}
|
|
2078
|
+
set(value, key) {
|
|
2079
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
2080
|
+
}
|
|
2081
|
+
};
|
|
2082
|
+
var Pools = class extends HeyApiClient$2 {
|
|
2083
|
+
/**
|
|
2084
|
+
* Pools
|
|
2085
|
+
*
|
|
2086
|
+
* Returns a paginated list of pools
|
|
2087
|
+
*/
|
|
2088
|
+
getPools(options) {
|
|
2089
|
+
return (options?.client ?? this.client).get({
|
|
2090
|
+
url: "/pools",
|
|
2091
|
+
...options
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
/**
|
|
2095
|
+
* Groups
|
|
2096
|
+
*
|
|
2097
|
+
* Returns a paginated list of pool groups
|
|
2098
|
+
*/
|
|
2099
|
+
getGroups(options) {
|
|
2100
|
+
return (options?.client ?? this.client).get({
|
|
2101
|
+
url: "/pools/groups",
|
|
2102
|
+
...options
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Group
|
|
2107
|
+
*
|
|
2108
|
+
* Returns a paginated list of pools that belong to a specific pool group
|
|
2109
|
+
*/
|
|
2110
|
+
getGroup(options) {
|
|
2111
|
+
return (options.client ?? this.client).get({
|
|
2112
|
+
url: "/pools/groups/{lexical_order_mints}",
|
|
2113
|
+
...options
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Pool
|
|
2118
|
+
*
|
|
2119
|
+
* Returns metadata and current state for a single pool
|
|
2120
|
+
*/
|
|
2121
|
+
getPool(options) {
|
|
2122
|
+
return (options.client ?? this.client).get({
|
|
2123
|
+
url: "/pools/{address}",
|
|
2124
|
+
...options
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* OHLCV
|
|
2129
|
+
*
|
|
2130
|
+
* Returns OHLCV candles for a single pool over a time range
|
|
2131
|
+
*
|
|
2132
|
+
* **Notes**
|
|
2133
|
+
* - If both `start_time` and `end_time` are provided, candles are returned in the range `[start_time, end_time]`
|
|
2134
|
+
* - If only one of `start_time` or `end_time` is provided, the missing bound is inferred using the selected `timeframe`
|
|
2135
|
+
* - If neither is provided, a default range is used based on `timeframe`
|
|
2136
|
+
*/
|
|
2137
|
+
getOhlcv(options) {
|
|
2138
|
+
return (options.client ?? this.client).get({
|
|
2139
|
+
url: "/pools/{address}/ohlcv",
|
|
2140
|
+
...options
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Historical Volume
|
|
2145
|
+
*
|
|
2146
|
+
* Returns historical volume for a pool aggregated into time buckets
|
|
2147
|
+
*
|
|
2148
|
+
* **Notes**
|
|
2149
|
+
* - If both `start_time` and `end_time` are provided, the result covers the range `[start_time, end_time]`
|
|
2150
|
+
* - If only one of `start_time` or `end_time` is provided, the missing bound is inferred using the selected `timeframe`
|
|
2151
|
+
* - If neither is provided, a default range is used based on `timeframe`
|
|
2152
|
+
*/
|
|
2153
|
+
getHistoricalVolume(options) {
|
|
2154
|
+
return (options.client ?? this.client).get({
|
|
2155
|
+
url: "/pools/{address}/volume/history",
|
|
2156
|
+
...options
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
var Portfolio = class extends HeyApiClient$2 {
|
|
2161
|
+
/**
|
|
2162
|
+
* Get user portfolio with all pools containing closed positions
|
|
2163
|
+
*
|
|
2164
|
+
* Returns a paginated list of pools where the user has closed positions,
|
|
2165
|
+
* sorted by most recent activity (last_closed_at DESC). The response includes:
|
|
2166
|
+
* - Pool metadata (address, token symbols, icons, fees)
|
|
2167
|
+
* - Aggregated PnL data (deposits, withdrawals, fees, total PnL)
|
|
2168
|
+
* - Per-token breakdowns (X and Y)
|
|
2169
|
+
*
|
|
2170
|
+
* For detailed position history within each pool, call the /positions/{pool_address}/pnl endpoint.
|
|
2171
|
+
*
|
|
2172
|
+
*
|
|
2173
|
+
*
|
|
2174
|
+
* # Arguments
|
|
2175
|
+
*
|
|
2176
|
+
* * `user` - The wallet address of the user
|
|
2177
|
+
* * `page` - Page number for pagination (default: 1)
|
|
2178
|
+
* * `page_size` - Number of pools per page (default: 120, max: 365)
|
|
2179
|
+
* * `days_back` - Only include pools with positions closed within this many days (default: 90)
|
|
2180
|
+
*
|
|
2181
|
+
* # Returns
|
|
2182
|
+
*
|
|
2183
|
+
* * `200` - The user's portfolio with pool metadata and aggregated PnL
|
|
2184
|
+
* * `400` - Invalid user address or query parameters
|
|
2185
|
+
*/
|
|
2186
|
+
getUserPortfolio(options) {
|
|
2187
|
+
return (options.client ?? this.client).get({
|
|
2188
|
+
url: "/portfolio",
|
|
2189
|
+
...options
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Get user portfolio with all pools containing open positions
|
|
2194
|
+
*
|
|
2195
|
+
* Returns a paginated list of pools where the user has open (active) positions.
|
|
2196
|
+
* The response includes:
|
|
2197
|
+
* - Pool metadata (address, bin step, base fee, token symbols, icons)
|
|
2198
|
+
* - Current balances and unclaimed fees in USD and SOL
|
|
2199
|
+
* - Pool metrics (TVL, 24h volume, fee/TVL ratio)
|
|
2200
|
+
* - List of open position addresses for each pool
|
|
2201
|
+
* - Aggregated total metrics across all pools (balances, unclaimed fees, PnL) in USD and SOL
|
|
2202
|
+
* - SOL price used for conversion (omitted if unavailable)
|
|
2203
|
+
*
|
|
2204
|
+
* Results can be sorted by various metrics and support pagination.
|
|
2205
|
+
*
|
|
2206
|
+
* # Arguments
|
|
2207
|
+
*
|
|
2208
|
+
* * `user` - The wallet address of the user
|
|
2209
|
+
* * `page` - Page number for pagination (default: 1, minimum: 1)
|
|
2210
|
+
* * `page_size` - Number of pools per page (default: 20, maximum: 50)
|
|
2211
|
+
* * `sort_by` - Field to sort by: `current_balances`, `unclaimed_fee`, `pool_tvl`,
|
|
2212
|
+
* `pool_volume_24h`, or `fee_per_tvl_24h` (default: `current_balances`)
|
|
2213
|
+
* * `sort_direction` - Sort direction: `asc` or `desc` (default: `desc`)
|
|
2214
|
+
*
|
|
2215
|
+
* # Returns
|
|
2216
|
+
*
|
|
2217
|
+
* * `200` - The user's open portfolio with pool metadata, balances, and total metrics
|
|
2218
|
+
* * `400` - Invalid user address or query parameters
|
|
2219
|
+
*/
|
|
2220
|
+
getUserOpenPortfolio(options) {
|
|
2221
|
+
return (options.client ?? this.client).get({
|
|
2222
|
+
url: "/portfolio/open",
|
|
2223
|
+
...options
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Get total portfolio PnL across all pools
|
|
2228
|
+
*
|
|
2229
|
+
* Returns the all-time total PnL in USD and percentage change across all user's pools.
|
|
2230
|
+
* This aggregates data from all closed positions across the entire portfolio.
|
|
2231
|
+
*
|
|
2232
|
+
* # Arguments
|
|
2233
|
+
*
|
|
2234
|
+
* * `user` - The wallet address of the user
|
|
2235
|
+
*
|
|
2236
|
+
* # Returns
|
|
2237
|
+
*
|
|
2238
|
+
* * `200` - The user's total portfolio PnL
|
|
2239
|
+
* * `400` - Invalid user address or query parameters
|
|
2240
|
+
*/
|
|
2241
|
+
getPortfolioTotal(options) {
|
|
2242
|
+
return (options.client ?? this.client).get({
|
|
2243
|
+
url: "/portfolio/total",
|
|
2244
|
+
...options
|
|
2245
|
+
});
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
var Positions = class extends HeyApiClient$2 {
|
|
2249
|
+
/**
|
|
2250
|
+
* Get the historical events for a position
|
|
2251
|
+
*
|
|
2252
|
+
* This endpoint returns the historical actions for a position.
|
|
2253
|
+
*
|
|
2254
|
+
* # Arguments
|
|
2255
|
+
*
|
|
2256
|
+
* * `address` - The address of the position
|
|
2257
|
+
*
|
|
2258
|
+
* # Returns
|
|
2259
|
+
*
|
|
2260
|
+
* * `200` - The historical actions for the position
|
|
2261
|
+
*/
|
|
2262
|
+
getPositionHistoricalEvents(options) {
|
|
2263
|
+
return (options.client ?? this.client).get({
|
|
2264
|
+
url: "/positions/{address}/historical",
|
|
2265
|
+
...options
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
/**
|
|
2269
|
+
* Get position PnL data (open and closed positions with on-the-fly calculation)
|
|
2270
|
+
*
|
|
2271
|
+
* Returns positions for a specific pool and user with calculated PnL values.
|
|
2272
|
+
* Includes SOL-denominated amounts when SOL price is available (omitted otherwise).
|
|
2273
|
+
* Results can be filtered by status (open/closed) and are paginated.
|
|
2274
|
+
*
|
|
2275
|
+
* # Arguments
|
|
2276
|
+
*
|
|
2277
|
+
* * `pool_address` - The address of the pool
|
|
2278
|
+
* * `user` - The user address
|
|
2279
|
+
* * `status` - Filter by status: "open", "closed", or omit for all (default: all)
|
|
2280
|
+
* * `page` - Page number starting from 1 (default: 1)
|
|
2281
|
+
*
|
|
2282
|
+
* # Returns
|
|
2283
|
+
*
|
|
2284
|
+
* * `200` - Paginated list of positions with PnL data in USD and SOL
|
|
2285
|
+
*/
|
|
2286
|
+
getPoolPositionPnl(options) {
|
|
2287
|
+
return (options.client ?? this.client).get({
|
|
2288
|
+
url: "/positions/{pool_address}/pnl",
|
|
2289
|
+
...options
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
};
|
|
2293
|
+
var Stats = class extends HeyApiClient$2 {
|
|
2294
|
+
/**
|
|
2295
|
+
* Protocol Overview
|
|
2296
|
+
*
|
|
2297
|
+
* Returns aggregated protocol-level metrics across all pools
|
|
2298
|
+
*/
|
|
2299
|
+
getProtocolOverview(options) {
|
|
2300
|
+
return (options?.client ?? this.client).get({
|
|
2301
|
+
url: "/stats/protocol_metrics",
|
|
2302
|
+
...options
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
};
|
|
2306
|
+
var LimitOrders = class extends HeyApiClient$2 {
|
|
2307
|
+
/**
|
|
2308
|
+
* Get Closed Limit Order Pools
|
|
2309
|
+
*
|
|
2310
|
+
* Paginated per-pool summary of the wallet's closed limit orders, sorted by
|
|
2311
|
+
* `last_closed_at` DESC. A limit order is closed iff it has a row in
|
|
2312
|
+
* `close_limit_orders` — cancel-only orders remain in `/open`.
|
|
2313
|
+
*/
|
|
2314
|
+
getClosedLimitOrderPools(options) {
|
|
2315
|
+
return (options.client ?? this.client).get({
|
|
2316
|
+
url: "/wallets/{wallet}/limit_orders/closed/pools",
|
|
2317
|
+
...options
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
/**
|
|
2321
|
+
* Get Closed Limit Orders For Pool
|
|
2322
|
+
*
|
|
2323
|
+
* Paginated per-order lifecycle view for the wallet's closed limit orders in
|
|
2324
|
+
* one pool, sorted by `last_closed_at` DESC.
|
|
2325
|
+
*/
|
|
2326
|
+
getClosedLimitOrdersForPool(options) {
|
|
2327
|
+
return (options.client ?? this.client).get({
|
|
2328
|
+
url: "/wallets/{wallet}/limit_orders/closed/pools/{pool_address}",
|
|
2329
|
+
...options
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* Get Open Limit Order Pools
|
|
2334
|
+
*
|
|
2335
|
+
* Paginated per-pool summary of the wallet's live limit orders, sorted by
|
|
2336
|
+
* deposit USD DESC. A limit order is live until it has a `close_limit_orders`
|
|
2337
|
+
* row — cancels do not remove it from this view.
|
|
2338
|
+
*/
|
|
2339
|
+
getOpenLimitOrderPools(options) {
|
|
2340
|
+
return (options.client ?? this.client).get({
|
|
2341
|
+
url: "/wallets/{wallet}/limit_orders/open/pools",
|
|
2342
|
+
...options
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
/**
|
|
2346
|
+
* Get Open Limit Orders For Pool
|
|
2347
|
+
*
|
|
2348
|
+
* Paginated per-order detail for the wallet's live limit orders in one pool,
|
|
2349
|
+
* sorted by placement time DESC. "Live" = has no `close_limit_orders` row.
|
|
2350
|
+
*/
|
|
2351
|
+
getOpenLimitOrdersForPool(options) {
|
|
2352
|
+
return (options.client ?? this.client).get({
|
|
2353
|
+
url: "/wallets/{wallet}/limit_orders/open/pools/{pool_address}",
|
|
2354
|
+
...options
|
|
2355
|
+
});
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Get Bonus Claimed For Pool
|
|
2359
|
+
*
|
|
2360
|
+
* Returns the total realized bonus a wallet has claimed on one DLMM pool,
|
|
2361
|
+
* aggregated across every cancel event the wallet has on the pool. Includes
|
|
2362
|
+
* cancels on orders that have not yet been closed (a cancel pays bonus
|
|
2363
|
+
* immediately; the on-chain account is closed separately via
|
|
2364
|
+
* `CloseLimitOrderIfEmpty`). USD/SOL values are derived using each cancel
|
|
2365
|
+
* row's stored cancel-time price ratios — not current spot.
|
|
2366
|
+
*/
|
|
2367
|
+
getBonusClaimedForPool(options) {
|
|
2368
|
+
return (options.client ?? this.client).get({
|
|
2369
|
+
url: "/wallets/{wallet}/limit_orders/pools/{pool_address}/bonus_claimed",
|
|
2370
|
+
...options
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Get Limit Order Summary
|
|
2375
|
+
*
|
|
2376
|
+
* Returns aggregate totals for a user's limit orders across all pools:
|
|
2377
|
+
* open/closed order counts, total deposit value, and total bonus fees earned.
|
|
2378
|
+
* "Open" means placed with no `close_limit_orders` row. "Closed" means the
|
|
2379
|
+
* order has a `close_limit_orders` row (`CloseLimitOrderIfEmpty` was invoked).
|
|
2380
|
+
*/
|
|
2381
|
+
getLimitOrderSummary(options) {
|
|
2382
|
+
return (options.client ?? this.client).get({
|
|
2383
|
+
url: "/wallets/{wallet}/limit_orders/summary",
|
|
2384
|
+
...options
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
var Wallets = class extends HeyApiClient$2 {
|
|
2389
|
+
/**
|
|
2390
|
+
* Get Wallet Pool Total Claims
|
|
2391
|
+
*
|
|
2392
|
+
* Returns combined total claimed fees and rewards for a wallet in a specific pool
|
|
2393
|
+
*/
|
|
2394
|
+
getWalletPoolTotalClaims(options) {
|
|
2395
|
+
return (options.client ?? this.client).get({
|
|
2396
|
+
url: "/wallets/{wallet}/pools/{pool_address}/total_claims",
|
|
2397
|
+
...options
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2401
|
+
var DlmmApi = class DlmmApi extends HeyApiClient$2 {
|
|
2402
|
+
static __registry = new HeyApiRegistry$2();
|
|
2403
|
+
constructor(args) {
|
|
2404
|
+
super(args);
|
|
2405
|
+
DlmmApi.__registry.set(this, args?.key);
|
|
2406
|
+
}
|
|
2407
|
+
_pools;
|
|
2408
|
+
get pools() {
|
|
2409
|
+
return this._pools ??= new Pools({ client: this.client });
|
|
2410
|
+
}
|
|
2411
|
+
_portfolio;
|
|
2412
|
+
get portfolio() {
|
|
2413
|
+
return this._portfolio ??= new Portfolio({ client: this.client });
|
|
2414
|
+
}
|
|
2415
|
+
_positions;
|
|
2416
|
+
get positions() {
|
|
2417
|
+
return this._positions ??= new Positions({ client: this.client });
|
|
2418
|
+
}
|
|
2419
|
+
_stats;
|
|
2420
|
+
get stats() {
|
|
2421
|
+
return this._stats ??= new Stats({ client: this.client });
|
|
2422
|
+
}
|
|
2423
|
+
_limitOrders;
|
|
2424
|
+
get limitOrders() {
|
|
2425
|
+
return this._limitOrders ??= new LimitOrders({ client: this.client });
|
|
2426
|
+
}
|
|
2427
|
+
_wallets;
|
|
2428
|
+
get wallets() {
|
|
2429
|
+
return this._wallets ??= new Wallets({ client: this.client });
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
//#endregion
|
|
2433
|
+
//#region generated/dynamic-vault/core/bodySerializer.gen.ts
|
|
2434
|
+
const jsonBodySerializer$1 = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
2435
|
+
//#endregion
|
|
2436
|
+
//#region generated/dynamic-vault/core/serverSentEvents.gen.ts
|
|
2437
|
+
function createSseClient$1({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
2438
|
+
let lastEventId;
|
|
2439
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
2440
|
+
const createStream = async function* () {
|
|
2441
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
2442
|
+
let attempt = 0;
|
|
2443
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
2444
|
+
while (true) {
|
|
2445
|
+
if (signal.aborted) break;
|
|
2446
|
+
attempt++;
|
|
2447
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
2448
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
2449
|
+
try {
|
|
2450
|
+
const requestInit = {
|
|
2451
|
+
redirect: "follow",
|
|
2452
|
+
...options,
|
|
2453
|
+
body: options.serializedBody,
|
|
2454
|
+
headers,
|
|
2455
|
+
signal
|
|
2456
|
+
};
|
|
2457
|
+
let request = new Request(url, requestInit);
|
|
2458
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
2459
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
2460
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
2461
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
2462
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
2463
|
+
let buffer = "";
|
|
2464
|
+
const abortHandler = () => {
|
|
2465
|
+
try {
|
|
2466
|
+
reader.cancel();
|
|
2467
|
+
} catch {}
|
|
2468
|
+
};
|
|
2469
|
+
signal.addEventListener("abort", abortHandler);
|
|
2470
|
+
try {
|
|
2471
|
+
while (true) {
|
|
2472
|
+
const { done, value } = await reader.read();
|
|
2473
|
+
if (done) break;
|
|
2474
|
+
buffer += value;
|
|
2475
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
2476
|
+
const chunks = buffer.split("\n\n");
|
|
2477
|
+
buffer = chunks.pop() ?? "";
|
|
2478
|
+
for (const chunk of chunks) {
|
|
2479
|
+
const lines = chunk.split("\n");
|
|
2480
|
+
const dataLines = [];
|
|
2481
|
+
let eventName;
|
|
2482
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
2483
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
2484
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
2485
|
+
else if (line.startsWith("retry:")) {
|
|
2486
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
2487
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
2488
|
+
}
|
|
2489
|
+
let data;
|
|
2490
|
+
let parsedJson = false;
|
|
2491
|
+
if (dataLines.length) {
|
|
2492
|
+
const rawData = dataLines.join("\n");
|
|
2493
|
+
try {
|
|
2494
|
+
data = JSON.parse(rawData);
|
|
2495
|
+
parsedJson = true;
|
|
2496
|
+
} catch {
|
|
2497
|
+
data = rawData;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
if (parsedJson) {
|
|
2501
|
+
if (responseValidator) await responseValidator(data);
|
|
2502
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
2503
|
+
}
|
|
2504
|
+
onSseEvent?.({
|
|
2505
|
+
data,
|
|
2506
|
+
event: eventName,
|
|
2507
|
+
id: lastEventId,
|
|
2508
|
+
retry: retryDelay
|
|
2509
|
+
});
|
|
2510
|
+
if (dataLines.length) yield data;
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
} finally {
|
|
2514
|
+
signal.removeEventListener("abort", abortHandler);
|
|
2515
|
+
reader.releaseLock();
|
|
2516
|
+
}
|
|
2517
|
+
break;
|
|
2518
|
+
} catch (error) {
|
|
2519
|
+
onSseError?.(error);
|
|
2520
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
2521
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
2522
|
+
await sleep(backoff);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
};
|
|
2526
|
+
return { stream: createStream() };
|
|
2527
|
+
}
|
|
2528
|
+
//#endregion
|
|
2529
|
+
//#region generated/dynamic-vault/core/pathSerializer.gen.ts
|
|
2530
|
+
const separatorArrayExplode$1 = (style) => {
|
|
2531
|
+
switch (style) {
|
|
2532
|
+
case "label": return ".";
|
|
2533
|
+
case "matrix": return ";";
|
|
2534
|
+
case "simple": return ",";
|
|
2535
|
+
default: return "&";
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
const separatorArrayNoExplode$1 = (style) => {
|
|
2539
|
+
switch (style) {
|
|
2540
|
+
case "form": return ",";
|
|
2541
|
+
case "pipeDelimited": return "|";
|
|
2542
|
+
case "spaceDelimited": return "%20";
|
|
2543
|
+
default: return ",";
|
|
2544
|
+
}
|
|
2545
|
+
};
|
|
2546
|
+
const separatorObjectExplode$1 = (style) => {
|
|
2547
|
+
switch (style) {
|
|
2548
|
+
case "label": return ".";
|
|
2549
|
+
case "matrix": return ";";
|
|
2550
|
+
case "simple": return ",";
|
|
2551
|
+
default: return "&";
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
const serializeArrayParam$1 = ({ allowReserved, explode, name, style, value }) => {
|
|
2555
|
+
if (!explode) {
|
|
2556
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode$1(style));
|
|
2557
|
+
switch (style) {
|
|
2558
|
+
case "label": return `.${joinedValues}`;
|
|
2559
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
2560
|
+
case "simple": return joinedValues;
|
|
2561
|
+
default: return `${name}=${joinedValues}`;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
const separator = separatorArrayExplode$1(style);
|
|
2565
|
+
const joinedValues = value.map((v) => {
|
|
2566
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
2567
|
+
return serializePrimitiveParam$1({
|
|
2568
|
+
allowReserved,
|
|
2569
|
+
name,
|
|
2570
|
+
value: v
|
|
2571
|
+
});
|
|
2572
|
+
}).join(separator);
|
|
2573
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
2574
|
+
};
|
|
2575
|
+
const serializePrimitiveParam$1 = ({ allowReserved, name, value }) => {
|
|
2576
|
+
if (value === void 0 || value === null) return "";
|
|
2577
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
2578
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
2579
|
+
};
|
|
2580
|
+
const serializeObjectParam$1 = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
2581
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
2582
|
+
if (style !== "deepObject" && !explode) {
|
|
2583
|
+
let values = [];
|
|
2584
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
2585
|
+
values = [
|
|
2586
|
+
...values,
|
|
2587
|
+
key,
|
|
2588
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
2589
|
+
];
|
|
2590
|
+
});
|
|
2591
|
+
const joinedValues = values.join(",");
|
|
2592
|
+
switch (style) {
|
|
2593
|
+
case "form": return `${name}=${joinedValues}`;
|
|
2594
|
+
case "label": return `.${joinedValues}`;
|
|
2595
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
2596
|
+
default: return joinedValues;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
const separator = separatorObjectExplode$1(style);
|
|
2600
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam$1({
|
|
2601
|
+
allowReserved,
|
|
2602
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
2603
|
+
value: v
|
|
2604
|
+
})).join(separator);
|
|
2605
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
2606
|
+
};
|
|
2607
|
+
//#endregion
|
|
2608
|
+
//#region generated/dynamic-vault/core/utils.gen.ts
|
|
2609
|
+
const PATH_PARAM_RE$1 = /\{[^{}]+\}/g;
|
|
2610
|
+
const defaultPathSerializer$1 = ({ path, url: _url }) => {
|
|
2611
|
+
let url = _url;
|
|
2612
|
+
const matches = _url.match(PATH_PARAM_RE$1);
|
|
2613
|
+
if (matches) for (const match of matches) {
|
|
2614
|
+
let explode = false;
|
|
2615
|
+
let name = match.substring(1, match.length - 1);
|
|
2616
|
+
let style = "simple";
|
|
2617
|
+
if (name.endsWith("*")) {
|
|
2618
|
+
explode = true;
|
|
2619
|
+
name = name.substring(0, name.length - 1);
|
|
2620
|
+
}
|
|
2621
|
+
if (name.startsWith(".")) {
|
|
2622
|
+
name = name.substring(1);
|
|
2623
|
+
style = "label";
|
|
2624
|
+
} else if (name.startsWith(";")) {
|
|
2625
|
+
name = name.substring(1);
|
|
2626
|
+
style = "matrix";
|
|
2627
|
+
}
|
|
2628
|
+
const value = path[name];
|
|
2629
|
+
if (value === void 0 || value === null) continue;
|
|
2630
|
+
if (Array.isArray(value)) {
|
|
2631
|
+
url = url.replace(match, serializeArrayParam$1({
|
|
2632
|
+
explode,
|
|
2633
|
+
name,
|
|
2634
|
+
style,
|
|
2635
|
+
value
|
|
2636
|
+
}));
|
|
2637
|
+
continue;
|
|
2638
|
+
}
|
|
2639
|
+
if (typeof value === "object") {
|
|
2640
|
+
url = url.replace(match, serializeObjectParam$1({
|
|
2641
|
+
explode,
|
|
2642
|
+
name,
|
|
2643
|
+
style,
|
|
2644
|
+
value,
|
|
2645
|
+
valueOnly: true
|
|
2646
|
+
}));
|
|
2647
|
+
continue;
|
|
2648
|
+
}
|
|
2649
|
+
if (style === "matrix") {
|
|
2650
|
+
url = url.replace(match, `;${serializePrimitiveParam$1({
|
|
2651
|
+
name,
|
|
2652
|
+
value
|
|
2653
|
+
})}`);
|
|
2654
|
+
continue;
|
|
2655
|
+
}
|
|
2656
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
2657
|
+
url = url.replace(match, replaceValue);
|
|
2658
|
+
}
|
|
2659
|
+
return url;
|
|
2660
|
+
};
|
|
2661
|
+
const getUrl$1 = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
2662
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
2663
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
2664
|
+
if (path) url = defaultPathSerializer$1({
|
|
2665
|
+
path,
|
|
2666
|
+
url
|
|
2667
|
+
});
|
|
2668
|
+
let search = query ? querySerializer(query) : "";
|
|
2669
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
2670
|
+
if (search) url += `?${search}`;
|
|
2671
|
+
return url;
|
|
2672
|
+
};
|
|
2673
|
+
function getValidRequestBody$1(options) {
|
|
2674
|
+
const hasBody = options.body !== void 0;
|
|
2675
|
+
if (hasBody && options.bodySerializer) {
|
|
2676
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
2677
|
+
return options.body !== "" ? options.body : null;
|
|
2678
|
+
}
|
|
2679
|
+
if (hasBody) return options.body;
|
|
2680
|
+
}
|
|
2681
|
+
//#endregion
|
|
2682
|
+
//#region generated/dynamic-vault/core/auth.gen.ts
|
|
2683
|
+
const getAuthToken$1 = async (auth, callback) => {
|
|
2684
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
2685
|
+
if (!token) return;
|
|
2686
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
2687
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
2688
|
+
return token;
|
|
2689
|
+
};
|
|
2690
|
+
//#endregion
|
|
2691
|
+
//#region generated/dynamic-vault/client/utils.gen.ts
|
|
2692
|
+
const createQuerySerializer$1 = ({ parameters = {}, ...args } = {}) => {
|
|
2693
|
+
const querySerializer = (queryParams) => {
|
|
2694
|
+
const search = [];
|
|
2695
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
2696
|
+
const value = queryParams[name];
|
|
2697
|
+
if (value === void 0 || value === null) continue;
|
|
2698
|
+
const options = parameters[name] || args;
|
|
2699
|
+
if (Array.isArray(value)) {
|
|
2700
|
+
const serializedArray = serializeArrayParam$1({
|
|
2701
|
+
allowReserved: options.allowReserved,
|
|
2702
|
+
explode: true,
|
|
2703
|
+
name,
|
|
2704
|
+
style: "form",
|
|
2705
|
+
value,
|
|
2706
|
+
...options.array
|
|
2707
|
+
});
|
|
2708
|
+
if (serializedArray) search.push(serializedArray);
|
|
2709
|
+
} else if (typeof value === "object") {
|
|
2710
|
+
const serializedObject = serializeObjectParam$1({
|
|
2711
|
+
allowReserved: options.allowReserved,
|
|
2712
|
+
explode: true,
|
|
2713
|
+
name,
|
|
2714
|
+
style: "deepObject",
|
|
2715
|
+
value,
|
|
2716
|
+
...options.object
|
|
2717
|
+
});
|
|
2718
|
+
if (serializedObject) search.push(serializedObject);
|
|
2719
|
+
} else {
|
|
2720
|
+
const serializedPrimitive = serializePrimitiveParam$1({
|
|
2721
|
+
allowReserved: options.allowReserved,
|
|
2722
|
+
name,
|
|
2723
|
+
value
|
|
2724
|
+
});
|
|
2725
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
return search.join("&");
|
|
2729
|
+
};
|
|
2730
|
+
return querySerializer;
|
|
2731
|
+
};
|
|
2732
|
+
/**
|
|
2733
|
+
* Infers parseAs value from provided Content-Type header.
|
|
2734
|
+
*/
|
|
2735
|
+
const getParseAs$1 = (contentType) => {
|
|
2736
|
+
if (!contentType) return "stream";
|
|
2737
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
2738
|
+
if (!cleanContent) return;
|
|
2739
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
2740
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
2741
|
+
if ([
|
|
2742
|
+
"application/",
|
|
2743
|
+
"audio/",
|
|
2744
|
+
"image/",
|
|
2745
|
+
"video/"
|
|
2746
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
2747
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
2748
|
+
};
|
|
2749
|
+
const checkForExistence$1 = (options, name) => {
|
|
2750
|
+
if (!name) return false;
|
|
2751
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
2752
|
+
return false;
|
|
2753
|
+
};
|
|
2754
|
+
async function setAuthParams$1(options) {
|
|
2755
|
+
for (const auth of options.security ?? []) {
|
|
2756
|
+
if (checkForExistence$1(options, auth.name)) continue;
|
|
2757
|
+
const token = await getAuthToken$1(auth, options.auth);
|
|
2758
|
+
if (!token) continue;
|
|
2759
|
+
const name = auth.name ?? "Authorization";
|
|
2760
|
+
switch (auth.in) {
|
|
2761
|
+
case "query":
|
|
2762
|
+
if (!options.query) options.query = {};
|
|
2763
|
+
options.query[name] = token;
|
|
2764
|
+
break;
|
|
2765
|
+
case "cookie":
|
|
2766
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
2767
|
+
break;
|
|
2768
|
+
default: options.headers.set(name, token);
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
const buildUrl$1 = (options) => getUrl$1({
|
|
2773
|
+
baseUrl: options.baseUrl,
|
|
2774
|
+
path: options.path,
|
|
2775
|
+
query: options.query,
|
|
2776
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer$1(options.querySerializer),
|
|
2777
|
+
url: options.url
|
|
2778
|
+
});
|
|
2779
|
+
const mergeConfigs$1 = (a, b) => {
|
|
2780
|
+
const config = {
|
|
2781
|
+
...a,
|
|
2782
|
+
...b
|
|
2783
|
+
};
|
|
2784
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
2785
|
+
config.headers = mergeHeaders$1(a.headers, b.headers);
|
|
2786
|
+
return config;
|
|
2787
|
+
};
|
|
2788
|
+
const headersEntries$1 = (headers) => {
|
|
2789
|
+
const entries = [];
|
|
2790
|
+
headers.forEach((value, key) => {
|
|
2791
|
+
entries.push([key, value]);
|
|
2792
|
+
});
|
|
2793
|
+
return entries;
|
|
2794
|
+
};
|
|
2795
|
+
const mergeHeaders$1 = (...headers) => {
|
|
2796
|
+
const mergedHeaders = new Headers();
|
|
2797
|
+
for (const header of headers) {
|
|
2798
|
+
if (!header) continue;
|
|
2799
|
+
const iterator = header instanceof Headers ? headersEntries$1(header) : Object.entries(header);
|
|
2800
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
2801
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
2802
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
2803
|
+
}
|
|
2804
|
+
return mergedHeaders;
|
|
2805
|
+
};
|
|
2806
|
+
var Interceptors$1 = class {
|
|
2807
|
+
fns = [];
|
|
2808
|
+
clear() {
|
|
2809
|
+
this.fns = [];
|
|
2810
|
+
}
|
|
2811
|
+
eject(id) {
|
|
2812
|
+
const index = this.getInterceptorIndex(id);
|
|
2813
|
+
if (this.fns[index]) this.fns[index] = null;
|
|
2814
|
+
}
|
|
2815
|
+
exists(id) {
|
|
2816
|
+
const index = this.getInterceptorIndex(id);
|
|
2817
|
+
return Boolean(this.fns[index]);
|
|
2818
|
+
}
|
|
2819
|
+
getInterceptorIndex(id) {
|
|
2820
|
+
if (typeof id === "number") return this.fns[id] ? id : -1;
|
|
2821
|
+
return this.fns.indexOf(id);
|
|
2822
|
+
}
|
|
2823
|
+
update(id, fn) {
|
|
2824
|
+
const index = this.getInterceptorIndex(id);
|
|
2825
|
+
if (this.fns[index]) {
|
|
2826
|
+
this.fns[index] = fn;
|
|
2827
|
+
return id;
|
|
2828
|
+
}
|
|
2829
|
+
return false;
|
|
2830
|
+
}
|
|
2831
|
+
use(fn) {
|
|
2832
|
+
this.fns.push(fn);
|
|
2833
|
+
return this.fns.length - 1;
|
|
2834
|
+
}
|
|
2835
|
+
};
|
|
2836
|
+
const createInterceptors$1 = () => ({
|
|
2837
|
+
error: new Interceptors$1(),
|
|
2838
|
+
request: new Interceptors$1(),
|
|
2839
|
+
response: new Interceptors$1()
|
|
2840
|
+
});
|
|
2841
|
+
const defaultQuerySerializer$1 = createQuerySerializer$1({
|
|
2842
|
+
allowReserved: false,
|
|
2843
|
+
array: {
|
|
2844
|
+
explode: true,
|
|
2845
|
+
style: "form"
|
|
2846
|
+
},
|
|
2847
|
+
object: {
|
|
2848
|
+
explode: true,
|
|
2849
|
+
style: "deepObject"
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
const defaultHeaders$1 = { "Content-Type": "application/json" };
|
|
2853
|
+
const createConfig$1 = (override = {}) => ({
|
|
2854
|
+
...jsonBodySerializer$1,
|
|
2855
|
+
headers: defaultHeaders$1,
|
|
2856
|
+
parseAs: "auto",
|
|
2857
|
+
querySerializer: defaultQuerySerializer$1,
|
|
2858
|
+
...override
|
|
2859
|
+
});
|
|
2860
|
+
//#endregion
|
|
2861
|
+
//#region generated/dynamic-vault/client/client.gen.ts
|
|
2862
|
+
const createClient$3 = (config = {}) => {
|
|
2863
|
+
let _config = mergeConfigs$1(createConfig$1(), config);
|
|
2864
|
+
const getConfig = () => ({ ..._config });
|
|
2865
|
+
const setConfig = (config) => {
|
|
2866
|
+
_config = mergeConfigs$1(_config, config);
|
|
2867
|
+
return getConfig();
|
|
2868
|
+
};
|
|
2869
|
+
const interceptors = createInterceptors$1();
|
|
2870
|
+
const beforeRequest = async (options) => {
|
|
2871
|
+
const opts = {
|
|
2872
|
+
..._config,
|
|
2873
|
+
...options,
|
|
2874
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
2875
|
+
headers: mergeHeaders$1(_config.headers, options.headers),
|
|
2876
|
+
serializedBody: void 0
|
|
2877
|
+
};
|
|
2878
|
+
if (opts.security) await setAuthParams$1(opts);
|
|
2879
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
2880
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
2881
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
2882
|
+
const resolvedOpts = opts;
|
|
2883
|
+
return {
|
|
2884
|
+
opts: resolvedOpts,
|
|
2885
|
+
url: buildUrl$1(resolvedOpts)
|
|
2886
|
+
};
|
|
2887
|
+
};
|
|
2888
|
+
const request = async (options) => {
|
|
2889
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
2890
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
2891
|
+
let request;
|
|
2892
|
+
let response;
|
|
2893
|
+
try {
|
|
2894
|
+
const { opts, url } = await beforeRequest(options);
|
|
2895
|
+
const requestInit = {
|
|
2896
|
+
redirect: "follow",
|
|
2897
|
+
...opts,
|
|
2898
|
+
body: getValidRequestBody$1(opts)
|
|
2899
|
+
};
|
|
2900
|
+
request = new Request(url, requestInit);
|
|
2901
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
2902
|
+
const _fetch = opts.fetch;
|
|
2903
|
+
response = await _fetch(request);
|
|
2904
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
2905
|
+
const result = {
|
|
2906
|
+
request,
|
|
2907
|
+
response
|
|
2908
|
+
};
|
|
2909
|
+
if (response.ok) {
|
|
2910
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs$1(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
2911
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
2912
|
+
let emptyData;
|
|
2913
|
+
switch (parseAs) {
|
|
2914
|
+
case "arrayBuffer":
|
|
2915
|
+
case "blob":
|
|
2916
|
+
case "text":
|
|
2917
|
+
emptyData = await response[parseAs]();
|
|
2918
|
+
break;
|
|
2919
|
+
case "formData":
|
|
2920
|
+
emptyData = new FormData();
|
|
2921
|
+
break;
|
|
2922
|
+
case "stream":
|
|
2923
|
+
emptyData = response.body;
|
|
2924
|
+
break;
|
|
2925
|
+
default: emptyData = {};
|
|
2926
|
+
}
|
|
2927
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
2928
|
+
data: emptyData,
|
|
2929
|
+
...result
|
|
2930
|
+
};
|
|
2931
|
+
}
|
|
2932
|
+
let data;
|
|
2933
|
+
switch (parseAs) {
|
|
2934
|
+
case "arrayBuffer":
|
|
2935
|
+
case "blob":
|
|
2936
|
+
case "formData":
|
|
2937
|
+
case "text":
|
|
2938
|
+
data = await response[parseAs]();
|
|
2939
|
+
break;
|
|
2940
|
+
case "json": {
|
|
2941
|
+
const text = await response.text();
|
|
2942
|
+
data = text ? JSON.parse(text) : {};
|
|
2943
|
+
break;
|
|
2944
|
+
}
|
|
2945
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
2946
|
+
data: response.body,
|
|
2947
|
+
...result
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
if (parseAs === "json") {
|
|
2951
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
2952
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
2953
|
+
}
|
|
2954
|
+
return opts.responseStyle === "data" ? data : {
|
|
2955
|
+
data,
|
|
2956
|
+
...result
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
const textError = await response.text();
|
|
2960
|
+
let jsonError;
|
|
2961
|
+
try {
|
|
2962
|
+
jsonError = JSON.parse(textError);
|
|
2963
|
+
} catch {}
|
|
2964
|
+
throw jsonError ?? textError;
|
|
2965
|
+
} catch (error) {
|
|
2966
|
+
let finalError = error;
|
|
2967
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
2968
|
+
finalError = finalError || {};
|
|
2969
|
+
if (throwOnError) throw finalError;
|
|
2970
|
+
return responseStyle === "data" ? void 0 : {
|
|
2971
|
+
error: finalError,
|
|
2972
|
+
request,
|
|
2973
|
+
response
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
const makeMethodFn = (method) => (options) => request({
|
|
2978
|
+
...options,
|
|
2979
|
+
method
|
|
2980
|
+
});
|
|
2981
|
+
const makeSseFn = (method) => async (options) => {
|
|
2982
|
+
const { opts, url } = await beforeRequest(options);
|
|
2983
|
+
return createSseClient$1({
|
|
2984
|
+
...opts,
|
|
2985
|
+
body: opts.body,
|
|
2986
|
+
method,
|
|
2987
|
+
onRequest: async (url, init) => {
|
|
2988
|
+
let request = new Request(url, init);
|
|
2989
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
2990
|
+
return request;
|
|
2991
|
+
},
|
|
2992
|
+
serializedBody: getValidRequestBody$1(opts),
|
|
2993
|
+
url
|
|
2994
|
+
});
|
|
2995
|
+
};
|
|
2996
|
+
const _buildUrl = (options) => buildUrl$1({
|
|
2997
|
+
..._config,
|
|
2998
|
+
...options
|
|
2999
|
+
});
|
|
3000
|
+
return {
|
|
3001
|
+
buildUrl: _buildUrl,
|
|
3002
|
+
connect: makeMethodFn("CONNECT"),
|
|
3003
|
+
delete: makeMethodFn("DELETE"),
|
|
3004
|
+
get: makeMethodFn("GET"),
|
|
3005
|
+
getConfig,
|
|
3006
|
+
head: makeMethodFn("HEAD"),
|
|
3007
|
+
interceptors,
|
|
3008
|
+
options: makeMethodFn("OPTIONS"),
|
|
3009
|
+
patch: makeMethodFn("PATCH"),
|
|
3010
|
+
post: makeMethodFn("POST"),
|
|
3011
|
+
put: makeMethodFn("PUT"),
|
|
3012
|
+
request,
|
|
3013
|
+
setConfig,
|
|
3014
|
+
sse: {
|
|
3015
|
+
connect: makeSseFn("CONNECT"),
|
|
3016
|
+
delete: makeSseFn("DELETE"),
|
|
3017
|
+
get: makeSseFn("GET"),
|
|
3018
|
+
head: makeSseFn("HEAD"),
|
|
3019
|
+
options: makeSseFn("OPTIONS"),
|
|
3020
|
+
patch: makeSseFn("PATCH"),
|
|
3021
|
+
post: makeSseFn("POST"),
|
|
3022
|
+
put: makeSseFn("PUT"),
|
|
3023
|
+
trace: makeSseFn("TRACE")
|
|
3024
|
+
},
|
|
3025
|
+
trace: makeMethodFn("TRACE")
|
|
3026
|
+
};
|
|
3027
|
+
};
|
|
3028
|
+
//#endregion
|
|
3029
|
+
//#region generated/dynamic-vault/client.gen.ts
|
|
3030
|
+
const client$1 = createClient$3(createConfig$1({ baseUrl: "https://merv2-api.meteora.ag" }));
|
|
3031
|
+
//#endregion
|
|
3032
|
+
//#region generated/dynamic-vault/sdk.gen.ts
|
|
3033
|
+
var HeyApiClient$1 = class {
|
|
3034
|
+
client;
|
|
3035
|
+
constructor(args) {
|
|
3036
|
+
this.client = args?.client ?? client$1;
|
|
3037
|
+
}
|
|
3038
|
+
};
|
|
3039
|
+
var HeyApiRegistry$1 = class {
|
|
3040
|
+
defaultKey = "default";
|
|
3041
|
+
instances = /* @__PURE__ */ new Map();
|
|
3042
|
+
get(key) {
|
|
3043
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
3044
|
+
if (!instance) throw new Error(`No SDK client found. Create one with "new DynamicVaultApi()" to fix this error.`);
|
|
3045
|
+
return instance;
|
|
3046
|
+
}
|
|
3047
|
+
set(value, key) {
|
|
3048
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
3049
|
+
}
|
|
3050
|
+
};
|
|
3051
|
+
var Vaults$1 = class extends HeyApiClient$1 {
|
|
3052
|
+
/**
|
|
3053
|
+
* get_vault_info
|
|
3054
|
+
*
|
|
3055
|
+
* Returns detailed information about all monitored vaults including their states, strategies, and performance metrics
|
|
3056
|
+
*/
|
|
3057
|
+
getVaultInfo(options) {
|
|
3058
|
+
return (options?.client ?? this.client).get({
|
|
3059
|
+
url: "/vault_info",
|
|
3060
|
+
...options
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* get_vault_addresses
|
|
3065
|
+
*
|
|
3066
|
+
* Returns a list of vault addresses with their associated information
|
|
3067
|
+
*/
|
|
3068
|
+
getVaultAddresses(options) {
|
|
3069
|
+
return (options?.client ?? this.client).get({
|
|
3070
|
+
url: "/vault_addresses",
|
|
3071
|
+
...options
|
|
3072
|
+
});
|
|
3073
|
+
}
|
|
3074
|
+
/**
|
|
3075
|
+
* get_vault_state
|
|
3076
|
+
*
|
|
3077
|
+
* Returns the current state of a specific vault identified by its token mint address
|
|
3078
|
+
*/
|
|
3079
|
+
getVaultState(options) {
|
|
3080
|
+
return (options.client ?? this.client).get({
|
|
3081
|
+
url: "/vault_state/{token_mint}",
|
|
3082
|
+
...options
|
|
3083
|
+
});
|
|
3084
|
+
}
|
|
3085
|
+
};
|
|
3086
|
+
var Apy = class extends HeyApiClient$1 {
|
|
3087
|
+
/**
|
|
3088
|
+
* get_apy_state
|
|
3089
|
+
*
|
|
3090
|
+
* Returns APY (Annual Percentage Yield) information for strategies associated with a specific token mint
|
|
3091
|
+
*/
|
|
3092
|
+
getApyState(options) {
|
|
3093
|
+
return (options.client ?? this.client).get({
|
|
3094
|
+
url: "/apy_state/{token_mint}",
|
|
3095
|
+
...options
|
|
3096
|
+
});
|
|
3097
|
+
}
|
|
3098
|
+
/**
|
|
3099
|
+
* get_apy_by_time_range
|
|
3100
|
+
*
|
|
3101
|
+
* Returns APY information for a specific token mint within a given time range
|
|
3102
|
+
*/
|
|
3103
|
+
getFilterApyByTimeRange(options) {
|
|
3104
|
+
return (options.client ?? this.client).get({
|
|
3105
|
+
url: "/apy_filter/{token_mint}/{start_timestamp}/{end_timestamp}",
|
|
3106
|
+
...options
|
|
3107
|
+
});
|
|
3108
|
+
}
|
|
3109
|
+
};
|
|
3110
|
+
var VirtualPrice = class extends HeyApiClient$1 {
|
|
3111
|
+
/**
|
|
3112
|
+
* get_virtual_price
|
|
3113
|
+
*
|
|
3114
|
+
* Returns virtual price information for a specific strategy within a vault
|
|
3115
|
+
*/
|
|
3116
|
+
getVirtualPrice(options) {
|
|
3117
|
+
return (options.client ?? this.client).get({
|
|
3118
|
+
url: "/virtual_price/{token_mint}/{strategy}",
|
|
3119
|
+
...options
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
};
|
|
3123
|
+
var DynamicVaultApi = class DynamicVaultApi extends HeyApiClient$1 {
|
|
3124
|
+
static __registry = new HeyApiRegistry$1();
|
|
3125
|
+
constructor(args) {
|
|
3126
|
+
super(args);
|
|
3127
|
+
DynamicVaultApi.__registry.set(this, args?.key);
|
|
3128
|
+
}
|
|
3129
|
+
_vaults;
|
|
3130
|
+
get vaults() {
|
|
3131
|
+
return this._vaults ??= new Vaults$1({ client: this.client });
|
|
3132
|
+
}
|
|
3133
|
+
_apy;
|
|
3134
|
+
get apy() {
|
|
3135
|
+
return this._apy ??= new Apy({ client: this.client });
|
|
3136
|
+
}
|
|
3137
|
+
_virtualPrice;
|
|
3138
|
+
get virtualPrice() {
|
|
3139
|
+
return this._virtualPrice ??= new VirtualPrice({ client: this.client });
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
//#endregion
|
|
3143
|
+
//#region generated/stake2earn/core/bodySerializer.gen.ts
|
|
3144
|
+
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
3145
|
+
//#endregion
|
|
3146
|
+
//#region generated/stake2earn/core/serverSentEvents.gen.ts
|
|
3147
|
+
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
3148
|
+
let lastEventId;
|
|
3149
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
3150
|
+
const createStream = async function* () {
|
|
3151
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
3152
|
+
let attempt = 0;
|
|
3153
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
3154
|
+
while (true) {
|
|
3155
|
+
if (signal.aborted) break;
|
|
3156
|
+
attempt++;
|
|
3157
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
3158
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
3159
|
+
try {
|
|
3160
|
+
const requestInit = {
|
|
3161
|
+
redirect: "follow",
|
|
3162
|
+
...options,
|
|
3163
|
+
body: options.serializedBody,
|
|
3164
|
+
headers,
|
|
3165
|
+
signal
|
|
3166
|
+
};
|
|
3167
|
+
let request = new Request(url, requestInit);
|
|
3168
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
3169
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
3170
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
3171
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
3172
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
3173
|
+
let buffer = "";
|
|
3174
|
+
const abortHandler = () => {
|
|
3175
|
+
try {
|
|
3176
|
+
reader.cancel();
|
|
3177
|
+
} catch {}
|
|
3178
|
+
};
|
|
3179
|
+
signal.addEventListener("abort", abortHandler);
|
|
3180
|
+
try {
|
|
3181
|
+
while (true) {
|
|
3182
|
+
const { done, value } = await reader.read();
|
|
3183
|
+
if (done) break;
|
|
3184
|
+
buffer += value;
|
|
3185
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
3186
|
+
const chunks = buffer.split("\n\n");
|
|
3187
|
+
buffer = chunks.pop() ?? "";
|
|
3188
|
+
for (const chunk of chunks) {
|
|
3189
|
+
const lines = chunk.split("\n");
|
|
3190
|
+
const dataLines = [];
|
|
3191
|
+
let eventName;
|
|
3192
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
3193
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
3194
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
3195
|
+
else if (line.startsWith("retry:")) {
|
|
3196
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
3197
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
3198
|
+
}
|
|
3199
|
+
let data;
|
|
3200
|
+
let parsedJson = false;
|
|
3201
|
+
if (dataLines.length) {
|
|
3202
|
+
const rawData = dataLines.join("\n");
|
|
3203
|
+
try {
|
|
3204
|
+
data = JSON.parse(rawData);
|
|
3205
|
+
parsedJson = true;
|
|
3206
|
+
} catch {
|
|
3207
|
+
data = rawData;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
if (parsedJson) {
|
|
3211
|
+
if (responseValidator) await responseValidator(data);
|
|
3212
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
3213
|
+
}
|
|
3214
|
+
onSseEvent?.({
|
|
3215
|
+
data,
|
|
3216
|
+
event: eventName,
|
|
3217
|
+
id: lastEventId,
|
|
3218
|
+
retry: retryDelay
|
|
3219
|
+
});
|
|
3220
|
+
if (dataLines.length) yield data;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
} finally {
|
|
3224
|
+
signal.removeEventListener("abort", abortHandler);
|
|
3225
|
+
reader.releaseLock();
|
|
3226
|
+
}
|
|
3227
|
+
break;
|
|
3228
|
+
} catch (error) {
|
|
3229
|
+
onSseError?.(error);
|
|
3230
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
3231
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
3232
|
+
await sleep(backoff);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
};
|
|
3236
|
+
return { stream: createStream() };
|
|
3237
|
+
}
|
|
3238
|
+
//#endregion
|
|
3239
|
+
//#region generated/stake2earn/core/pathSerializer.gen.ts
|
|
3240
|
+
const separatorArrayExplode = (style) => {
|
|
3241
|
+
switch (style) {
|
|
3242
|
+
case "label": return ".";
|
|
3243
|
+
case "matrix": return ";";
|
|
3244
|
+
case "simple": return ",";
|
|
3245
|
+
default: return "&";
|
|
3246
|
+
}
|
|
3247
|
+
};
|
|
3248
|
+
const separatorArrayNoExplode = (style) => {
|
|
3249
|
+
switch (style) {
|
|
3250
|
+
case "form": return ",";
|
|
3251
|
+
case "pipeDelimited": return "|";
|
|
3252
|
+
case "spaceDelimited": return "%20";
|
|
3253
|
+
default: return ",";
|
|
3254
|
+
}
|
|
3255
|
+
};
|
|
3256
|
+
const separatorObjectExplode = (style) => {
|
|
3257
|
+
switch (style) {
|
|
3258
|
+
case "label": return ".";
|
|
3259
|
+
case "matrix": return ";";
|
|
3260
|
+
case "simple": return ",";
|
|
3261
|
+
default: return "&";
|
|
3262
|
+
}
|
|
3263
|
+
};
|
|
3264
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
3265
|
+
if (!explode) {
|
|
3266
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
3267
|
+
switch (style) {
|
|
3268
|
+
case "label": return `.${joinedValues}`;
|
|
3269
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
3270
|
+
case "simple": return joinedValues;
|
|
3271
|
+
default: return `${name}=${joinedValues}`;
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
const separator = separatorArrayExplode(style);
|
|
3275
|
+
const joinedValues = value.map((v) => {
|
|
3276
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
3277
|
+
return serializePrimitiveParam({
|
|
3278
|
+
allowReserved,
|
|
3279
|
+
name,
|
|
3280
|
+
value: v
|
|
3281
|
+
});
|
|
3282
|
+
}).join(separator);
|
|
3283
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
3284
|
+
};
|
|
3285
|
+
const serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
3286
|
+
if (value === void 0 || value === null) return "";
|
|
3287
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
3288
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
3289
|
+
};
|
|
3290
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
3291
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
3292
|
+
if (style !== "deepObject" && !explode) {
|
|
3293
|
+
let values = [];
|
|
3294
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
3295
|
+
values = [
|
|
3296
|
+
...values,
|
|
3297
|
+
key,
|
|
3298
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
3299
|
+
];
|
|
3300
|
+
});
|
|
3301
|
+
const joinedValues = values.join(",");
|
|
3302
|
+
switch (style) {
|
|
3303
|
+
case "form": return `${name}=${joinedValues}`;
|
|
3304
|
+
case "label": return `.${joinedValues}`;
|
|
3305
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
3306
|
+
default: return joinedValues;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
const separator = separatorObjectExplode(style);
|
|
3310
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
3311
|
+
allowReserved,
|
|
3312
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
3313
|
+
value: v
|
|
3314
|
+
})).join(separator);
|
|
3315
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
3316
|
+
};
|
|
3317
|
+
//#endregion
|
|
3318
|
+
//#region generated/stake2earn/core/utils.gen.ts
|
|
3319
|
+
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
3320
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
3321
|
+
let url = _url;
|
|
3322
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
3323
|
+
if (matches) for (const match of matches) {
|
|
3324
|
+
let explode = false;
|
|
3325
|
+
let name = match.substring(1, match.length - 1);
|
|
3326
|
+
let style = "simple";
|
|
3327
|
+
if (name.endsWith("*")) {
|
|
3328
|
+
explode = true;
|
|
3329
|
+
name = name.substring(0, name.length - 1);
|
|
3330
|
+
}
|
|
3331
|
+
if (name.startsWith(".")) {
|
|
3332
|
+
name = name.substring(1);
|
|
3333
|
+
style = "label";
|
|
3334
|
+
} else if (name.startsWith(";")) {
|
|
3335
|
+
name = name.substring(1);
|
|
3336
|
+
style = "matrix";
|
|
3337
|
+
}
|
|
3338
|
+
const value = path[name];
|
|
3339
|
+
if (value === void 0 || value === null) continue;
|
|
3340
|
+
if (Array.isArray(value)) {
|
|
3341
|
+
url = url.replace(match, serializeArrayParam({
|
|
3342
|
+
explode,
|
|
3343
|
+
name,
|
|
3344
|
+
style,
|
|
3345
|
+
value
|
|
3346
|
+
}));
|
|
3347
|
+
continue;
|
|
3348
|
+
}
|
|
3349
|
+
if (typeof value === "object") {
|
|
3350
|
+
url = url.replace(match, serializeObjectParam({
|
|
3351
|
+
explode,
|
|
3352
|
+
name,
|
|
3353
|
+
style,
|
|
3354
|
+
value,
|
|
3355
|
+
valueOnly: true
|
|
3356
|
+
}));
|
|
3357
|
+
continue;
|
|
3358
|
+
}
|
|
3359
|
+
if (style === "matrix") {
|
|
3360
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
3361
|
+
name,
|
|
3362
|
+
value
|
|
3363
|
+
})}`);
|
|
3364
|
+
continue;
|
|
3365
|
+
}
|
|
3366
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
3367
|
+
url = url.replace(match, replaceValue);
|
|
3368
|
+
}
|
|
3369
|
+
return url;
|
|
3370
|
+
};
|
|
3371
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
3372
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
3373
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
3374
|
+
if (path) url = defaultPathSerializer({
|
|
3375
|
+
path,
|
|
3376
|
+
url
|
|
3377
|
+
});
|
|
3378
|
+
let search = query ? querySerializer(query) : "";
|
|
3379
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
3380
|
+
if (search) url += `?${search}`;
|
|
3381
|
+
return url;
|
|
3382
|
+
};
|
|
3383
|
+
function getValidRequestBody(options) {
|
|
3384
|
+
const hasBody = options.body !== void 0;
|
|
3385
|
+
if (hasBody && options.bodySerializer) {
|
|
3386
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
3387
|
+
return options.body !== "" ? options.body : null;
|
|
3388
|
+
}
|
|
3389
|
+
if (hasBody) return options.body;
|
|
3390
|
+
}
|
|
3391
|
+
//#endregion
|
|
3392
|
+
//#region generated/stake2earn/core/auth.gen.ts
|
|
3393
|
+
const getAuthToken = async (auth, callback) => {
|
|
3394
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
3395
|
+
if (!token) return;
|
|
3396
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
3397
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
3398
|
+
return token;
|
|
3399
|
+
};
|
|
3400
|
+
//#endregion
|
|
3401
|
+
//#region generated/stake2earn/client/utils.gen.ts
|
|
3402
|
+
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
3403
|
+
const querySerializer = (queryParams) => {
|
|
3404
|
+
const search = [];
|
|
3405
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
3406
|
+
const value = queryParams[name];
|
|
3407
|
+
if (value === void 0 || value === null) continue;
|
|
3408
|
+
const options = parameters[name] || args;
|
|
3409
|
+
if (Array.isArray(value)) {
|
|
3410
|
+
const serializedArray = serializeArrayParam({
|
|
3411
|
+
allowReserved: options.allowReserved,
|
|
3412
|
+
explode: true,
|
|
3413
|
+
name,
|
|
3414
|
+
style: "form",
|
|
3415
|
+
value,
|
|
3416
|
+
...options.array
|
|
3417
|
+
});
|
|
3418
|
+
if (serializedArray) search.push(serializedArray);
|
|
3419
|
+
} else if (typeof value === "object") {
|
|
3420
|
+
const serializedObject = serializeObjectParam({
|
|
3421
|
+
allowReserved: options.allowReserved,
|
|
3422
|
+
explode: true,
|
|
3423
|
+
name,
|
|
3424
|
+
style: "deepObject",
|
|
3425
|
+
value,
|
|
3426
|
+
...options.object
|
|
3427
|
+
});
|
|
3428
|
+
if (serializedObject) search.push(serializedObject);
|
|
3429
|
+
} else {
|
|
3430
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
3431
|
+
allowReserved: options.allowReserved,
|
|
3432
|
+
name,
|
|
3433
|
+
value
|
|
3434
|
+
});
|
|
3435
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
return search.join("&");
|
|
3439
|
+
};
|
|
3440
|
+
return querySerializer;
|
|
3441
|
+
};
|
|
3442
|
+
/**
|
|
3443
|
+
* Infers parseAs value from provided Content-Type header.
|
|
3444
|
+
*/
|
|
3445
|
+
const getParseAs = (contentType) => {
|
|
3446
|
+
if (!contentType) return "stream";
|
|
3447
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
3448
|
+
if (!cleanContent) return;
|
|
3449
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
3450
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
3451
|
+
if ([
|
|
3452
|
+
"application/",
|
|
3453
|
+
"audio/",
|
|
3454
|
+
"image/",
|
|
3455
|
+
"video/"
|
|
3456
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
3457
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
3458
|
+
};
|
|
3459
|
+
const checkForExistence = (options, name) => {
|
|
3460
|
+
if (!name) return false;
|
|
3461
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
3462
|
+
return false;
|
|
3463
|
+
};
|
|
3464
|
+
async function setAuthParams(options) {
|
|
3465
|
+
for (const auth of options.security ?? []) {
|
|
3466
|
+
if (checkForExistence(options, auth.name)) continue;
|
|
3467
|
+
const token = await getAuthToken(auth, options.auth);
|
|
3468
|
+
if (!token) continue;
|
|
3469
|
+
const name = auth.name ?? "Authorization";
|
|
3470
|
+
switch (auth.in) {
|
|
3471
|
+
case "query":
|
|
3472
|
+
if (!options.query) options.query = {};
|
|
3473
|
+
options.query[name] = token;
|
|
3474
|
+
break;
|
|
3475
|
+
case "cookie":
|
|
3476
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
3477
|
+
break;
|
|
3478
|
+
default: options.headers.set(name, token);
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
const buildUrl = (options) => getUrl({
|
|
3483
|
+
baseUrl: options.baseUrl,
|
|
3484
|
+
path: options.path,
|
|
3485
|
+
query: options.query,
|
|
3486
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
3487
|
+
url: options.url
|
|
3488
|
+
});
|
|
3489
|
+
const mergeConfigs = (a, b) => {
|
|
3490
|
+
const config = {
|
|
3491
|
+
...a,
|
|
3492
|
+
...b
|
|
3493
|
+
};
|
|
3494
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
3495
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
3496
|
+
return config;
|
|
3497
|
+
};
|
|
3498
|
+
const headersEntries = (headers) => {
|
|
3499
|
+
const entries = [];
|
|
3500
|
+
headers.forEach((value, key) => {
|
|
3501
|
+
entries.push([key, value]);
|
|
3502
|
+
});
|
|
3503
|
+
return entries;
|
|
3504
|
+
};
|
|
3505
|
+
const mergeHeaders = (...headers) => {
|
|
3506
|
+
const mergedHeaders = new Headers();
|
|
3507
|
+
for (const header of headers) {
|
|
3508
|
+
if (!header) continue;
|
|
3509
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
3510
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
3511
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
3512
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
3513
|
+
}
|
|
3514
|
+
return mergedHeaders;
|
|
3515
|
+
};
|
|
3516
|
+
var Interceptors = class {
|
|
3517
|
+
fns = [];
|
|
3518
|
+
clear() {
|
|
3519
|
+
this.fns = [];
|
|
3520
|
+
}
|
|
3521
|
+
eject(id) {
|
|
3522
|
+
const index = this.getInterceptorIndex(id);
|
|
3523
|
+
if (this.fns[index]) this.fns[index] = null;
|
|
3524
|
+
}
|
|
3525
|
+
exists(id) {
|
|
3526
|
+
const index = this.getInterceptorIndex(id);
|
|
3527
|
+
return Boolean(this.fns[index]);
|
|
3528
|
+
}
|
|
3529
|
+
getInterceptorIndex(id) {
|
|
3530
|
+
if (typeof id === "number") return this.fns[id] ? id : -1;
|
|
3531
|
+
return this.fns.indexOf(id);
|
|
3532
|
+
}
|
|
3533
|
+
update(id, fn) {
|
|
3534
|
+
const index = this.getInterceptorIndex(id);
|
|
3535
|
+
if (this.fns[index]) {
|
|
3536
|
+
this.fns[index] = fn;
|
|
3537
|
+
return id;
|
|
3538
|
+
}
|
|
3539
|
+
return false;
|
|
3540
|
+
}
|
|
3541
|
+
use(fn) {
|
|
3542
|
+
this.fns.push(fn);
|
|
3543
|
+
return this.fns.length - 1;
|
|
3544
|
+
}
|
|
3545
|
+
};
|
|
3546
|
+
const createInterceptors = () => ({
|
|
3547
|
+
error: new Interceptors(),
|
|
3548
|
+
request: new Interceptors(),
|
|
3549
|
+
response: new Interceptors()
|
|
3550
|
+
});
|
|
3551
|
+
const defaultQuerySerializer = createQuerySerializer({
|
|
3552
|
+
allowReserved: false,
|
|
3553
|
+
array: {
|
|
3554
|
+
explode: true,
|
|
3555
|
+
style: "form"
|
|
3556
|
+
},
|
|
3557
|
+
object: {
|
|
3558
|
+
explode: true,
|
|
3559
|
+
style: "deepObject"
|
|
3560
|
+
}
|
|
3561
|
+
});
|
|
3562
|
+
const defaultHeaders = { "Content-Type": "application/json" };
|
|
3563
|
+
const createConfig = (override = {}) => ({
|
|
3564
|
+
...jsonBodySerializer,
|
|
3565
|
+
headers: defaultHeaders,
|
|
3566
|
+
parseAs: "auto",
|
|
3567
|
+
querySerializer: defaultQuerySerializer,
|
|
3568
|
+
...override
|
|
3569
|
+
});
|
|
3570
|
+
//#endregion
|
|
3571
|
+
//#region generated/stake2earn/client/client.gen.ts
|
|
3572
|
+
const createClient$4 = (config = {}) => {
|
|
3573
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
3574
|
+
const getConfig = () => ({ ..._config });
|
|
3575
|
+
const setConfig = (config) => {
|
|
3576
|
+
_config = mergeConfigs(_config, config);
|
|
3577
|
+
return getConfig();
|
|
3578
|
+
};
|
|
3579
|
+
const interceptors = createInterceptors();
|
|
3580
|
+
const beforeRequest = async (options) => {
|
|
3581
|
+
const opts = {
|
|
3582
|
+
..._config,
|
|
3583
|
+
...options,
|
|
3584
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
3585
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
3586
|
+
serializedBody: void 0
|
|
3587
|
+
};
|
|
3588
|
+
if (opts.security) await setAuthParams(opts);
|
|
3589
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
3590
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
3591
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
3592
|
+
const resolvedOpts = opts;
|
|
3593
|
+
return {
|
|
3594
|
+
opts: resolvedOpts,
|
|
3595
|
+
url: buildUrl(resolvedOpts)
|
|
3596
|
+
};
|
|
3597
|
+
};
|
|
3598
|
+
const request = async (options) => {
|
|
3599
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
3600
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
3601
|
+
let request;
|
|
3602
|
+
let response;
|
|
3603
|
+
try {
|
|
3604
|
+
const { opts, url } = await beforeRequest(options);
|
|
3605
|
+
const requestInit = {
|
|
3606
|
+
redirect: "follow",
|
|
3607
|
+
...opts,
|
|
3608
|
+
body: getValidRequestBody(opts)
|
|
3609
|
+
};
|
|
3610
|
+
request = new Request(url, requestInit);
|
|
3611
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
3612
|
+
const _fetch = opts.fetch;
|
|
3613
|
+
response = await _fetch(request);
|
|
3614
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
3615
|
+
const result = {
|
|
3616
|
+
request,
|
|
3617
|
+
response
|
|
3618
|
+
};
|
|
3619
|
+
if (response.ok) {
|
|
3620
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
3621
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
3622
|
+
let emptyData;
|
|
3623
|
+
switch (parseAs) {
|
|
3624
|
+
case "arrayBuffer":
|
|
3625
|
+
case "blob":
|
|
3626
|
+
case "text":
|
|
3627
|
+
emptyData = await response[parseAs]();
|
|
3628
|
+
break;
|
|
3629
|
+
case "formData":
|
|
3630
|
+
emptyData = new FormData();
|
|
3631
|
+
break;
|
|
3632
|
+
case "stream":
|
|
3633
|
+
emptyData = response.body;
|
|
3634
|
+
break;
|
|
3635
|
+
default: emptyData = {};
|
|
3636
|
+
}
|
|
3637
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
3638
|
+
data: emptyData,
|
|
3639
|
+
...result
|
|
3640
|
+
};
|
|
3641
|
+
}
|
|
3642
|
+
let data;
|
|
3643
|
+
switch (parseAs) {
|
|
3644
|
+
case "arrayBuffer":
|
|
3645
|
+
case "blob":
|
|
3646
|
+
case "formData":
|
|
3647
|
+
case "text":
|
|
3648
|
+
data = await response[parseAs]();
|
|
3649
|
+
break;
|
|
3650
|
+
case "json": {
|
|
3651
|
+
const text = await response.text();
|
|
3652
|
+
data = text ? JSON.parse(text) : {};
|
|
3653
|
+
break;
|
|
3654
|
+
}
|
|
3655
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
3656
|
+
data: response.body,
|
|
3657
|
+
...result
|
|
3658
|
+
};
|
|
3659
|
+
}
|
|
3660
|
+
if (parseAs === "json") {
|
|
3661
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
3662
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
3663
|
+
}
|
|
3664
|
+
return opts.responseStyle === "data" ? data : {
|
|
3665
|
+
data,
|
|
3666
|
+
...result
|
|
3667
|
+
};
|
|
3668
|
+
}
|
|
3669
|
+
const textError = await response.text();
|
|
3670
|
+
let jsonError;
|
|
3671
|
+
try {
|
|
3672
|
+
jsonError = JSON.parse(textError);
|
|
3673
|
+
} catch {}
|
|
3674
|
+
throw jsonError ?? textError;
|
|
3675
|
+
} catch (error) {
|
|
3676
|
+
let finalError = error;
|
|
3677
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
3678
|
+
finalError = finalError || {};
|
|
3679
|
+
if (throwOnError) throw finalError;
|
|
3680
|
+
return responseStyle === "data" ? void 0 : {
|
|
3681
|
+
error: finalError,
|
|
3682
|
+
request,
|
|
3683
|
+
response
|
|
3684
|
+
};
|
|
3685
|
+
}
|
|
3686
|
+
};
|
|
3687
|
+
const makeMethodFn = (method) => (options) => request({
|
|
3688
|
+
...options,
|
|
3689
|
+
method
|
|
3690
|
+
});
|
|
3691
|
+
const makeSseFn = (method) => async (options) => {
|
|
3692
|
+
const { opts, url } = await beforeRequest(options);
|
|
3693
|
+
return createSseClient({
|
|
3694
|
+
...opts,
|
|
3695
|
+
body: opts.body,
|
|
3696
|
+
method,
|
|
3697
|
+
onRequest: async (url, init) => {
|
|
3698
|
+
let request = new Request(url, init);
|
|
3699
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
3700
|
+
return request;
|
|
3701
|
+
},
|
|
3702
|
+
serializedBody: getValidRequestBody(opts),
|
|
3703
|
+
url
|
|
3704
|
+
});
|
|
3705
|
+
};
|
|
3706
|
+
const _buildUrl = (options) => buildUrl({
|
|
3707
|
+
..._config,
|
|
3708
|
+
...options
|
|
3709
|
+
});
|
|
3710
|
+
return {
|
|
3711
|
+
buildUrl: _buildUrl,
|
|
3712
|
+
connect: makeMethodFn("CONNECT"),
|
|
3713
|
+
delete: makeMethodFn("DELETE"),
|
|
3714
|
+
get: makeMethodFn("GET"),
|
|
3715
|
+
getConfig,
|
|
3716
|
+
head: makeMethodFn("HEAD"),
|
|
3717
|
+
interceptors,
|
|
3718
|
+
options: makeMethodFn("OPTIONS"),
|
|
3719
|
+
patch: makeMethodFn("PATCH"),
|
|
3720
|
+
post: makeMethodFn("POST"),
|
|
3721
|
+
put: makeMethodFn("PUT"),
|
|
3722
|
+
request,
|
|
3723
|
+
setConfig,
|
|
3724
|
+
sse: {
|
|
3725
|
+
connect: makeSseFn("CONNECT"),
|
|
3726
|
+
delete: makeSseFn("DELETE"),
|
|
3727
|
+
get: makeSseFn("GET"),
|
|
3728
|
+
head: makeSseFn("HEAD"),
|
|
3729
|
+
options: makeSseFn("OPTIONS"),
|
|
3730
|
+
patch: makeSseFn("PATCH"),
|
|
3731
|
+
post: makeSseFn("POST"),
|
|
3732
|
+
put: makeSseFn("PUT"),
|
|
3733
|
+
trace: makeSseFn("TRACE")
|
|
3734
|
+
},
|
|
3735
|
+
trace: makeMethodFn("TRACE")
|
|
3736
|
+
};
|
|
3737
|
+
};
|
|
3738
|
+
//#endregion
|
|
3739
|
+
//#region generated/stake2earn/client.gen.ts
|
|
3740
|
+
const client = createClient$4(createConfig({ baseUrl: "https://stake-for-fee-api.meteora.ag" }));
|
|
3741
|
+
//#endregion
|
|
3742
|
+
//#region generated/stake2earn/sdk.gen.ts
|
|
3743
|
+
var HeyApiClient = class {
|
|
3744
|
+
client;
|
|
3745
|
+
constructor(args) {
|
|
3746
|
+
this.client = args?.client ?? client;
|
|
3747
|
+
}
|
|
3748
|
+
};
|
|
3749
|
+
var HeyApiRegistry = class {
|
|
3750
|
+
defaultKey = "default";
|
|
3751
|
+
instances = /* @__PURE__ */ new Map();
|
|
3752
|
+
get(key) {
|
|
3753
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
3754
|
+
if (!instance) throw new Error(`No SDK client found. Create one with "new Stake2EarnApi()" to fix this error.`);
|
|
3755
|
+
return instance;
|
|
3756
|
+
}
|
|
3757
|
+
set(value, key) {
|
|
3758
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
3759
|
+
}
|
|
3760
|
+
};
|
|
3761
|
+
var Analytics = class extends HeyApiClient {
|
|
3762
|
+
getAllAnalytics(options) {
|
|
3763
|
+
return (options?.client ?? this.client).get({
|
|
3764
|
+
url: "/analytics/all",
|
|
3765
|
+
...options
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
};
|
|
3769
|
+
var Vaults = class extends HeyApiClient {
|
|
3770
|
+
getAllVaults(options) {
|
|
3771
|
+
return (options?.client ?? this.client).get({
|
|
3772
|
+
url: "/vault/all",
|
|
3773
|
+
...options
|
|
3774
|
+
});
|
|
3775
|
+
}
|
|
3776
|
+
filterVaults(options) {
|
|
3777
|
+
return (options?.client ?? this.client).get({
|
|
3778
|
+
url: "/vault/filter",
|
|
3779
|
+
...options
|
|
3780
|
+
});
|
|
3781
|
+
}
|
|
3782
|
+
getOneVault(options) {
|
|
3783
|
+
return (options.client ?? this.client).get({
|
|
3784
|
+
url: "/vault/{vault_address}",
|
|
3785
|
+
...options
|
|
3786
|
+
});
|
|
3787
|
+
}
|
|
3788
|
+
};
|
|
3789
|
+
var Stake2EarnApi = class Stake2EarnApi extends HeyApiClient {
|
|
3790
|
+
static __registry = new HeyApiRegistry();
|
|
3791
|
+
constructor(args) {
|
|
3792
|
+
super(args);
|
|
3793
|
+
Stake2EarnApi.__registry.set(this, args?.key);
|
|
3794
|
+
}
|
|
3795
|
+
_analytics;
|
|
3796
|
+
get analytics() {
|
|
3797
|
+
return this._analytics ??= new Analytics({ client: this.client });
|
|
3798
|
+
}
|
|
3799
|
+
_vaults;
|
|
3800
|
+
get vaults() {
|
|
3801
|
+
return this._vaults ??= new Vaults({ client: this.client });
|
|
3802
|
+
}
|
|
3803
|
+
};
|
|
3804
|
+
//#endregion
|
|
3805
|
+
export { DammV1Api, DammV2Api, DlmmApi, DynamicVaultApi, Stake2EarnApi, createClient as createDammV1ApiClient, createClient$1 as createDammV2ApiClient, createClient$2 as createDlmmApiClient, createClient$3 as createDynamicVaultApiClient, createClient$4 as createStake2EarnApiClient };
|
|
3806
|
+
|
|
3807
|
+
//# sourceMappingURL=index.mjs.map
|