@pear-protocol/types 2.19.0 → 2.21.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.
@@ -84,3 +84,28 @@ export declare const LeaderboardQueryParams: z.ZodObject<{
84
84
  }, z.core.$strip>;
85
85
  export type LeaderboardQueryParamsInput = z.input<typeof LeaderboardQueryParams>;
86
86
  export type LeaderboardQueryParams = z.output<typeof LeaderboardQueryParams>;
87
+ export declare const LeaderboardSnapshotParams: z.ZodObject<{
88
+ slug: z.ZodString;
89
+ }, z.core.$strip>;
90
+ export type LeaderboardSnapshotParams = z.output<typeof LeaderboardSnapshotParams>;
91
+ export declare const LeaderboardSnapshotQueryParams: z.ZodObject<{
92
+ sortBy: z.ZodOptional<z.ZodEnum<{
93
+ volume: "volume";
94
+ totalNetPnl: "totalNetPnl";
95
+ roi: "roi";
96
+ trades: "trades";
97
+ }>>;
98
+ limit: z.ZodDefault<z.ZodCoercedNumber<number>>;
99
+ }, z.core.$strip>;
100
+ export type LeaderboardSnapshotQueryParamsInput = z.input<typeof LeaderboardSnapshotQueryParams>;
101
+ export type LeaderboardSnapshotQueryParams = z.output<typeof LeaderboardSnapshotQueryParams>;
102
+ export declare const LeaderboardArchiveParams: z.ZodObject<{
103
+ slug: z.ZodString;
104
+ }, z.core.$strip>;
105
+ export type LeaderboardArchiveParams = z.output<typeof LeaderboardArchiveParams>;
106
+ export declare const LeaderboardArchivePeriodParams: z.ZodObject<{
107
+ slug: z.ZodString;
108
+ startDate: z.ZodPipe<z.ZodCoercedNumber<number>, z.ZodTransform<Date, number>>;
109
+ }, z.core.$strip>;
110
+ export type LeaderboardArchivePeriodParamsInput = z.input<typeof LeaderboardArchivePeriodParams>;
111
+ export type LeaderboardArchivePeriodParams = z.output<typeof LeaderboardArchivePeriodParams>;
@@ -89,5 +89,23 @@ const LeaderboardQueryParams = z.object({
89
89
  }).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
90
90
  message: "startDate must be before endDate"
91
91
  });
92
+ const LeaderboardSnapshotParams = z.object({
93
+ slug: z.string()
94
+ });
95
+ const LeaderboardSnapshotQueryParams = z.object({
96
+ // Absent means the default the board was published with, never the registry's current one.
97
+ sortBy: LeaderboardSortBy.optional(),
98
+ // Defaults to the free-form board's 200, so a migrating client sees no change. Deliberately
99
+ // uncapped, unlike LEADERBOARD_MAX_LIMIT there: the snapshot already holds every qualifying
100
+ // row, so a larger limit costs response size, not a ranking.
101
+ limit: z.coerce.number().int().positive().default(200)
102
+ });
103
+ const LeaderboardArchiveParams = z.object({
104
+ slug: z.string()
105
+ });
106
+ const LeaderboardArchivePeriodParams = z.object({
107
+ slug: z.string(),
108
+ startDate: UnixSeconds
109
+ });
92
110
 
93
- export { LEADERBOARD_MAX_LIMIT, LeaderboardQueryParams, LeaderboardSortBy, OiStatisticsQueryParams, StatisticsTotalsQueryParams, VolumeStatisticsQueryParams };
111
+ export { LEADERBOARD_MAX_LIMIT, LeaderboardArchiveParams, LeaderboardArchivePeriodParams, LeaderboardQueryParams, LeaderboardSnapshotParams, LeaderboardSnapshotQueryParams, LeaderboardSortBy, OiStatisticsQueryParams, StatisticsTotalsQueryParams, VolumeStatisticsQueryParams };
@@ -37,6 +37,126 @@ export declare const LeaderboardResponse: z.ZodObject<{
37
37
  }, z.core.$strip>>;
38
38
  }, z.core.$strip>;
39
39
  export type LeaderboardResponse = z.output<typeof LeaderboardResponse>;
40
+ export declare const LeaderboardStatus: z.ZodEnum<{
41
+ upcoming: "upcoming";
42
+ live: "live";
43
+ final: "final";
44
+ }>;
45
+ export type LeaderboardStatus = z.output<typeof LeaderboardStatus>;
46
+ export declare const LeaderboardSnapshotResponse: z.ZodObject<{
47
+ slug: z.ZodString;
48
+ status: z.ZodEnum<{
49
+ upcoming: "upcoming";
50
+ live: "live";
51
+ final: "final";
52
+ }>;
53
+ sortBy: z.ZodEnum<{
54
+ volume: "volume";
55
+ totalNetPnl: "totalNetPnl";
56
+ roi: "roi";
57
+ trades: "trades";
58
+ }>;
59
+ updatedAt: z.ZodISODateTime;
60
+ window: z.ZodObject<{
61
+ startDate: z.ZodOptional<z.ZodNumber>;
62
+ endDate: z.ZodOptional<z.ZodNumber>;
63
+ }, z.core.$strip>;
64
+ data: z.ZodArray<z.ZodObject<{
65
+ tradeAccountId: z.ZodString;
66
+ userId: z.ZodString;
67
+ connector: z.ZodEnum<{
68
+ hyperliquid: "hyperliquid";
69
+ binance: "binance";
70
+ bybit: "bybit";
71
+ okx: "okx";
72
+ lighter: "lighter";
73
+ lighter_rhc: "lighter_rhc";
74
+ }>;
75
+ followers: z.ZodArray<z.ZodObject<{
76
+ tradeAccountId: z.ZodUUID;
77
+ status: z.ZodLiteral<"ACTIVE">;
78
+ followedAt: z.ZodString;
79
+ xUserId: z.ZodOptional<z.ZodString>;
80
+ xHandle: z.ZodOptional<z.ZodString>;
81
+ xName: z.ZodOptional<z.ZodString>;
82
+ xAvatarUrl: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>>;
84
+ followerCount: z.ZodNumber;
85
+ volume: z.ZodString;
86
+ grossRealizedPnl: z.ZodString;
87
+ grossUpnl: z.ZodString;
88
+ fundingPayment: z.ZodString;
89
+ totalNetPnl: z.ZodString;
90
+ pearFee: z.ZodString;
91
+ tradeFee: z.ZodString;
92
+ totalTrades: z.ZodNumber;
93
+ roi: z.ZodOptional<z.ZodString>;
94
+ xHandle: z.ZodOptional<z.ZodString>;
95
+ xName: z.ZodOptional<z.ZodString>;
96
+ xAvatarUrl: z.ZodOptional<z.ZodString>;
97
+ xUserId: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>>;
99
+ }, z.core.$strip>;
100
+ export type LeaderboardSnapshotResponse = z.output<typeof LeaderboardSnapshotResponse>;
101
+ export declare const LeaderboardArchiveListResponse: z.ZodObject<{
102
+ slug: z.ZodString;
103
+ periods: z.ZodArray<z.ZodObject<{
104
+ startDate: z.ZodNumber;
105
+ endDate: z.ZodNumber;
106
+ archivedAt: z.ZodISODateTime;
107
+ }, z.core.$strip>>;
108
+ }, z.core.$strip>;
109
+ export type LeaderboardArchiveListResponse = z.output<typeof LeaderboardArchiveListResponse>;
110
+ export declare const LeaderboardArchiveResponse: z.ZodObject<{
111
+ slug: z.ZodString;
112
+ sortBy: z.ZodEnum<{
113
+ volume: "volume";
114
+ totalNetPnl: "totalNetPnl";
115
+ roi: "roi";
116
+ trades: "trades";
117
+ }>;
118
+ window: z.ZodObject<{
119
+ startDate: z.ZodNumber;
120
+ endDate: z.ZodNumber;
121
+ }, z.core.$strip>;
122
+ archivedAt: z.ZodISODateTime;
123
+ data: z.ZodArray<z.ZodObject<{
124
+ tradeAccountId: z.ZodString;
125
+ userId: z.ZodString;
126
+ connector: z.ZodEnum<{
127
+ hyperliquid: "hyperliquid";
128
+ binance: "binance";
129
+ bybit: "bybit";
130
+ okx: "okx";
131
+ lighter: "lighter";
132
+ lighter_rhc: "lighter_rhc";
133
+ }>;
134
+ followers: z.ZodArray<z.ZodObject<{
135
+ tradeAccountId: z.ZodUUID;
136
+ status: z.ZodLiteral<"ACTIVE">;
137
+ followedAt: z.ZodString;
138
+ xUserId: z.ZodOptional<z.ZodString>;
139
+ xHandle: z.ZodOptional<z.ZodString>;
140
+ xName: z.ZodOptional<z.ZodString>;
141
+ xAvatarUrl: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strip>>;
143
+ followerCount: z.ZodNumber;
144
+ volume: z.ZodString;
145
+ grossRealizedPnl: z.ZodString;
146
+ grossUpnl: z.ZodString;
147
+ fundingPayment: z.ZodString;
148
+ totalNetPnl: z.ZodString;
149
+ pearFee: z.ZodString;
150
+ tradeFee: z.ZodString;
151
+ totalTrades: z.ZodNumber;
152
+ roi: z.ZodOptional<z.ZodString>;
153
+ xHandle: z.ZodOptional<z.ZodString>;
154
+ xName: z.ZodOptional<z.ZodString>;
155
+ xAvatarUrl: z.ZodOptional<z.ZodString>;
156
+ xUserId: z.ZodOptional<z.ZodString>;
157
+ }, z.core.$strip>>;
158
+ }, z.core.$strip>;
159
+ export type LeaderboardArchiveResponse = z.output<typeof LeaderboardArchiveResponse>;
40
160
  export declare const VolumeStatisticsResponse: z.ZodObject<{
41
161
  data: z.ZodArray<z.ZodObject<{
42
162
  timestamp: z.ZodNumber;
@@ -1,9 +1,59 @@
1
1
  import { z } from 'zod';
2
2
  import { LeaderboardRow, VolumeStatistics, OiStatistics, StatisticsTotals } from './entities';
3
+ import { LeaderboardSortBy } from './queries';
3
4
 
4
5
  const LeaderboardResponse = z.object({
5
6
  data: z.array(LeaderboardRow)
6
7
  });
8
+ const UnixSeconds = z.number().int().nonnegative();
9
+ const LeaderboardStatus = z.enum([
10
+ "upcoming",
11
+ "live",
12
+ "final"
13
+ ]);
14
+ const LeaderboardSnapshotResponse = z.object({
15
+ // Echoes the path parameter.
16
+ slug: z.string(),
17
+ // Lifecycle of the requested competition; final rows come from its frozen archive.
18
+ status: LeaderboardStatus,
19
+ // The order the rows are in, including when the board's published default was applied.
20
+ sortBy: LeaderboardSortBy,
21
+ // Live: computed at; final: archived at; upcoming: lifecycle evaluated at.
22
+ updatedAt: z.iso.datetime(),
23
+ // The period the rows cover, in the free-form board's query units, so a consumer can feed
24
+ // these back as its startDate/endDate to reproduce the board. An absent bound is open.
25
+ window: z.object({
26
+ startDate: UnixSeconds.optional(),
27
+ endDate: UnixSeconds.optional()
28
+ }),
29
+ data: z.array(LeaderboardRow)
30
+ });
31
+ const LeaderboardArchiveListResponse = z.object({
32
+ // Echoes the path parameter.
33
+ slug: z.string(),
34
+ periods: z.array(z.object({
35
+ // The period's bounds in the free-form board's query units; startDate addresses the period.
36
+ startDate: UnixSeconds,
37
+ endDate: UnixSeconds,
38
+ // When the period was ranked — not a freshness signal, the board never changes after it.
39
+ archivedAt: z.iso.datetime()
40
+ }))
41
+ });
42
+ const LeaderboardArchiveResponse = z.object({
43
+ // Echoes the path parameter.
44
+ slug: z.string(),
45
+ // The order the rows are in, including when the archived query's default was applied.
46
+ sortBy: LeaderboardSortBy,
47
+ // A finished period always has both bounds, in the free-form board's query units, so a
48
+ // consumer can feed them back as its startDate/endDate to re-query the period.
49
+ window: z.object({
50
+ startDate: UnixSeconds,
51
+ endDate: UnixSeconds
52
+ }),
53
+ // When the period was ranked; distinct from a live board's updatedAt, it says nothing of freshness.
54
+ archivedAt: z.iso.datetime(),
55
+ data: z.array(LeaderboardRow)
56
+ });
7
57
  const VolumeStatisticsResponse = z.object({
8
58
  data: z.array(VolumeStatistics)
9
59
  });
@@ -14,4 +64,4 @@ const StatisticsTotalsResponse = z.object({
14
64
  data: StatisticsTotals
15
65
  });
16
66
 
17
- export { LeaderboardResponse, OiStatisticsResponse, StatisticsTotalsResponse, VolumeStatisticsResponse };
67
+ export { LeaderboardArchiveListResponse, LeaderboardArchiveResponse, LeaderboardResponse, LeaderboardSnapshotResponse, LeaderboardStatus, OiStatisticsResponse, StatisticsTotalsResponse, VolumeStatisticsResponse };
@@ -5,6 +5,7 @@ export declare const SyncFillsSinceResponse: z.ZodObject<{
5
5
  neverSynced: z.ZodBoolean;
6
6
  firstSyncStartedAt: z.ZodOptional<z.ZodNumber>;
7
7
  confirmedExchangeFillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
+ hasPendingSynthetics: z.ZodOptional<z.ZodBoolean>;
8
9
  executionsUpdatedAtEpochMs: z.ZodNumber;
9
10
  }, z.core.$strip>;
10
11
  export declare const SyncFundingSinceResponse: z.ZodObject<{
@@ -11,6 +11,8 @@ const SyncFillsSinceResponse = z.object({
11
11
  // through when an empty exchange fetch provides no fill-derived checkpoint.
12
12
  firstSyncStartedAt: z.number().int().nonnegative().optional(),
13
13
  confirmedExchangeFillIds: z.array(z.string()).optional(),
14
+ // A pending correction needs the next full snapshot even when there are no fills to apply.
15
+ hasPendingSynthetics: z.boolean().optional(),
14
16
  // Newest executions.updatedAt this response can have observed, as epoch ms ceiled to the next
15
17
  // whole millisecond (the column keeps microseconds); 0 when the account has no executions. The
16
18
  // client echoes it verbatim in the create meta — core defers the create when any execution
@@ -30,8 +30,8 @@ const BoundReferralReferee = z.object({
30
30
  status: z.literal("BOUND").describe("The referee resolves to a V3 user with a permanent binding"),
31
31
  address: EthereumAddress.optional().describe("Linked EVM wallet address when the referee has one"),
32
32
  referredAt: z.number().int().nonnegative().optional().describe("V3 attribution time in epoch milliseconds; not the original legacy on-chain referral time, and absent on a historical binding without a recoverable date"),
33
- tradeCount: z.number().int().nonnegative().describe("Distinct Pear executions with at least one real confirmed fill"),
34
- volumeUsd: UnsignedDecimalString.describe("Post-binding V3 volume from real confirmed Pear fills, in USD")
33
+ tradeCount: z.number().int().nonnegative().describe("Distinct Pear executions with at least one real confirmed Hyperliquid or Lighter fill"),
34
+ volumeUsd: UnsignedDecimalString.describe("Post-binding V3 volume from real confirmed Pear fills on Hyperliquid and Lighter, in USD")
35
35
  });
36
36
  const PendingReferralReferee = z.object({
37
37
  status: z.literal("PENDING").describe("A verified legacy referee that has no V3 identity yet"),
@@ -42,6 +42,7 @@ export declare const ReferralRefereeListResponse: z.ZodObject<{
42
42
  count: z.ZodNumber;
43
43
  pendingCount: z.ZodNumber;
44
44
  totalVolumeUsd: z.ZodString;
45
+ totalEarnedUsd: z.ZodString;
45
46
  referees: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
46
47
  status: z.ZodLiteral<"BOUND">;
47
48
  address: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("..").EthereumAddress, string>>>;
@@ -20,7 +20,8 @@ const ReferralStatusResponse = z.object({
20
20
  const ReferralRefereeListResponse = CursorResponse.extend({
21
21
  count: z.number().int().nonnegative().describe("Total referees this list yields, counting bound V3 users and pending legacy wallets together"),
22
22
  pendingCount: z.number().int().nonnegative().describe("Subset of count whose verified legacy wallet has no V3 identity yet, so no binding exists"),
23
- totalVolumeUsd: UnsignedDecimalString.describe("Post-binding V3 volume from real confirmed Pear fills across the complete bound referee set, independent of pagination"),
23
+ totalVolumeUsd: UnsignedDecimalString.describe("Post-binding V3 volume from real confirmed Pear fills on Hyperliquid and Lighter across the complete bound referee set, independent of pagination"),
24
+ totalEarnedUsd: UnsignedDecimalString.describe("The referrer's share of the Pear fees on the same fills totalVolumeUsd counts, independent of pagination"),
24
25
  referees: z.array(ReferralReferee)
25
26
  });
26
27
 
@@ -355,15 +355,6 @@ export declare const ActivityItemResponse: z.ZodObject<{
355
355
  }, z.core.$strip>;
356
356
  }, z.core.$strip>;
357
357
  export type ActivityItemResponse = z.output<typeof ActivityItemResponse>;
358
- export declare const AgentBalancesResponse: z.ZodObject<{
359
- agentAddress: z.ZodString;
360
- spot: z.ZodRecord<z.ZodString, z.ZodString>;
361
- perp: z.ZodObject<{
362
- accountValue: z.ZodString;
363
- withdrawable: z.ZodString;
364
- }, z.core.$strip>;
365
- }, z.core.$strip>;
366
- export type AgentBalancesResponse = z.infer<typeof AgentBalancesResponse>;
367
358
  /** Bare agent-approve outcome: the service returns exactly this union. */
368
359
  export declare const AgentApproveResult: z.ZodDiscriminatedUnion<[z.ZodObject<{
369
360
  success: z.ZodLiteral<true>;
@@ -159,14 +159,6 @@ const ActivityResponse = z.object({
159
159
  const ActivityItemResponse = z.object({
160
160
  activity: Activity
161
161
  });
162
- const AgentBalancesResponse = z.object({
163
- agentAddress: z.string(),
164
- spot: z.record(z.string(), z.string()),
165
- perp: z.object({
166
- accountValue: z.string(),
167
- withdrawable: z.string()
168
- })
169
- });
170
162
  const AgentApproveSent = z.object({
171
163
  success: z.literal(true),
172
164
  transactionHash: z.string(),
@@ -373,4 +365,4 @@ const VaultServiceError = z.discriminatedUnion("error", [
373
365
  })
374
366
  ]);
375
367
 
376
- export { ActivityItemResponse, ActivityResponse, AgentApproveResponse, AgentApproveResult, AgentBalancesResponse, BulkSnapshotsResponse, CreatedVaultResponse, CreatedVaultResult, NavRangeResponse, NavSnapshotResponse, NavStatsResponse, SetTraderResponse, SetTraderResult, UnifiedAccountResponse, UpdateVaultMetadataResponse, UpdateVaultMetadataResult, VaultEventListResponse, VaultInvestmentsResponse, VaultListResponse, VaultOverviewResponse, VaultRequestIssue, VaultResponse, VaultServiceError, VaultStatsResponse, WithdrawToEvmResponse, WithdrawToEvmResult };
368
+ export { ActivityItemResponse, ActivityResponse, AgentApproveResponse, AgentApproveResult, BulkSnapshotsResponse, CreatedVaultResponse, CreatedVaultResult, NavRangeResponse, NavSnapshotResponse, NavStatsResponse, SetTraderResponse, SetTraderResult, UnifiedAccountResponse, UpdateVaultMetadataResponse, UpdateVaultMetadataResult, VaultEventListResponse, VaultInvestmentsResponse, VaultListResponse, VaultOverviewResponse, VaultRequestIssue, VaultResponse, VaultServiceError, VaultStatsResponse, WithdrawToEvmResponse, WithdrawToEvmResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "2.19.0",
3
+ "version": "2.21.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "test": "vitest run --typecheck",
24
24
  "build": "tsup && tsc -p tsconfig.build.json",
25
25
  "clean": "rm -rf dist .turbo",
26
- "typecheck": "tsc --noEmit"
26
+ "typecheck": "bunx --package bun@1.4.3 bun --check --threads=2"
27
27
  },
28
28
  "dependencies": {
29
29
  "zod": "4.1.12"