@pear-protocol/types 2.0.0 → 2.1.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.
@@ -51,6 +51,7 @@ export declare const ApiKeyMeResponse: z.ZodObject<{
51
51
  role: z.ZodEnum<{
52
52
  basic: "basic";
53
53
  pro: "pro";
54
+ vault: "vault";
54
55
  }>;
55
56
  scope: z.ZodEnum<{
56
57
  read: "read";
@@ -34,7 +34,8 @@ const ApiKeyMeResponse = z.object({
34
34
  id: z.uuid().describe("User UUID that owns the API key"),
35
35
  role: z.enum([
36
36
  "basic",
37
- "pro"
37
+ "pro",
38
+ "vault"
38
39
  ]).describe("User role"),
39
40
  scope: ApiKeyScope,
40
41
  authMethod: z.literal("api_key")
@@ -10,6 +10,7 @@ export declare const AuthenticatedUser: z.ZodObject<{
10
10
  role: z.ZodEnum<{
11
11
  basic: "basic";
12
12
  pro: "pro";
13
+ vault: "vault";
13
14
  }>;
14
15
  providerId: z.ZodNullable<z.ZodString>;
15
16
  loginMethod: z.ZodEnum<{
@@ -10,7 +10,8 @@ const AuthenticatedUser = z.object({
10
10
  id: z.uuid().describe("User UUID"),
11
11
  role: z.enum([
12
12
  "basic",
13
- "pro"
13
+ "pro",
14
+ "vault"
14
15
  ]).describe("User role"),
15
16
  providerId: z.string().nullable().describe("Provider identifier (wallet address or email)"),
16
17
  loginMethod: LoginMethod.describe("Authentication provider used for the current session")
@@ -7,6 +7,7 @@ export declare const LoginResponse: z.ZodObject<{
7
7
  role: z.ZodEnum<{
8
8
  basic: "basic";
9
9
  pro: "pro";
10
+ vault: "vault";
10
11
  }>;
11
12
  providerId: z.ZodNullable<z.ZodString>;
12
13
  loginMethod: z.ZodEnum<{
@@ -77,6 +78,7 @@ export declare const MeResponse: z.ZodObject<{
77
78
  role: z.ZodEnum<{
78
79
  basic: "basic";
79
80
  pro: "pro";
81
+ vault: "vault";
80
82
  }>;
81
83
  providerId: z.ZodNullable<z.ZodString>;
82
84
  loginMethod: z.ZodEnum<{
package/dist/bundle.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './instrument';
11
11
  export * from './instrument-precision';
12
12
  export * from './ladder';
13
13
  export * from './leverage';
14
+ export * from './margin';
14
15
  export * from './market';
15
16
  export * from './misc';
16
17
  export * from './notification';
package/dist/bundle.js CHANGED
@@ -11,6 +11,7 @@ export * from './instrument';
11
11
  export * from './instrument-precision';
12
12
  export * from './ladder';
13
13
  export * from './leverage';
14
+ export * from './margin';
14
15
  export * from './market';
15
16
  export * from './misc';
16
17
  export * from './notification';
@@ -23,6 +23,7 @@ export type FeeConnector = z.output<typeof FeeConnector>;
23
23
  export declare const FeeRole: z.ZodEnum<{
24
24
  basic: "basic";
25
25
  pro: "pro";
26
+ vault: "vault";
26
27
  }>;
27
28
  export type FeeRole = z.output<typeof FeeRole>;
28
29
  export declare const FeeBps: z.ZodString;
@@ -17,7 +17,8 @@ const FeeDiscountScope = z.enum([
17
17
  const FeeConnector = z.enum(Connector.options);
18
18
  const FeeRole = z.enum([
19
19
  "basic",
20
- "pro"
20
+ "pro",
21
+ "vault"
21
22
  ]);
22
23
  const FeeBps = z.string().regex(/^\d{1,2}(\.\d)?$/, "Fee bps must be a decimal with at most one decimal place").refine((value) => Number(value) <= MAX_FEE_BPS, `Fee bps must not exceed ${MAX_FEE_BPS}`);
23
24
  const DiscountRate = z.string().regex(/^(0(\.\d{1,4})?|1(\.0{1,4})?)$/, 'Discount rate must be a fraction from 0 to 1, e.g. "0.2" for 20% off');
@@ -0,0 +1,2 @@
1
+ export * from './payloads';
2
+ export * from './response';
@@ -0,0 +1,2 @@
1
+ export * from './payloads';
2
+ export * from './response';
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export declare const AdjustIsolatedMargin: z.ZodObject<{
3
+ symbol: z.ZodString;
4
+ amount: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
5
+ idempotencyKey: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export type AdjustIsolatedMargin = z.infer<typeof AdjustIsolatedMargin>;
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { SignedDecimalString } from '../common/schema';
3
+ import { InstrumentId } from '../instrument/entities';
4
+
5
+ const AdjustIsolatedMargin = z.object({
6
+ symbol: InstrumentId,
7
+ /**
8
+ * Signed margin movement in USD: `"+50"` adds 50 to the position, `"-50"` removes 50 from it.
9
+ * The sign is required, so a movement can never mean the opposite of what was intended.
10
+ */
11
+ amount: SignedDecimalString.refine((amount) => Number(amount) !== 0, "Amount must not be zero"),
12
+ /**
13
+ * Optional caller-supplied idempotency key, scoped to the trade account. A retry carrying the
14
+ * same key attaches to the first attempt and receives its outcome instead of moving the margin
15
+ * again. Omitted, the server mints one; either way it is returned as `adjustmentId`.
16
+ */
17
+ idempotencyKey: z.string().min(1).max(128).optional()
18
+ });
19
+
20
+ export { AdjustIsolatedMargin };
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const AdjustIsolatedMarginResponse: z.ZodObject<{
3
+ adjustmentId: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export type AdjustIsolatedMarginResponse = z.infer<typeof AdjustIsolatedMarginResponse>;
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+
3
+ const AdjustIsolatedMarginResponse = z.object({
4
+ /**
5
+ * The caller's `idempotencyKey` when supplied, otherwise a server-minted UUID. Reusing it as the
6
+ * request key replays this movement's outcome.
7
+ */
8
+ adjustmentId: z.string().min(1).max(128)
9
+ });
10
+
11
+ export { AdjustIsolatedMarginResponse };
@@ -20,6 +20,10 @@ export declare const TradeAccount: z.ZodObject<{
20
20
  okx: "okx";
21
21
  lighter: "lighter";
22
22
  }>;
23
+ kind: z.ZodEnum<{
24
+ vault: "vault";
25
+ eoa: "eoa";
26
+ }>;
23
27
  exchangeIdentifier: z.ZodString;
24
28
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
25
29
  agentWalletAddress: z.ZodString;
@@ -17,6 +17,10 @@ const TradeAccount = z.object({
17
17
  id: z.uuid().describe("Trade account UUID"),
18
18
  alias: z.string().describe("User-defined trade account alias"),
19
19
  connector: Connector.describe("Exchange connector type"),
20
+ kind: z.enum([
21
+ "eoa",
22
+ "vault"
23
+ ]).describe("Whether the account trades an EOA or a Pear vault"),
20
24
  exchangeIdentifier: z.string().describe("User identifier on the exchange"),
21
25
  metadata: ConnectorMetadata.describe("Connector-specific metadata"),
22
26
  createdAt: z.string().describe("Creation timestamp (ISO 8601)"),
@@ -109,6 +109,16 @@ export declare const CreateTradeAccount: z.ZodDiscriminatedUnion<[z.ZodObject<{
109
109
  l1_address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
110
110
  }, z.core.$strip>;
111
111
  }, z.core.$strip>], "connector">;
112
+ /**
113
+ * Payload to create a Pear-vault-backed Hyperliquid trade account. The backend
114
+ * generates and approves the API wallet itself (via pear-vault-service), so
115
+ * the payload carries no credentials.
116
+ */
117
+ export declare const CreateVaultTradeAccount: z.ZodObject<{
118
+ vaultAddress: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
119
+ alias: z.ZodString;
120
+ idempotencyKey: z.ZodOptional<z.ZodString>;
121
+ }, z.core.$strip>;
112
122
  /**
113
123
  * Payload to update a trade account
114
124
  */
@@ -174,6 +184,8 @@ export type CreateLighterCredentials = z.infer<typeof CreateLighterCredentials>;
174
184
  export type CreateLighterMetadata = z.infer<typeof CreateLighterMetadata>;
175
185
  export type CreateTradeAccountInput = z.input<typeof CreateTradeAccount>;
176
186
  export type CreateTradeAccount = z.output<typeof CreateTradeAccount>;
187
+ export type CreateVaultTradeAccountInput = z.input<typeof CreateVaultTradeAccount>;
188
+ export type CreateVaultTradeAccount = z.output<typeof CreateVaultTradeAccount>;
177
189
  export type UpdateTradeAccountInput = z.input<typeof UpdateTradeAccount>;
178
190
  export type UpdateTradeAccount = z.output<typeof UpdateTradeAccount>;
179
191
  export {};
@@ -104,6 +104,15 @@ const CreateTradeAccount = z.discriminatedUnion("connector", [
104
104
  CreateOkxAccount,
105
105
  CreateLighterAccount
106
106
  ]);
107
+ const CreateVaultTradeAccount = z.object({
108
+ vaultAddress: EthereumAddress,
109
+ alias: AccountAlias,
110
+ /**
111
+ * Optional caller-supplied key. Reusing it attaches a transport retry to the first attempt;
112
+ * omitting it starts a new create attempt.
113
+ */
114
+ idempotencyKey: z.string().min(1).max(128).optional()
115
+ });
107
116
  const UpdateTradeAccount = z.discriminatedUnion("connector", [
108
117
  UpdateHyperliquidAccount,
109
118
  UpdateBinanceAccount,
@@ -112,4 +121,4 @@ const UpdateTradeAccount = z.discriminatedUnion("connector", [
112
121
  UpdateLighterAccount
113
122
  ]);
114
123
 
115
- export { CreateTradeAccount, UpdateTradeAccount };
124
+ export { CreateTradeAccount, CreateVaultTradeAccount, UpdateTradeAccount };
@@ -10,6 +10,10 @@ export declare const TradeAccountResponse: z.ZodObject<{
10
10
  okx: "okx";
11
11
  lighter: "lighter";
12
12
  }>;
13
+ kind: z.ZodEnum<{
14
+ vault: "vault";
15
+ eoa: "eoa";
16
+ }>;
13
17
  exchangeIdentifier: z.ZodString;
14
18
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
15
19
  agentWalletAddress: z.ZodString;
@@ -35,6 +39,10 @@ export declare const TradeAccountListResponse: z.ZodObject<{
35
39
  okx: "okx";
36
40
  lighter: "lighter";
37
41
  }>;
42
+ kind: z.ZodEnum<{
43
+ vault: "vault";
44
+ eoa: "eoa";
45
+ }>;
38
46
  exchangeIdentifier: z.ZodString;
39
47
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
40
48
  agentWalletAddress: z.ZodString;
@@ -49,6 +57,79 @@ export declare const TradeAccountListResponse: z.ZodObject<{
49
57
  }, z.core.$strip>>;
50
58
  }, z.core.$strip>;
51
59
  export type TradeAccountListResponse = z.infer<typeof TradeAccountListResponse>;
60
+ /**
61
+ * Whether a vault already has a pear-pro trade account (UI: create vs trade). The account is owned by
62
+ * the vault's own synthetic user, so it never shows up in the caller's own list — this is where an
63
+ * authorized owner/trader gets it in order to trade as the vault (via the `pear-vault-address` header).
64
+ */
65
+ export declare const VaultTradeAccountStatus: z.ZodDiscriminatedUnion<[z.ZodObject<{
66
+ exists: z.ZodLiteral<false>;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ exists: z.ZodLiteral<true>;
69
+ tradeAccountId: z.ZodString;
70
+ account: z.ZodObject<{
71
+ id: z.ZodUUID;
72
+ alias: z.ZodString;
73
+ connector: z.ZodEnum<{
74
+ hyperliquid: "hyperliquid";
75
+ binance: "binance";
76
+ bybit: "bybit";
77
+ okx: "okx";
78
+ lighter: "lighter";
79
+ }>;
80
+ kind: z.ZodEnum<{
81
+ vault: "vault";
82
+ eoa: "eoa";
83
+ }>;
84
+ exchangeIdentifier: z.ZodString;
85
+ metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
86
+ agentWalletAddress: z.ZodString;
87
+ isSubaccount: z.ZodBoolean;
88
+ mainAccountAddress: z.ZodString;
89
+ }, z.core.$strip>, z.ZodObject<{
90
+ l1_address: z.ZodString;
91
+ }, z.core.$strip>]>>;
92
+ createdAt: z.ZodString;
93
+ updatedAt: z.ZodString;
94
+ deletedAt: z.ZodOptional<z.ZodString>;
95
+ }, z.core.$strip>;
96
+ }, z.core.$strip>], "exists">;
97
+ export type VaultTradeAccountStatus = z.infer<typeof VaultTradeAccountStatus>;
98
+ export declare const VaultTradeAccountStatusResponse: z.ZodObject<{
99
+ status: z.ZodDiscriminatedUnion<[z.ZodObject<{
100
+ exists: z.ZodLiteral<false>;
101
+ }, z.core.$strip>, z.ZodObject<{
102
+ exists: z.ZodLiteral<true>;
103
+ tradeAccountId: z.ZodString;
104
+ account: z.ZodObject<{
105
+ id: z.ZodUUID;
106
+ alias: z.ZodString;
107
+ connector: z.ZodEnum<{
108
+ hyperliquid: "hyperliquid";
109
+ binance: "binance";
110
+ bybit: "bybit";
111
+ okx: "okx";
112
+ lighter: "lighter";
113
+ }>;
114
+ kind: z.ZodEnum<{
115
+ vault: "vault";
116
+ eoa: "eoa";
117
+ }>;
118
+ exchangeIdentifier: z.ZodString;
119
+ metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
120
+ agentWalletAddress: z.ZodString;
121
+ isSubaccount: z.ZodBoolean;
122
+ mainAccountAddress: z.ZodString;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ l1_address: z.ZodString;
125
+ }, z.core.$strip>]>>;
126
+ createdAt: z.ZodString;
127
+ updatedAt: z.ZodString;
128
+ deletedAt: z.ZodOptional<z.ZodString>;
129
+ }, z.core.$strip>;
130
+ }, z.core.$strip>], "exists">;
131
+ }, z.core.$strip>;
132
+ export type VaultTradeAccountStatusResponse = z.infer<typeof VaultTradeAccountStatusResponse>;
52
133
  export declare const ExchangeCredentialsResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
53
134
  connector: z.ZodLiteral<"hyperliquid">;
54
135
  account: z.ZodObject<{
@@ -61,6 +142,10 @@ export declare const ExchangeCredentialsResponse: z.ZodDiscriminatedUnion<[z.Zod
61
142
  okx: "okx";
62
143
  lighter: "lighter";
63
144
  }>;
145
+ kind: z.ZodEnum<{
146
+ vault: "vault";
147
+ eoa: "eoa";
148
+ }>;
64
149
  exchangeIdentifier: z.ZodString;
65
150
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
66
151
  agentWalletAddress: z.ZodString;
@@ -88,6 +173,10 @@ export declare const ExchangeCredentialsResponse: z.ZodDiscriminatedUnion<[z.Zod
88
173
  okx: "okx";
89
174
  lighter: "lighter";
90
175
  }>;
176
+ kind: z.ZodEnum<{
177
+ vault: "vault";
178
+ eoa: "eoa";
179
+ }>;
91
180
  exchangeIdentifier: z.ZodString;
92
181
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
93
182
  agentWalletAddress: z.ZodString;
@@ -122,6 +211,10 @@ export declare const ExchangeCredentialsResponse: z.ZodDiscriminatedUnion<[z.Zod
122
211
  okx: "okx";
123
212
  lighter: "lighter";
124
213
  }>;
214
+ kind: z.ZodEnum<{
215
+ vault: "vault";
216
+ eoa: "eoa";
217
+ }>;
125
218
  exchangeIdentifier: z.ZodString;
126
219
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
127
220
  agentWalletAddress: z.ZodString;
@@ -150,6 +243,10 @@ export declare const ExchangeCredentialsResponse: z.ZodDiscriminatedUnion<[z.Zod
150
243
  okx: "okx";
151
244
  lighter: "lighter";
152
245
  }>;
246
+ kind: z.ZodEnum<{
247
+ vault: "vault";
248
+ eoa: "eoa";
249
+ }>;
153
250
  exchangeIdentifier: z.ZodString;
154
251
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
155
252
  agentWalletAddress: z.ZodString;
@@ -179,6 +276,10 @@ export declare const ExchangeCredentialsResponse: z.ZodDiscriminatedUnion<[z.Zod
179
276
  okx: "okx";
180
277
  lighter: "lighter";
181
278
  }>;
279
+ kind: z.ZodEnum<{
280
+ vault: "vault";
281
+ eoa: "eoa";
282
+ }>;
182
283
  exchangeIdentifier: z.ZodString;
183
284
  metadata: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
184
285
  agentWalletAddress: z.ZodString;
@@ -7,6 +7,19 @@ const TradeAccountResponse = z.object({
7
7
  const TradeAccountListResponse = z.object({
8
8
  accounts: z.array(TradeAccount)
9
9
  });
10
+ const VaultTradeAccountStatus = z.discriminatedUnion("exists", [
11
+ z.object({
12
+ exists: z.literal(false)
13
+ }),
14
+ z.object({
15
+ exists: z.literal(true),
16
+ tradeAccountId: z.string(),
17
+ account: TradeAccount
18
+ })
19
+ ]);
20
+ const VaultTradeAccountStatusResponse = z.object({
21
+ status: VaultTradeAccountStatus
22
+ });
10
23
  const HyperliquidCredentialsResponse = z.object({
11
24
  connector: z.literal("hyperliquid"),
12
25
  account: TradeAccount,
@@ -59,4 +72,4 @@ const ExchangeCredentialsResponse = z.discriminatedUnion("connector", [
59
72
  LighterCredentialsResponse
60
73
  ]);
61
74
 
62
- export { ExchangeCredentialsResponse, TradeAccountListResponse, TradeAccountResponse };
75
+ export { ExchangeCredentialsResponse, TradeAccountListResponse, TradeAccountResponse, VaultTradeAccountStatus, VaultTradeAccountStatusResponse };
@@ -8,6 +8,7 @@ export declare const UserProfile: z.ZodObject<{
8
8
  role: z.ZodEnum<{
9
9
  basic: "basic";
10
10
  pro: "pro";
11
+ vault: "vault";
11
12
  }>;
12
13
  address: z.ZodNullable<z.ZodString>;
13
14
  email: z.ZodNullable<z.ZodString>;
@@ -10,7 +10,8 @@ const UserProfile = z.object({
10
10
  displayName: z.string().describe("Public display name"),
11
11
  role: z.enum([
12
12
  "basic",
13
- "pro"
13
+ "pro",
14
+ "vault"
14
15
  ]).describe("User role"),
15
16
  address: z.string().nullable().describe("Linked wallet address (for evm_wallet provider)"),
16
17
  email: z.string().nullable().describe("Linked email address (for email provider)"),
@@ -6,6 +6,7 @@ export declare const ProfileResponse: z.ZodObject<{
6
6
  role: z.ZodEnum<{
7
7
  basic: "basic";
8
8
  pro: "pro";
9
+ vault: "vault";
9
10
  }>;
10
11
  address: z.ZodNullable<z.ZodString>;
11
12
  email: z.ZodNullable<z.ZodString>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",