@crypticdot/defituna-api 1.1.29 → 1.1.31

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
@@ -4,6 +4,9 @@ declare const NotificationEntity: {
4
4
  readonly POOL_SWAP: "pool_swap";
5
5
  readonly POOL_PRICE: "pool_price";
6
6
  readonly ORDER_BOOK: "order_book";
7
+ readonly TUNA_POSITION: "tuna_position";
8
+ readonly LENDING_POSITION: "lending_position";
9
+ readonly FUSION_LIMIT_ORDER: "fusion_limit_order";
7
10
  };
8
11
  declare const NotificationAction: {
9
12
  readonly CREATE: "create";
@@ -26,11 +29,23 @@ declare const LimitOrderState: {
26
29
  readonly COMPLETE: "complete";
27
30
  readonly CANCELLED: "cancelled";
28
31
  };
29
- declare const NotificationEntitySchema: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
32
+ declare const PoolSubscriptionTopic: {
33
+ readonly ORDER_BOOK: "order_book";
34
+ readonly POOL_PRICES: "pool_prices";
35
+ readonly POOL_SWAPS: "pool_swaps";
36
+ };
37
+ declare const WalletSubscriptionTopic: {
38
+ readonly TUNA_POSITIONS: "tuna_positions";
39
+ readonly LENDING_POSITIONS: "lending_positions";
40
+ readonly FUSION_LIMIT_ORDERS: "fusion_limit_orders";
41
+ };
42
+ declare const NotificationEntitySchema: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
30
43
  declare const NotificationActionSchema: z.ZodEnum<["create", ...("create" | "update")[]]>;
31
44
  declare const PoolProviderSchema: z.ZodEnum<["orca", ...("orca" | "fusion")[]]>;
32
45
  declare const TunaPositionStateSchema: z.ZodEnum<["open", ...("open" | "liquidated" | "closed_by_limit_order" | "closed")[]]>;
33
46
  declare const LimitOrderStateSchema: z.ZodEnum<["open", ...("open" | "partially_filled" | "filled" | "complete" | "cancelled")[]]>;
47
+ declare const PoolSubscriptionTopicSchema: z.ZodEnum<["order_book", ...("order_book" | "pool_prices" | "pool_swaps")[]]>;
48
+ declare const WalletSubscriptionTopicSchema: z.ZodEnum<["tuna_positions", ...("tuna_positions" | "lending_positions" | "fusion_limit_orders")[]]>;
34
49
  declare const Mint$1: z.ZodObject<{
35
50
  symbol: z.ZodString;
36
51
  mint: z.ZodString;
@@ -746,6 +761,7 @@ declare const TunaPosition$1: z.ZodObject<{
746
761
  }>;
747
762
  openedAt: z.ZodDate;
748
763
  updatedAtSlot: z.ZodBigInt;
764
+ closedAt: z.ZodNullable<z.ZodDate>;
749
765
  }, "strip", z.ZodTypeAny, {
750
766
  address: string;
751
767
  liquidity: bigint;
@@ -833,6 +849,7 @@ declare const TunaPosition$1: z.ZodObject<{
833
849
  };
834
850
  openedAt: Date;
835
851
  updatedAtSlot: bigint;
852
+ closedAt: Date | null;
836
853
  }, {
837
854
  address: string;
838
855
  liquidity: bigint;
@@ -920,6 +937,7 @@ declare const TunaPosition$1: z.ZodObject<{
920
937
  };
921
938
  openedAt: Date;
922
939
  updatedAtSlot: bigint;
940
+ closedAt: Date | null;
923
941
  }>;
924
942
  declare const PoolSwap$1: z.ZodObject<{
925
943
  id: z.ZodString;
@@ -1096,6 +1114,7 @@ declare const LimitOrder$1: z.ZodObject<{
1096
1114
  state: "open" | "partially_filled" | "filled" | "complete" | "cancelled";
1097
1115
  pool: string;
1098
1116
  openedAt: Date;
1117
+ closedAt: Date | null;
1099
1118
  amountIn: {
1100
1119
  amount: bigint;
1101
1120
  usd: number;
@@ -1109,13 +1128,13 @@ declare const LimitOrder$1: z.ZodObject<{
1109
1128
  fillRatio: number;
1110
1129
  openTxSignature: string;
1111
1130
  closeTxSignature: string | null;
1112
- closedAt: Date | null;
1113
1131
  }, {
1114
1132
  mint: string;
1115
1133
  address: string;
1116
1134
  state: "open" | "partially_filled" | "filled" | "complete" | "cancelled";
1117
1135
  pool: string;
1118
1136
  openedAt: Date;
1137
+ closedAt: Date | null;
1119
1138
  amountIn: {
1120
1139
  amount: bigint;
1121
1140
  usd: number;
@@ -1129,7 +1148,6 @@ declare const LimitOrder$1: z.ZodObject<{
1129
1148
  fillRatio: number;
1130
1149
  openTxSignature: string;
1131
1150
  closeTxSignature: string | null;
1132
- closedAt: Date | null;
1133
1151
  }>;
1134
1152
  declare const PoolPriceCandle$1: z.ZodObject<{
1135
1153
  time: z.ZodNumber;
@@ -1150,6 +1168,13 @@ declare const PoolPriceCandle$1: z.ZodObject<{
1150
1168
  high: number;
1151
1169
  low: number;
1152
1170
  }>;
1171
+ declare const UpdateStreamSubscriptionResult: z.ZodObject<{
1172
+ status: z.ZodString;
1173
+ }, "strip", z.ZodTypeAny, {
1174
+ status: string;
1175
+ }, {
1176
+ status: string;
1177
+ }>;
1153
1178
  declare const OrderBookNotificationMeta: z.ZodObject<{
1154
1179
  pool: z.ZodString;
1155
1180
  priceStep: z.ZodNumber;
@@ -1165,7 +1190,7 @@ declare const OrderBookNotificationMeta: z.ZodObject<{
1165
1190
  }>;
1166
1191
  declare const PoolSwapNotification: z.ZodObject<{
1167
1192
  meta: z.ZodTypeAny;
1168
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1193
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1169
1194
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1170
1195
  data: z.ZodObject<{
1171
1196
  id: z.ZodString;
@@ -1193,7 +1218,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1193
1218
  authority: z.ZodNullable<z.ZodString>;
1194
1219
  } | {
1195
1220
  meta: z.ZodNullable<z.ZodUndefined>;
1196
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1221
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1197
1222
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1198
1223
  data: z.ZodObject<{
1199
1224
  id: z.ZodString;
@@ -1222,7 +1247,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1222
1247
  }, "strip", z.ZodTypeAny, {
1223
1248
  authority: string | null;
1224
1249
  id: string;
1225
- entity: "pool_swap" | "pool_price" | "order_book";
1250
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1226
1251
  action: "create" | "update";
1227
1252
  data: {
1228
1253
  time: Date;
@@ -1236,7 +1261,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1236
1261
  } | {
1237
1262
  authority: string | null;
1238
1263
  id: string;
1239
- entity: "pool_swap" | "pool_price" | "order_book";
1264
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1240
1265
  action: "create" | "update";
1241
1266
  data: {
1242
1267
  time: Date;
@@ -1250,7 +1275,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1250
1275
  }, {
1251
1276
  authority: string | null;
1252
1277
  id: string;
1253
- entity: "pool_swap" | "pool_price" | "order_book";
1278
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1254
1279
  action: "create" | "update";
1255
1280
  data: {
1256
1281
  time: Date;
@@ -1264,7 +1289,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1264
1289
  } | {
1265
1290
  authority: string | null;
1266
1291
  id: string;
1267
- entity: "pool_swap" | "pool_price" | "order_book";
1292
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1268
1293
  action: "create" | "update";
1269
1294
  data: {
1270
1295
  time: Date;
@@ -1278,7 +1303,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1278
1303
  }>;
1279
1304
  declare const PoolPriceUpdateNotification: z.ZodObject<{
1280
1305
  meta: z.ZodTypeAny;
1281
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1306
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1282
1307
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1283
1308
  data: z.ZodObject<{
1284
1309
  pool: z.ZodString;
@@ -1300,7 +1325,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1300
1325
  authority: z.ZodNullable<z.ZodString>;
1301
1326
  } | {
1302
1327
  meta: z.ZodNullable<z.ZodUndefined>;
1303
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1328
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1304
1329
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1305
1330
  data: z.ZodObject<{
1306
1331
  pool: z.ZodString;
@@ -1323,7 +1348,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1323
1348
  }, "strip", z.ZodTypeAny, {
1324
1349
  authority: string | null;
1325
1350
  id: string;
1326
- entity: "pool_swap" | "pool_price" | "order_book";
1351
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1327
1352
  action: "create" | "update";
1328
1353
  data: {
1329
1354
  price: number;
@@ -1335,7 +1360,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1335
1360
  } | {
1336
1361
  authority: string | null;
1337
1362
  id: string;
1338
- entity: "pool_swap" | "pool_price" | "order_book";
1363
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1339
1364
  action: "create" | "update";
1340
1365
  data: {
1341
1366
  price: number;
@@ -1347,7 +1372,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1347
1372
  }, {
1348
1373
  authority: string | null;
1349
1374
  id: string;
1350
- entity: "pool_swap" | "pool_price" | "order_book";
1375
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1351
1376
  action: "create" | "update";
1352
1377
  data: {
1353
1378
  price: number;
@@ -1359,7 +1384,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1359
1384
  } | {
1360
1385
  authority: string | null;
1361
1386
  id: string;
1362
- entity: "pool_swap" | "pool_price" | "order_book";
1387
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1363
1388
  action: "create" | "update";
1364
1389
  data: {
1365
1390
  price: number;
@@ -1383,7 +1408,7 @@ declare const OrderBookNotification: z.ZodObject<{
1383
1408
  priceStep: number;
1384
1409
  inverted: boolean;
1385
1410
  }>;
1386
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1411
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1387
1412
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1388
1413
  data: z.ZodObject<{
1389
1414
  entries: z.ZodArray<z.ZodObject<{
@@ -1454,7 +1479,7 @@ declare const OrderBookNotification: z.ZodObject<{
1454
1479
  authority: z.ZodNullable<z.ZodString>;
1455
1480
  } | {
1456
1481
  meta: z.ZodNullable<z.ZodUndefined>;
1457
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1482
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1458
1483
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1459
1484
  data: z.ZodObject<{
1460
1485
  entries: z.ZodArray<z.ZodObject<{
@@ -1526,7 +1551,7 @@ declare const OrderBookNotification: z.ZodObject<{
1526
1551
  }, "strip", z.ZodTypeAny, {
1527
1552
  authority: string | null;
1528
1553
  id: string;
1529
- entity: "pool_swap" | "pool_price" | "order_book";
1554
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1530
1555
  action: "create" | "update";
1531
1556
  data: {
1532
1557
  entries: {
@@ -1551,7 +1576,7 @@ declare const OrderBookNotification: z.ZodObject<{
1551
1576
  } | {
1552
1577
  authority: string | null;
1553
1578
  id: string;
1554
- entity: "pool_swap" | "pool_price" | "order_book";
1579
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1555
1580
  action: "create" | "update";
1556
1581
  data: {
1557
1582
  entries: {
@@ -1576,7 +1601,7 @@ declare const OrderBookNotification: z.ZodObject<{
1576
1601
  }, {
1577
1602
  authority: string | null;
1578
1603
  id: string;
1579
- entity: "pool_swap" | "pool_price" | "order_book";
1604
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1580
1605
  action: "create" | "update";
1581
1606
  data: {
1582
1607
  entries: {
@@ -1601,7 +1626,7 @@ declare const OrderBookNotification: z.ZodObject<{
1601
1626
  } | {
1602
1627
  authority: string | null;
1603
1628
  id: string;
1604
- entity: "pool_swap" | "pool_price" | "order_book";
1629
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1605
1630
  action: "create" | "update";
1606
1631
  data: {
1607
1632
  entries: {
@@ -1636,16 +1661,23 @@ declare const schemas_OrderBookNotificationMeta: typeof OrderBookNotificationMet
1636
1661
  declare const schemas_PoolPriceUpdateNotification: typeof PoolPriceUpdateNotification;
1637
1662
  declare const schemas_PoolProvider: typeof PoolProvider;
1638
1663
  declare const schemas_PoolProviderSchema: typeof PoolProviderSchema;
1664
+ declare const schemas_PoolSubscriptionTopic: typeof PoolSubscriptionTopic;
1665
+ declare const schemas_PoolSubscriptionTopicSchema: typeof PoolSubscriptionTopicSchema;
1639
1666
  declare const schemas_PoolSwapNotification: typeof PoolSwapNotification;
1640
1667
  declare const schemas_TunaPositionState: typeof TunaPositionState;
1641
1668
  declare const schemas_TunaPositionStateSchema: typeof TunaPositionStateSchema;
1669
+ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscriptionResult;
1670
+ declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
1671
+ declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
1642
1672
  declare namespace schemas {
1643
- export { LendingPosition$1 as LendingPosition, LimitOrder$1 as LimitOrder, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, TunaPosition$1 as TunaPosition, schemas_TunaPositionState as TunaPositionState, schemas_TunaPositionStateSchema as TunaPositionStateSchema, Vault$1 as Vault };
1673
+ export { LendingPosition$1 as LendingPosition, LimitOrder$1 as LimitOrder, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, schemas_PoolSubscriptionTopic as PoolSubscriptionTopic, schemas_PoolSubscriptionTopicSchema as PoolSubscriptionTopicSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, TunaPosition$1 as TunaPosition, schemas_TunaPositionState as TunaPositionState, schemas_TunaPositionStateSchema as TunaPositionStateSchema, schemas_UpdateStreamSubscriptionResult as UpdateStreamSubscriptionResult, Vault$1 as Vault, schemas_WalletSubscriptionTopic as WalletSubscriptionTopic, schemas_WalletSubscriptionTopicSchema as WalletSubscriptionTopicSchema };
1644
1674
  }
1645
1675
 
1646
1676
  type PoolProviderType = z.infer<typeof PoolProviderSchema>;
1647
1677
  type TunaPositionStateType = z.infer<typeof TunaPositionStateSchema>;
1648
1678
  type LimitOrderStateType = z.infer<typeof LimitOrderStateSchema>;
1679
+ type PoolSubscriptionTopicType = z.infer<typeof PoolSubscriptionTopicSchema>;
1680
+ type WalletSubscriptionTopicType = z.infer<typeof WalletSubscriptionTopicSchema>;
1649
1681
  type Mint = z.infer<typeof Mint$1>;
1650
1682
  type Market = z.infer<typeof Market$1>;
1651
1683
  type TokenOraclePrice = z.infer<typeof TokenOraclePrice$1>;
@@ -1661,6 +1693,18 @@ type TunaPosition = z.infer<typeof TunaPosition$1>;
1661
1693
  type LimitOrder = z.infer<typeof LimitOrder$1>;
1662
1694
  type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
1663
1695
  type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
1696
+ type SubscriptionPayload = {
1697
+ pools?: {
1698
+ address: string;
1699
+ topics: PoolSubscriptionTopicType[];
1700
+ orderBookPriceStep?: number;
1701
+ isInverted?: boolean;
1702
+ }[];
1703
+ wallet?: {
1704
+ address: string;
1705
+ topics: WalletSubscriptionTopicType[];
1706
+ };
1707
+ };
1664
1708
  type DurationInMs = number;
1665
1709
  declare enum ProviderFilter {
1666
1710
  ORCA = "orca",
@@ -1722,9 +1766,14 @@ declare class TunaApiClient {
1722
1766
  getUserTunaPositionByAddress(userAddress: string, tunaPositionAddress: string): Promise<TunaPosition>;
1723
1767
  getUserLimitOrders(userAddress: string, poolFilter?: string): Promise<LimitOrder[]>;
1724
1768
  getUserLimitOrderByAddress(userAddress: string, limitOrderAddress: string): Promise<LimitOrder>;
1769
+ /**
1770
+ * @deprecated Use getUpdatesStream instead
1771
+ */
1725
1772
  getPoolUpdatesStream(poolAddress: string, priceStep?: number, inverted?: boolean): Promise<EventSource>;
1773
+ getUpdatesStream(): Promise<EventSource>;
1774
+ updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
1726
1775
  private buildURL;
1727
1776
  private appendUrlSearchParams;
1728
1777
  }
1729
1778
 
1730
- export { type DurationInMs, type GetPoolPriceCandlesOptions, type LendingPosition, type LimitOrder, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSwap, type PoolTicks, ProviderFilter, type Tick, type TokenOraclePrice, TunaApiClient, type TunaApiClientConfig, type TunaPosition, TunaPositionState, type TunaPositionStateType, type Vault, schemas };
1779
+ export { type DurationInMs, type GetPoolPriceCandlesOptions, type LendingPosition, type LimitOrder, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSubscriptionTopicType, type PoolSwap, type PoolTicks, ProviderFilter, type SubscriptionPayload, type Tick, type TokenOraclePrice, TunaApiClient, type TunaApiClientConfig, type TunaPosition, TunaPositionState, type TunaPositionStateType, type Vault, type WalletSubscriptionTopicType, schemas };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,9 @@ declare const NotificationEntity: {
4
4
  readonly POOL_SWAP: "pool_swap";
5
5
  readonly POOL_PRICE: "pool_price";
6
6
  readonly ORDER_BOOK: "order_book";
7
+ readonly TUNA_POSITION: "tuna_position";
8
+ readonly LENDING_POSITION: "lending_position";
9
+ readonly FUSION_LIMIT_ORDER: "fusion_limit_order";
7
10
  };
8
11
  declare const NotificationAction: {
9
12
  readonly CREATE: "create";
@@ -26,11 +29,23 @@ declare const LimitOrderState: {
26
29
  readonly COMPLETE: "complete";
27
30
  readonly CANCELLED: "cancelled";
28
31
  };
29
- declare const NotificationEntitySchema: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
32
+ declare const PoolSubscriptionTopic: {
33
+ readonly ORDER_BOOK: "order_book";
34
+ readonly POOL_PRICES: "pool_prices";
35
+ readonly POOL_SWAPS: "pool_swaps";
36
+ };
37
+ declare const WalletSubscriptionTopic: {
38
+ readonly TUNA_POSITIONS: "tuna_positions";
39
+ readonly LENDING_POSITIONS: "lending_positions";
40
+ readonly FUSION_LIMIT_ORDERS: "fusion_limit_orders";
41
+ };
42
+ declare const NotificationEntitySchema: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
30
43
  declare const NotificationActionSchema: z.ZodEnum<["create", ...("create" | "update")[]]>;
31
44
  declare const PoolProviderSchema: z.ZodEnum<["orca", ...("orca" | "fusion")[]]>;
32
45
  declare const TunaPositionStateSchema: z.ZodEnum<["open", ...("open" | "liquidated" | "closed_by_limit_order" | "closed")[]]>;
33
46
  declare const LimitOrderStateSchema: z.ZodEnum<["open", ...("open" | "partially_filled" | "filled" | "complete" | "cancelled")[]]>;
47
+ declare const PoolSubscriptionTopicSchema: z.ZodEnum<["order_book", ...("order_book" | "pool_prices" | "pool_swaps")[]]>;
48
+ declare const WalletSubscriptionTopicSchema: z.ZodEnum<["tuna_positions", ...("tuna_positions" | "lending_positions" | "fusion_limit_orders")[]]>;
34
49
  declare const Mint$1: z.ZodObject<{
35
50
  symbol: z.ZodString;
36
51
  mint: z.ZodString;
@@ -746,6 +761,7 @@ declare const TunaPosition$1: z.ZodObject<{
746
761
  }>;
747
762
  openedAt: z.ZodDate;
748
763
  updatedAtSlot: z.ZodBigInt;
764
+ closedAt: z.ZodNullable<z.ZodDate>;
749
765
  }, "strip", z.ZodTypeAny, {
750
766
  address: string;
751
767
  liquidity: bigint;
@@ -833,6 +849,7 @@ declare const TunaPosition$1: z.ZodObject<{
833
849
  };
834
850
  openedAt: Date;
835
851
  updatedAtSlot: bigint;
852
+ closedAt: Date | null;
836
853
  }, {
837
854
  address: string;
838
855
  liquidity: bigint;
@@ -920,6 +937,7 @@ declare const TunaPosition$1: z.ZodObject<{
920
937
  };
921
938
  openedAt: Date;
922
939
  updatedAtSlot: bigint;
940
+ closedAt: Date | null;
923
941
  }>;
924
942
  declare const PoolSwap$1: z.ZodObject<{
925
943
  id: z.ZodString;
@@ -1096,6 +1114,7 @@ declare const LimitOrder$1: z.ZodObject<{
1096
1114
  state: "open" | "partially_filled" | "filled" | "complete" | "cancelled";
1097
1115
  pool: string;
1098
1116
  openedAt: Date;
1117
+ closedAt: Date | null;
1099
1118
  amountIn: {
1100
1119
  amount: bigint;
1101
1120
  usd: number;
@@ -1109,13 +1128,13 @@ declare const LimitOrder$1: z.ZodObject<{
1109
1128
  fillRatio: number;
1110
1129
  openTxSignature: string;
1111
1130
  closeTxSignature: string | null;
1112
- closedAt: Date | null;
1113
1131
  }, {
1114
1132
  mint: string;
1115
1133
  address: string;
1116
1134
  state: "open" | "partially_filled" | "filled" | "complete" | "cancelled";
1117
1135
  pool: string;
1118
1136
  openedAt: Date;
1137
+ closedAt: Date | null;
1119
1138
  amountIn: {
1120
1139
  amount: bigint;
1121
1140
  usd: number;
@@ -1129,7 +1148,6 @@ declare const LimitOrder$1: z.ZodObject<{
1129
1148
  fillRatio: number;
1130
1149
  openTxSignature: string;
1131
1150
  closeTxSignature: string | null;
1132
- closedAt: Date | null;
1133
1151
  }>;
1134
1152
  declare const PoolPriceCandle$1: z.ZodObject<{
1135
1153
  time: z.ZodNumber;
@@ -1150,6 +1168,13 @@ declare const PoolPriceCandle$1: z.ZodObject<{
1150
1168
  high: number;
1151
1169
  low: number;
1152
1170
  }>;
1171
+ declare const UpdateStreamSubscriptionResult: z.ZodObject<{
1172
+ status: z.ZodString;
1173
+ }, "strip", z.ZodTypeAny, {
1174
+ status: string;
1175
+ }, {
1176
+ status: string;
1177
+ }>;
1153
1178
  declare const OrderBookNotificationMeta: z.ZodObject<{
1154
1179
  pool: z.ZodString;
1155
1180
  priceStep: z.ZodNumber;
@@ -1165,7 +1190,7 @@ declare const OrderBookNotificationMeta: z.ZodObject<{
1165
1190
  }>;
1166
1191
  declare const PoolSwapNotification: z.ZodObject<{
1167
1192
  meta: z.ZodTypeAny;
1168
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1193
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1169
1194
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1170
1195
  data: z.ZodObject<{
1171
1196
  id: z.ZodString;
@@ -1193,7 +1218,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1193
1218
  authority: z.ZodNullable<z.ZodString>;
1194
1219
  } | {
1195
1220
  meta: z.ZodNullable<z.ZodUndefined>;
1196
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1221
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1197
1222
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1198
1223
  data: z.ZodObject<{
1199
1224
  id: z.ZodString;
@@ -1222,7 +1247,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1222
1247
  }, "strip", z.ZodTypeAny, {
1223
1248
  authority: string | null;
1224
1249
  id: string;
1225
- entity: "pool_swap" | "pool_price" | "order_book";
1250
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1226
1251
  action: "create" | "update";
1227
1252
  data: {
1228
1253
  time: Date;
@@ -1236,7 +1261,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1236
1261
  } | {
1237
1262
  authority: string | null;
1238
1263
  id: string;
1239
- entity: "pool_swap" | "pool_price" | "order_book";
1264
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1240
1265
  action: "create" | "update";
1241
1266
  data: {
1242
1267
  time: Date;
@@ -1250,7 +1275,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1250
1275
  }, {
1251
1276
  authority: string | null;
1252
1277
  id: string;
1253
- entity: "pool_swap" | "pool_price" | "order_book";
1278
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1254
1279
  action: "create" | "update";
1255
1280
  data: {
1256
1281
  time: Date;
@@ -1264,7 +1289,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1264
1289
  } | {
1265
1290
  authority: string | null;
1266
1291
  id: string;
1267
- entity: "pool_swap" | "pool_price" | "order_book";
1292
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1268
1293
  action: "create" | "update";
1269
1294
  data: {
1270
1295
  time: Date;
@@ -1278,7 +1303,7 @@ declare const PoolSwapNotification: z.ZodObject<{
1278
1303
  }>;
1279
1304
  declare const PoolPriceUpdateNotification: z.ZodObject<{
1280
1305
  meta: z.ZodTypeAny;
1281
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1306
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1282
1307
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1283
1308
  data: z.ZodObject<{
1284
1309
  pool: z.ZodString;
@@ -1300,7 +1325,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1300
1325
  authority: z.ZodNullable<z.ZodString>;
1301
1326
  } | {
1302
1327
  meta: z.ZodNullable<z.ZodUndefined>;
1303
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1328
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1304
1329
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1305
1330
  data: z.ZodObject<{
1306
1331
  pool: z.ZodString;
@@ -1323,7 +1348,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1323
1348
  }, "strip", z.ZodTypeAny, {
1324
1349
  authority: string | null;
1325
1350
  id: string;
1326
- entity: "pool_swap" | "pool_price" | "order_book";
1351
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1327
1352
  action: "create" | "update";
1328
1353
  data: {
1329
1354
  price: number;
@@ -1335,7 +1360,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1335
1360
  } | {
1336
1361
  authority: string | null;
1337
1362
  id: string;
1338
- entity: "pool_swap" | "pool_price" | "order_book";
1363
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1339
1364
  action: "create" | "update";
1340
1365
  data: {
1341
1366
  price: number;
@@ -1347,7 +1372,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1347
1372
  }, {
1348
1373
  authority: string | null;
1349
1374
  id: string;
1350
- entity: "pool_swap" | "pool_price" | "order_book";
1375
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1351
1376
  action: "create" | "update";
1352
1377
  data: {
1353
1378
  price: number;
@@ -1359,7 +1384,7 @@ declare const PoolPriceUpdateNotification: z.ZodObject<{
1359
1384
  } | {
1360
1385
  authority: string | null;
1361
1386
  id: string;
1362
- entity: "pool_swap" | "pool_price" | "order_book";
1387
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1363
1388
  action: "create" | "update";
1364
1389
  data: {
1365
1390
  price: number;
@@ -1383,7 +1408,7 @@ declare const OrderBookNotification: z.ZodObject<{
1383
1408
  priceStep: number;
1384
1409
  inverted: boolean;
1385
1410
  }>;
1386
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1411
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1387
1412
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1388
1413
  data: z.ZodObject<{
1389
1414
  entries: z.ZodArray<z.ZodObject<{
@@ -1454,7 +1479,7 @@ declare const OrderBookNotification: z.ZodObject<{
1454
1479
  authority: z.ZodNullable<z.ZodString>;
1455
1480
  } | {
1456
1481
  meta: z.ZodNullable<z.ZodUndefined>;
1457
- entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book")[]]>;
1482
+ entity: z.ZodEnum<["pool_swap", ...("pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order")[]]>;
1458
1483
  action: z.ZodEnum<["create", ...("create" | "update")[]]>;
1459
1484
  data: z.ZodObject<{
1460
1485
  entries: z.ZodArray<z.ZodObject<{
@@ -1526,7 +1551,7 @@ declare const OrderBookNotification: z.ZodObject<{
1526
1551
  }, "strip", z.ZodTypeAny, {
1527
1552
  authority: string | null;
1528
1553
  id: string;
1529
- entity: "pool_swap" | "pool_price" | "order_book";
1554
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1530
1555
  action: "create" | "update";
1531
1556
  data: {
1532
1557
  entries: {
@@ -1551,7 +1576,7 @@ declare const OrderBookNotification: z.ZodObject<{
1551
1576
  } | {
1552
1577
  authority: string | null;
1553
1578
  id: string;
1554
- entity: "pool_swap" | "pool_price" | "order_book";
1579
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1555
1580
  action: "create" | "update";
1556
1581
  data: {
1557
1582
  entries: {
@@ -1576,7 +1601,7 @@ declare const OrderBookNotification: z.ZodObject<{
1576
1601
  }, {
1577
1602
  authority: string | null;
1578
1603
  id: string;
1579
- entity: "pool_swap" | "pool_price" | "order_book";
1604
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1580
1605
  action: "create" | "update";
1581
1606
  data: {
1582
1607
  entries: {
@@ -1601,7 +1626,7 @@ declare const OrderBookNotification: z.ZodObject<{
1601
1626
  } | {
1602
1627
  authority: string | null;
1603
1628
  id: string;
1604
- entity: "pool_swap" | "pool_price" | "order_book";
1629
+ entity: "pool_swap" | "pool_price" | "order_book" | "tuna_position" | "lending_position" | "fusion_limit_order";
1605
1630
  action: "create" | "update";
1606
1631
  data: {
1607
1632
  entries: {
@@ -1636,16 +1661,23 @@ declare const schemas_OrderBookNotificationMeta: typeof OrderBookNotificationMet
1636
1661
  declare const schemas_PoolPriceUpdateNotification: typeof PoolPriceUpdateNotification;
1637
1662
  declare const schemas_PoolProvider: typeof PoolProvider;
1638
1663
  declare const schemas_PoolProviderSchema: typeof PoolProviderSchema;
1664
+ declare const schemas_PoolSubscriptionTopic: typeof PoolSubscriptionTopic;
1665
+ declare const schemas_PoolSubscriptionTopicSchema: typeof PoolSubscriptionTopicSchema;
1639
1666
  declare const schemas_PoolSwapNotification: typeof PoolSwapNotification;
1640
1667
  declare const schemas_TunaPositionState: typeof TunaPositionState;
1641
1668
  declare const schemas_TunaPositionStateSchema: typeof TunaPositionStateSchema;
1669
+ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscriptionResult;
1670
+ declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
1671
+ declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
1642
1672
  declare namespace schemas {
1643
- export { LendingPosition$1 as LendingPosition, LimitOrder$1 as LimitOrder, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, TunaPosition$1 as TunaPosition, schemas_TunaPositionState as TunaPositionState, schemas_TunaPositionStateSchema as TunaPositionStateSchema, Vault$1 as Vault };
1673
+ export { LendingPosition$1 as LendingPosition, LimitOrder$1 as LimitOrder, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, schemas_PoolSubscriptionTopic as PoolSubscriptionTopic, schemas_PoolSubscriptionTopicSchema as PoolSubscriptionTopicSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, TunaPosition$1 as TunaPosition, schemas_TunaPositionState as TunaPositionState, schemas_TunaPositionStateSchema as TunaPositionStateSchema, schemas_UpdateStreamSubscriptionResult as UpdateStreamSubscriptionResult, Vault$1 as Vault, schemas_WalletSubscriptionTopic as WalletSubscriptionTopic, schemas_WalletSubscriptionTopicSchema as WalletSubscriptionTopicSchema };
1644
1674
  }
1645
1675
 
1646
1676
  type PoolProviderType = z.infer<typeof PoolProviderSchema>;
1647
1677
  type TunaPositionStateType = z.infer<typeof TunaPositionStateSchema>;
1648
1678
  type LimitOrderStateType = z.infer<typeof LimitOrderStateSchema>;
1679
+ type PoolSubscriptionTopicType = z.infer<typeof PoolSubscriptionTopicSchema>;
1680
+ type WalletSubscriptionTopicType = z.infer<typeof WalletSubscriptionTopicSchema>;
1649
1681
  type Mint = z.infer<typeof Mint$1>;
1650
1682
  type Market = z.infer<typeof Market$1>;
1651
1683
  type TokenOraclePrice = z.infer<typeof TokenOraclePrice$1>;
@@ -1661,6 +1693,18 @@ type TunaPosition = z.infer<typeof TunaPosition$1>;
1661
1693
  type LimitOrder = z.infer<typeof LimitOrder$1>;
1662
1694
  type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
1663
1695
  type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
1696
+ type SubscriptionPayload = {
1697
+ pools?: {
1698
+ address: string;
1699
+ topics: PoolSubscriptionTopicType[];
1700
+ orderBookPriceStep?: number;
1701
+ isInverted?: boolean;
1702
+ }[];
1703
+ wallet?: {
1704
+ address: string;
1705
+ topics: WalletSubscriptionTopicType[];
1706
+ };
1707
+ };
1664
1708
  type DurationInMs = number;
1665
1709
  declare enum ProviderFilter {
1666
1710
  ORCA = "orca",
@@ -1722,9 +1766,14 @@ declare class TunaApiClient {
1722
1766
  getUserTunaPositionByAddress(userAddress: string, tunaPositionAddress: string): Promise<TunaPosition>;
1723
1767
  getUserLimitOrders(userAddress: string, poolFilter?: string): Promise<LimitOrder[]>;
1724
1768
  getUserLimitOrderByAddress(userAddress: string, limitOrderAddress: string): Promise<LimitOrder>;
1769
+ /**
1770
+ * @deprecated Use getUpdatesStream instead
1771
+ */
1725
1772
  getPoolUpdatesStream(poolAddress: string, priceStep?: number, inverted?: boolean): Promise<EventSource>;
1773
+ getUpdatesStream(): Promise<EventSource>;
1774
+ updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
1726
1775
  private buildURL;
1727
1776
  private appendUrlSearchParams;
1728
1777
  }
1729
1778
 
1730
- export { type DurationInMs, type GetPoolPriceCandlesOptions, type LendingPosition, type LimitOrder, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSwap, type PoolTicks, ProviderFilter, type Tick, type TokenOraclePrice, TunaApiClient, type TunaApiClientConfig, type TunaPosition, TunaPositionState, type TunaPositionStateType, type Vault, schemas };
1779
+ export { type DurationInMs, type GetPoolPriceCandlesOptions, type LendingPosition, type LimitOrder, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSubscriptionTopicType, type PoolSwap, type PoolTicks, ProviderFilter, type SubscriptionPayload, type Tick, type TokenOraclePrice, TunaApiClient, type TunaApiClientConfig, type TunaPosition, TunaPositionState, type TunaPositionStateType, type Vault, type WalletSubscriptionTopicType, schemas };
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ module.exports = __toCommonJS(index_exports);
41
41
 
42
42
  // src/client/client.ts
43
43
  var import_camelcase_keys = __toESM(require("camelcase-keys"));
44
+ var import_snakecase_keys = __toESM(require("snakecase-keys"));
44
45
 
45
46
  // src/client/schemas.ts
46
47
  var schemas_exports = {};
@@ -65,6 +66,8 @@ __export(schemas_exports, {
65
66
  PoolPriceUpdateNotification: () => PoolPriceUpdateNotification,
66
67
  PoolProvider: () => PoolProvider,
67
68
  PoolProviderSchema: () => PoolProviderSchema,
69
+ PoolSubscriptionTopic: () => PoolSubscriptionTopic,
70
+ PoolSubscriptionTopicSchema: () => PoolSubscriptionTopicSchema,
68
71
  PoolSwap: () => PoolSwap,
69
72
  PoolSwapNotification: () => PoolSwapNotification,
70
73
  PoolTicks: () => PoolTicks,
@@ -73,7 +76,10 @@ __export(schemas_exports, {
73
76
  TunaPosition: () => TunaPosition,
74
77
  TunaPositionState: () => TunaPositionState,
75
78
  TunaPositionStateSchema: () => TunaPositionStateSchema,
76
- Vault: () => Vault
79
+ UpdateStreamSubscriptionResult: () => UpdateStreamSubscriptionResult,
80
+ Vault: () => Vault,
81
+ WalletSubscriptionTopic: () => WalletSubscriptionTopic,
82
+ WalletSubscriptionTopicSchema: () => WalletSubscriptionTopicSchema
77
83
  });
78
84
  var import_zod = require("zod");
79
85
  var amountWithoutUsd = import_zod.z.object({
@@ -94,7 +100,10 @@ var usdPnl = import_zod.z.object({
94
100
  var NotificationEntity = {
95
101
  POOL_SWAP: "pool_swap",
96
102
  POOL_PRICE: "pool_price",
97
- ORDER_BOOK: "order_book"
103
+ ORDER_BOOK: "order_book",
104
+ TUNA_POSITION: "tuna_position",
105
+ LENDING_POSITION: "lending_position",
106
+ FUSION_LIMIT_ORDER: "fusion_limit_order"
98
107
  };
99
108
  var NotificationAction = {
100
109
  CREATE: "create",
@@ -117,11 +126,29 @@ var LimitOrderState = {
117
126
  COMPLETE: "complete",
118
127
  CANCELLED: "cancelled"
119
128
  };
129
+ var PoolSubscriptionTopic = {
130
+ ORDER_BOOK: "order_book",
131
+ POOL_PRICES: "pool_prices",
132
+ POOL_SWAPS: "pool_swaps"
133
+ };
134
+ var WalletSubscriptionTopic = {
135
+ TUNA_POSITIONS: "tuna_positions",
136
+ LENDING_POSITIONS: "lending_positions",
137
+ FUSION_LIMIT_ORDERS: "fusion_limit_orders"
138
+ };
120
139
  var NotificationEntitySchema = import_zod.z.enum([NotificationEntity.POOL_SWAP, ...Object.values(NotificationEntity)]);
121
140
  var NotificationActionSchema = import_zod.z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
122
141
  var PoolProviderSchema = import_zod.z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
123
142
  var TunaPositionStateSchema = import_zod.z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
124
143
  var LimitOrderStateSchema = import_zod.z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
144
+ var PoolSubscriptionTopicSchema = import_zod.z.enum([
145
+ PoolSubscriptionTopic.ORDER_BOOK,
146
+ ...Object.values(PoolSubscriptionTopic)
147
+ ]);
148
+ var WalletSubscriptionTopicSchema = import_zod.z.enum([
149
+ WalletSubscriptionTopic.TUNA_POSITIONS,
150
+ ...Object.values(WalletSubscriptionTopic)
151
+ ]);
125
152
  var Mint = import_zod.z.object({
126
153
  symbol: import_zod.z.string(),
127
154
  mint: import_zod.z.string(),
@@ -257,7 +284,8 @@ var TunaPosition = import_zod.z.object({
257
284
  pnlB: tokensPnl,
258
285
  pnlUsd: usdPnl,
259
286
  openedAt: import_zod.z.coerce.date(),
260
- updatedAtSlot: import_zod.z.coerce.bigint()
287
+ updatedAtSlot: import_zod.z.coerce.bigint(),
288
+ closedAt: import_zod.z.nullable(import_zod.z.coerce.date())
261
289
  });
262
290
  var PoolSwap = import_zod.z.object({
263
291
  id: import_zod.z.string(),
@@ -298,11 +326,11 @@ var LimitOrder = import_zod.z.object({
298
326
  tickIndex: import_zod.z.number(),
299
327
  fillRatio: import_zod.z.number(),
300
328
  openTxSignature: import_zod.z.string(),
301
- closeTxSignature: import_zod.z.string().nullable(),
329
+ closeTxSignature: import_zod.z.nullable(import_zod.z.string()),
302
330
  amountIn: amountWithUsd,
303
331
  amountOut: amountWithUsd,
304
332
  openedAt: import_zod.z.coerce.date(),
305
- closedAt: import_zod.z.coerce.date().nullable()
333
+ closedAt: import_zod.z.nullable(import_zod.z.coerce.date())
306
334
  });
307
335
  var PoolPriceCandle = import_zod.z.object({
308
336
  time: import_zod.z.number(),
@@ -311,6 +339,9 @@ var PoolPriceCandle = import_zod.z.object({
311
339
  high: import_zod.z.number(),
312
340
  low: import_zod.z.number()
313
341
  });
342
+ var UpdateStreamSubscriptionResult = import_zod.z.object({
343
+ status: import_zod.z.string()
344
+ });
314
345
  var createNotificationSchema = (dataSchema, metaSchema) => import_zod.z.object({
315
346
  entity: NotificationEntitySchema,
316
347
  action: NotificationActionSchema,
@@ -374,7 +405,7 @@ var TunaApiClient = class {
374
405
  const response = await fetch(url, {
375
406
  ...options,
376
407
  signal,
377
- headers: { ...this.headers, ...options?.headers }
408
+ headers: { "Content-Type": "application/json", ...this.headers, ...options?.headers }
378
409
  });
379
410
  clearTimeout(abort);
380
411
  if (!response.ok) {
@@ -490,6 +521,9 @@ var TunaApiClient = class {
490
521
  const url = this.buildURL(`users/${userAddress}/limit-orders/${limitOrderAddress}`);
491
522
  return await this.httpRequest(url.toString(), LimitOrder);
492
523
  }
524
+ /**
525
+ * @deprecated Use getUpdatesStream instead
526
+ */
493
527
  async getPoolUpdatesStream(poolAddress, priceStep, inverted) {
494
528
  const url = this.buildURL(`stream`);
495
529
  this.appendUrlSearchParams(url, { pool: poolAddress });
@@ -501,6 +535,15 @@ var TunaApiClient = class {
501
535
  }
502
536
  return new EventSource(url.toString());
503
537
  }
538
+ async getUpdatesStream() {
539
+ const url = this.buildURL(`streams/sse`);
540
+ return new EventSource(url.toString());
541
+ }
542
+ async updateStreamSubscription(streamId, subscription) {
543
+ const url = this.buildURL(`streams/${streamId}/subscription`);
544
+ const body = JSON.stringify((0, import_snakecase_keys.default)(subscription, { deep: true }));
545
+ return await this.httpRequest(url.toString(), UpdateStreamSubscriptionResult, { method: "PUT", body });
546
+ }
504
547
  /* Utility functions */
505
548
  buildURL(endpoint) {
506
549
  return new URL(
package/dist/index.mjs CHANGED
@@ -6,6 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/client/client.ts
8
8
  import camelcaseKeys from "camelcase-keys";
9
+ import snakecaseKeys from "snakecase-keys";
9
10
 
10
11
  // src/client/schemas.ts
11
12
  var schemas_exports = {};
@@ -30,6 +31,8 @@ __export(schemas_exports, {
30
31
  PoolPriceUpdateNotification: () => PoolPriceUpdateNotification,
31
32
  PoolProvider: () => PoolProvider,
32
33
  PoolProviderSchema: () => PoolProviderSchema,
34
+ PoolSubscriptionTopic: () => PoolSubscriptionTopic,
35
+ PoolSubscriptionTopicSchema: () => PoolSubscriptionTopicSchema,
33
36
  PoolSwap: () => PoolSwap,
34
37
  PoolSwapNotification: () => PoolSwapNotification,
35
38
  PoolTicks: () => PoolTicks,
@@ -38,7 +41,10 @@ __export(schemas_exports, {
38
41
  TunaPosition: () => TunaPosition,
39
42
  TunaPositionState: () => TunaPositionState,
40
43
  TunaPositionStateSchema: () => TunaPositionStateSchema,
41
- Vault: () => Vault
44
+ UpdateStreamSubscriptionResult: () => UpdateStreamSubscriptionResult,
45
+ Vault: () => Vault,
46
+ WalletSubscriptionTopic: () => WalletSubscriptionTopic,
47
+ WalletSubscriptionTopicSchema: () => WalletSubscriptionTopicSchema
42
48
  });
43
49
  import { z } from "zod";
44
50
  var amountWithoutUsd = z.object({
@@ -59,7 +65,10 @@ var usdPnl = z.object({
59
65
  var NotificationEntity = {
60
66
  POOL_SWAP: "pool_swap",
61
67
  POOL_PRICE: "pool_price",
62
- ORDER_BOOK: "order_book"
68
+ ORDER_BOOK: "order_book",
69
+ TUNA_POSITION: "tuna_position",
70
+ LENDING_POSITION: "lending_position",
71
+ FUSION_LIMIT_ORDER: "fusion_limit_order"
63
72
  };
64
73
  var NotificationAction = {
65
74
  CREATE: "create",
@@ -82,11 +91,29 @@ var LimitOrderState = {
82
91
  COMPLETE: "complete",
83
92
  CANCELLED: "cancelled"
84
93
  };
94
+ var PoolSubscriptionTopic = {
95
+ ORDER_BOOK: "order_book",
96
+ POOL_PRICES: "pool_prices",
97
+ POOL_SWAPS: "pool_swaps"
98
+ };
99
+ var WalletSubscriptionTopic = {
100
+ TUNA_POSITIONS: "tuna_positions",
101
+ LENDING_POSITIONS: "lending_positions",
102
+ FUSION_LIMIT_ORDERS: "fusion_limit_orders"
103
+ };
85
104
  var NotificationEntitySchema = z.enum([NotificationEntity.POOL_SWAP, ...Object.values(NotificationEntity)]);
86
105
  var NotificationActionSchema = z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
87
106
  var PoolProviderSchema = z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
88
107
  var TunaPositionStateSchema = z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
89
108
  var LimitOrderStateSchema = z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
109
+ var PoolSubscriptionTopicSchema = z.enum([
110
+ PoolSubscriptionTopic.ORDER_BOOK,
111
+ ...Object.values(PoolSubscriptionTopic)
112
+ ]);
113
+ var WalletSubscriptionTopicSchema = z.enum([
114
+ WalletSubscriptionTopic.TUNA_POSITIONS,
115
+ ...Object.values(WalletSubscriptionTopic)
116
+ ]);
90
117
  var Mint = z.object({
91
118
  symbol: z.string(),
92
119
  mint: z.string(),
@@ -222,7 +249,8 @@ var TunaPosition = z.object({
222
249
  pnlB: tokensPnl,
223
250
  pnlUsd: usdPnl,
224
251
  openedAt: z.coerce.date(),
225
- updatedAtSlot: z.coerce.bigint()
252
+ updatedAtSlot: z.coerce.bigint(),
253
+ closedAt: z.nullable(z.coerce.date())
226
254
  });
227
255
  var PoolSwap = z.object({
228
256
  id: z.string(),
@@ -263,11 +291,11 @@ var LimitOrder = z.object({
263
291
  tickIndex: z.number(),
264
292
  fillRatio: z.number(),
265
293
  openTxSignature: z.string(),
266
- closeTxSignature: z.string().nullable(),
294
+ closeTxSignature: z.nullable(z.string()),
267
295
  amountIn: amountWithUsd,
268
296
  amountOut: amountWithUsd,
269
297
  openedAt: z.coerce.date(),
270
- closedAt: z.coerce.date().nullable()
298
+ closedAt: z.nullable(z.coerce.date())
271
299
  });
272
300
  var PoolPriceCandle = z.object({
273
301
  time: z.number(),
@@ -276,6 +304,9 @@ var PoolPriceCandle = z.object({
276
304
  high: z.number(),
277
305
  low: z.number()
278
306
  });
307
+ var UpdateStreamSubscriptionResult = z.object({
308
+ status: z.string()
309
+ });
279
310
  var createNotificationSchema = (dataSchema, metaSchema) => z.object({
280
311
  entity: NotificationEntitySchema,
281
312
  action: NotificationActionSchema,
@@ -339,7 +370,7 @@ var TunaApiClient = class {
339
370
  const response = await fetch(url, {
340
371
  ...options,
341
372
  signal,
342
- headers: { ...this.headers, ...options?.headers }
373
+ headers: { "Content-Type": "application/json", ...this.headers, ...options?.headers }
343
374
  });
344
375
  clearTimeout(abort);
345
376
  if (!response.ok) {
@@ -455,6 +486,9 @@ var TunaApiClient = class {
455
486
  const url = this.buildURL(`users/${userAddress}/limit-orders/${limitOrderAddress}`);
456
487
  return await this.httpRequest(url.toString(), LimitOrder);
457
488
  }
489
+ /**
490
+ * @deprecated Use getUpdatesStream instead
491
+ */
458
492
  async getPoolUpdatesStream(poolAddress, priceStep, inverted) {
459
493
  const url = this.buildURL(`stream`);
460
494
  this.appendUrlSearchParams(url, { pool: poolAddress });
@@ -466,6 +500,15 @@ var TunaApiClient = class {
466
500
  }
467
501
  return new EventSource(url.toString());
468
502
  }
503
+ async getUpdatesStream() {
504
+ const url = this.buildURL(`streams/sse`);
505
+ return new EventSource(url.toString());
506
+ }
507
+ async updateStreamSubscription(streamId, subscription) {
508
+ const url = this.buildURL(`streams/${streamId}/subscription`);
509
+ const body = JSON.stringify(snakecaseKeys(subscription, { deep: true }));
510
+ return await this.httpRequest(url.toString(), UpdateStreamSubscriptionResult, { method: "PUT", body });
511
+ }
469
512
  /* Utility functions */
470
513
  buildURL(endpoint) {
471
514
  return new URL(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crypticdot/defituna-api",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -32,6 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "camelcase-keys": "^9.1.3",
35
+ "snakecase-keys": "^8.0.1",
35
36
  "zod": "^3.24.1"
36
37
  },
37
38
  "scripts": {