@crypticdot/defituna-api 1.1.35 → 1.1.37
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 +337 -27
- package/dist/index.d.ts +337 -27
- package/dist/index.js +88 -0
- package/dist/index.mjs +88 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -73,6 +73,11 @@ __export(schemas_exports, {
|
|
|
73
73
|
PoolSwap: () => PoolSwap,
|
|
74
74
|
PoolSwapNotification: () => PoolSwapNotification,
|
|
75
75
|
PoolTicks: () => PoolTicks,
|
|
76
|
+
StakingPosition: () => StakingPosition,
|
|
77
|
+
StakingPositionHistoryAction: () => StakingPositionHistoryAction,
|
|
78
|
+
StakingPositionHistoryActionType: () => StakingPositionHistoryActionType,
|
|
79
|
+
StakingPositionHistoryActionTypeSchema: () => StakingPositionHistoryActionTypeSchema,
|
|
80
|
+
StakingTreasury: () => StakingTreasury,
|
|
76
81
|
Tick: () => Tick,
|
|
77
82
|
TokenOraclePrice: () => TokenOraclePrice,
|
|
78
83
|
TunaPosition: () => TunaPosition,
|
|
@@ -81,6 +86,7 @@ __export(schemas_exports, {
|
|
|
81
86
|
TunaPositionStateSchema: () => TunaPositionStateSchema,
|
|
82
87
|
UpdateStreamSubscriptionResult: () => UpdateStreamSubscriptionResult,
|
|
83
88
|
Vault: () => Vault,
|
|
89
|
+
VaultHistoricalStats: () => VaultHistoricalStats,
|
|
84
90
|
WalletSubscriptionTopic: () => WalletSubscriptionTopic,
|
|
85
91
|
WalletSubscriptionTopicSchema: () => WalletSubscriptionTopicSchema
|
|
86
92
|
});
|
|
@@ -129,6 +135,12 @@ var LimitOrderState = {
|
|
|
129
135
|
COMPLETE: "complete",
|
|
130
136
|
CANCELLED: "cancelled"
|
|
131
137
|
};
|
|
138
|
+
var StakingPositionHistoryActionType = {
|
|
139
|
+
STAKE: "stake",
|
|
140
|
+
UNSTAKE: "unstake",
|
|
141
|
+
WITHDRAW: "withdraw",
|
|
142
|
+
CLAIM_REWARDS: "claim_rewards"
|
|
143
|
+
};
|
|
132
144
|
var PoolSubscriptionTopic = {
|
|
133
145
|
ORDER_BOOK: "order_book",
|
|
134
146
|
POOL_PRICES: "pool_prices",
|
|
@@ -144,6 +156,10 @@ var NotificationActionSchema = import_zod.z.enum([NotificationAction.CREATE, ...
|
|
|
144
156
|
var PoolProviderSchema = import_zod.z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
|
|
145
157
|
var TunaPositionStateSchema = import_zod.z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
|
|
146
158
|
var LimitOrderStateSchema = import_zod.z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
|
|
159
|
+
var StakingPositionHistoryActionTypeSchema = import_zod.z.enum([
|
|
160
|
+
StakingPositionHistoryActionType.STAKE,
|
|
161
|
+
...Object.values(StakingPositionHistoryActionType)
|
|
162
|
+
]);
|
|
147
163
|
var PoolSubscriptionTopicSchema = import_zod.z.enum([
|
|
148
164
|
PoolSubscriptionTopic.ORDER_BOOK,
|
|
149
165
|
...Object.values(PoolSubscriptionTopic)
|
|
@@ -198,6 +214,23 @@ var Vault = import_zod.z.object({
|
|
|
198
214
|
pythOracleFeedId: import_zod.z.string(),
|
|
199
215
|
pythOraclePriceUpdate: import_zod.z.string()
|
|
200
216
|
});
|
|
217
|
+
var VaultHistoricalStats = import_zod.z.object({
|
|
218
|
+
date: import_zod.z.preprocess((val, ctx) => {
|
|
219
|
+
if (typeof val === "string") {
|
|
220
|
+
const [year, month, day] = val.split("-").map(Number);
|
|
221
|
+
return new Date(year, month - 1, day);
|
|
222
|
+
}
|
|
223
|
+
ctx.addIssue({
|
|
224
|
+
code: "custom",
|
|
225
|
+
message: "Not a valid date string"
|
|
226
|
+
});
|
|
227
|
+
return import_zod.z.NEVER;
|
|
228
|
+
}, import_zod.z.date()),
|
|
229
|
+
supply: amountWithUsd,
|
|
230
|
+
borrow: amountWithUsd,
|
|
231
|
+
supplyApy: import_zod.z.number(),
|
|
232
|
+
borrowApr: import_zod.z.number()
|
|
233
|
+
});
|
|
201
234
|
var Pool = import_zod.z.object({
|
|
202
235
|
address: import_zod.z.string(),
|
|
203
236
|
provider: PoolProviderSchema,
|
|
@@ -336,6 +369,39 @@ var LimitOrder = import_zod.z.object({
|
|
|
336
369
|
openedAt: import_zod.z.coerce.date(),
|
|
337
370
|
closedAt: import_zod.z.nullable(import_zod.z.coerce.date())
|
|
338
371
|
});
|
|
372
|
+
var StakingTreasury = import_zod.z.object({
|
|
373
|
+
address: import_zod.z.string(),
|
|
374
|
+
stakedTokenMint: import_zod.z.string(),
|
|
375
|
+
rewardTokenMint: import_zod.z.string(),
|
|
376
|
+
apy: import_zod.z.number(),
|
|
377
|
+
totalStaked: amountWithUsd,
|
|
378
|
+
totalReward: amountWithUsd,
|
|
379
|
+
unstakeCooldown: import_zod.z.coerce.bigint()
|
|
380
|
+
});
|
|
381
|
+
var StakingPosition = import_zod.z.object({
|
|
382
|
+
address: import_zod.z.string(),
|
|
383
|
+
owner: import_zod.z.string(),
|
|
384
|
+
staked: amountWithUsd,
|
|
385
|
+
unstaked: amountWithUsd,
|
|
386
|
+
claimedReward: amountWithUsd,
|
|
387
|
+
unclaimedReward: amountWithUsd,
|
|
388
|
+
vesting: import_zod.z.object({
|
|
389
|
+
locked: amountWithUsd,
|
|
390
|
+
unlocked: amountWithUsd,
|
|
391
|
+
unlockRate: import_zod.z.coerce.bigint(),
|
|
392
|
+
unlockPeriod: import_zod.z.number(),
|
|
393
|
+
unlockCliff: import_zod.z.number(),
|
|
394
|
+
lockedAt: import_zod.z.nullable(import_zod.z.date())
|
|
395
|
+
}),
|
|
396
|
+
lastUnstakedAt: import_zod.z.nullable(import_zod.z.date()),
|
|
397
|
+
withdrawAvailableAt: import_zod.z.nullable(import_zod.z.date())
|
|
398
|
+
});
|
|
399
|
+
var StakingPositionHistoryAction = import_zod.z.object({
|
|
400
|
+
position: import_zod.z.string(),
|
|
401
|
+
action: StakingPositionHistoryActionTypeSchema,
|
|
402
|
+
txSignature: import_zod.z.string(),
|
|
403
|
+
time: import_zod.z.date()
|
|
404
|
+
});
|
|
339
405
|
var PoolPriceCandle = import_zod.z.object({
|
|
340
406
|
time: import_zod.z.number(),
|
|
341
407
|
open: import_zod.z.number(),
|
|
@@ -464,6 +530,16 @@ var TunaApiClient = class {
|
|
|
464
530
|
const url = this.buildURL(`vaults/${vaultAddress}`);
|
|
465
531
|
return await this.httpRequest(url.toString(), Vault);
|
|
466
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Returns vault historical data for selected time interval.
|
|
535
|
+
*
|
|
536
|
+
* Example usage: getVaultHistory('H3ifgix98vzi3yCPbmZDLTheeTRf2jykXx8FpY5L7Sfd', '2025-03-10', '2025-04-10')
|
|
537
|
+
*/
|
|
538
|
+
async getVaultHistory(vaultAddress, from, to) {
|
|
539
|
+
const url = this.buildURL(`vaults/${vaultAddress}/history`);
|
|
540
|
+
this.appendUrlSearchParams(url, { from: from.toISOString().slice(0, 10), to: to.toISOString().slice(0, 10) });
|
|
541
|
+
return await this.httpRequest(url.toString(), VaultHistoricalStats.array());
|
|
542
|
+
}
|
|
467
543
|
async getPools(providerFilter) {
|
|
468
544
|
const url = this.buildURL("pools");
|
|
469
545
|
if (providerFilter && providerFilter !== "all" /* ALL */) {
|
|
@@ -502,6 +578,10 @@ var TunaApiClient = class {
|
|
|
502
578
|
});
|
|
503
579
|
return await this.httpRequest(url.toString(), PoolPriceCandle.array());
|
|
504
580
|
}
|
|
581
|
+
async getStakingTreasury() {
|
|
582
|
+
const url = this.buildURL(`staking/treasury`);
|
|
583
|
+
return await this.httpRequest(url.toString(), StakingTreasury);
|
|
584
|
+
}
|
|
505
585
|
async getUserLendingPositions(userAddress) {
|
|
506
586
|
const url = this.buildURL(`users/${userAddress}/lending-positions`);
|
|
507
587
|
return await this.httpRequest(url.toString(), LendingPosition.array());
|
|
@@ -529,6 +609,14 @@ var TunaApiClient = class {
|
|
|
529
609
|
const url = this.buildURL(`users/${userAddress}/limit-orders/${limitOrderAddress}`);
|
|
530
610
|
return await this.httpRequest(url.toString(), LimitOrder);
|
|
531
611
|
}
|
|
612
|
+
async getUserStakingPosition(userAddress) {
|
|
613
|
+
const url = this.buildURL(`users/${userAddress}/staking-position`);
|
|
614
|
+
return await this.httpRequest(url.toString(), StakingPosition);
|
|
615
|
+
}
|
|
616
|
+
async getUserStakingPositionHistory(userAddress) {
|
|
617
|
+
const url = this.buildURL(`users/${userAddress}/staking-position/history`);
|
|
618
|
+
return await this.httpRequest(url.toString(), StakingPositionHistoryAction.array());
|
|
619
|
+
}
|
|
532
620
|
/**
|
|
533
621
|
* @deprecated Use getUpdatesStream instead
|
|
534
622
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,11 @@ __export(schemas_exports, {
|
|
|
38
38
|
PoolSwap: () => PoolSwap,
|
|
39
39
|
PoolSwapNotification: () => PoolSwapNotification,
|
|
40
40
|
PoolTicks: () => PoolTicks,
|
|
41
|
+
StakingPosition: () => StakingPosition,
|
|
42
|
+
StakingPositionHistoryAction: () => StakingPositionHistoryAction,
|
|
43
|
+
StakingPositionHistoryActionType: () => StakingPositionHistoryActionType,
|
|
44
|
+
StakingPositionHistoryActionTypeSchema: () => StakingPositionHistoryActionTypeSchema,
|
|
45
|
+
StakingTreasury: () => StakingTreasury,
|
|
41
46
|
Tick: () => Tick,
|
|
42
47
|
TokenOraclePrice: () => TokenOraclePrice,
|
|
43
48
|
TunaPosition: () => TunaPosition,
|
|
@@ -46,6 +51,7 @@ __export(schemas_exports, {
|
|
|
46
51
|
TunaPositionStateSchema: () => TunaPositionStateSchema,
|
|
47
52
|
UpdateStreamSubscriptionResult: () => UpdateStreamSubscriptionResult,
|
|
48
53
|
Vault: () => Vault,
|
|
54
|
+
VaultHistoricalStats: () => VaultHistoricalStats,
|
|
49
55
|
WalletSubscriptionTopic: () => WalletSubscriptionTopic,
|
|
50
56
|
WalletSubscriptionTopicSchema: () => WalletSubscriptionTopicSchema
|
|
51
57
|
});
|
|
@@ -94,6 +100,12 @@ var LimitOrderState = {
|
|
|
94
100
|
COMPLETE: "complete",
|
|
95
101
|
CANCELLED: "cancelled"
|
|
96
102
|
};
|
|
103
|
+
var StakingPositionHistoryActionType = {
|
|
104
|
+
STAKE: "stake",
|
|
105
|
+
UNSTAKE: "unstake",
|
|
106
|
+
WITHDRAW: "withdraw",
|
|
107
|
+
CLAIM_REWARDS: "claim_rewards"
|
|
108
|
+
};
|
|
97
109
|
var PoolSubscriptionTopic = {
|
|
98
110
|
ORDER_BOOK: "order_book",
|
|
99
111
|
POOL_PRICES: "pool_prices",
|
|
@@ -109,6 +121,10 @@ var NotificationActionSchema = z.enum([NotificationAction.CREATE, ...Object.valu
|
|
|
109
121
|
var PoolProviderSchema = z.enum([PoolProvider.ORCA, ...Object.values(PoolProvider)]);
|
|
110
122
|
var TunaPositionStateSchema = z.enum([TunaPositionState.OPEN, ...Object.values(TunaPositionState)]);
|
|
111
123
|
var LimitOrderStateSchema = z.enum([LimitOrderState.OPEN, ...Object.values(LimitOrderState)]);
|
|
124
|
+
var StakingPositionHistoryActionTypeSchema = z.enum([
|
|
125
|
+
StakingPositionHistoryActionType.STAKE,
|
|
126
|
+
...Object.values(StakingPositionHistoryActionType)
|
|
127
|
+
]);
|
|
112
128
|
var PoolSubscriptionTopicSchema = z.enum([
|
|
113
129
|
PoolSubscriptionTopic.ORDER_BOOK,
|
|
114
130
|
...Object.values(PoolSubscriptionTopic)
|
|
@@ -163,6 +179,23 @@ var Vault = z.object({
|
|
|
163
179
|
pythOracleFeedId: z.string(),
|
|
164
180
|
pythOraclePriceUpdate: z.string()
|
|
165
181
|
});
|
|
182
|
+
var VaultHistoricalStats = z.object({
|
|
183
|
+
date: z.preprocess((val, ctx) => {
|
|
184
|
+
if (typeof val === "string") {
|
|
185
|
+
const [year, month, day] = val.split("-").map(Number);
|
|
186
|
+
return new Date(year, month - 1, day);
|
|
187
|
+
}
|
|
188
|
+
ctx.addIssue({
|
|
189
|
+
code: "custom",
|
|
190
|
+
message: "Not a valid date string"
|
|
191
|
+
});
|
|
192
|
+
return z.NEVER;
|
|
193
|
+
}, z.date()),
|
|
194
|
+
supply: amountWithUsd,
|
|
195
|
+
borrow: amountWithUsd,
|
|
196
|
+
supplyApy: z.number(),
|
|
197
|
+
borrowApr: z.number()
|
|
198
|
+
});
|
|
166
199
|
var Pool = z.object({
|
|
167
200
|
address: z.string(),
|
|
168
201
|
provider: PoolProviderSchema,
|
|
@@ -301,6 +334,39 @@ var LimitOrder = z.object({
|
|
|
301
334
|
openedAt: z.coerce.date(),
|
|
302
335
|
closedAt: z.nullable(z.coerce.date())
|
|
303
336
|
});
|
|
337
|
+
var StakingTreasury = z.object({
|
|
338
|
+
address: z.string(),
|
|
339
|
+
stakedTokenMint: z.string(),
|
|
340
|
+
rewardTokenMint: z.string(),
|
|
341
|
+
apy: z.number(),
|
|
342
|
+
totalStaked: amountWithUsd,
|
|
343
|
+
totalReward: amountWithUsd,
|
|
344
|
+
unstakeCooldown: z.coerce.bigint()
|
|
345
|
+
});
|
|
346
|
+
var StakingPosition = z.object({
|
|
347
|
+
address: z.string(),
|
|
348
|
+
owner: z.string(),
|
|
349
|
+
staked: amountWithUsd,
|
|
350
|
+
unstaked: amountWithUsd,
|
|
351
|
+
claimedReward: amountWithUsd,
|
|
352
|
+
unclaimedReward: amountWithUsd,
|
|
353
|
+
vesting: z.object({
|
|
354
|
+
locked: amountWithUsd,
|
|
355
|
+
unlocked: amountWithUsd,
|
|
356
|
+
unlockRate: z.coerce.bigint(),
|
|
357
|
+
unlockPeriod: z.number(),
|
|
358
|
+
unlockCliff: z.number(),
|
|
359
|
+
lockedAt: z.nullable(z.date())
|
|
360
|
+
}),
|
|
361
|
+
lastUnstakedAt: z.nullable(z.date()),
|
|
362
|
+
withdrawAvailableAt: z.nullable(z.date())
|
|
363
|
+
});
|
|
364
|
+
var StakingPositionHistoryAction = z.object({
|
|
365
|
+
position: z.string(),
|
|
366
|
+
action: StakingPositionHistoryActionTypeSchema,
|
|
367
|
+
txSignature: z.string(),
|
|
368
|
+
time: z.date()
|
|
369
|
+
});
|
|
304
370
|
var PoolPriceCandle = z.object({
|
|
305
371
|
time: z.number(),
|
|
306
372
|
open: z.number(),
|
|
@@ -429,6 +495,16 @@ var TunaApiClient = class {
|
|
|
429
495
|
const url = this.buildURL(`vaults/${vaultAddress}`);
|
|
430
496
|
return await this.httpRequest(url.toString(), Vault);
|
|
431
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* Returns vault historical data for selected time interval.
|
|
500
|
+
*
|
|
501
|
+
* Example usage: getVaultHistory('H3ifgix98vzi3yCPbmZDLTheeTRf2jykXx8FpY5L7Sfd', '2025-03-10', '2025-04-10')
|
|
502
|
+
*/
|
|
503
|
+
async getVaultHistory(vaultAddress, from, to) {
|
|
504
|
+
const url = this.buildURL(`vaults/${vaultAddress}/history`);
|
|
505
|
+
this.appendUrlSearchParams(url, { from: from.toISOString().slice(0, 10), to: to.toISOString().slice(0, 10) });
|
|
506
|
+
return await this.httpRequest(url.toString(), VaultHistoricalStats.array());
|
|
507
|
+
}
|
|
432
508
|
async getPools(providerFilter) {
|
|
433
509
|
const url = this.buildURL("pools");
|
|
434
510
|
if (providerFilter && providerFilter !== "all" /* ALL */) {
|
|
@@ -467,6 +543,10 @@ var TunaApiClient = class {
|
|
|
467
543
|
});
|
|
468
544
|
return await this.httpRequest(url.toString(), PoolPriceCandle.array());
|
|
469
545
|
}
|
|
546
|
+
async getStakingTreasury() {
|
|
547
|
+
const url = this.buildURL(`staking/treasury`);
|
|
548
|
+
return await this.httpRequest(url.toString(), StakingTreasury);
|
|
549
|
+
}
|
|
470
550
|
async getUserLendingPositions(userAddress) {
|
|
471
551
|
const url = this.buildURL(`users/${userAddress}/lending-positions`);
|
|
472
552
|
return await this.httpRequest(url.toString(), LendingPosition.array());
|
|
@@ -494,6 +574,14 @@ var TunaApiClient = class {
|
|
|
494
574
|
const url = this.buildURL(`users/${userAddress}/limit-orders/${limitOrderAddress}`);
|
|
495
575
|
return await this.httpRequest(url.toString(), LimitOrder);
|
|
496
576
|
}
|
|
577
|
+
async getUserStakingPosition(userAddress) {
|
|
578
|
+
const url = this.buildURL(`users/${userAddress}/staking-position`);
|
|
579
|
+
return await this.httpRequest(url.toString(), StakingPosition);
|
|
580
|
+
}
|
|
581
|
+
async getUserStakingPositionHistory(userAddress) {
|
|
582
|
+
const url = this.buildURL(`users/${userAddress}/staking-position/history`);
|
|
583
|
+
return await this.httpRequest(url.toString(), StakingPositionHistoryAction.array());
|
|
584
|
+
}
|
|
497
585
|
/**
|
|
498
586
|
* @deprecated Use getUpdatesStream instead
|
|
499
587
|
*/
|