@crypticdot/defituna-api 1.1.54 → 1.1.56

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.d.mts CHANGED
@@ -665,9 +665,21 @@ declare const TunaPosition$1: z.ZodObject<{
665
665
  liquidity: z.ZodBigInt;
666
666
  tickLowerIndex: z.ZodNumber;
667
667
  tickUpperIndex: z.ZodNumber;
668
+ /**
669
+ * @deprecated Use entrySqrtPrice
670
+ */
668
671
  tickEntryIndex: z.ZodNumber;
672
+ /**
673
+ * @deprecated Use lowerLimitOrderSqrtPrice
674
+ */
669
675
  tickStopLossIndex: z.ZodNumber;
676
+ /**
677
+ * @deprecated Use upperLimitOrderSqrtPrice
678
+ */
670
679
  tickTakeProfitIndex: z.ZodNumber;
680
+ entrySqrtPrice: z.ZodBigInt;
681
+ lowerLimitOrderSqrtPrice: z.ZodBigInt;
682
+ upperLimitOrderSqrtPrice: z.ZodBigInt;
671
683
  swapToTokenOnLimitOrder: z.ZodNumber;
672
684
  flags: z.ZodNumber;
673
685
  pool: z.ZodString;
@@ -858,6 +870,9 @@ declare const TunaPosition$1: z.ZodObject<{
858
870
  tickEntryIndex: number;
859
871
  tickStopLossIndex: number;
860
872
  tickTakeProfitIndex: number;
873
+ entrySqrtPrice: bigint;
874
+ lowerLimitOrderSqrtPrice: bigint;
875
+ upperLimitOrderSqrtPrice: bigint;
861
876
  swapToTokenOnLimitOrder: number;
862
877
  flags: number;
863
878
  pool: string;
@@ -946,6 +961,9 @@ declare const TunaPosition$1: z.ZodObject<{
946
961
  tickEntryIndex: number;
947
962
  tickStopLossIndex: number;
948
963
  tickTakeProfitIndex: number;
964
+ entrySqrtPrice: bigint;
965
+ lowerLimitOrderSqrtPrice: bigint;
966
+ upperLimitOrderSqrtPrice: bigint;
949
967
  swapToTokenOnLimitOrder: number;
950
968
  flags: number;
951
969
  pool: string;
@@ -2226,9 +2244,21 @@ declare const TunaPositionNotification: z.ZodObject<{
2226
2244
  liquidity: z.ZodBigInt;
2227
2245
  tickLowerIndex: z.ZodNumber;
2228
2246
  tickUpperIndex: z.ZodNumber;
2247
+ /**
2248
+ * @deprecated Use entrySqrtPrice
2249
+ */
2229
2250
  tickEntryIndex: z.ZodNumber;
2251
+ /**
2252
+ * @deprecated Use lowerLimitOrderSqrtPrice
2253
+ */
2230
2254
  tickStopLossIndex: z.ZodNumber;
2255
+ /**
2256
+ * @deprecated Use upperLimitOrderSqrtPrice
2257
+ */
2231
2258
  tickTakeProfitIndex: z.ZodNumber;
2259
+ entrySqrtPrice: z.ZodBigInt;
2260
+ lowerLimitOrderSqrtPrice: z.ZodBigInt;
2261
+ upperLimitOrderSqrtPrice: z.ZodBigInt;
2232
2262
  swapToTokenOnLimitOrder: z.ZodNumber;
2233
2263
  flags: z.ZodNumber;
2234
2264
  pool: z.ZodString;
@@ -2419,6 +2449,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2419
2449
  tickEntryIndex: number;
2420
2450
  tickStopLossIndex: number;
2421
2451
  tickTakeProfitIndex: number;
2452
+ entrySqrtPrice: bigint;
2453
+ lowerLimitOrderSqrtPrice: bigint;
2454
+ upperLimitOrderSqrtPrice: bigint;
2422
2455
  swapToTokenOnLimitOrder: number;
2423
2456
  flags: number;
2424
2457
  pool: string;
@@ -2507,6 +2540,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2507
2540
  tickEntryIndex: number;
2508
2541
  tickStopLossIndex: number;
2509
2542
  tickTakeProfitIndex: number;
2543
+ entrySqrtPrice: bigint;
2544
+ lowerLimitOrderSqrtPrice: bigint;
2545
+ upperLimitOrderSqrtPrice: bigint;
2510
2546
  swapToTokenOnLimitOrder: number;
2511
2547
  flags: number;
2512
2548
  pool: string;
@@ -2599,9 +2635,21 @@ declare const TunaPositionNotification: z.ZodObject<{
2599
2635
  liquidity: z.ZodBigInt;
2600
2636
  tickLowerIndex: z.ZodNumber;
2601
2637
  tickUpperIndex: z.ZodNumber;
2638
+ /**
2639
+ * @deprecated Use entrySqrtPrice
2640
+ */
2602
2641
  tickEntryIndex: z.ZodNumber;
2642
+ /**
2643
+ * @deprecated Use lowerLimitOrderSqrtPrice
2644
+ */
2603
2645
  tickStopLossIndex: z.ZodNumber;
2646
+ /**
2647
+ * @deprecated Use upperLimitOrderSqrtPrice
2648
+ */
2604
2649
  tickTakeProfitIndex: z.ZodNumber;
2650
+ entrySqrtPrice: z.ZodBigInt;
2651
+ lowerLimitOrderSqrtPrice: z.ZodBigInt;
2652
+ upperLimitOrderSqrtPrice: z.ZodBigInt;
2605
2653
  swapToTokenOnLimitOrder: z.ZodNumber;
2606
2654
  flags: z.ZodNumber;
2607
2655
  pool: z.ZodString;
@@ -2792,6 +2840,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2792
2840
  tickEntryIndex: number;
2793
2841
  tickStopLossIndex: number;
2794
2842
  tickTakeProfitIndex: number;
2843
+ entrySqrtPrice: bigint;
2844
+ lowerLimitOrderSqrtPrice: bigint;
2845
+ upperLimitOrderSqrtPrice: bigint;
2795
2846
  swapToTokenOnLimitOrder: number;
2796
2847
  flags: number;
2797
2848
  pool: string;
@@ -2880,6 +2931,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2880
2931
  tickEntryIndex: number;
2881
2932
  tickStopLossIndex: number;
2882
2933
  tickTakeProfitIndex: number;
2934
+ entrySqrtPrice: bigint;
2935
+ lowerLimitOrderSqrtPrice: bigint;
2936
+ upperLimitOrderSqrtPrice: bigint;
2883
2937
  swapToTokenOnLimitOrder: number;
2884
2938
  flags: number;
2885
2939
  pool: string;
@@ -2974,6 +3028,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2974
3028
  tickEntryIndex: number;
2975
3029
  tickStopLossIndex: number;
2976
3030
  tickTakeProfitIndex: number;
3031
+ entrySqrtPrice: bigint;
3032
+ lowerLimitOrderSqrtPrice: bigint;
3033
+ upperLimitOrderSqrtPrice: bigint;
2977
3034
  swapToTokenOnLimitOrder: number;
2978
3035
  flags: number;
2979
3036
  pool: string;
@@ -3069,6 +3126,9 @@ declare const TunaPositionNotification: z.ZodObject<{
3069
3126
  tickEntryIndex: number;
3070
3127
  tickStopLossIndex: number;
3071
3128
  tickTakeProfitIndex: number;
3129
+ entrySqrtPrice: bigint;
3130
+ lowerLimitOrderSqrtPrice: bigint;
3131
+ upperLimitOrderSqrtPrice: bigint;
3072
3132
  swapToTokenOnLimitOrder: number;
3073
3133
  flags: number;
3074
3134
  pool: string;
@@ -3164,6 +3224,9 @@ declare const TunaPositionNotification: z.ZodObject<{
3164
3224
  tickEntryIndex: number;
3165
3225
  tickStopLossIndex: number;
3166
3226
  tickTakeProfitIndex: number;
3227
+ entrySqrtPrice: bigint;
3228
+ lowerLimitOrderSqrtPrice: bigint;
3229
+ upperLimitOrderSqrtPrice: bigint;
3167
3230
  swapToTokenOnLimitOrder: number;
3168
3231
  flags: number;
3169
3232
  pool: string;
@@ -3259,6 +3322,9 @@ declare const TunaPositionNotification: z.ZodObject<{
3259
3322
  tickEntryIndex: number;
3260
3323
  tickStopLossIndex: number;
3261
3324
  tickTakeProfitIndex: number;
3325
+ entrySqrtPrice: bigint;
3326
+ lowerLimitOrderSqrtPrice: bigint;
3327
+ upperLimitOrderSqrtPrice: bigint;
3262
3328
  swapToTokenOnLimitOrder: number;
3263
3329
  flags: number;
3264
3330
  pool: string;
package/dist/index.d.ts CHANGED
@@ -665,9 +665,21 @@ declare const TunaPosition$1: z.ZodObject<{
665
665
  liquidity: z.ZodBigInt;
666
666
  tickLowerIndex: z.ZodNumber;
667
667
  tickUpperIndex: z.ZodNumber;
668
+ /**
669
+ * @deprecated Use entrySqrtPrice
670
+ */
668
671
  tickEntryIndex: z.ZodNumber;
672
+ /**
673
+ * @deprecated Use lowerLimitOrderSqrtPrice
674
+ */
669
675
  tickStopLossIndex: z.ZodNumber;
676
+ /**
677
+ * @deprecated Use upperLimitOrderSqrtPrice
678
+ */
670
679
  tickTakeProfitIndex: z.ZodNumber;
680
+ entrySqrtPrice: z.ZodBigInt;
681
+ lowerLimitOrderSqrtPrice: z.ZodBigInt;
682
+ upperLimitOrderSqrtPrice: z.ZodBigInt;
671
683
  swapToTokenOnLimitOrder: z.ZodNumber;
672
684
  flags: z.ZodNumber;
673
685
  pool: z.ZodString;
@@ -858,6 +870,9 @@ declare const TunaPosition$1: z.ZodObject<{
858
870
  tickEntryIndex: number;
859
871
  tickStopLossIndex: number;
860
872
  tickTakeProfitIndex: number;
873
+ entrySqrtPrice: bigint;
874
+ lowerLimitOrderSqrtPrice: bigint;
875
+ upperLimitOrderSqrtPrice: bigint;
861
876
  swapToTokenOnLimitOrder: number;
862
877
  flags: number;
863
878
  pool: string;
@@ -946,6 +961,9 @@ declare const TunaPosition$1: z.ZodObject<{
946
961
  tickEntryIndex: number;
947
962
  tickStopLossIndex: number;
948
963
  tickTakeProfitIndex: number;
964
+ entrySqrtPrice: bigint;
965
+ lowerLimitOrderSqrtPrice: bigint;
966
+ upperLimitOrderSqrtPrice: bigint;
949
967
  swapToTokenOnLimitOrder: number;
950
968
  flags: number;
951
969
  pool: string;
@@ -2226,9 +2244,21 @@ declare const TunaPositionNotification: z.ZodObject<{
2226
2244
  liquidity: z.ZodBigInt;
2227
2245
  tickLowerIndex: z.ZodNumber;
2228
2246
  tickUpperIndex: z.ZodNumber;
2247
+ /**
2248
+ * @deprecated Use entrySqrtPrice
2249
+ */
2229
2250
  tickEntryIndex: z.ZodNumber;
2251
+ /**
2252
+ * @deprecated Use lowerLimitOrderSqrtPrice
2253
+ */
2230
2254
  tickStopLossIndex: z.ZodNumber;
2255
+ /**
2256
+ * @deprecated Use upperLimitOrderSqrtPrice
2257
+ */
2231
2258
  tickTakeProfitIndex: z.ZodNumber;
2259
+ entrySqrtPrice: z.ZodBigInt;
2260
+ lowerLimitOrderSqrtPrice: z.ZodBigInt;
2261
+ upperLimitOrderSqrtPrice: z.ZodBigInt;
2232
2262
  swapToTokenOnLimitOrder: z.ZodNumber;
2233
2263
  flags: z.ZodNumber;
2234
2264
  pool: z.ZodString;
@@ -2419,6 +2449,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2419
2449
  tickEntryIndex: number;
2420
2450
  tickStopLossIndex: number;
2421
2451
  tickTakeProfitIndex: number;
2452
+ entrySqrtPrice: bigint;
2453
+ lowerLimitOrderSqrtPrice: bigint;
2454
+ upperLimitOrderSqrtPrice: bigint;
2422
2455
  swapToTokenOnLimitOrder: number;
2423
2456
  flags: number;
2424
2457
  pool: string;
@@ -2507,6 +2540,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2507
2540
  tickEntryIndex: number;
2508
2541
  tickStopLossIndex: number;
2509
2542
  tickTakeProfitIndex: number;
2543
+ entrySqrtPrice: bigint;
2544
+ lowerLimitOrderSqrtPrice: bigint;
2545
+ upperLimitOrderSqrtPrice: bigint;
2510
2546
  swapToTokenOnLimitOrder: number;
2511
2547
  flags: number;
2512
2548
  pool: string;
@@ -2599,9 +2635,21 @@ declare const TunaPositionNotification: z.ZodObject<{
2599
2635
  liquidity: z.ZodBigInt;
2600
2636
  tickLowerIndex: z.ZodNumber;
2601
2637
  tickUpperIndex: z.ZodNumber;
2638
+ /**
2639
+ * @deprecated Use entrySqrtPrice
2640
+ */
2602
2641
  tickEntryIndex: z.ZodNumber;
2642
+ /**
2643
+ * @deprecated Use lowerLimitOrderSqrtPrice
2644
+ */
2603
2645
  tickStopLossIndex: z.ZodNumber;
2646
+ /**
2647
+ * @deprecated Use upperLimitOrderSqrtPrice
2648
+ */
2604
2649
  tickTakeProfitIndex: z.ZodNumber;
2650
+ entrySqrtPrice: z.ZodBigInt;
2651
+ lowerLimitOrderSqrtPrice: z.ZodBigInt;
2652
+ upperLimitOrderSqrtPrice: z.ZodBigInt;
2605
2653
  swapToTokenOnLimitOrder: z.ZodNumber;
2606
2654
  flags: z.ZodNumber;
2607
2655
  pool: z.ZodString;
@@ -2792,6 +2840,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2792
2840
  tickEntryIndex: number;
2793
2841
  tickStopLossIndex: number;
2794
2842
  tickTakeProfitIndex: number;
2843
+ entrySqrtPrice: bigint;
2844
+ lowerLimitOrderSqrtPrice: bigint;
2845
+ upperLimitOrderSqrtPrice: bigint;
2795
2846
  swapToTokenOnLimitOrder: number;
2796
2847
  flags: number;
2797
2848
  pool: string;
@@ -2880,6 +2931,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2880
2931
  tickEntryIndex: number;
2881
2932
  tickStopLossIndex: number;
2882
2933
  tickTakeProfitIndex: number;
2934
+ entrySqrtPrice: bigint;
2935
+ lowerLimitOrderSqrtPrice: bigint;
2936
+ upperLimitOrderSqrtPrice: bigint;
2883
2937
  swapToTokenOnLimitOrder: number;
2884
2938
  flags: number;
2885
2939
  pool: string;
@@ -2974,6 +3028,9 @@ declare const TunaPositionNotification: z.ZodObject<{
2974
3028
  tickEntryIndex: number;
2975
3029
  tickStopLossIndex: number;
2976
3030
  tickTakeProfitIndex: number;
3031
+ entrySqrtPrice: bigint;
3032
+ lowerLimitOrderSqrtPrice: bigint;
3033
+ upperLimitOrderSqrtPrice: bigint;
2977
3034
  swapToTokenOnLimitOrder: number;
2978
3035
  flags: number;
2979
3036
  pool: string;
@@ -3069,6 +3126,9 @@ declare const TunaPositionNotification: z.ZodObject<{
3069
3126
  tickEntryIndex: number;
3070
3127
  tickStopLossIndex: number;
3071
3128
  tickTakeProfitIndex: number;
3129
+ entrySqrtPrice: bigint;
3130
+ lowerLimitOrderSqrtPrice: bigint;
3131
+ upperLimitOrderSqrtPrice: bigint;
3072
3132
  swapToTokenOnLimitOrder: number;
3073
3133
  flags: number;
3074
3134
  pool: string;
@@ -3164,6 +3224,9 @@ declare const TunaPositionNotification: z.ZodObject<{
3164
3224
  tickEntryIndex: number;
3165
3225
  tickStopLossIndex: number;
3166
3226
  tickTakeProfitIndex: number;
3227
+ entrySqrtPrice: bigint;
3228
+ lowerLimitOrderSqrtPrice: bigint;
3229
+ upperLimitOrderSqrtPrice: bigint;
3167
3230
  swapToTokenOnLimitOrder: number;
3168
3231
  flags: number;
3169
3232
  pool: string;
@@ -3259,6 +3322,9 @@ declare const TunaPositionNotification: z.ZodObject<{
3259
3322
  tickEntryIndex: number;
3260
3323
  tickStopLossIndex: number;
3261
3324
  tickTakeProfitIndex: number;
3325
+ entrySqrtPrice: bigint;
3326
+ lowerLimitOrderSqrtPrice: bigint;
3327
+ upperLimitOrderSqrtPrice: bigint;
3262
3328
  swapToTokenOnLimitOrder: number;
3263
3329
  flags: number;
3264
3330
  pool: string;
package/dist/index.js CHANGED
@@ -310,9 +310,21 @@ var TunaPosition = import_zod.z.object({
310
310
  liquidity: import_zod.z.coerce.bigint(),
311
311
  tickLowerIndex: import_zod.z.number(),
312
312
  tickUpperIndex: import_zod.z.number(),
313
+ /**
314
+ * @deprecated Use entrySqrtPrice
315
+ */
313
316
  tickEntryIndex: import_zod.z.number(),
317
+ /**
318
+ * @deprecated Use lowerLimitOrderSqrtPrice
319
+ */
314
320
  tickStopLossIndex: import_zod.z.number(),
321
+ /**
322
+ * @deprecated Use upperLimitOrderSqrtPrice
323
+ */
315
324
  tickTakeProfitIndex: import_zod.z.number(),
325
+ entrySqrtPrice: import_zod.z.coerce.bigint(),
326
+ lowerLimitOrderSqrtPrice: import_zod.z.coerce.bigint(),
327
+ upperLimitOrderSqrtPrice: import_zod.z.coerce.bigint(),
316
328
  swapToTokenOnLimitOrder: import_zod.z.number(),
317
329
  flags: import_zod.z.number(),
318
330
  pool: import_zod.z.string(),
@@ -576,35 +588,35 @@ var TunaApiClient = class {
576
588
  /* Endpoints */
577
589
  async getMints() {
578
590
  const url = this.buildURL("mints");
579
- return await this.httpRequest(url.toString(), Mint.array());
591
+ return await this.httpRequest(url, Mint.array());
580
592
  }
581
593
  async getMint(mintAddress) {
582
594
  const url = this.buildURL(`mints/${mintAddress}`);
583
- return await this.httpRequest(url.toString(), Mint);
595
+ return await this.httpRequest(url, Mint);
584
596
  }
585
597
  async getMarkets() {
586
598
  const url = this.buildURL("markets");
587
- return await this.httpRequest(url.toString(), Market.array());
599
+ return await this.httpRequest(url, Market.array());
588
600
  }
589
601
  async getMarket(marketAddress) {
590
602
  const url = this.buildURL(`markets/${marketAddress}`);
591
- return await this.httpRequest(url.toString(), Market);
603
+ return await this.httpRequest(url, Market);
592
604
  }
593
605
  async getOraclePrices() {
594
606
  const url = this.buildURL("oracle-prices");
595
- return await this.httpRequest(url.toString(), TokenOraclePrice.array());
607
+ return await this.httpRequest(url, TokenOraclePrice.array());
596
608
  }
597
609
  async getOraclePrice(mintAddress) {
598
610
  const url = this.buildURL(`oracle-prices/${mintAddress}`);
599
- return await this.httpRequest(url.toString(), TokenOraclePrice);
611
+ return await this.httpRequest(url, TokenOraclePrice);
600
612
  }
601
613
  async getVaults() {
602
614
  const url = this.buildURL("vaults");
603
- return await this.httpRequest(url.toString(), Vault.array());
615
+ return await this.httpRequest(url, Vault.array());
604
616
  }
605
617
  async getVault(vaultAddress) {
606
618
  const url = this.buildURL(`vaults/${vaultAddress}`);
607
- return await this.httpRequest(url.toString(), Vault);
619
+ return await this.httpRequest(url, Vault);
608
620
  }
609
621
  /**
610
622
  * Returns vault historical data for selected time interval.
@@ -612,137 +624,132 @@ var TunaApiClient = class {
612
624
  * Example usage: getVaultHistory('H3ifgix98vzi3yCPbmZDLTheeTRf2jykXx8FpY5L7Sfd', '2025-03-10', '2025-04-10')
613
625
  */
614
626
  async getVaultHistory(vaultAddress, from, to) {
615
- const url = this.buildURL(`vaults/${vaultAddress}/history`);
616
- this.appendUrlSearchParams(url, { from: from.toISOString().slice(0, 10), to: to.toISOString().slice(0, 10) });
617
- return await this.httpRequest(url.toString(), VaultHistoricalStats.array());
627
+ const url = this.appendUrlSearchParams(this.buildURL(`vaults/${vaultAddress}/history`), {
628
+ from: from.toISOString().slice(0, 10),
629
+ to: to.toISOString().slice(0, 10)
630
+ });
631
+ return await this.httpRequest(url, VaultHistoricalStats.array());
618
632
  }
619
633
  async getPools(providerFilter) {
620
- const url = this.buildURL("pools");
621
- if (providerFilter && providerFilter !== "all" /* ALL */) {
622
- this.appendUrlSearchParams(url, { provider: providerFilter });
623
- }
624
- return await this.httpRequest(url.toString(), Pool.array());
634
+ const url = this.appendUrlSearchParams(this.buildURL("pools"), {
635
+ provider: providerFilter && providerFilter !== "all" /* ALL */ ? providerFilter : void 0
636
+ });
637
+ return await this.httpRequest(url, Pool.array());
625
638
  }
626
639
  async getPool(address) {
627
640
  const url = this.buildURL(`pools/${address}`);
628
- return await this.httpRequest(url.toString(), Pool);
641
+ return await this.httpRequest(url, Pool);
629
642
  }
630
643
  async getPoolTicks(poolAddress) {
631
644
  const url = this.buildURL(`pools/${poolAddress}/ticks`);
632
- return await this.httpRequest(url.toString(), PoolTicks);
645
+ return await this.httpRequest(url, PoolTicks);
633
646
  }
634
647
  async getPoolSwaps(poolAddress) {
635
648
  const url = this.buildURL(`pools/${poolAddress}/swaps`);
636
- return await this.httpRequest(url.toString(), PoolSwap.array());
649
+ return await this.httpRequest(url, PoolSwap.array());
637
650
  }
638
651
  async getPoolOrderBook(poolAddress, priceStep, inverted) {
639
- const url = this.buildURL(`pools/${poolAddress}/order-book`);
640
- this.appendUrlSearchParams(url, { price_step: priceStep.toString() });
641
- if (inverted) {
642
- this.appendUrlSearchParams(url, { inverted: inverted.toString() });
643
- }
644
- return await this.httpRequest(url.toString(), OrderBook);
652
+ const url = this.appendUrlSearchParams(this.buildURL(`pools/${poolAddress}/order-book`), {
653
+ price_step: priceStep,
654
+ inverted: inverted || void 0
655
+ });
656
+ return await this.httpRequest(url, OrderBook);
645
657
  }
646
658
  async getPoolPriceCandles(poolAddress, options) {
647
659
  const { from, to, interval, candles } = options;
648
- const url = this.buildURL(`pools/${poolAddress}/candles`);
649
- this.appendUrlSearchParams(url, {
660
+ const url = this.appendUrlSearchParams(this.buildURL(`pools/${poolAddress}/candles`), {
650
661
  from: from.toISOString(),
651
662
  to: to.toISOString(),
652
- candles: candles.toString(),
663
+ candles,
653
664
  interval
654
665
  });
655
- return await this.httpRequest(url.toString(), PoolPriceCandle.array());
666
+ return await this.httpRequest(url, PoolPriceCandle.array());
656
667
  }
657
668
  async getStakingTreasury() {
658
669
  const url = this.buildURL(`staking/treasury`);
659
- return await this.httpRequest(url.toString(), StakingTreasury);
670
+ return await this.httpRequest(url, StakingTreasury);
660
671
  }
661
672
  async getStakingLeaderboard(page, pageSize, search) {
662
- const url = this.buildURL(`staking/leaderboard`);
663
- this.appendUrlSearchParams(url, {
664
- page: page.toString(),
665
- page_size: pageSize.toString(),
666
- ...search ? { search } : {}
673
+ const url = this.appendUrlSearchParams(this.buildURL(`staking/leaderboard`), {
674
+ page,
675
+ page_size: pageSize,
676
+ search: search || void 0
667
677
  });
668
- return await this.httpRequest(url.toString(), StakingLeaderboardPage, { parseRoot: true });
678
+ return await this.httpRequest(url, StakingLeaderboardPage, { parseRoot: true });
669
679
  }
670
680
  async getUserLendingPositions(userAddress) {
671
681
  const url = this.buildURL(`users/${userAddress}/lending-positions`);
672
- return await this.httpRequest(url.toString(), LendingPosition.array());
682
+ return await this.httpRequest(url, LendingPosition.array());
673
683
  }
674
684
  async getUserLendingPositionByAddress(userAddress, lendingPositionAddress) {
675
685
  const url = this.buildURL(`users/${userAddress}/lending-positions/${lendingPositionAddress}`);
676
- return await this.httpRequest(url.toString(), LendingPosition);
686
+ return await this.httpRequest(url, LendingPosition);
677
687
  }
678
688
  async getUserTunaPositions(userAddress) {
679
689
  const url = this.buildURL(`users/${userAddress}/tuna-positions`);
680
- return await this.httpRequest(url.toString(), TunaPosition.array());
690
+ return await this.httpRequest(url, TunaPosition.array());
681
691
  }
682
692
  async getUserTunaPositionByAddress(userAddress, tunaPositionAddress) {
683
693
  const url = this.buildURL(`users/${userAddress}/tuna-positions/${tunaPositionAddress}`);
684
- return await this.httpRequest(url.toString(), TunaPosition);
694
+ return await this.httpRequest(url, TunaPosition);
685
695
  }
686
696
  async getUserLimitOrders(userAddress, poolFilter) {
687
- const url = this.buildURL(`users/${userAddress}/limit-orders`);
688
- if (poolFilter) {
689
- this.appendUrlSearchParams(url, { pool: poolFilter });
690
- }
691
- return await this.httpRequest(url.toString(), LimitOrder.array());
697
+ const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/limit-orders`), {
698
+ pool: poolFilter || void 0
699
+ });
700
+ return await this.httpRequest(url, LimitOrder.array());
692
701
  }
693
702
  async getUserLimitOrderByAddress(userAddress, limitOrderAddress) {
694
703
  const url = this.buildURL(`users/${userAddress}/limit-orders/${limitOrderAddress}`);
695
- return await this.httpRequest(url.toString(), LimitOrder);
704
+ return await this.httpRequest(url, LimitOrder);
696
705
  }
697
706
  async getUserStakingPosition(userAddress) {
698
707
  const url = this.buildURL(`users/${userAddress}/staking-position`);
699
- return await this.httpRequest(url.toString(), StakingPosition);
708
+ return await this.httpRequest(url, StakingPosition);
700
709
  }
701
710
  async getUserStakingPositionHistory(userAddress) {
702
711
  const url = this.buildURL(`users/${userAddress}/staking-position/history`);
703
- return await this.httpRequest(url.toString(), StakingPositionHistoryAction.array());
712
+ return await this.httpRequest(url, StakingPositionHistoryAction.array());
704
713
  }
705
714
  async getFeesStats(from, to, interval) {
706
- const url = this.buildURL(`stats/fees`);
707
- this.appendUrlSearchParams(url, {
715
+ const url = this.appendUrlSearchParams(this.buildURL(`stats/fees`), {
708
716
  from: from.toISOString(),
709
717
  to: to.toISOString(),
710
718
  interval
711
719
  });
712
- return await this.httpRequest(url.toString(), FeesStatsGroup.array());
720
+ return await this.httpRequest(url, FeesStatsGroup.array());
713
721
  }
714
722
  async getStakingRevenueStats(from, to) {
715
- const url = this.buildURL(`stats/staking/revenue`);
716
- this.appendUrlSearchParams(url, {
723
+ const url = this.appendUrlSearchParams(this.buildURL(`stats/staking/revenue`), {
717
724
  from: from.toISOString().split("T")[0],
718
725
  to: to.toISOString().split("T")[0]
719
726
  });
720
- return await this.httpRequest(url.toString(), StakingRevenueStatsGroup.array());
727
+ return await this.httpRequest(url, StakingRevenueStatsGroup.array());
721
728
  }
722
729
  async getUpdatesStream() {
723
730
  const url = this.buildURL(`streams/sse`);
724
- return new EventSource(url.toString());
731
+ return new EventSource(url);
725
732
  }
726
733
  async updateStreamSubscription(streamId, subscription) {
727
734
  const url = this.buildURL(`streams/${streamId}/subscription`);
728
735
  const body = JSON.stringify((0, import_snakecase_keys.default)(subscription, { deep: true }));
729
- return await this.httpRequest(url.toString(), UpdateStreamSubscriptionResult, { method: "PUT", body });
736
+ return await this.httpRequest(url, UpdateStreamSubscriptionResult, { method: "PUT", body });
730
737
  }
731
738
  /* Utility functions */
732
739
  buildURL(endpoint) {
733
- return new URL(
734
- `./v1/${endpoint}`,
735
- // We ensure the `baseURL` ends with a `/` so that URL doesn't resolve the
736
- // path relative to the parent.
737
- `${this.baseURL}${this.baseURL.endsWith("/") ? "" : "/"}`
738
- );
740
+ return `${this.baseURL}${this.baseURL.endsWith("/") ? "" : "/"}v1/${endpoint}`;
739
741
  }
740
742
  appendUrlSearchParams(url, params) {
743
+ const urlSearchParams = new URLSearchParams();
741
744
  Object.entries(params).forEach(([key, value]) => {
742
745
  if (value !== void 0) {
743
- url.searchParams.append(key, String(value));
746
+ urlSearchParams.append(key, String(value));
744
747
  }
745
748
  });
749
+ if (urlSearchParams.size > 0) {
750
+ return `${url}?${urlSearchParams.toString()}`;
751
+ }
752
+ return url;
746
753
  }
747
754
  };
748
755
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -275,9 +275,21 @@ var TunaPosition = z.object({
275
275
  liquidity: z.coerce.bigint(),
276
276
  tickLowerIndex: z.number(),
277
277
  tickUpperIndex: z.number(),
278
+ /**
279
+ * @deprecated Use entrySqrtPrice
280
+ */
278
281
  tickEntryIndex: z.number(),
282
+ /**
283
+ * @deprecated Use lowerLimitOrderSqrtPrice
284
+ */
279
285
  tickStopLossIndex: z.number(),
286
+ /**
287
+ * @deprecated Use upperLimitOrderSqrtPrice
288
+ */
280
289
  tickTakeProfitIndex: z.number(),
290
+ entrySqrtPrice: z.coerce.bigint(),
291
+ lowerLimitOrderSqrtPrice: z.coerce.bigint(),
292
+ upperLimitOrderSqrtPrice: z.coerce.bigint(),
281
293
  swapToTokenOnLimitOrder: z.number(),
282
294
  flags: z.number(),
283
295
  pool: z.string(),
@@ -541,35 +553,35 @@ var TunaApiClient = class {
541
553
  /* Endpoints */
542
554
  async getMints() {
543
555
  const url = this.buildURL("mints");
544
- return await this.httpRequest(url.toString(), Mint.array());
556
+ return await this.httpRequest(url, Mint.array());
545
557
  }
546
558
  async getMint(mintAddress) {
547
559
  const url = this.buildURL(`mints/${mintAddress}`);
548
- return await this.httpRequest(url.toString(), Mint);
560
+ return await this.httpRequest(url, Mint);
549
561
  }
550
562
  async getMarkets() {
551
563
  const url = this.buildURL("markets");
552
- return await this.httpRequest(url.toString(), Market.array());
564
+ return await this.httpRequest(url, Market.array());
553
565
  }
554
566
  async getMarket(marketAddress) {
555
567
  const url = this.buildURL(`markets/${marketAddress}`);
556
- return await this.httpRequest(url.toString(), Market);
568
+ return await this.httpRequest(url, Market);
557
569
  }
558
570
  async getOraclePrices() {
559
571
  const url = this.buildURL("oracle-prices");
560
- return await this.httpRequest(url.toString(), TokenOraclePrice.array());
572
+ return await this.httpRequest(url, TokenOraclePrice.array());
561
573
  }
562
574
  async getOraclePrice(mintAddress) {
563
575
  const url = this.buildURL(`oracle-prices/${mintAddress}`);
564
- return await this.httpRequest(url.toString(), TokenOraclePrice);
576
+ return await this.httpRequest(url, TokenOraclePrice);
565
577
  }
566
578
  async getVaults() {
567
579
  const url = this.buildURL("vaults");
568
- return await this.httpRequest(url.toString(), Vault.array());
580
+ return await this.httpRequest(url, Vault.array());
569
581
  }
570
582
  async getVault(vaultAddress) {
571
583
  const url = this.buildURL(`vaults/${vaultAddress}`);
572
- return await this.httpRequest(url.toString(), Vault);
584
+ return await this.httpRequest(url, Vault);
573
585
  }
574
586
  /**
575
587
  * Returns vault historical data for selected time interval.
@@ -577,137 +589,132 @@ var TunaApiClient = class {
577
589
  * Example usage: getVaultHistory('H3ifgix98vzi3yCPbmZDLTheeTRf2jykXx8FpY5L7Sfd', '2025-03-10', '2025-04-10')
578
590
  */
579
591
  async getVaultHistory(vaultAddress, from, to) {
580
- const url = this.buildURL(`vaults/${vaultAddress}/history`);
581
- this.appendUrlSearchParams(url, { from: from.toISOString().slice(0, 10), to: to.toISOString().slice(0, 10) });
582
- return await this.httpRequest(url.toString(), VaultHistoricalStats.array());
592
+ const url = this.appendUrlSearchParams(this.buildURL(`vaults/${vaultAddress}/history`), {
593
+ from: from.toISOString().slice(0, 10),
594
+ to: to.toISOString().slice(0, 10)
595
+ });
596
+ return await this.httpRequest(url, VaultHistoricalStats.array());
583
597
  }
584
598
  async getPools(providerFilter) {
585
- const url = this.buildURL("pools");
586
- if (providerFilter && providerFilter !== "all" /* ALL */) {
587
- this.appendUrlSearchParams(url, { provider: providerFilter });
588
- }
589
- return await this.httpRequest(url.toString(), Pool.array());
599
+ const url = this.appendUrlSearchParams(this.buildURL("pools"), {
600
+ provider: providerFilter && providerFilter !== "all" /* ALL */ ? providerFilter : void 0
601
+ });
602
+ return await this.httpRequest(url, Pool.array());
590
603
  }
591
604
  async getPool(address) {
592
605
  const url = this.buildURL(`pools/${address}`);
593
- return await this.httpRequest(url.toString(), Pool);
606
+ return await this.httpRequest(url, Pool);
594
607
  }
595
608
  async getPoolTicks(poolAddress) {
596
609
  const url = this.buildURL(`pools/${poolAddress}/ticks`);
597
- return await this.httpRequest(url.toString(), PoolTicks);
610
+ return await this.httpRequest(url, PoolTicks);
598
611
  }
599
612
  async getPoolSwaps(poolAddress) {
600
613
  const url = this.buildURL(`pools/${poolAddress}/swaps`);
601
- return await this.httpRequest(url.toString(), PoolSwap.array());
614
+ return await this.httpRequest(url, PoolSwap.array());
602
615
  }
603
616
  async getPoolOrderBook(poolAddress, priceStep, inverted) {
604
- const url = this.buildURL(`pools/${poolAddress}/order-book`);
605
- this.appendUrlSearchParams(url, { price_step: priceStep.toString() });
606
- if (inverted) {
607
- this.appendUrlSearchParams(url, { inverted: inverted.toString() });
608
- }
609
- return await this.httpRequest(url.toString(), OrderBook);
617
+ const url = this.appendUrlSearchParams(this.buildURL(`pools/${poolAddress}/order-book`), {
618
+ price_step: priceStep,
619
+ inverted: inverted || void 0
620
+ });
621
+ return await this.httpRequest(url, OrderBook);
610
622
  }
611
623
  async getPoolPriceCandles(poolAddress, options) {
612
624
  const { from, to, interval, candles } = options;
613
- const url = this.buildURL(`pools/${poolAddress}/candles`);
614
- this.appendUrlSearchParams(url, {
625
+ const url = this.appendUrlSearchParams(this.buildURL(`pools/${poolAddress}/candles`), {
615
626
  from: from.toISOString(),
616
627
  to: to.toISOString(),
617
- candles: candles.toString(),
628
+ candles,
618
629
  interval
619
630
  });
620
- return await this.httpRequest(url.toString(), PoolPriceCandle.array());
631
+ return await this.httpRequest(url, PoolPriceCandle.array());
621
632
  }
622
633
  async getStakingTreasury() {
623
634
  const url = this.buildURL(`staking/treasury`);
624
- return await this.httpRequest(url.toString(), StakingTreasury);
635
+ return await this.httpRequest(url, StakingTreasury);
625
636
  }
626
637
  async getStakingLeaderboard(page, pageSize, search) {
627
- const url = this.buildURL(`staking/leaderboard`);
628
- this.appendUrlSearchParams(url, {
629
- page: page.toString(),
630
- page_size: pageSize.toString(),
631
- ...search ? { search } : {}
638
+ const url = this.appendUrlSearchParams(this.buildURL(`staking/leaderboard`), {
639
+ page,
640
+ page_size: pageSize,
641
+ search: search || void 0
632
642
  });
633
- return await this.httpRequest(url.toString(), StakingLeaderboardPage, { parseRoot: true });
643
+ return await this.httpRequest(url, StakingLeaderboardPage, { parseRoot: true });
634
644
  }
635
645
  async getUserLendingPositions(userAddress) {
636
646
  const url = this.buildURL(`users/${userAddress}/lending-positions`);
637
- return await this.httpRequest(url.toString(), LendingPosition.array());
647
+ return await this.httpRequest(url, LendingPosition.array());
638
648
  }
639
649
  async getUserLendingPositionByAddress(userAddress, lendingPositionAddress) {
640
650
  const url = this.buildURL(`users/${userAddress}/lending-positions/${lendingPositionAddress}`);
641
- return await this.httpRequest(url.toString(), LendingPosition);
651
+ return await this.httpRequest(url, LendingPosition);
642
652
  }
643
653
  async getUserTunaPositions(userAddress) {
644
654
  const url = this.buildURL(`users/${userAddress}/tuna-positions`);
645
- return await this.httpRequest(url.toString(), TunaPosition.array());
655
+ return await this.httpRequest(url, TunaPosition.array());
646
656
  }
647
657
  async getUserTunaPositionByAddress(userAddress, tunaPositionAddress) {
648
658
  const url = this.buildURL(`users/${userAddress}/tuna-positions/${tunaPositionAddress}`);
649
- return await this.httpRequest(url.toString(), TunaPosition);
659
+ return await this.httpRequest(url, TunaPosition);
650
660
  }
651
661
  async getUserLimitOrders(userAddress, poolFilter) {
652
- const url = this.buildURL(`users/${userAddress}/limit-orders`);
653
- if (poolFilter) {
654
- this.appendUrlSearchParams(url, { pool: poolFilter });
655
- }
656
- return await this.httpRequest(url.toString(), LimitOrder.array());
662
+ const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/limit-orders`), {
663
+ pool: poolFilter || void 0
664
+ });
665
+ return await this.httpRequest(url, LimitOrder.array());
657
666
  }
658
667
  async getUserLimitOrderByAddress(userAddress, limitOrderAddress) {
659
668
  const url = this.buildURL(`users/${userAddress}/limit-orders/${limitOrderAddress}`);
660
- return await this.httpRequest(url.toString(), LimitOrder);
669
+ return await this.httpRequest(url, LimitOrder);
661
670
  }
662
671
  async getUserStakingPosition(userAddress) {
663
672
  const url = this.buildURL(`users/${userAddress}/staking-position`);
664
- return await this.httpRequest(url.toString(), StakingPosition);
673
+ return await this.httpRequest(url, StakingPosition);
665
674
  }
666
675
  async getUserStakingPositionHistory(userAddress) {
667
676
  const url = this.buildURL(`users/${userAddress}/staking-position/history`);
668
- return await this.httpRequest(url.toString(), StakingPositionHistoryAction.array());
677
+ return await this.httpRequest(url, StakingPositionHistoryAction.array());
669
678
  }
670
679
  async getFeesStats(from, to, interval) {
671
- const url = this.buildURL(`stats/fees`);
672
- this.appendUrlSearchParams(url, {
680
+ const url = this.appendUrlSearchParams(this.buildURL(`stats/fees`), {
673
681
  from: from.toISOString(),
674
682
  to: to.toISOString(),
675
683
  interval
676
684
  });
677
- return await this.httpRequest(url.toString(), FeesStatsGroup.array());
685
+ return await this.httpRequest(url, FeesStatsGroup.array());
678
686
  }
679
687
  async getStakingRevenueStats(from, to) {
680
- const url = this.buildURL(`stats/staking/revenue`);
681
- this.appendUrlSearchParams(url, {
688
+ const url = this.appendUrlSearchParams(this.buildURL(`stats/staking/revenue`), {
682
689
  from: from.toISOString().split("T")[0],
683
690
  to: to.toISOString().split("T")[0]
684
691
  });
685
- return await this.httpRequest(url.toString(), StakingRevenueStatsGroup.array());
692
+ return await this.httpRequest(url, StakingRevenueStatsGroup.array());
686
693
  }
687
694
  async getUpdatesStream() {
688
695
  const url = this.buildURL(`streams/sse`);
689
- return new EventSource(url.toString());
696
+ return new EventSource(url);
690
697
  }
691
698
  async updateStreamSubscription(streamId, subscription) {
692
699
  const url = this.buildURL(`streams/${streamId}/subscription`);
693
700
  const body = JSON.stringify(snakecaseKeys(subscription, { deep: true }));
694
- return await this.httpRequest(url.toString(), UpdateStreamSubscriptionResult, { method: "PUT", body });
701
+ return await this.httpRequest(url, UpdateStreamSubscriptionResult, { method: "PUT", body });
695
702
  }
696
703
  /* Utility functions */
697
704
  buildURL(endpoint) {
698
- return new URL(
699
- `./v1/${endpoint}`,
700
- // We ensure the `baseURL` ends with a `/` so that URL doesn't resolve the
701
- // path relative to the parent.
702
- `${this.baseURL}${this.baseURL.endsWith("/") ? "" : "/"}`
703
- );
705
+ return `${this.baseURL}${this.baseURL.endsWith("/") ? "" : "/"}v1/${endpoint}`;
704
706
  }
705
707
  appendUrlSearchParams(url, params) {
708
+ const urlSearchParams = new URLSearchParams();
706
709
  Object.entries(params).forEach(([key, value]) => {
707
710
  if (value !== void 0) {
708
- url.searchParams.append(key, String(value));
711
+ urlSearchParams.append(key, String(value));
709
712
  }
710
713
  });
714
+ if (urlSearchParams.size > 0) {
715
+ return `${url}?${urlSearchParams.toString()}`;
716
+ }
717
+ return url;
711
718
  }
712
719
  };
713
720
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crypticdot/defituna-api",
3
- "version": "1.1.54",
3
+ "version": "1.1.56",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",