@crypticdot/defituna-api 1.1.56 → 1.2.1
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 +688 -46
- package/dist/index.d.ts +688 -46
- package/dist/index.js +47 -0
- package/dist/index.mjs +47 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -90,6 +90,10 @@ __export(schemas_exports, {
|
|
|
90
90
|
TunaPositionNotification: () => TunaPositionNotification,
|
|
91
91
|
TunaPositionState: () => TunaPositionState,
|
|
92
92
|
TunaPositionStateSchema: () => TunaPositionStateSchema,
|
|
93
|
+
TunaSpotPosition: () => TunaSpotPosition,
|
|
94
|
+
TunaSpotPositionNotification: () => TunaSpotPositionNotification,
|
|
95
|
+
TunaSpotPositionState: () => TunaSpotPositionState,
|
|
96
|
+
TunaSpotPositionStateSchema: () => TunaSpotPositionStateSchema,
|
|
93
97
|
UpdateStreamSubscriptionResult: () => UpdateStreamSubscriptionResult,
|
|
94
98
|
Vault: () => Vault,
|
|
95
99
|
VaultHistoricalStats: () => VaultHistoricalStats,
|
|
@@ -117,6 +121,7 @@ var NotificationEntity = {
|
|
|
117
121
|
POOL_PRICE: "pool_price",
|
|
118
122
|
ORDER_BOOK: "order_book",
|
|
119
123
|
TUNA_POSITION: "tuna_position",
|
|
124
|
+
TUNA_SPOT_POSITION: "tuna_spot_position",
|
|
120
125
|
LENDING_POSITION: "lending_position",
|
|
121
126
|
STAKING_POSITION: "staking_position",
|
|
122
127
|
FUSION_LIMIT_ORDER: "fusion_limit_order"
|
|
@@ -135,6 +140,10 @@ var TunaPositionState = {
|
|
|
135
140
|
CLOSED_BY_LIMIT_ORDER: "closed_by_limit_order",
|
|
136
141
|
CLOSED: "closed"
|
|
137
142
|
};
|
|
143
|
+
var TunaSpotPositionState = {
|
|
144
|
+
OPEN: "open",
|
|
145
|
+
CLOSED: "closed"
|
|
146
|
+
};
|
|
138
147
|
var LimitOrderState = {
|
|
139
148
|
OPEN: "open",
|
|
140
149
|
PARTIALLY_FILLED: "partially_filled",
|
|
@@ -156,6 +165,7 @@ var PoolSubscriptionTopic = {
|
|
|
156
165
|
};
|
|
157
166
|
var WalletSubscriptionTopic = {
|
|
158
167
|
TUNA_POSITIONS: "tuna_positions",
|
|
168
|
+
TUNA_SPOT_POSITIONS: "tuna_spot_positions",
|
|
159
169
|
LENDING_POSITIONS: "lending_positions",
|
|
160
170
|
FUSION_LIMIT_ORDERS: "fusion_limit_orders",
|
|
161
171
|
STAKING_POSITION: "staking_position"
|
|
@@ -164,6 +174,10 @@ var NotificationEntitySchema = import_zod.z.enum([NotificationEntity.POOL_SWAP,
|
|
|
164
174
|
var NotificationActionSchema = import_zod.z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
|
|
165
175
|
var PoolProviderSchema = import_zod.z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
|
|
166
176
|
var TunaPositionStateSchema = import_zod.z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
|
|
177
|
+
var TunaSpotPositionStateSchema = import_zod.z.enum([
|
|
178
|
+
TunaSpotPositionState.OPEN,
|
|
179
|
+
...Object.values(TunaSpotPositionState)
|
|
180
|
+
]);
|
|
167
181
|
var LimitOrderStateSchema = import_zod.z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
|
|
168
182
|
var StakingPositionHistoryActionTypeSchema = import_zod.z.enum([
|
|
169
183
|
StakingPositionHistoryActionType.STAKE,
|
|
@@ -353,6 +367,30 @@ var TunaPosition = import_zod.z.object({
|
|
|
353
367
|
updatedAtSlot: import_zod.z.coerce.bigint(),
|
|
354
368
|
closedAt: import_zod.z.nullable(import_zod.z.coerce.date())
|
|
355
369
|
});
|
|
370
|
+
var TunaSpotPosition = import_zod.z.object({
|
|
371
|
+
address: import_zod.z.string(),
|
|
372
|
+
authority: import_zod.z.string(),
|
|
373
|
+
version: import_zod.z.number(),
|
|
374
|
+
state: TunaSpotPositionStateSchema,
|
|
375
|
+
entrySqrtPrice: import_zod.z.coerce.bigint(),
|
|
376
|
+
lowerLimitOrderSqrtPrice: import_zod.z.coerce.bigint(),
|
|
377
|
+
upperLimitOrderSqrtPrice: import_zod.z.coerce.bigint(),
|
|
378
|
+
flags: import_zod.z.number(),
|
|
379
|
+
pool: import_zod.z.string(),
|
|
380
|
+
poolSqrtPrice: import_zod.z.coerce.bigint(),
|
|
381
|
+
collateralToken: import_zod.z.string(),
|
|
382
|
+
borrowToken: import_zod.z.string(),
|
|
383
|
+
positionToken: import_zod.z.string(),
|
|
384
|
+
collateral: amountWithUsd,
|
|
385
|
+
loanFunds: amountWithUsd,
|
|
386
|
+
currentLoan: amountWithUsd,
|
|
387
|
+
total: amountWithUsd,
|
|
388
|
+
pnlUsd: usdPnl,
|
|
389
|
+
openedAt: import_zod.z.coerce.date(),
|
|
390
|
+
openedAtSlot: import_zod.z.coerce.bigint(),
|
|
391
|
+
updatedAtSlot: import_zod.z.coerce.bigint(),
|
|
392
|
+
closedAt: import_zod.z.nullable(import_zod.z.coerce.date())
|
|
393
|
+
});
|
|
356
394
|
var PoolSwap = import_zod.z.object({
|
|
357
395
|
id: import_zod.z.string(),
|
|
358
396
|
amountIn: import_zod.z.coerce.bigint(),
|
|
@@ -514,6 +552,7 @@ var PoolSwapNotification = createNotificationSchema(PoolSwap);
|
|
|
514
552
|
var PoolPriceUpdateNotification = createNotificationSchema(PoolPriceUpdate);
|
|
515
553
|
var OrderBookNotification = createNotificationSchema(OrderBook, OrderBookNotificationMeta);
|
|
516
554
|
var TunaPositionNotification = createNotificationSchema(TunaPosition);
|
|
555
|
+
var TunaSpotPositionNotification = createNotificationSchema(TunaSpotPosition);
|
|
517
556
|
var LendingPositionNotification = createNotificationSchema(LendingPosition);
|
|
518
557
|
var LimitOrderNotification = createNotificationSchema(LimitOrder);
|
|
519
558
|
var StakingPositionNotification = createNotificationSchema(StakingPosition);
|
|
@@ -693,6 +732,14 @@ var TunaApiClient = class {
|
|
|
693
732
|
const url = this.buildURL(`users/${userAddress}/tuna-positions/${tunaPositionAddress}`);
|
|
694
733
|
return await this.httpRequest(url, TunaPosition);
|
|
695
734
|
}
|
|
735
|
+
async getUserTunaSpotPositions(userAddress) {
|
|
736
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions`);
|
|
737
|
+
return await this.httpRequest(url, TunaSpotPosition.array());
|
|
738
|
+
}
|
|
739
|
+
async getUserTunaSpotPositionByAddress(userAddress, tunaSpotPositionAddress) {
|
|
740
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions/${tunaSpotPositionAddress}`);
|
|
741
|
+
return await this.httpRequest(url, TunaSpotPosition);
|
|
742
|
+
}
|
|
696
743
|
async getUserLimitOrders(userAddress, poolFilter) {
|
|
697
744
|
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/limit-orders`), {
|
|
698
745
|
pool: poolFilter || void 0
|
package/dist/index.mjs
CHANGED
|
@@ -55,6 +55,10 @@ __export(schemas_exports, {
|
|
|
55
55
|
TunaPositionNotification: () => TunaPositionNotification,
|
|
56
56
|
TunaPositionState: () => TunaPositionState,
|
|
57
57
|
TunaPositionStateSchema: () => TunaPositionStateSchema,
|
|
58
|
+
TunaSpotPosition: () => TunaSpotPosition,
|
|
59
|
+
TunaSpotPositionNotification: () => TunaSpotPositionNotification,
|
|
60
|
+
TunaSpotPositionState: () => TunaSpotPositionState,
|
|
61
|
+
TunaSpotPositionStateSchema: () => TunaSpotPositionStateSchema,
|
|
58
62
|
UpdateStreamSubscriptionResult: () => UpdateStreamSubscriptionResult,
|
|
59
63
|
Vault: () => Vault,
|
|
60
64
|
VaultHistoricalStats: () => VaultHistoricalStats,
|
|
@@ -82,6 +86,7 @@ var NotificationEntity = {
|
|
|
82
86
|
POOL_PRICE: "pool_price",
|
|
83
87
|
ORDER_BOOK: "order_book",
|
|
84
88
|
TUNA_POSITION: "tuna_position",
|
|
89
|
+
TUNA_SPOT_POSITION: "tuna_spot_position",
|
|
85
90
|
LENDING_POSITION: "lending_position",
|
|
86
91
|
STAKING_POSITION: "staking_position",
|
|
87
92
|
FUSION_LIMIT_ORDER: "fusion_limit_order"
|
|
@@ -100,6 +105,10 @@ var TunaPositionState = {
|
|
|
100
105
|
CLOSED_BY_LIMIT_ORDER: "closed_by_limit_order",
|
|
101
106
|
CLOSED: "closed"
|
|
102
107
|
};
|
|
108
|
+
var TunaSpotPositionState = {
|
|
109
|
+
OPEN: "open",
|
|
110
|
+
CLOSED: "closed"
|
|
111
|
+
};
|
|
103
112
|
var LimitOrderState = {
|
|
104
113
|
OPEN: "open",
|
|
105
114
|
PARTIALLY_FILLED: "partially_filled",
|
|
@@ -121,6 +130,7 @@ var PoolSubscriptionTopic = {
|
|
|
121
130
|
};
|
|
122
131
|
var WalletSubscriptionTopic = {
|
|
123
132
|
TUNA_POSITIONS: "tuna_positions",
|
|
133
|
+
TUNA_SPOT_POSITIONS: "tuna_spot_positions",
|
|
124
134
|
LENDING_POSITIONS: "lending_positions",
|
|
125
135
|
FUSION_LIMIT_ORDERS: "fusion_limit_orders",
|
|
126
136
|
STAKING_POSITION: "staking_position"
|
|
@@ -129,6 +139,10 @@ var NotificationEntitySchema = z.enum([NotificationEntity.POOL_SWAP, ...Object.v
|
|
|
129
139
|
var NotificationActionSchema = z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
|
|
130
140
|
var PoolProviderSchema = z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
|
|
131
141
|
var TunaPositionStateSchema = z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
|
|
142
|
+
var TunaSpotPositionStateSchema = z.enum([
|
|
143
|
+
TunaSpotPositionState.OPEN,
|
|
144
|
+
...Object.values(TunaSpotPositionState)
|
|
145
|
+
]);
|
|
132
146
|
var LimitOrderStateSchema = z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
|
|
133
147
|
var StakingPositionHistoryActionTypeSchema = z.enum([
|
|
134
148
|
StakingPositionHistoryActionType.STAKE,
|
|
@@ -318,6 +332,30 @@ var TunaPosition = z.object({
|
|
|
318
332
|
updatedAtSlot: z.coerce.bigint(),
|
|
319
333
|
closedAt: z.nullable(z.coerce.date())
|
|
320
334
|
});
|
|
335
|
+
var TunaSpotPosition = z.object({
|
|
336
|
+
address: z.string(),
|
|
337
|
+
authority: z.string(),
|
|
338
|
+
version: z.number(),
|
|
339
|
+
state: TunaSpotPositionStateSchema,
|
|
340
|
+
entrySqrtPrice: z.coerce.bigint(),
|
|
341
|
+
lowerLimitOrderSqrtPrice: z.coerce.bigint(),
|
|
342
|
+
upperLimitOrderSqrtPrice: z.coerce.bigint(),
|
|
343
|
+
flags: z.number(),
|
|
344
|
+
pool: z.string(),
|
|
345
|
+
poolSqrtPrice: z.coerce.bigint(),
|
|
346
|
+
collateralToken: z.string(),
|
|
347
|
+
borrowToken: z.string(),
|
|
348
|
+
positionToken: z.string(),
|
|
349
|
+
collateral: amountWithUsd,
|
|
350
|
+
loanFunds: amountWithUsd,
|
|
351
|
+
currentLoan: amountWithUsd,
|
|
352
|
+
total: amountWithUsd,
|
|
353
|
+
pnlUsd: usdPnl,
|
|
354
|
+
openedAt: z.coerce.date(),
|
|
355
|
+
openedAtSlot: z.coerce.bigint(),
|
|
356
|
+
updatedAtSlot: z.coerce.bigint(),
|
|
357
|
+
closedAt: z.nullable(z.coerce.date())
|
|
358
|
+
});
|
|
321
359
|
var PoolSwap = z.object({
|
|
322
360
|
id: z.string(),
|
|
323
361
|
amountIn: z.coerce.bigint(),
|
|
@@ -479,6 +517,7 @@ var PoolSwapNotification = createNotificationSchema(PoolSwap);
|
|
|
479
517
|
var PoolPriceUpdateNotification = createNotificationSchema(PoolPriceUpdate);
|
|
480
518
|
var OrderBookNotification = createNotificationSchema(OrderBook, OrderBookNotificationMeta);
|
|
481
519
|
var TunaPositionNotification = createNotificationSchema(TunaPosition);
|
|
520
|
+
var TunaSpotPositionNotification = createNotificationSchema(TunaSpotPosition);
|
|
482
521
|
var LendingPositionNotification = createNotificationSchema(LendingPosition);
|
|
483
522
|
var LimitOrderNotification = createNotificationSchema(LimitOrder);
|
|
484
523
|
var StakingPositionNotification = createNotificationSchema(StakingPosition);
|
|
@@ -658,6 +697,14 @@ var TunaApiClient = class {
|
|
|
658
697
|
const url = this.buildURL(`users/${userAddress}/tuna-positions/${tunaPositionAddress}`);
|
|
659
698
|
return await this.httpRequest(url, TunaPosition);
|
|
660
699
|
}
|
|
700
|
+
async getUserTunaSpotPositions(userAddress) {
|
|
701
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions`);
|
|
702
|
+
return await this.httpRequest(url, TunaSpotPosition.array());
|
|
703
|
+
}
|
|
704
|
+
async getUserTunaSpotPositionByAddress(userAddress, tunaSpotPositionAddress) {
|
|
705
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions/${tunaSpotPositionAddress}`);
|
|
706
|
+
return await this.httpRequest(url, TunaSpotPosition);
|
|
707
|
+
}
|
|
661
708
|
async getUserLimitOrders(userAddress, poolFilter) {
|
|
662
709
|
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/limit-orders`), {
|
|
663
710
|
pool: poolFilter || void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crypticdot/defituna-api",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@crypticdot/defituna-client": "^
|
|
18
|
-
"@crypticdot/eslint-config": "^1.0.
|
|
17
|
+
"@crypticdot/defituna-client": "^3.0.2",
|
|
18
|
+
"@crypticdot/eslint-config": "^1.0.2",
|
|
19
19
|
"@crypticdot/prettier-config": "^1.0.0",
|
|
20
20
|
"@crypticdot/typescript-config": "^1.0.0",
|
|
21
21
|
"@solana/kit": "^2.1.0",
|