@crypticdot/defituna-api 1.1.51 → 1.1.53
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 +169 -58
- package/dist/index.d.ts +169 -58
- package/dist/index.js +29 -0
- package/dist/index.mjs +29 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -63,6 +63,7 @@ __export(schemas_exports, {
|
|
|
63
63
|
OrderBookEntry: () => OrderBookEntry,
|
|
64
64
|
OrderBookNotification: () => OrderBookNotification,
|
|
65
65
|
OrderBookNotificationMeta: () => OrderBookNotificationMeta,
|
|
66
|
+
PaginationMeta: () => PaginationMeta,
|
|
66
67
|
Pool: () => Pool,
|
|
67
68
|
PoolPriceCandle: () => PoolPriceCandle,
|
|
68
69
|
PoolPriceUpdate: () => PoolPriceUpdate,
|
|
@@ -74,6 +75,8 @@ __export(schemas_exports, {
|
|
|
74
75
|
PoolSwap: () => PoolSwap,
|
|
75
76
|
PoolSwapNotification: () => PoolSwapNotification,
|
|
76
77
|
PoolTicks: () => PoolTicks,
|
|
78
|
+
StakingLeaderboardPage: () => StakingLeaderboardPage,
|
|
79
|
+
StakingLeaderboardPosition: () => StakingLeaderboardPosition,
|
|
77
80
|
StakingPosition: () => StakingPosition,
|
|
78
81
|
StakingPositionHistoryAction: () => StakingPositionHistoryAction,
|
|
79
82
|
StakingPositionHistoryActionType: () => StakingPositionHistoryActionType,
|
|
@@ -174,6 +177,9 @@ var WalletSubscriptionTopicSchema = import_zod.z.enum([
|
|
|
174
177
|
WalletSubscriptionTopic.TUNA_POSITIONS,
|
|
175
178
|
...Object.values(WalletSubscriptionTopic)
|
|
176
179
|
]);
|
|
180
|
+
var PaginationMeta = import_zod.z.object({
|
|
181
|
+
total: import_zod.z.number()
|
|
182
|
+
});
|
|
177
183
|
var Mint = import_zod.z.object({
|
|
178
184
|
symbol: import_zod.z.string(),
|
|
179
185
|
mint: import_zod.z.string(),
|
|
@@ -386,6 +392,7 @@ var StakingTreasury = import_zod.z.object({
|
|
|
386
392
|
stakedTokenMint: import_zod.z.string(),
|
|
387
393
|
rewardTokenMint: import_zod.z.string(),
|
|
388
394
|
apy: import_zod.z.number(),
|
|
395
|
+
uniqueStakers: import_zod.z.number(),
|
|
389
396
|
totalStaked: amountWithUsd,
|
|
390
397
|
totalReward: amountWithUsd,
|
|
391
398
|
unstakeCooldownSeconds: import_zod.z.number(),
|
|
@@ -411,6 +418,16 @@ var StakingPosition = import_zod.z.object({
|
|
|
411
418
|
lastUnstakedAt: import_zod.z.nullable(import_zod.z.coerce.date()),
|
|
412
419
|
withdrawAvailableAt: import_zod.z.nullable(import_zod.z.coerce.date())
|
|
413
420
|
});
|
|
421
|
+
var StakingLeaderboardPosition = import_zod.z.object({
|
|
422
|
+
rank: import_zod.z.number(),
|
|
423
|
+
address: import_zod.z.string(),
|
|
424
|
+
owner: import_zod.z.string(),
|
|
425
|
+
staked: amountWithUsd
|
|
426
|
+
});
|
|
427
|
+
var StakingLeaderboardPage = import_zod.z.object({
|
|
428
|
+
data: StakingLeaderboardPosition.array(),
|
|
429
|
+
meta: PaginationMeta
|
|
430
|
+
});
|
|
414
431
|
var StakingPositionHistoryAction = import_zod.z.object({
|
|
415
432
|
position: import_zod.z.string(),
|
|
416
433
|
action: StakingPositionHistoryActionTypeSchema,
|
|
@@ -543,6 +560,9 @@ var TunaApiClient = class {
|
|
|
543
560
|
}
|
|
544
561
|
const data = await response.json();
|
|
545
562
|
const transformed = (0, import_camelcase_keys.default)(data, { deep: true, exclude: ["24h", "7d", "30d"] });
|
|
563
|
+
if (options?.parseRoot) {
|
|
564
|
+
return schema.parse(transformed);
|
|
565
|
+
}
|
|
546
566
|
return schema.parse(transformed.data);
|
|
547
567
|
} catch (error) {
|
|
548
568
|
if (retries > 0 && !(error instanceof Error && error.name === "AbortError")) {
|
|
@@ -637,6 +657,15 @@ var TunaApiClient = class {
|
|
|
637
657
|
const url = this.buildURL(`staking/treasury`);
|
|
638
658
|
return await this.httpRequest(url.toString(), StakingTreasury);
|
|
639
659
|
}
|
|
660
|
+
async getStakingLeaderboard(page, pageSize, search) {
|
|
661
|
+
const url = this.buildURL(`staking/leaderboard`);
|
|
662
|
+
this.appendUrlSearchParams(url, {
|
|
663
|
+
page: page.toString(),
|
|
664
|
+
page_size: pageSize.toString(),
|
|
665
|
+
...search ? { search } : {}
|
|
666
|
+
});
|
|
667
|
+
return await this.httpRequest(url.toString(), StakingLeaderboardPage, { parseRoot: true });
|
|
668
|
+
}
|
|
640
669
|
async getUserLendingPositions(userAddress) {
|
|
641
670
|
const url = this.buildURL(`users/${userAddress}/lending-positions`);
|
|
642
671
|
return await this.httpRequest(url.toString(), LendingPosition.array());
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,7 @@ __export(schemas_exports, {
|
|
|
28
28
|
OrderBookEntry: () => OrderBookEntry,
|
|
29
29
|
OrderBookNotification: () => OrderBookNotification,
|
|
30
30
|
OrderBookNotificationMeta: () => OrderBookNotificationMeta,
|
|
31
|
+
PaginationMeta: () => PaginationMeta,
|
|
31
32
|
Pool: () => Pool,
|
|
32
33
|
PoolPriceCandle: () => PoolPriceCandle,
|
|
33
34
|
PoolPriceUpdate: () => PoolPriceUpdate,
|
|
@@ -39,6 +40,8 @@ __export(schemas_exports, {
|
|
|
39
40
|
PoolSwap: () => PoolSwap,
|
|
40
41
|
PoolSwapNotification: () => PoolSwapNotification,
|
|
41
42
|
PoolTicks: () => PoolTicks,
|
|
43
|
+
StakingLeaderboardPage: () => StakingLeaderboardPage,
|
|
44
|
+
StakingLeaderboardPosition: () => StakingLeaderboardPosition,
|
|
42
45
|
StakingPosition: () => StakingPosition,
|
|
43
46
|
StakingPositionHistoryAction: () => StakingPositionHistoryAction,
|
|
44
47
|
StakingPositionHistoryActionType: () => StakingPositionHistoryActionType,
|
|
@@ -139,6 +142,9 @@ var WalletSubscriptionTopicSchema = z.enum([
|
|
|
139
142
|
WalletSubscriptionTopic.TUNA_POSITIONS,
|
|
140
143
|
...Object.values(WalletSubscriptionTopic)
|
|
141
144
|
]);
|
|
145
|
+
var PaginationMeta = z.object({
|
|
146
|
+
total: z.number()
|
|
147
|
+
});
|
|
142
148
|
var Mint = z.object({
|
|
143
149
|
symbol: z.string(),
|
|
144
150
|
mint: z.string(),
|
|
@@ -351,6 +357,7 @@ var StakingTreasury = z.object({
|
|
|
351
357
|
stakedTokenMint: z.string(),
|
|
352
358
|
rewardTokenMint: z.string(),
|
|
353
359
|
apy: z.number(),
|
|
360
|
+
uniqueStakers: z.number(),
|
|
354
361
|
totalStaked: amountWithUsd,
|
|
355
362
|
totalReward: amountWithUsd,
|
|
356
363
|
unstakeCooldownSeconds: z.number(),
|
|
@@ -376,6 +383,16 @@ var StakingPosition = z.object({
|
|
|
376
383
|
lastUnstakedAt: z.nullable(z.coerce.date()),
|
|
377
384
|
withdrawAvailableAt: z.nullable(z.coerce.date())
|
|
378
385
|
});
|
|
386
|
+
var StakingLeaderboardPosition = z.object({
|
|
387
|
+
rank: z.number(),
|
|
388
|
+
address: z.string(),
|
|
389
|
+
owner: z.string(),
|
|
390
|
+
staked: amountWithUsd
|
|
391
|
+
});
|
|
392
|
+
var StakingLeaderboardPage = z.object({
|
|
393
|
+
data: StakingLeaderboardPosition.array(),
|
|
394
|
+
meta: PaginationMeta
|
|
395
|
+
});
|
|
379
396
|
var StakingPositionHistoryAction = z.object({
|
|
380
397
|
position: z.string(),
|
|
381
398
|
action: StakingPositionHistoryActionTypeSchema,
|
|
@@ -508,6 +525,9 @@ var TunaApiClient = class {
|
|
|
508
525
|
}
|
|
509
526
|
const data = await response.json();
|
|
510
527
|
const transformed = camelcaseKeys(data, { deep: true, exclude: ["24h", "7d", "30d"] });
|
|
528
|
+
if (options?.parseRoot) {
|
|
529
|
+
return schema.parse(transformed);
|
|
530
|
+
}
|
|
511
531
|
return schema.parse(transformed.data);
|
|
512
532
|
} catch (error) {
|
|
513
533
|
if (retries > 0 && !(error instanceof Error && error.name === "AbortError")) {
|
|
@@ -602,6 +622,15 @@ var TunaApiClient = class {
|
|
|
602
622
|
const url = this.buildURL(`staking/treasury`);
|
|
603
623
|
return await this.httpRequest(url.toString(), StakingTreasury);
|
|
604
624
|
}
|
|
625
|
+
async getStakingLeaderboard(page, pageSize, search) {
|
|
626
|
+
const url = this.buildURL(`staking/leaderboard`);
|
|
627
|
+
this.appendUrlSearchParams(url, {
|
|
628
|
+
page: page.toString(),
|
|
629
|
+
page_size: pageSize.toString(),
|
|
630
|
+
...search ? { search } : {}
|
|
631
|
+
});
|
|
632
|
+
return await this.httpRequest(url.toString(), StakingLeaderboardPage, { parseRoot: true });
|
|
633
|
+
}
|
|
605
634
|
async getUserLendingPositions(userAddress) {
|
|
606
635
|
const url = this.buildURL(`users/${userAddress}/lending-positions`);
|
|
607
636
|
return await this.httpRequest(url.toString(), LendingPosition.array());
|