@crypticdot/defituna-api 1.3.9 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +573 -58
- package/dist/index.d.ts +573 -58
- package/dist/index.js +92 -3
- package/dist/index.mjs +92 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -63,6 +63,14 @@ __export(schemas_exports, {
|
|
|
63
63
|
OrderBookEntry: () => OrderBookEntry,
|
|
64
64
|
OrderBookNotification: () => OrderBookNotification,
|
|
65
65
|
OrderBookNotificationMeta: () => OrderBookNotificationMeta,
|
|
66
|
+
OrderHistoryEntry: () => OrderHistoryEntry,
|
|
67
|
+
OrderHistoryEntryNotification: () => OrderHistoryEntryNotification,
|
|
68
|
+
OrderHistoryOrderType: () => OrderHistoryOrderType,
|
|
69
|
+
OrderHistoryOrderTypeSchema: () => OrderHistoryOrderTypeSchema,
|
|
70
|
+
OrderHistoryStatus: () => OrderHistoryStatus,
|
|
71
|
+
OrderHistoryStatusSchema: () => OrderHistoryStatusSchema,
|
|
72
|
+
OrderHistoryUIDirection: () => OrderHistoryUIDirection,
|
|
73
|
+
OrderHistoryUIDirectionSchema: () => OrderHistoryUIDirectionSchema,
|
|
66
74
|
PaginationMeta: () => PaginationMeta,
|
|
67
75
|
Pool: () => Pool,
|
|
68
76
|
PoolPriceCandle: () => PoolPriceCandle,
|
|
@@ -131,7 +139,8 @@ var NotificationEntity = {
|
|
|
131
139
|
LENDING_POSITION: "lending_position",
|
|
132
140
|
STAKING_POSITION: "staking_position",
|
|
133
141
|
FUSION_LIMIT_ORDER: "fusion_limit_order",
|
|
134
|
-
TRADE_HISTORY_ENTRY: "trade_history_entry"
|
|
142
|
+
TRADE_HISTORY_ENTRY: "trade_history_entry",
|
|
143
|
+
ORDER_HISTORY_ENTRY: "order_history_entry"
|
|
135
144
|
};
|
|
136
145
|
var NotificationAction = {
|
|
137
146
|
CREATE: "create",
|
|
@@ -175,6 +184,27 @@ var TradeHistoryUIDirection = {
|
|
|
175
184
|
OPEN_SHORT: "open_short",
|
|
176
185
|
CLOSE_SHORT: "close_short"
|
|
177
186
|
};
|
|
187
|
+
var OrderHistoryOrderType = {
|
|
188
|
+
MARKET: "market",
|
|
189
|
+
LIMIT: "limit",
|
|
190
|
+
TAKE_PROFIT_MARKET: "take_profit_market",
|
|
191
|
+
STOP_LOSS_MARKET: "stop_loss_market",
|
|
192
|
+
LIQUIDATION_MARKET: "liquidation_market"
|
|
193
|
+
};
|
|
194
|
+
var OrderHistoryStatus = {
|
|
195
|
+
OPEN: "open",
|
|
196
|
+
PARTIALLY_FILLED: "partially_filled",
|
|
197
|
+
FILLED: "filled",
|
|
198
|
+
CANCELLED: "cancelled",
|
|
199
|
+
CLAIMED: "claimed",
|
|
200
|
+
REJECTED: "rejected"
|
|
201
|
+
};
|
|
202
|
+
var OrderHistoryUIDirection = {
|
|
203
|
+
BUY: "buy",
|
|
204
|
+
SELL: "sell",
|
|
205
|
+
LONG: "long",
|
|
206
|
+
SHORT: "short"
|
|
207
|
+
};
|
|
178
208
|
var StakingPositionHistoryActionType = {
|
|
179
209
|
STAKE: "stake",
|
|
180
210
|
UNSTAKE: "unstake",
|
|
@@ -193,7 +223,8 @@ var WalletSubscriptionTopic = {
|
|
|
193
223
|
LENDING_POSITIONS: "lending_positions",
|
|
194
224
|
FUSION_LIMIT_ORDERS: "fusion_limit_orders",
|
|
195
225
|
STAKING_POSITION: "staking_position",
|
|
196
|
-
TRADE_HISTORY: "trade_history"
|
|
226
|
+
TRADE_HISTORY: "trade_history",
|
|
227
|
+
ORDER_HISTORY: "order_history"
|
|
197
228
|
};
|
|
198
229
|
var NotificationEntitySchema = import_zod.z.enum([NotificationEntity.POOL_SWAP, ...Object.values(NotificationEntity)]);
|
|
199
230
|
var NotificationActionSchema = import_zod.z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
|
|
@@ -209,6 +240,15 @@ var TradeHistoryUIDirectionSchema = import_zod.z.enum([
|
|
|
209
240
|
TradeHistoryUIDirection.BUY,
|
|
210
241
|
...Object.values(TradeHistoryUIDirection)
|
|
211
242
|
]);
|
|
243
|
+
var OrderHistoryOrderTypeSchema = import_zod.z.enum([
|
|
244
|
+
OrderHistoryOrderType.MARKET,
|
|
245
|
+
...Object.values(OrderHistoryOrderType)
|
|
246
|
+
]);
|
|
247
|
+
var OrderHistoryStatusSchema = import_zod.z.enum([OrderHistoryStatus.OPEN, ...Object.values(OrderHistoryStatus)]);
|
|
248
|
+
var OrderHistoryUIDirectionSchema = import_zod.z.enum([
|
|
249
|
+
OrderHistoryUIDirection.BUY,
|
|
250
|
+
...Object.values(OrderHistoryUIDirection)
|
|
251
|
+
]);
|
|
212
252
|
var StakingPositionHistoryActionTypeSchema = import_zod.z.enum([
|
|
213
253
|
StakingPositionHistoryActionType.STAKE,
|
|
214
254
|
...Object.values(StakingPositionHistoryActionType)
|
|
@@ -245,13 +285,16 @@ var Market = import_zod.z.object({
|
|
|
245
285
|
liquidationThreshold: import_zod.z.number(),
|
|
246
286
|
oraclePriceDeviationThreshold: import_zod.z.number(),
|
|
247
287
|
limitOrderExecutionFee: import_zod.z.number(),
|
|
288
|
+
maxSpotPositionSizeA: amountWithUsd,
|
|
289
|
+
maxSpotPositionSizeB: amountWithUsd,
|
|
248
290
|
borrowedFundsA: amountWithUsd,
|
|
249
291
|
borrowedFundsB: amountWithUsd,
|
|
250
292
|
availableBorrowA: amountWithUsd,
|
|
251
293
|
availableBorrowB: amountWithUsd,
|
|
252
294
|
borrowLimitA: amountWithUsd,
|
|
253
295
|
borrowLimitB: amountWithUsd,
|
|
254
|
-
disabled: import_zod.z.boolean()
|
|
296
|
+
disabled: import_zod.z.boolean(),
|
|
297
|
+
createdAt: import_zod.z.coerce.date()
|
|
255
298
|
});
|
|
256
299
|
var TokenOraclePrice = import_zod.z.object({
|
|
257
300
|
mint: import_zod.z.string(),
|
|
@@ -481,6 +524,29 @@ var TradeHistoryEntry = import_zod.z.object({
|
|
|
481
524
|
slot: import_zod.z.coerce.bigint(),
|
|
482
525
|
ts: import_zod.z.coerce.date()
|
|
483
526
|
});
|
|
527
|
+
var OrderHistoryEntry = import_zod.z.object({
|
|
528
|
+
// Internal entry ID
|
|
529
|
+
id: import_zod.z.string(),
|
|
530
|
+
pool: import_zod.z.string(),
|
|
531
|
+
authority: import_zod.z.string(),
|
|
532
|
+
orderType: OrderHistoryOrderTypeSchema,
|
|
533
|
+
isReduceOnly: import_zod.z.nullable(import_zod.z.boolean()),
|
|
534
|
+
uiTakeProfitPrice: import_zod.z.nullable(import_zod.z.number()),
|
|
535
|
+
uiStopLossPrice: import_zod.z.nullable(import_zod.z.number()),
|
|
536
|
+
aToB: import_zod.z.boolean(),
|
|
537
|
+
uiDirection: OrderHistoryUIDirectionSchema,
|
|
538
|
+
uiPrice: import_zod.z.nullable(import_zod.z.number()),
|
|
539
|
+
uiExecutionPrice: import_zod.z.nullable(import_zod.z.number()),
|
|
540
|
+
status: OrderHistoryStatusSchema,
|
|
541
|
+
baseToken: amountWithUsd,
|
|
542
|
+
quoteToken: amountWithUsd,
|
|
543
|
+
baseTokenConsumedAmount: import_zod.z.nullable(import_zod.z.coerce.bigint()),
|
|
544
|
+
quoteTokenFilledAmount: import_zod.z.nullable(import_zod.z.coerce.bigint()),
|
|
545
|
+
txSignature: import_zod.z.nullable(import_zod.z.string()),
|
|
546
|
+
positionAddress: import_zod.z.nullable(import_zod.z.string()),
|
|
547
|
+
slot: import_zod.z.coerce.bigint(),
|
|
548
|
+
ts: import_zod.z.coerce.date()
|
|
549
|
+
});
|
|
484
550
|
var StakingTreasury = import_zod.z.object({
|
|
485
551
|
address: import_zod.z.string(),
|
|
486
552
|
stakedTokenMint: import_zod.z.string(),
|
|
@@ -600,6 +666,7 @@ var TunaSpotPositionNotification = createNotificationSchema(TunaSpotPosition);
|
|
|
600
666
|
var LendingPositionNotification = createNotificationSchema(LendingPosition);
|
|
601
667
|
var LimitOrderNotification = createNotificationSchema(LimitOrder);
|
|
602
668
|
var TradeHistoryEntryNotification = createNotificationSchema(TradeHistoryEntry);
|
|
669
|
+
var OrderHistoryEntryNotification = createNotificationSchema(OrderHistoryEntry);
|
|
603
670
|
var StakingPositionNotification = createNotificationSchema(StakingPosition);
|
|
604
671
|
|
|
605
672
|
// src/client/client.ts
|
|
@@ -842,6 +909,28 @@ var TunaApiClient = class {
|
|
|
842
909
|
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/trade-history`), query);
|
|
843
910
|
return await this.httpRequest(url, TradeHistoryEntry.array());
|
|
844
911
|
}
|
|
912
|
+
async getUserOrderHistory(userAddress, options) {
|
|
913
|
+
let query = {};
|
|
914
|
+
if (options) {
|
|
915
|
+
if (options.pool?.length) {
|
|
916
|
+
query.pool = options.pool.join(",");
|
|
917
|
+
}
|
|
918
|
+
if (options.orderType?.length) {
|
|
919
|
+
query.order_type = options.orderType.join(",");
|
|
920
|
+
}
|
|
921
|
+
if (options.limit) {
|
|
922
|
+
query.limit = options.limit;
|
|
923
|
+
}
|
|
924
|
+
if (options.cursor) {
|
|
925
|
+
query.cursor = options.cursor;
|
|
926
|
+
}
|
|
927
|
+
if (options.desc !== void 0) {
|
|
928
|
+
query.desc = options.desc;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/order-history`), query);
|
|
932
|
+
return await this.httpRequest(url, OrderHistoryEntry.array());
|
|
933
|
+
}
|
|
845
934
|
async getUserStakingPosition(userAddress) {
|
|
846
935
|
const url = this.buildURL(`users/${userAddress}/staking-position`);
|
|
847
936
|
return await this.httpRequest(url, StakingPosition);
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,14 @@ __export(schemas_exports, {
|
|
|
28
28
|
OrderBookEntry: () => OrderBookEntry,
|
|
29
29
|
OrderBookNotification: () => OrderBookNotification,
|
|
30
30
|
OrderBookNotificationMeta: () => OrderBookNotificationMeta,
|
|
31
|
+
OrderHistoryEntry: () => OrderHistoryEntry,
|
|
32
|
+
OrderHistoryEntryNotification: () => OrderHistoryEntryNotification,
|
|
33
|
+
OrderHistoryOrderType: () => OrderHistoryOrderType,
|
|
34
|
+
OrderHistoryOrderTypeSchema: () => OrderHistoryOrderTypeSchema,
|
|
35
|
+
OrderHistoryStatus: () => OrderHistoryStatus,
|
|
36
|
+
OrderHistoryStatusSchema: () => OrderHistoryStatusSchema,
|
|
37
|
+
OrderHistoryUIDirection: () => OrderHistoryUIDirection,
|
|
38
|
+
OrderHistoryUIDirectionSchema: () => OrderHistoryUIDirectionSchema,
|
|
31
39
|
PaginationMeta: () => PaginationMeta,
|
|
32
40
|
Pool: () => Pool,
|
|
33
41
|
PoolPriceCandle: () => PoolPriceCandle,
|
|
@@ -96,7 +104,8 @@ var NotificationEntity = {
|
|
|
96
104
|
LENDING_POSITION: "lending_position",
|
|
97
105
|
STAKING_POSITION: "staking_position",
|
|
98
106
|
FUSION_LIMIT_ORDER: "fusion_limit_order",
|
|
99
|
-
TRADE_HISTORY_ENTRY: "trade_history_entry"
|
|
107
|
+
TRADE_HISTORY_ENTRY: "trade_history_entry",
|
|
108
|
+
ORDER_HISTORY_ENTRY: "order_history_entry"
|
|
100
109
|
};
|
|
101
110
|
var NotificationAction = {
|
|
102
111
|
CREATE: "create",
|
|
@@ -140,6 +149,27 @@ var TradeHistoryUIDirection = {
|
|
|
140
149
|
OPEN_SHORT: "open_short",
|
|
141
150
|
CLOSE_SHORT: "close_short"
|
|
142
151
|
};
|
|
152
|
+
var OrderHistoryOrderType = {
|
|
153
|
+
MARKET: "market",
|
|
154
|
+
LIMIT: "limit",
|
|
155
|
+
TAKE_PROFIT_MARKET: "take_profit_market",
|
|
156
|
+
STOP_LOSS_MARKET: "stop_loss_market",
|
|
157
|
+
LIQUIDATION_MARKET: "liquidation_market"
|
|
158
|
+
};
|
|
159
|
+
var OrderHistoryStatus = {
|
|
160
|
+
OPEN: "open",
|
|
161
|
+
PARTIALLY_FILLED: "partially_filled",
|
|
162
|
+
FILLED: "filled",
|
|
163
|
+
CANCELLED: "cancelled",
|
|
164
|
+
CLAIMED: "claimed",
|
|
165
|
+
REJECTED: "rejected"
|
|
166
|
+
};
|
|
167
|
+
var OrderHistoryUIDirection = {
|
|
168
|
+
BUY: "buy",
|
|
169
|
+
SELL: "sell",
|
|
170
|
+
LONG: "long",
|
|
171
|
+
SHORT: "short"
|
|
172
|
+
};
|
|
143
173
|
var StakingPositionHistoryActionType = {
|
|
144
174
|
STAKE: "stake",
|
|
145
175
|
UNSTAKE: "unstake",
|
|
@@ -158,7 +188,8 @@ var WalletSubscriptionTopic = {
|
|
|
158
188
|
LENDING_POSITIONS: "lending_positions",
|
|
159
189
|
FUSION_LIMIT_ORDERS: "fusion_limit_orders",
|
|
160
190
|
STAKING_POSITION: "staking_position",
|
|
161
|
-
TRADE_HISTORY: "trade_history"
|
|
191
|
+
TRADE_HISTORY: "trade_history",
|
|
192
|
+
ORDER_HISTORY: "order_history"
|
|
162
193
|
};
|
|
163
194
|
var NotificationEntitySchema = z.enum([NotificationEntity.POOL_SWAP, ...Object.values(NotificationEntity)]);
|
|
164
195
|
var NotificationActionSchema = z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
|
|
@@ -174,6 +205,15 @@ var TradeHistoryUIDirectionSchema = z.enum([
|
|
|
174
205
|
TradeHistoryUIDirection.BUY,
|
|
175
206
|
...Object.values(TradeHistoryUIDirection)
|
|
176
207
|
]);
|
|
208
|
+
var OrderHistoryOrderTypeSchema = z.enum([
|
|
209
|
+
OrderHistoryOrderType.MARKET,
|
|
210
|
+
...Object.values(OrderHistoryOrderType)
|
|
211
|
+
]);
|
|
212
|
+
var OrderHistoryStatusSchema = z.enum([OrderHistoryStatus.OPEN, ...Object.values(OrderHistoryStatus)]);
|
|
213
|
+
var OrderHistoryUIDirectionSchema = z.enum([
|
|
214
|
+
OrderHistoryUIDirection.BUY,
|
|
215
|
+
...Object.values(OrderHistoryUIDirection)
|
|
216
|
+
]);
|
|
177
217
|
var StakingPositionHistoryActionTypeSchema = z.enum([
|
|
178
218
|
StakingPositionHistoryActionType.STAKE,
|
|
179
219
|
...Object.values(StakingPositionHistoryActionType)
|
|
@@ -210,13 +250,16 @@ var Market = z.object({
|
|
|
210
250
|
liquidationThreshold: z.number(),
|
|
211
251
|
oraclePriceDeviationThreshold: z.number(),
|
|
212
252
|
limitOrderExecutionFee: z.number(),
|
|
253
|
+
maxSpotPositionSizeA: amountWithUsd,
|
|
254
|
+
maxSpotPositionSizeB: amountWithUsd,
|
|
213
255
|
borrowedFundsA: amountWithUsd,
|
|
214
256
|
borrowedFundsB: amountWithUsd,
|
|
215
257
|
availableBorrowA: amountWithUsd,
|
|
216
258
|
availableBorrowB: amountWithUsd,
|
|
217
259
|
borrowLimitA: amountWithUsd,
|
|
218
260
|
borrowLimitB: amountWithUsd,
|
|
219
|
-
disabled: z.boolean()
|
|
261
|
+
disabled: z.boolean(),
|
|
262
|
+
createdAt: z.coerce.date()
|
|
220
263
|
});
|
|
221
264
|
var TokenOraclePrice = z.object({
|
|
222
265
|
mint: z.string(),
|
|
@@ -446,6 +489,29 @@ var TradeHistoryEntry = z.object({
|
|
|
446
489
|
slot: z.coerce.bigint(),
|
|
447
490
|
ts: z.coerce.date()
|
|
448
491
|
});
|
|
492
|
+
var OrderHistoryEntry = z.object({
|
|
493
|
+
// Internal entry ID
|
|
494
|
+
id: z.string(),
|
|
495
|
+
pool: z.string(),
|
|
496
|
+
authority: z.string(),
|
|
497
|
+
orderType: OrderHistoryOrderTypeSchema,
|
|
498
|
+
isReduceOnly: z.nullable(z.boolean()),
|
|
499
|
+
uiTakeProfitPrice: z.nullable(z.number()),
|
|
500
|
+
uiStopLossPrice: z.nullable(z.number()),
|
|
501
|
+
aToB: z.boolean(),
|
|
502
|
+
uiDirection: OrderHistoryUIDirectionSchema,
|
|
503
|
+
uiPrice: z.nullable(z.number()),
|
|
504
|
+
uiExecutionPrice: z.nullable(z.number()),
|
|
505
|
+
status: OrderHistoryStatusSchema,
|
|
506
|
+
baseToken: amountWithUsd,
|
|
507
|
+
quoteToken: amountWithUsd,
|
|
508
|
+
baseTokenConsumedAmount: z.nullable(z.coerce.bigint()),
|
|
509
|
+
quoteTokenFilledAmount: z.nullable(z.coerce.bigint()),
|
|
510
|
+
txSignature: z.nullable(z.string()),
|
|
511
|
+
positionAddress: z.nullable(z.string()),
|
|
512
|
+
slot: z.coerce.bigint(),
|
|
513
|
+
ts: z.coerce.date()
|
|
514
|
+
});
|
|
449
515
|
var StakingTreasury = z.object({
|
|
450
516
|
address: z.string(),
|
|
451
517
|
stakedTokenMint: z.string(),
|
|
@@ -565,6 +631,7 @@ var TunaSpotPositionNotification = createNotificationSchema(TunaSpotPosition);
|
|
|
565
631
|
var LendingPositionNotification = createNotificationSchema(LendingPosition);
|
|
566
632
|
var LimitOrderNotification = createNotificationSchema(LimitOrder);
|
|
567
633
|
var TradeHistoryEntryNotification = createNotificationSchema(TradeHistoryEntry);
|
|
634
|
+
var OrderHistoryEntryNotification = createNotificationSchema(OrderHistoryEntry);
|
|
568
635
|
var StakingPositionNotification = createNotificationSchema(StakingPosition);
|
|
569
636
|
|
|
570
637
|
// src/client/client.ts
|
|
@@ -807,6 +874,28 @@ var TunaApiClient = class {
|
|
|
807
874
|
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/trade-history`), query);
|
|
808
875
|
return await this.httpRequest(url, TradeHistoryEntry.array());
|
|
809
876
|
}
|
|
877
|
+
async getUserOrderHistory(userAddress, options) {
|
|
878
|
+
let query = {};
|
|
879
|
+
if (options) {
|
|
880
|
+
if (options.pool?.length) {
|
|
881
|
+
query.pool = options.pool.join(",");
|
|
882
|
+
}
|
|
883
|
+
if (options.orderType?.length) {
|
|
884
|
+
query.order_type = options.orderType.join(",");
|
|
885
|
+
}
|
|
886
|
+
if (options.limit) {
|
|
887
|
+
query.limit = options.limit;
|
|
888
|
+
}
|
|
889
|
+
if (options.cursor) {
|
|
890
|
+
query.cursor = options.cursor;
|
|
891
|
+
}
|
|
892
|
+
if (options.desc !== void 0) {
|
|
893
|
+
query.desc = options.desc;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/order-history`), query);
|
|
897
|
+
return await this.httpRequest(url, OrderHistoryEntry.array());
|
|
898
|
+
}
|
|
810
899
|
async getUserStakingPosition(userAddress) {
|
|
811
900
|
const url = this.buildURL(`users/${userAddress}/staking-position`);
|
|
812
901
|
return await this.httpRequest(url, StakingPosition);
|