@crypticdot/defituna-api 1.1.56 → 1.2.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 +644 -3
- package/dist/index.d.ts +644 -3
- package/dist/index.js +46 -0
- package/dist/index.mjs +46 -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,
|
|
@@ -135,6 +139,10 @@ var TunaPositionState = {
|
|
|
135
139
|
CLOSED_BY_LIMIT_ORDER: "closed_by_limit_order",
|
|
136
140
|
CLOSED: "closed"
|
|
137
141
|
};
|
|
142
|
+
var TunaSpotPositionState = {
|
|
143
|
+
OPEN: "open",
|
|
144
|
+
CLOSED: "closed"
|
|
145
|
+
};
|
|
138
146
|
var LimitOrderState = {
|
|
139
147
|
OPEN: "open",
|
|
140
148
|
PARTIALLY_FILLED: "partially_filled",
|
|
@@ -156,6 +164,7 @@ var PoolSubscriptionTopic = {
|
|
|
156
164
|
};
|
|
157
165
|
var WalletSubscriptionTopic = {
|
|
158
166
|
TUNA_POSITIONS: "tuna_positions",
|
|
167
|
+
TUNA_SPOT_POSITIONS: "tuna_spot_positions",
|
|
159
168
|
LENDING_POSITIONS: "lending_positions",
|
|
160
169
|
FUSION_LIMIT_ORDERS: "fusion_limit_orders",
|
|
161
170
|
STAKING_POSITION: "staking_position"
|
|
@@ -164,6 +173,10 @@ var NotificationEntitySchema = import_zod.z.enum([NotificationEntity.POOL_SWAP,
|
|
|
164
173
|
var NotificationActionSchema = import_zod.z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
|
|
165
174
|
var PoolProviderSchema = import_zod.z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
|
|
166
175
|
var TunaPositionStateSchema = import_zod.z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
|
|
176
|
+
var TunaSpotPositionStateSchema = import_zod.z.enum([
|
|
177
|
+
TunaSpotPositionState.OPEN,
|
|
178
|
+
...Object.values(TunaSpotPositionState)
|
|
179
|
+
]);
|
|
167
180
|
var LimitOrderStateSchema = import_zod.z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
|
|
168
181
|
var StakingPositionHistoryActionTypeSchema = import_zod.z.enum([
|
|
169
182
|
StakingPositionHistoryActionType.STAKE,
|
|
@@ -353,6 +366,30 @@ var TunaPosition = import_zod.z.object({
|
|
|
353
366
|
updatedAtSlot: import_zod.z.coerce.bigint(),
|
|
354
367
|
closedAt: import_zod.z.nullable(import_zod.z.coerce.date())
|
|
355
368
|
});
|
|
369
|
+
var TunaSpotPosition = import_zod.z.object({
|
|
370
|
+
address: import_zod.z.string(),
|
|
371
|
+
authority: import_zod.z.string(),
|
|
372
|
+
version: import_zod.z.number(),
|
|
373
|
+
state: TunaSpotPositionStateSchema,
|
|
374
|
+
entrySqrtPrice: import_zod.z.coerce.bigint(),
|
|
375
|
+
lowerLimitOrderSqrtPrice: import_zod.z.coerce.bigint(),
|
|
376
|
+
upperLimitOrderSqrtPrice: import_zod.z.coerce.bigint(),
|
|
377
|
+
flags: import_zod.z.number(),
|
|
378
|
+
pool: import_zod.z.string(),
|
|
379
|
+
poolSqrtPrice: import_zod.z.coerce.bigint(),
|
|
380
|
+
collateralToken: import_zod.z.string(),
|
|
381
|
+
borrowToken: import_zod.z.string(),
|
|
382
|
+
positionToken: import_zod.z.string(),
|
|
383
|
+
collateral: amountWithUsd,
|
|
384
|
+
loanFunds: amountWithUsd,
|
|
385
|
+
currentLoan: amountWithUsd,
|
|
386
|
+
total: amountWithUsd,
|
|
387
|
+
pnlUsd: usdPnl,
|
|
388
|
+
openedAt: import_zod.z.coerce.date(),
|
|
389
|
+
openedAtSlot: import_zod.z.coerce.bigint(),
|
|
390
|
+
updatedAtSlot: import_zod.z.coerce.bigint(),
|
|
391
|
+
closedAt: import_zod.z.nullable(import_zod.z.coerce.date())
|
|
392
|
+
});
|
|
356
393
|
var PoolSwap = import_zod.z.object({
|
|
357
394
|
id: import_zod.z.string(),
|
|
358
395
|
amountIn: import_zod.z.coerce.bigint(),
|
|
@@ -514,6 +551,7 @@ var PoolSwapNotification = createNotificationSchema(PoolSwap);
|
|
|
514
551
|
var PoolPriceUpdateNotification = createNotificationSchema(PoolPriceUpdate);
|
|
515
552
|
var OrderBookNotification = createNotificationSchema(OrderBook, OrderBookNotificationMeta);
|
|
516
553
|
var TunaPositionNotification = createNotificationSchema(TunaPosition);
|
|
554
|
+
var TunaSpotPositionNotification = createNotificationSchema(TunaSpotPosition);
|
|
517
555
|
var LendingPositionNotification = createNotificationSchema(LendingPosition);
|
|
518
556
|
var LimitOrderNotification = createNotificationSchema(LimitOrder);
|
|
519
557
|
var StakingPositionNotification = createNotificationSchema(StakingPosition);
|
|
@@ -693,6 +731,14 @@ var TunaApiClient = class {
|
|
|
693
731
|
const url = this.buildURL(`users/${userAddress}/tuna-positions/${tunaPositionAddress}`);
|
|
694
732
|
return await this.httpRequest(url, TunaPosition);
|
|
695
733
|
}
|
|
734
|
+
async getUserTunaSpotPositions(userAddress) {
|
|
735
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions`);
|
|
736
|
+
return await this.httpRequest(url, TunaSpotPosition.array());
|
|
737
|
+
}
|
|
738
|
+
async getUserTunaSpotPositionByAddress(userAddress, tunaSpotPositionAddress) {
|
|
739
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions/${tunaSpotPositionAddress}`);
|
|
740
|
+
return await this.httpRequest(url, TunaSpotPosition);
|
|
741
|
+
}
|
|
696
742
|
async getUserLimitOrders(userAddress, poolFilter) {
|
|
697
743
|
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/limit-orders`), {
|
|
698
744
|
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,
|
|
@@ -100,6 +104,10 @@ var TunaPositionState = {
|
|
|
100
104
|
CLOSED_BY_LIMIT_ORDER: "closed_by_limit_order",
|
|
101
105
|
CLOSED: "closed"
|
|
102
106
|
};
|
|
107
|
+
var TunaSpotPositionState = {
|
|
108
|
+
OPEN: "open",
|
|
109
|
+
CLOSED: "closed"
|
|
110
|
+
};
|
|
103
111
|
var LimitOrderState = {
|
|
104
112
|
OPEN: "open",
|
|
105
113
|
PARTIALLY_FILLED: "partially_filled",
|
|
@@ -121,6 +129,7 @@ var PoolSubscriptionTopic = {
|
|
|
121
129
|
};
|
|
122
130
|
var WalletSubscriptionTopic = {
|
|
123
131
|
TUNA_POSITIONS: "tuna_positions",
|
|
132
|
+
TUNA_SPOT_POSITIONS: "tuna_spot_positions",
|
|
124
133
|
LENDING_POSITIONS: "lending_positions",
|
|
125
134
|
FUSION_LIMIT_ORDERS: "fusion_limit_orders",
|
|
126
135
|
STAKING_POSITION: "staking_position"
|
|
@@ -129,6 +138,10 @@ var NotificationEntitySchema = z.enum([NotificationEntity.POOL_SWAP, ...Object.v
|
|
|
129
138
|
var NotificationActionSchema = z.enum([NotificationAction.CREATE, ...Object.values(NotificationAction)]);
|
|
130
139
|
var PoolProviderSchema = z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
|
|
131
140
|
var TunaPositionStateSchema = z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
|
|
141
|
+
var TunaSpotPositionStateSchema = z.enum([
|
|
142
|
+
TunaSpotPositionState.OPEN,
|
|
143
|
+
...Object.values(TunaSpotPositionState)
|
|
144
|
+
]);
|
|
132
145
|
var LimitOrderStateSchema = z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
|
|
133
146
|
var StakingPositionHistoryActionTypeSchema = z.enum([
|
|
134
147
|
StakingPositionHistoryActionType.STAKE,
|
|
@@ -318,6 +331,30 @@ var TunaPosition = z.object({
|
|
|
318
331
|
updatedAtSlot: z.coerce.bigint(),
|
|
319
332
|
closedAt: z.nullable(z.coerce.date())
|
|
320
333
|
});
|
|
334
|
+
var TunaSpotPosition = z.object({
|
|
335
|
+
address: z.string(),
|
|
336
|
+
authority: z.string(),
|
|
337
|
+
version: z.number(),
|
|
338
|
+
state: TunaSpotPositionStateSchema,
|
|
339
|
+
entrySqrtPrice: z.coerce.bigint(),
|
|
340
|
+
lowerLimitOrderSqrtPrice: z.coerce.bigint(),
|
|
341
|
+
upperLimitOrderSqrtPrice: z.coerce.bigint(),
|
|
342
|
+
flags: z.number(),
|
|
343
|
+
pool: z.string(),
|
|
344
|
+
poolSqrtPrice: z.coerce.bigint(),
|
|
345
|
+
collateralToken: z.string(),
|
|
346
|
+
borrowToken: z.string(),
|
|
347
|
+
positionToken: z.string(),
|
|
348
|
+
collateral: amountWithUsd,
|
|
349
|
+
loanFunds: amountWithUsd,
|
|
350
|
+
currentLoan: amountWithUsd,
|
|
351
|
+
total: amountWithUsd,
|
|
352
|
+
pnlUsd: usdPnl,
|
|
353
|
+
openedAt: z.coerce.date(),
|
|
354
|
+
openedAtSlot: z.coerce.bigint(),
|
|
355
|
+
updatedAtSlot: z.coerce.bigint(),
|
|
356
|
+
closedAt: z.nullable(z.coerce.date())
|
|
357
|
+
});
|
|
321
358
|
var PoolSwap = z.object({
|
|
322
359
|
id: z.string(),
|
|
323
360
|
amountIn: z.coerce.bigint(),
|
|
@@ -479,6 +516,7 @@ var PoolSwapNotification = createNotificationSchema(PoolSwap);
|
|
|
479
516
|
var PoolPriceUpdateNotification = createNotificationSchema(PoolPriceUpdate);
|
|
480
517
|
var OrderBookNotification = createNotificationSchema(OrderBook, OrderBookNotificationMeta);
|
|
481
518
|
var TunaPositionNotification = createNotificationSchema(TunaPosition);
|
|
519
|
+
var TunaSpotPositionNotification = createNotificationSchema(TunaSpotPosition);
|
|
482
520
|
var LendingPositionNotification = createNotificationSchema(LendingPosition);
|
|
483
521
|
var LimitOrderNotification = createNotificationSchema(LimitOrder);
|
|
484
522
|
var StakingPositionNotification = createNotificationSchema(StakingPosition);
|
|
@@ -658,6 +696,14 @@ var TunaApiClient = class {
|
|
|
658
696
|
const url = this.buildURL(`users/${userAddress}/tuna-positions/${tunaPositionAddress}`);
|
|
659
697
|
return await this.httpRequest(url, TunaPosition);
|
|
660
698
|
}
|
|
699
|
+
async getUserTunaSpotPositions(userAddress) {
|
|
700
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions`);
|
|
701
|
+
return await this.httpRequest(url, TunaSpotPosition.array());
|
|
702
|
+
}
|
|
703
|
+
async getUserTunaSpotPositionByAddress(userAddress, tunaSpotPositionAddress) {
|
|
704
|
+
const url = this.buildURL(`users/${userAddress}/spot-positions/${tunaSpotPositionAddress}`);
|
|
705
|
+
return await this.httpRequest(url, TunaSpotPosition);
|
|
706
|
+
}
|
|
661
707
|
async getUserLimitOrders(userAddress, poolFilter) {
|
|
662
708
|
const url = this.appendUrlSearchParams(this.buildURL(`users/${userAddress}/limit-orders`), {
|
|
663
709
|
pool: poolFilter || void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crypticdot/defituna-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|