@pear-protocol/types 1.25.1 → 1.26.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.
@@ -18,6 +18,9 @@ export declare const LinkWalletRequest: z.ZodObject<{
18
18
  export declare const StartXLinkRequest: z.ZodObject<{
19
19
  returnTo: z.ZodOptional<z.ZodString>;
20
20
  }, z.core.$strip>;
21
+ export declare const SetXVisibilityRequest: z.ZodObject<{
22
+ xHidden: z.ZodBoolean;
23
+ }, z.core.$strip>;
21
24
  export declare const StartXLoginRequest: z.ZodObject<{
22
25
  returnTo: z.ZodOptional<z.ZodString>;
23
26
  handoffId: z.ZodString;
@@ -83,6 +86,7 @@ export type EmailRegisterRequest = z.infer<typeof EmailRegisterRequest>;
83
86
  export type LinkEmailRequest = z.infer<typeof LinkEmailRequest>;
84
87
  export type LinkWalletRequest = z.infer<typeof LinkWalletRequest>;
85
88
  export type StartXLinkRequest = z.infer<typeof StartXLinkRequest>;
89
+ export type SetXVisibilityRequest = z.infer<typeof SetXVisibilityRequest>;
86
90
  export type StartXLoginRequest = z.infer<typeof StartXLoginRequest>;
87
91
  export type ExchangeXLoginRequest = z.infer<typeof ExchangeXLoginRequest>;
88
92
  export type EmailLoginRequest = z.infer<typeof EmailLoginRequest>;
@@ -24,6 +24,9 @@ const LinkWalletRequest = z.object({
24
24
  const StartXLinkRequest = z.object({
25
25
  returnTo: z.string().optional().describe("Page to send the browser back to once the link finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin.")
26
26
  }).describe("Start of the X account link flow");
27
+ const SetXVisibilityRequest = z.object({
28
+ xHidden: z.boolean().describe("True to withhold the linked X account from the leaderboard, false to publish it. The wanted state rather than a flip, so a retry lands on the same result and two tabs cannot disagree. Named to match `xHidden` on the user profile - one name for one value.")
29
+ }).describe("Leaderboard visibility of the X account");
27
30
  const PkceValue = z.string().regex(/^[A-Za-z0-9_-]{43}$/, "Must be 43 base64url characters");
28
31
  const StartXLoginRequest = z.object({
29
32
  returnTo: z.string().optional().describe("Page to send the browser back to once the sign-in finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin. Any fragment is dropped - the flow returns its ticket there."),
@@ -78,4 +81,4 @@ const OauthInteractionConfirmRequest = z.object({
78
81
  scopes: z.array(z.string()).default([]).describe("The scope set the user granted at consent (opaque to the AS; empty resolves to the read-only fail-safe)")
79
82
  }).describe("Consent confirmation body \u2014 the granted scope set");
80
83
 
81
- export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ExchangeXLoginRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, StartXLinkRequest, StartXLoginRequest, VerifyEmailRequest, WalletLoginRequest };
84
+ export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ExchangeXLoginRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, SetXVisibilityRequest, StartXLinkRequest, StartXLoginRequest, VerifyEmailRequest, WalletLoginRequest };
@@ -54,6 +54,9 @@ export declare const LinkWalletResponse: z.ZodVoid;
54
54
  export declare const StartXLinkResponse: z.ZodObject<{
55
55
  authorizeUrl: z.ZodString;
56
56
  }, z.core.$strip>;
57
+ export declare const SetXVisibilityResponse: z.ZodObject<{
58
+ xHidden: z.ZodBoolean;
59
+ }, z.core.$strip>;
57
60
  export declare const DisconnectXResponse: z.ZodVoid;
58
61
  export declare const StartXLoginResponse: z.ZodObject<{
59
62
  authorizeUrl: z.ZodString;
@@ -137,6 +140,7 @@ export type RegisterEmailResponse = z.infer<typeof RegisterEmailResponse>;
137
140
  export type LinkEmailResponse = z.infer<typeof LinkEmailResponse>;
138
141
  export type LinkWalletResponse = z.infer<typeof LinkWalletResponse>;
139
142
  export type StartXLinkResponse = z.infer<typeof StartXLinkResponse>;
143
+ export type SetXVisibilityResponse = z.infer<typeof SetXVisibilityResponse>;
140
144
  export type DisconnectXResponse = z.infer<typeof DisconnectXResponse>;
141
145
  export type StartXLoginResponse = z.infer<typeof StartXLoginResponse>;
142
146
  export type MeResponse = z.infer<typeof MeResponse>;
@@ -37,6 +37,9 @@ const LinkWalletResponse = z.void().describe("Successful wallet link response");
37
37
  const StartXLinkResponse = z.object({
38
38
  authorizeUrl: z.string().describe("X authorization URL to send the browser to. Expires with the flow's state.")
39
39
  }).describe("Start of the X account link flow");
40
+ const SetXVisibilityResponse = z.object({
41
+ xHidden: z.boolean().describe("The stored state, read back from the write: true when the leaderboard withholds the X account. A confirmation of what was asked for, not a value the caller could not otherwise know.")
42
+ }).describe("Leaderboard visibility of the X account after the write");
40
43
  const DisconnectXResponse = z.void().describe("Successful X account disconnect response");
41
44
  const StartXLoginResponse = z.object({
42
45
  authorizeUrl: z.string().describe("X authorization URL to send the browser to. Expires with the flow's state.")
@@ -76,4 +79,4 @@ const OauthInteractionRedirectResponse = z.object({
76
79
  returnTo: z.string().describe("Provider URL to redirect the browser back to")
77
80
  }).describe("OAuth interaction redirect target after login/confirm/abort");
78
81
 
79
- export { ChangePasswordResponse, DisconnectXResponse, ForgotPasswordResponse, LinkEmailResponse, LinkWalletResponse, LoginResponse, LogoutResponse, MeResponse, OauthGrant, OauthGrantsResponse, OauthInteractionClient, OauthInteractionDetailsResponse, OauthInteractionRedirectResponse, RefreshSessionResponse, RefreshTokenResponse, RegisterEmailResponse, RequestNonceResponse, ResendVerificationResponse, ResetPasswordResponse, StartXLinkResponse, StartXLoginResponse, VerifyEmailResponse };
82
+ export { ChangePasswordResponse, DisconnectXResponse, ForgotPasswordResponse, LinkEmailResponse, LinkWalletResponse, LoginResponse, LogoutResponse, MeResponse, OauthGrant, OauthGrantsResponse, OauthInteractionClient, OauthInteractionDetailsResponse, OauthInteractionRedirectResponse, RefreshSessionResponse, RefreshTokenResponse, RegisterEmailResponse, RequestNonceResponse, ResendVerificationResponse, ResetPasswordResponse, SetXVisibilityResponse, StartXLinkResponse, StartXLoginResponse, VerifyEmailResponse };
@@ -1,5 +1,12 @@
1
1
  import z from 'zod';
2
2
  export declare const UnsignedDecimalString: z.ZodString;
3
+ /**
4
+ * Decimal string with an OPTIONAL sign ("0.8", "+0.8", "-0.1115").
5
+ * Sits between UnsignedDecimalString (no sign allowed) and SignedDecimalString
6
+ * (sign required): use it for wire fields that historically shipped unsigned but
7
+ * must now also carry negative values, so existing clients keep parsing.
8
+ */
9
+ export declare const DecimalString: z.ZodString;
3
10
  export declare const SignedDecimalString: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
4
11
  export declare const Side: z.ZodEnum<{
5
12
  BUY: "BUY";
@@ -1,6 +1,7 @@
1
1
  import z from 'zod';
2
2
 
3
3
  const UnsignedDecimalString = z.string().regex(/^\d+(\.\d+)?$/, "Must be a valid decimal string");
4
+ const DecimalString = z.string().regex(/^[+-]?\d+(\.\d+)?$/, "Must be a valid decimal string");
4
5
  const SignedDecimalString = z.string().regex(/^[+-]\d+(\.\d+)?$/, "Must be a valid signed decimal string").transform((val) => val);
5
6
  const Side = z.enum([
6
7
  "BUY",
@@ -14,4 +15,4 @@ const AssetWeight = z.number().positive({
14
15
  message: "Weight must be less than 1"
15
16
  });
16
17
 
17
- export { AssetWeight, Side, SignedDecimalString, UnsignedDecimalString };
18
+ export { AssetWeight, DecimalString, Side, SignedDecimalString, UnsignedDecimalString };
@@ -31,3 +31,20 @@ export declare const CreateAuthTokenParams: z.ZodObject<{
31
31
  ttlSeconds: z.ZodOptional<z.ZodNumber>;
32
32
  }, z.core.$strip>;
33
33
  export type CreateAuthTokenParams = z.output<typeof CreateAuthTokenParams>;
34
+ export declare const PrepareLighterFastWithdrawParams: z.ZodObject<{
35
+ accountIndex: z.ZodNumber;
36
+ toAddress: z.ZodString;
37
+ amount: z.ZodNumber;
38
+ apiKeyIndex: z.ZodNumber;
39
+ apiPrivateKey: z.ZodString;
40
+ }, z.core.$strip>;
41
+ export type PrepareLighterFastWithdrawParams = z.output<typeof PrepareLighterFastWithdrawParams>;
42
+ export declare const SubmitLighterFastWithdrawParams: z.ZodObject<{
43
+ accountIndex: z.ZodNumber;
44
+ toAddress: z.ZodString;
45
+ apiKeyIndex: z.ZodNumber;
46
+ apiPrivateKey: z.ZodString;
47
+ txInfo: z.ZodString;
48
+ l1Signature: z.ZodString;
49
+ }, z.core.$strip>;
50
+ export type SubmitLighterFastWithdrawParams = z.output<typeof SubmitLighterFastWithdrawParams>;
@@ -27,5 +27,20 @@ const CreateAuthTokenParams = z.object({
27
27
  apiPrivateKey: z.string(),
28
28
  ttlSeconds: z.number().optional()
29
29
  });
30
+ const PrepareLighterFastWithdrawParams = z.object({
31
+ accountIndex: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
32
+ toAddress: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
33
+ amount: z.number().int().min(4e6).max(Number.MAX_SAFE_INTEGER),
34
+ apiKeyIndex: z.number().int().nonnegative().max(254),
35
+ apiPrivateKey: z.string()
36
+ });
37
+ const SubmitLighterFastWithdrawParams = z.object({
38
+ accountIndex: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
39
+ toAddress: z.string().regex(/^0x[0-9a-fA-F]{40}$/),
40
+ apiKeyIndex: z.number().int().nonnegative().max(254),
41
+ apiPrivateKey: z.string(),
42
+ txInfo: z.string(),
43
+ l1Signature: z.string()
44
+ });
30
45
 
31
- export { CreateAuthTokenParams, CreateLighterApiKeyParams, PrepareApproveIntegratorParams, SubmitApproveIntegratorParams, SubmitChangePubKeyParams };
46
+ export { CreateAuthTokenParams, CreateLighterApiKeyParams, PrepareApproveIntegratorParams, PrepareLighterFastWithdrawParams, SubmitApproveIntegratorParams, SubmitChangePubKeyParams, SubmitLighterFastWithdrawParams };
@@ -24,3 +24,12 @@ export declare const CreateAuthTokenResult: z.ZodObject<{
24
24
  token: z.ZodString;
25
25
  }, z.core.$strip>;
26
26
  export type CreateAuthTokenResult = z.output<typeof CreateAuthTokenResult>;
27
+ export declare const PrepareLighterFastWithdrawResult: z.ZodObject<{
28
+ messageToSign: z.ZodString;
29
+ txInfo: z.ZodString;
30
+ }, z.core.$strip>;
31
+ export type PrepareLighterFastWithdrawResult = z.output<typeof PrepareLighterFastWithdrawResult>;
32
+ export declare const SubmitLighterFastWithdrawResult: z.ZodObject<{
33
+ txHash: z.ZodString;
34
+ }, z.core.$strip>;
35
+ export type SubmitLighterFastWithdrawResult = z.output<typeof SubmitLighterFastWithdrawResult>;
@@ -20,5 +20,12 @@ const SubmitApproveIntegratorResult = z.object({
20
20
  const CreateAuthTokenResult = z.object({
21
21
  token: z.string()
22
22
  });
23
+ const PrepareLighterFastWithdrawResult = z.object({
24
+ messageToSign: z.string(),
25
+ txInfo: z.string()
26
+ });
27
+ const SubmitLighterFastWithdrawResult = z.object({
28
+ txHash: z.string()
29
+ });
23
30
 
24
- export { CreateApiKeyWithMessageResult, CreateAuthTokenResult, PrepareApproveIntegratorResult, SubmitApproveIntegratorResult, SubmitChangePubKeyResult };
31
+ export { CreateApiKeyWithMessageResult, CreateAuthTokenResult, PrepareApproveIntegratorResult, PrepareLighterFastWithdrawResult, SubmitApproveIntegratorResult, SubmitChangePubKeyResult, SubmitLighterFastWithdrawResult };
@@ -8,9 +8,13 @@ const LeaderboardRow = z.object({
8
8
  // Address for Hyperliquid/Lighter, exchange account UID for CEXes.
9
9
  exchangeIdentifier: z.string(),
10
10
  connector: Connector,
11
+ // Every fill inside the window, whatever period its position began in — so unlike the
12
+ // money fields below, this can report trading whose fees and PnL belong to another window.
11
13
  volume: z.string(),
14
+ // Positions the window watched open, as are the fees and the return beside them.
12
15
  grossRealizedPnl: z.string(),
13
- // Zero on a ranged board — unrealized PnL is only meaningful as of now.
16
+ // Zero once the window has closed — unrealized PnL is a value as of now, so only a window
17
+ // that still contains now can report it. A window ending in the future does.
14
18
  grossUpnl: z.string(),
15
19
  // Net funding carry over the range, signed: negative when the trader paid to hold.
16
20
  // Account-level, so a client-scoped board reports the account's whole carry —
@@ -25,13 +29,22 @@ const LeaderboardRow = z.object({
25
29
  // Every position is weighted equally, so a small winner counts as much as a large one —
26
30
  // this is a measure of the trader's decisions, not of the dollars those decisions moved.
27
31
  //
28
- // Each position is measured against the size it opened with. An open position contributes
29
- // its unrealized PnL, a closed one what it realized after fees.
32
+ // One formula on every position: (realized + unrealized - fees paid) over the size it
33
+ // opened with. A closed position holds nothing, so its unrealized half is zero and this
34
+ // reduces to what the trader kept; a partly reduced open position counts both the profit
35
+ // it banked and the worth of what it still holds. Only fees of fills that happened are
36
+ // charged, so a running position never pays for the exit it has not made.
37
+ //
38
+ // Measured only where the window holds both the position's open and the moment the
39
+ // measurement is taken at: now for a running position, the closing fill for a finished
40
+ // one. A position that closed after the window ended is therefore left out — the window
41
+ // holds only part of what it realized, and part of a return is not a return.
30
42
  //
31
43
  // Absent when the board could measure none of the account's positions — never "0", which
32
44
  // would claim a break-even trader. An account reaches the board with nothing measurable
33
- // when its only activity in scope is a fill on a position opened before startDate, or when
34
- // none of its positions recorded an opening size.
45
+ // when its only trading in the window closed positions opened before it, when a closed
46
+ // window left its open positions unpriced, when every position it opened in the window
47
+ // closed after it, or when a position recorded no opening size.
35
48
  roi: z.string().optional(),
36
49
  // The trader's linked X account. Absent for an account whose owner has connected no X
37
50
  // account, and absent for an anonymous caller: the board itself is public, but pairing a
@@ -59,9 +59,17 @@ const LeaderboardQueryParams = z.object({
59
59
  // walk is independent, so selecting a subset leaves every remaining walk complete.
60
60
  asset: AssetArray.optional(),
61
61
  sortBy: LeaderboardSortBy.default("totalNetPnl"),
62
+ // Inclusive, and it scopes the money without scoping the trading. Volume and totalTrades
63
+ // count every fill inside the window, whatever period its position began in. Realized
64
+ // PnL, unrealized PnL, the fees behind them and roi count only for a position whose
65
+ // opening fill lands at or after this, so an exit is never booked — nor its fee charged —
66
+ // against an entry the window never saw. Volume is therefore additive across two adjacent
67
+ // windows and PnL is not, and a row can report volume beside no fees at all.
62
68
  startDate: UnixSeconds.optional(),
63
- // Absent endDate means the live board: unrealized PnL is included. Any
64
- // endDate at all yields a settled, reproducible board with no unrealized.
69
+ // Exclusive. Unrealized PnL is included whenever the window still contains now — an
70
+ // absent endDate, or one that has not yet arrived. Only a window that has already closed
71
+ // is settled and reproducible, and only there is unrealized PnL omitted: it is a value as
72
+ // of now, and now is outside such a window.
65
73
  endDate: UnixSeconds.optional(),
66
74
  limit: z.coerce.number().int().positive().max(LEADERBOARD_MAX_LIMIT).default(LEADERBOARD_MAX_LIMIT)
67
75
  }).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { RefineMinimumOneKeyValuePair } from '../common/refinement';
3
- import { UnsignedDecimalString, Side, SignedDecimalString } from '../common/schema';
3
+ import { UnsignedDecimalString, DecimalString, Side, SignedDecimalString } from '../common/schema';
4
4
  import { Connector } from '../connector';
5
5
  import { InstrumentId } from '../instrument';
6
6
  import { PositionClosedReason, PositionStatus, PositionOrigin } from '../position/entities';
@@ -10,6 +10,7 @@ const MsTimestamp = z.number().int().positive().describe("Unix timestamp in mill
10
10
  const LiquidationMark = z.object({
11
11
  mark: UnsignedDecimalString
12
12
  }).nullable();
13
+ const TradeFee = DecimalString;
13
14
  const OriginalFillRef = z.object({
14
15
  exchangeFillId: ExchangeFillId,
15
16
  quantity: UnsignedDecimalString
@@ -24,7 +25,7 @@ const UnknownExternalFill = z.object({
24
25
  side: Side,
25
26
  reduceOnly: z.boolean(),
26
27
  timestamp: MsTimestamp,
27
- tradeFee: UnsignedDecimalString,
28
+ tradeFee: TradeFee,
28
29
  builderFee: UnsignedDecimalString,
29
30
  liquidation: LiquidationMark
30
31
  });
@@ -37,7 +38,7 @@ const ConfirmableExternalFill = z.object({
37
38
  symbol: InstrumentId,
38
39
  quantity: UnsignedDecimalString,
39
40
  timestamp: MsTimestamp,
40
- tradeFee: UnsignedDecimalString,
41
+ tradeFee: TradeFee,
41
42
  builderFee: UnsignedDecimalString
42
43
  });
43
44
  const ReconcileReplacementExternalFill = z.object({
@@ -50,7 +51,7 @@ const ReconcileReplacementExternalFill = z.object({
50
51
  side: Side,
51
52
  reduceOnly: z.boolean(),
52
53
  timestamp: MsTimestamp,
53
- tradeFee: UnsignedDecimalString,
54
+ tradeFee: TradeFee,
54
55
  builderFee: UnsignedDecimalString,
55
56
  liquidation: LiquidationMark
56
57
  });
@@ -89,7 +90,7 @@ const ApplicableFill = z.object({
89
90
  reduceOnly: z.boolean(),
90
91
  synthetic: z.boolean(),
91
92
  isExternal: z.boolean(),
92
- tradeFee: UnsignedDecimalString,
93
+ tradeFee: TradeFee,
93
94
  builderFee: UnsignedDecimalString,
94
95
  closedReason: PositionClosedReason.optional().describe("e.g. NETTED for a synthetic close fill"),
95
96
  liquidation: LiquidationMark.optional(),
@@ -15,6 +15,7 @@ export declare const UserProfile: z.ZodObject<{
15
15
  xHandle: z.ZodNullable<z.ZodString>;
16
16
  xName: z.ZodNullable<z.ZodString>;
17
17
  xAvatarUrl: z.ZodNullable<z.ZodString>;
18
+ xHidden: z.ZodBoolean;
18
19
  }, z.core.$strip>;
19
20
  export type UserPreferences = z.infer<typeof UserPreferences>;
20
21
  export type UserProfile = z.infer<typeof UserProfile>;
@@ -18,7 +18,11 @@ const UserProfile = z.object({
18
18
  // conventions inside one object costs more than following its neighbours.
19
19
  xHandle: z.string().nullable().describe('Linked X handle, without the leading "@" (for x provider)'),
20
20
  xName: z.string().nullable().describe("Linked X display name"),
21
- xAvatarUrl: z.string().nullable().describe("Linked X avatar URL")
21
+ xAvatarUrl: z.string().nullable().describe("Linked X avatar URL"),
22
+ // A plain boolean rather than nullable, matching `emailVerified` above: this is the
23
+ // owner's own setting, which is known whether or not an X account is linked. With none
24
+ // linked it describes what would happen once one is.
25
+ xHidden: z.boolean().describe("Whether the leaderboard withholds the linked X account")
22
26
  }).describe("User profile of the authenticated user");
23
27
  const ReferralReferee = z.object({
24
28
  address: EthereumAddress.optional().describe("Linked EVM wallet address when the referee has one"),
@@ -13,6 +13,7 @@ export declare const ProfileResponse: z.ZodObject<{
13
13
  xHandle: z.ZodNullable<z.ZodString>;
14
14
  xName: z.ZodNullable<z.ZodString>;
15
15
  xAvatarUrl: z.ZodNullable<z.ZodString>;
16
+ xHidden: z.ZodBoolean;
16
17
  }, z.core.$strip>;
17
18
  preferences: z.ZodObject<{
18
19
  slippageToleranceBps: z.ZodInt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "1.25.1",
3
+ "version": "1.26.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",