@crypticdot/defituna-api 1.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,529 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ NotificationAction: () => NotificationAction,
33
+ NotificationEntity: () => NotificationEntity,
34
+ PoolProvider: () => PoolProvider,
35
+ ProviderFilter: () => ProviderFilter,
36
+ TunaApiClient: () => TunaApiClient,
37
+ TunaPositionState: () => TunaPositionState,
38
+ schemas: () => schemas_exports
39
+ });
40
+ module.exports = __toCommonJS(index_exports);
41
+
42
+ // src/client/client.ts
43
+ var import_camelcase_keys = __toESM(require("camelcase-keys"));
44
+
45
+ // src/client/schemas.ts
46
+ var schemas_exports = {};
47
+ __export(schemas_exports, {
48
+ LendingPosition: () => LendingPosition,
49
+ LimitOrder: () => LimitOrder,
50
+ LimitOrderState: () => LimitOrderState,
51
+ LimitOrderStateSchema: () => LimitOrderStateSchema,
52
+ Market: () => Market,
53
+ Mint: () => Mint,
54
+ NotificationAction: () => NotificationAction,
55
+ NotificationActionSchema: () => NotificationActionSchema,
56
+ NotificationEntity: () => NotificationEntity,
57
+ NotificationEntitySchema: () => NotificationEntitySchema,
58
+ OrderBook: () => OrderBook,
59
+ OrderBookEntry: () => OrderBookEntry,
60
+ OrderBookNotification: () => OrderBookNotification,
61
+ OrderBookNotificationMeta: () => OrderBookNotificationMeta,
62
+ Pool: () => Pool,
63
+ PoolPriceCandle: () => PoolPriceCandle,
64
+ PoolPriceUpdate: () => PoolPriceUpdate,
65
+ PoolPriceUpdateNotification: () => PoolPriceUpdateNotification,
66
+ PoolProvider: () => PoolProvider,
67
+ PoolProviderSchema: () => PoolProviderSchema,
68
+ PoolSwap: () => PoolSwap,
69
+ PoolSwapNotification: () => PoolSwapNotification,
70
+ PoolTicks: () => PoolTicks,
71
+ Tick: () => Tick,
72
+ TokenOraclePrice: () => TokenOraclePrice,
73
+ TunaPosition: () => TunaPosition,
74
+ TunaPositionState: () => TunaPositionState,
75
+ TunaPositionStateSchema: () => TunaPositionStateSchema,
76
+ Vault: () => Vault
77
+ });
78
+ var import_zod = require("zod");
79
+ var amountWithoutUsd = import_zod.z.object({
80
+ amount: import_zod.z.coerce.bigint()
81
+ });
82
+ var amountWithUsd = import_zod.z.object({
83
+ amount: import_zod.z.coerce.bigint(),
84
+ usd: import_zod.z.number()
85
+ });
86
+ var tokensPnl = import_zod.z.object({
87
+ amount: import_zod.z.coerce.bigint(),
88
+ bps: import_zod.z.number()
89
+ });
90
+ var usdPnl = import_zod.z.object({
91
+ amount: import_zod.z.number(),
92
+ bps: import_zod.z.number()
93
+ });
94
+ var NotificationEntity = {
95
+ POOL_SWAP: "pool_swap",
96
+ POOL_PRICE: "pool_price",
97
+ ORDER_BOOK: "order_book"
98
+ };
99
+ var NotificationAction = {
100
+ CREATE: "create",
101
+ UPDATE: "update"
102
+ };
103
+ var PoolProvider = {
104
+ ORCA: "orca",
105
+ FUSION: "fusion"
106
+ };
107
+ var TunaPositionState = {
108
+ OPEN: "open",
109
+ LIQUIDATED: "liquidated",
110
+ CLOSED_BY_LIMIT_ORDER: "closed_by_limit_order",
111
+ CLOSED: "closed"
112
+ };
113
+ var LimitOrderState = {
114
+ OPEN: "open",
115
+ PARTIALLY_FILLED: "partially_filled",
116
+ FILLED: "filled",
117
+ COMPLETE: "complete",
118
+ CANCELLED: "cancelled"
119
+ };
120
+ var NotificationEntitySchema = import_zod.z.enum([NotificationEntity.POOL_SWAP, ...Object.values(NotificationEntity)]);
121
+ var NotificationActionSchema = import_zod.z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
122
+ var PoolProviderSchema = import_zod.z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
123
+ var TunaPositionStateSchema = import_zod.z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
124
+ var LimitOrderStateSchema = import_zod.z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
125
+ var Mint = import_zod.z.object({
126
+ symbol: import_zod.z.string(),
127
+ mint: import_zod.z.string(),
128
+ logo: import_zod.z.string(),
129
+ decimals: import_zod.z.number()
130
+ });
131
+ var Market = import_zod.z.object({
132
+ address: import_zod.z.string(),
133
+ addressLookupTable: import_zod.z.string(),
134
+ poolAddress: import_zod.z.string(),
135
+ poolFeeRate: import_zod.z.number(),
136
+ provider: PoolProviderSchema,
137
+ maxLeverage: import_zod.z.number(),
138
+ protocolFee: import_zod.z.number(),
139
+ protocolFeeOnCollateral: import_zod.z.number(),
140
+ liquidationFee: import_zod.z.number(),
141
+ liquidationThreshold: import_zod.z.number(),
142
+ limitOrderExecutionFee: import_zod.z.number(),
143
+ borrowedFundsA: amountWithUsd,
144
+ borrowedFundsB: amountWithUsd,
145
+ availableBorrowA: amountWithUsd,
146
+ availableBorrowB: amountWithUsd,
147
+ borrowLimitA: amountWithUsd,
148
+ borrowLimitB: amountWithUsd,
149
+ disabled: import_zod.z.boolean()
150
+ });
151
+ var TokenOraclePrice = import_zod.z.object({
152
+ mint: import_zod.z.string(),
153
+ price: import_zod.z.coerce.bigint(),
154
+ decimals: import_zod.z.number(),
155
+ time: import_zod.z.coerce.date()
156
+ });
157
+ var Vault = import_zod.z.object({
158
+ address: import_zod.z.string(),
159
+ mint: import_zod.z.string(),
160
+ depositedFunds: amountWithUsd,
161
+ borrowedFunds: amountWithUsd,
162
+ supplyLimit: amountWithUsd,
163
+ borrowedShares: import_zod.z.coerce.bigint(),
164
+ depositedShares: import_zod.z.coerce.bigint(),
165
+ supplyApy: import_zod.z.number(),
166
+ borrowApy: import_zod.z.number(),
167
+ utilization: import_zod.z.number(),
168
+ pythOracleFeedId: import_zod.z.string(),
169
+ pythOraclePriceUpdate: import_zod.z.string()
170
+ });
171
+ var Pool = import_zod.z.object({
172
+ address: import_zod.z.string(),
173
+ provider: PoolProviderSchema,
174
+ tokenAMint: import_zod.z.string(),
175
+ tokenBMint: import_zod.z.string(),
176
+ tokenAVault: import_zod.z.string(),
177
+ tokenBVault: import_zod.z.string(),
178
+ tvlUsdc: import_zod.z.coerce.number(),
179
+ tickSpacing: import_zod.z.number(),
180
+ feeRate: import_zod.z.number(),
181
+ protocolFeeRate: import_zod.z.number(),
182
+ liquidity: import_zod.z.coerce.bigint(),
183
+ sqrtPrice: import_zod.z.coerce.bigint(),
184
+ tickCurrentIndex: import_zod.z.number(),
185
+ stats: import_zod.z.object({
186
+ "24h": import_zod.z.object({
187
+ volume: import_zod.z.coerce.number(),
188
+ fees: import_zod.z.coerce.number(),
189
+ rewards: import_zod.z.coerce.number(),
190
+ yieldOverTvl: import_zod.z.coerce.number()
191
+ }),
192
+ "7d": import_zod.z.object({
193
+ volume: import_zod.z.coerce.number(),
194
+ fees: import_zod.z.coerce.number(),
195
+ rewards: import_zod.z.coerce.number(),
196
+ yieldOverTvl: import_zod.z.coerce.number()
197
+ }),
198
+ "30d": import_zod.z.object({
199
+ volume: import_zod.z.coerce.number(),
200
+ fees: import_zod.z.coerce.number(),
201
+ rewards: import_zod.z.coerce.number(),
202
+ yieldOverTvl: import_zod.z.coerce.number()
203
+ })
204
+ })
205
+ });
206
+ var Tick = import_zod.z.object({
207
+ index: import_zod.z.number(),
208
+ liquidity: import_zod.z.coerce.bigint()
209
+ });
210
+ var PoolTicks = import_zod.z.object({
211
+ tickSpacing: import_zod.z.number(),
212
+ ticks: Tick.array()
213
+ });
214
+ var LendingPosition = import_zod.z.object({
215
+ address: import_zod.z.string(),
216
+ authority: import_zod.z.string(),
217
+ mint: import_zod.z.string(),
218
+ vault: import_zod.z.string(),
219
+ shares: import_zod.z.coerce.bigint(),
220
+ funds: amountWithUsd,
221
+ earned: amountWithUsd
222
+ });
223
+ var TunaPosition = import_zod.z.object({
224
+ address: import_zod.z.string(),
225
+ authority: import_zod.z.string(),
226
+ version: import_zod.z.number(),
227
+ state: TunaPositionStateSchema,
228
+ positionMint: import_zod.z.string(),
229
+ liquidity: import_zod.z.coerce.bigint(),
230
+ tickLowerIndex: import_zod.z.number(),
231
+ tickUpperIndex: import_zod.z.number(),
232
+ tickEntryIndex: import_zod.z.number(),
233
+ tickStopLossIndex: import_zod.z.number(),
234
+ tickTakeProfitIndex: import_zod.z.number(),
235
+ swapToTokenOnLimitOrder: import_zod.z.number(),
236
+ flags: import_zod.z.number(),
237
+ pool: import_zod.z.string(),
238
+ poolSqrtPrice: import_zod.z.coerce.bigint(),
239
+ depositedCollateralA: amountWithoutUsd,
240
+ depositedCollateralB: amountWithoutUsd,
241
+ depositedCollateralUsd: import_zod.z.object({
242
+ amount: import_zod.z.number()
243
+ }),
244
+ loanFundsA: amountWithUsd,
245
+ loanFundsB: amountWithUsd,
246
+ currentLoanA: amountWithUsd,
247
+ currentLoanB: amountWithUsd,
248
+ leftoversA: amountWithUsd,
249
+ leftoversB: amountWithUsd,
250
+ yieldA: amountWithUsd,
251
+ yieldB: amountWithUsd,
252
+ compoundedYieldA: amountWithUsd,
253
+ compoundedYieldB: amountWithUsd,
254
+ totalA: amountWithUsd,
255
+ totalB: amountWithUsd,
256
+ pnlA: tokensPnl,
257
+ pnlB: tokensPnl,
258
+ pnlUsd: usdPnl,
259
+ openedAt: import_zod.z.coerce.date(),
260
+ updatedAtSlot: import_zod.z.coerce.bigint()
261
+ });
262
+ var PoolSwap = import_zod.z.object({
263
+ id: import_zod.z.string(),
264
+ amountIn: import_zod.z.coerce.bigint(),
265
+ amountOut: import_zod.z.coerce.bigint(),
266
+ aToB: import_zod.z.boolean(),
267
+ pool: import_zod.z.string(),
268
+ time: import_zod.z.coerce.date()
269
+ });
270
+ var OrderBookEntry = import_zod.z.object({
271
+ concentratedAmount: import_zod.z.coerce.bigint(),
272
+ concentratedAmountQuote: import_zod.z.coerce.bigint(),
273
+ concentratedTotal: import_zod.z.coerce.bigint(),
274
+ concentratedTotalQuote: import_zod.z.coerce.bigint(),
275
+ limitAmount: import_zod.z.coerce.bigint(),
276
+ limitAmountQuote: import_zod.z.coerce.bigint(),
277
+ limitTotal: import_zod.z.coerce.bigint(),
278
+ limitTotalQuote: import_zod.z.coerce.bigint(),
279
+ price: import_zod.z.number(),
280
+ askSide: import_zod.z.boolean()
281
+ });
282
+ var PoolPriceUpdate = import_zod.z.object({
283
+ pool: import_zod.z.string(),
284
+ price: import_zod.z.number(),
285
+ sqrtPrice: import_zod.z.coerce.bigint(),
286
+ time: import_zod.z.coerce.date()
287
+ });
288
+ var OrderBook = import_zod.z.object({
289
+ entries: OrderBookEntry.array(),
290
+ poolPrice: import_zod.z.number()
291
+ });
292
+ var LimitOrder = import_zod.z.object({
293
+ address: import_zod.z.string(),
294
+ mint: import_zod.z.string(),
295
+ pool: import_zod.z.string(),
296
+ state: LimitOrderStateSchema,
297
+ aToB: import_zod.z.boolean(),
298
+ tickIndex: import_zod.z.number(),
299
+ fillRatio: import_zod.z.number(),
300
+ openTxSignature: import_zod.z.string(),
301
+ closeTxSignature: import_zod.z.string().nullable(),
302
+ amount: amountWithUsd,
303
+ openedAt: import_zod.z.coerce.date(),
304
+ closedAt: import_zod.z.coerce.date().nullable()
305
+ });
306
+ var PoolPriceCandle = import_zod.z.object({
307
+ time: import_zod.z.number(),
308
+ open: import_zod.z.number(),
309
+ close: import_zod.z.number(),
310
+ high: import_zod.z.number(),
311
+ low: import_zod.z.number()
312
+ });
313
+ var createNotificationSchema = (dataSchema, metaSchema) => import_zod.z.object({
314
+ entity: NotificationEntitySchema,
315
+ action: NotificationActionSchema,
316
+ data: dataSchema,
317
+ id: import_zod.z.string(),
318
+ authority: import_zod.z.nullable(import_zod.z.string()),
319
+ ...metaSchema ? { meta: metaSchema } : { meta: import_zod.z.undefined().nullable() }
320
+ });
321
+ var OrderBookNotificationMeta = import_zod.z.object({
322
+ pool: import_zod.z.string(),
323
+ priceStep: import_zod.z.number(),
324
+ inverted: import_zod.z.boolean()
325
+ });
326
+ var PoolSwapNotification = createNotificationSchema(PoolSwap);
327
+ var PoolPriceUpdateNotification = createNotificationSchema(PoolPriceUpdate);
328
+ var OrderBookNotification = createNotificationSchema(OrderBook, OrderBookNotificationMeta);
329
+
330
+ // src/client/client.ts
331
+ var DEFAULT_TIMEOUT = 5e3;
332
+ var DEFAULT_HTTP_RETRIES = 3;
333
+ var ProviderFilter = /* @__PURE__ */ ((ProviderFilter2) => {
334
+ ProviderFilter2["ORCA"] = "orca";
335
+ ProviderFilter2["FUSION"] = "fusion";
336
+ ProviderFilter2["ALL"] = "all";
337
+ return ProviderFilter2;
338
+ })(ProviderFilter || {});
339
+ var TunaApiClient = class {
340
+ get baseURL() {
341
+ return this._baseURL;
342
+ }
343
+ get timeout() {
344
+ return this._timeout;
345
+ }
346
+ get httpRetries() {
347
+ return this._httpRetries;
348
+ }
349
+ get headers() {
350
+ return this._headers;
351
+ }
352
+ constructor(baseURL, config) {
353
+ this._baseURL = baseURL;
354
+ this._timeout = config?.timeout ?? DEFAULT_TIMEOUT;
355
+ this._httpRetries = config?.httpRetries ?? DEFAULT_HTTP_RETRIES;
356
+ this._headers = config?.headers ?? {};
357
+ }
358
+ setConfig(config) {
359
+ if (config.baseURL) {
360
+ this._baseURL = config.baseURL;
361
+ }
362
+ this._timeout = config?.timeout ?? DEFAULT_TIMEOUT;
363
+ this._httpRetries = config?.httpRetries ?? DEFAULT_HTTP_RETRIES;
364
+ this._headers = config?.headers ?? {};
365
+ }
366
+ async httpRequest(url, schema, options, retries = this.httpRetries, backoff = 100 + Math.floor(Math.random() * 100)) {
367
+ try {
368
+ const controller = new AbortController();
369
+ const abort = setTimeout(() => {
370
+ controller.abort();
371
+ }, this.timeout);
372
+ const signal = options?.signal || controller.signal;
373
+ const response = await fetch(url, {
374
+ ...options,
375
+ signal,
376
+ headers: { ...this.headers, ...options?.headers }
377
+ });
378
+ clearTimeout(abort);
379
+ if (!response.ok) {
380
+ const errorBody = await response.json();
381
+ throw errorBody;
382
+ }
383
+ const data = await response.json();
384
+ const transformed = (0, import_camelcase_keys.default)(data, { deep: true, exclude: ["24h", "7d", "30d"] });
385
+ return schema.parse(transformed.data);
386
+ } catch (error) {
387
+ if (retries > 0 && !(error instanceof Error && error.name === "AbortError")) {
388
+ await new Promise((resolve) => setTimeout(resolve, backoff));
389
+ return this.httpRequest(url, schema, options, retries - 1, backoff * 2);
390
+ }
391
+ throw error;
392
+ }
393
+ }
394
+ /* Endpoints */
395
+ async getMints() {
396
+ const url = this.buildURL("mints");
397
+ return await this.httpRequest(url.toString(), Mint.array());
398
+ }
399
+ async getMint(mintAddress) {
400
+ const url = this.buildURL(`mints/${mintAddress}`);
401
+ return await this.httpRequest(url.toString(), Mint);
402
+ }
403
+ async getMarkets() {
404
+ const url = this.buildURL("markets");
405
+ return await this.httpRequest(url.toString(), Market.array());
406
+ }
407
+ async getMarket(marketAddress) {
408
+ const url = this.buildURL(`markets/${marketAddress}`);
409
+ return await this.httpRequest(url.toString(), Market);
410
+ }
411
+ async getOraclePrices() {
412
+ const url = this.buildURL("oracle-prices");
413
+ return await this.httpRequest(url.toString(), TokenOraclePrice.array());
414
+ }
415
+ async getOraclePrice(mintAddress) {
416
+ const url = this.buildURL(`oracle-prices/${mintAddress}`);
417
+ return await this.httpRequest(url.toString(), TokenOraclePrice);
418
+ }
419
+ async getVaults() {
420
+ const url = this.buildURL("vaults");
421
+ return await this.httpRequest(url.toString(), Vault.array());
422
+ }
423
+ async getVault(vaultAddress) {
424
+ const url = this.buildURL(`vaults/${vaultAddress}`);
425
+ return await this.httpRequest(url.toString(), Vault);
426
+ }
427
+ async getPools(providerFilter) {
428
+ const url = this.buildURL("pools");
429
+ if (providerFilter && providerFilter !== "all" /* ALL */) {
430
+ this.appendUrlSearchParams(url, { provider: providerFilter });
431
+ }
432
+ return await this.httpRequest(url.toString(), Pool.array());
433
+ }
434
+ async getPool(address) {
435
+ const url = this.buildURL(`pools/${address}`);
436
+ return await this.httpRequest(url.toString(), Pool);
437
+ }
438
+ async getPoolTicks(poolAddress) {
439
+ const url = this.buildURL(`pools/${poolAddress}/ticks`);
440
+ return await this.httpRequest(url.toString(), PoolTicks);
441
+ }
442
+ async getPoolSwaps(poolAddress) {
443
+ const url = this.buildURL(`pools/${poolAddress}/swaps`);
444
+ return await this.httpRequest(url.toString(), PoolSwap.array());
445
+ }
446
+ async getPoolOrderBook(poolAddress, priceStep, inverted) {
447
+ const url = this.buildURL(`pools/${poolAddress}/order-book`);
448
+ this.appendUrlSearchParams(url, { price_step: priceStep.toString() });
449
+ if (inverted) {
450
+ this.appendUrlSearchParams(url, { inverted: inverted.toString() });
451
+ }
452
+ return await this.httpRequest(url.toString(), OrderBook);
453
+ }
454
+ async getPoolPriceCandles(poolAddress, options) {
455
+ const { from, to, interval, candles } = options;
456
+ const url = this.buildURL(`pools/${poolAddress}/candles`);
457
+ this.appendUrlSearchParams(url, {
458
+ from: from.toISOString(),
459
+ to: to.toISOString(),
460
+ candles: candles.toString(),
461
+ interval
462
+ });
463
+ return await this.httpRequest(url.toString(), PoolPriceCandle.array());
464
+ }
465
+ async getUserLendingPositions(userAddress) {
466
+ const url = this.buildURL(`users/${userAddress}/lending-positions`);
467
+ return await this.httpRequest(url.toString(), LendingPosition.array());
468
+ }
469
+ async getUserLendingPositionByAddress(userAddress, lendingPositionAddress) {
470
+ const url = this.buildURL(`users/${userAddress}/lending-positions/${lendingPositionAddress}`);
471
+ return await this.httpRequest(url.toString(), LendingPosition);
472
+ }
473
+ async getUserTunaPositions(userAddress) {
474
+ const url = this.buildURL(`users/${userAddress}/tuna-positions`);
475
+ return await this.httpRequest(url.toString(), TunaPosition.array());
476
+ }
477
+ async getUserTunaPositionByAddress(userAddress, tunaPositionAddress) {
478
+ const url = this.buildURL(`users/${userAddress}/tuna-positions/${tunaPositionAddress}`);
479
+ return await this.httpRequest(url.toString(), TunaPosition);
480
+ }
481
+ async getUserLimitOrders(userAddress, poolFilter) {
482
+ const url = this.buildURL(`users/${userAddress}/limit-orders`);
483
+ if (poolFilter) {
484
+ this.appendUrlSearchParams(url, { pool: poolFilter });
485
+ }
486
+ return await this.httpRequest(url.toString(), LimitOrder.array());
487
+ }
488
+ async getUserLimitOrderByAddress(userAddress, limitOrderAddress) {
489
+ const url = this.buildURL(`users/${userAddress}/limit-orders/${limitOrderAddress}`);
490
+ return await this.httpRequest(url.toString(), LimitOrder);
491
+ }
492
+ async getPoolUpdatesStream(poolAddress, priceStep, inverted) {
493
+ const url = this.buildURL(`stream`);
494
+ this.appendUrlSearchParams(url, { pool: poolAddress });
495
+ if (priceStep) {
496
+ this.appendUrlSearchParams(url, { price_step: priceStep.toString() });
497
+ }
498
+ if (inverted) {
499
+ this.appendUrlSearchParams(url, { inverted: inverted.toString() });
500
+ }
501
+ return new EventSource(url.toString());
502
+ }
503
+ /* Utility functions */
504
+ buildURL(endpoint) {
505
+ return new URL(
506
+ `./v1/${endpoint}`,
507
+ // We ensure the `baseURL` ends with a `/` so that URL doesn't resolve the
508
+ // path relative to the parent.
509
+ `${this.baseURL}${this.baseURL.endsWith("/") ? "" : "/"}`
510
+ );
511
+ }
512
+ appendUrlSearchParams(url, params) {
513
+ Object.entries(params).forEach(([key, value]) => {
514
+ if (value !== void 0) {
515
+ url.searchParams.append(key, String(value));
516
+ }
517
+ });
518
+ }
519
+ };
520
+ // Annotate the CommonJS export names for ESM import in node:
521
+ 0 && (module.exports = {
522
+ NotificationAction,
523
+ NotificationEntity,
524
+ PoolProvider,
525
+ ProviderFilter,
526
+ TunaApiClient,
527
+ TunaPositionState,
528
+ schemas
529
+ });