@pear-protocol/types 1.24.0 → 1.24.1
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/auth/api-keys.js +11 -3
- package/dist/auth/entities.js +10 -2
- package/dist/auth/payloads.d.ts +7 -0
- package/dist/auth/payloads.js +15 -11
- package/dist/auth/response.js +4 -1
- package/dist/common/array.js +9 -2
- package/dist/common/refinement.js +25 -19
- package/dist/common/request.js +8 -8
- package/dist/common/response.js +10 -10
- package/dist/common/schema.js +9 -2
- package/dist/common/trade-legs.js +17 -12
- package/dist/connector/index.js +7 -1
- package/dist/execution/entities.js +96 -65
- package/dist/execution/queries.js +5 -1
- package/dist/execution/responses.js +3 -1
- package/dist/fee/entities.js +17 -3
- package/dist/fill/entities.js +33 -29
- package/dist/fill/queries.js +4 -1
- package/dist/funding/entities.js +4 -4
- package/dist/funding/responses.js +2 -2
- package/dist/instrument/entities.js +56 -44
- package/dist/instrument/queries.js +6 -1
- package/dist/instrument/responses.js +4 -4
- package/dist/instrument-precision/index.js +23 -23
- package/dist/ladder/entities.js +5 -1
- package/dist/ladder/payloads.js +15 -4
- package/dist/ladder/queries.js +0 -1
- package/dist/ladder/responses.js +12 -4
- package/dist/leverage/payloads.js +4 -1
- package/dist/notification/entities.js +37 -28
- package/dist/notification/payloads.js +9 -3
- package/dist/notification/queries.js +5 -1
- package/dist/notification/responses.js +4 -4
- package/dist/order/entities.js +38 -30
- package/dist/portfolio/queries.js +18 -3
- package/dist/position/entities.js +95 -72
- package/dist/position/queries.js +29 -23
- package/dist/price/entities.js +4 -1
- package/dist/price/responses.js +4 -4
- package/dist/rebalance/entities.js +23 -6
- package/dist/rebalance/payloads.js +23 -11
- package/dist/rebalance/queries.js +2 -8
- package/dist/rebalance/responses.js +12 -4
- package/dist/saved-baskets/entities.js +3 -1
- package/dist/saved-baskets/payloads.js +3 -1
- package/dist/schedule/entities.js +87 -71
- package/dist/schedule/payloads.js +36 -33
- package/dist/schedule/queries.js +5 -1
- package/dist/schedule/responses.js +12 -4
- package/dist/statistics/queries.js +15 -3
- package/dist/sync/payloads.js +13 -17
- package/dist/tca/entities.js +4 -1
- package/dist/tca/responses.js +4 -1
- package/dist/trade/payloads.js +37 -23
- package/dist/trade/responses.js +15 -5
- package/dist/trade-accounts/entities.js +4 -1
- package/dist/trade-accounts/response.js +6 -2
- package/dist/trigger/common/index.js +27 -6
- package/dist/trigger/entities/conditions.js +14 -15
- package/dist/trigger/entities/index.js +89 -80
- package/dist/trigger/oracle.js +10 -3
- package/dist/trigger/payloads/conditions.js +8 -2
- package/dist/trigger/payloads/index.js +18 -4
- package/dist/trigger/queries.js +5 -1
- package/dist/trigger/refinement/static.refinement.js +5 -2
- package/dist/trigger/refinement/trailing.refinement.js +8 -6
- package/dist/trigger/responses.js +12 -4
- package/dist/triggers/entities.js +8 -2
- package/dist/users/entities.js +4 -1
- package/dist/users/payloads.js +17 -18
- package/package.json +1 -1
package/dist/auth/api-keys.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
const ApiKeyScope = z.enum([
|
|
3
|
+
const ApiKeyScope = z.enum([
|
|
4
|
+
"read",
|
|
5
|
+
"read_write"
|
|
6
|
+
]).describe("API key access scope");
|
|
4
7
|
const CreateApiKeyInput = z.object({
|
|
5
8
|
label: z.string().trim().min(1, "Label is required").max(100).describe("Human label for the key"),
|
|
6
9
|
scope: ApiKeyScope.default("read"),
|
|
7
10
|
/** ISO-8601 datetime; omit for a key that never expires. */
|
|
8
|
-
expiresAt: z.iso.datetime({
|
|
11
|
+
expiresAt: z.iso.datetime({
|
|
12
|
+
offset: true
|
|
13
|
+
}).optional().describe("Optional expiry (ISO-8601)")
|
|
9
14
|
}).describe("Create a new API key");
|
|
10
15
|
const CreateApiKeyOutput = z.object({
|
|
11
16
|
id: z.uuid(),
|
|
@@ -27,7 +32,10 @@ const ApiKeySummary = z.object({
|
|
|
27
32
|
const ListApiKeysOutput = z.array(ApiKeySummary).describe("All API keys for the user");
|
|
28
33
|
const ApiKeyMeResponse = z.object({
|
|
29
34
|
id: z.uuid().describe("User UUID that owns the API key"),
|
|
30
|
-
role: z.enum([
|
|
35
|
+
role: z.enum([
|
|
36
|
+
"basic",
|
|
37
|
+
"pro"
|
|
38
|
+
]).describe("User role"),
|
|
31
39
|
scope: ApiKeyScope,
|
|
32
40
|
authMethod: z.literal("api_key")
|
|
33
41
|
}).describe("Identity of the caller authenticated via an API key");
|
package/dist/auth/entities.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
const LoginMethod = z.enum([
|
|
3
|
+
const LoginMethod = z.enum([
|
|
4
|
+
"email",
|
|
5
|
+
"evm_wallet",
|
|
6
|
+
"oauth",
|
|
7
|
+
"x"
|
|
8
|
+
]).describe("Authentication provider used for the current session");
|
|
4
9
|
const AuthenticatedUser = z.object({
|
|
5
10
|
id: z.uuid().describe("User UUID"),
|
|
6
|
-
role: z.enum([
|
|
11
|
+
role: z.enum([
|
|
12
|
+
"basic",
|
|
13
|
+
"pro"
|
|
14
|
+
]).describe("User role"),
|
|
7
15
|
providerId: z.string().nullable().describe("Provider identifier (wallet address or email)"),
|
|
8
16
|
loginMethod: LoginMethod.describe("Authentication provider used for the current session")
|
|
9
17
|
}).describe("Current authenticated user info");
|
package/dist/auth/payloads.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export declare const StartXLinkRequest: z.ZodObject<{
|
|
|
20
20
|
}, z.core.$strip>;
|
|
21
21
|
export declare const StartXLoginRequest: z.ZodObject<{
|
|
22
22
|
returnTo: z.ZodOptional<z.ZodString>;
|
|
23
|
+
handoffId: z.ZodString;
|
|
24
|
+
handoffChallenge: z.ZodString;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export declare const ExchangeXLoginRequest: z.ZodObject<{
|
|
27
|
+
ticket: z.ZodString;
|
|
28
|
+
handoffVerifier: z.ZodString;
|
|
23
29
|
}, z.core.$strip>;
|
|
24
30
|
export declare const WalletLoginRequest: z.ZodObject<{
|
|
25
31
|
method: z.ZodLiteral<"wallet">;
|
|
@@ -78,6 +84,7 @@ export type LinkEmailRequest = z.infer<typeof LinkEmailRequest>;
|
|
|
78
84
|
export type LinkWalletRequest = z.infer<typeof LinkWalletRequest>;
|
|
79
85
|
export type StartXLinkRequest = z.infer<typeof StartXLinkRequest>;
|
|
80
86
|
export type StartXLoginRequest = z.infer<typeof StartXLoginRequest>;
|
|
87
|
+
export type ExchangeXLoginRequest = z.infer<typeof ExchangeXLoginRequest>;
|
|
81
88
|
export type EmailLoginRequest = z.infer<typeof EmailLoginRequest>;
|
|
82
89
|
export type LoginRequest = z.infer<typeof LoginRequest>;
|
|
83
90
|
export type RefreshTokenRequest = z.infer<typeof RefreshTokenRequest>;
|
package/dist/auth/payloads.js
CHANGED
|
@@ -22,15 +22,18 @@ const LinkWalletRequest = z.object({
|
|
|
22
22
|
nonce: SignedNonce
|
|
23
23
|
}).describe("Link wallet credentials to the authenticated account");
|
|
24
24
|
const StartXLinkRequest = z.object({
|
|
25
|
-
returnTo: z.string().optional().describe(
|
|
26
|
-
"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."
|
|
27
|
-
)
|
|
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.")
|
|
28
26
|
}).describe("Start of the X account link flow");
|
|
27
|
+
const PkceValue = z.string().regex(/^[A-Za-z0-9_-]{43}$/, "Must be 43 base64url characters");
|
|
29
28
|
const StartXLoginRequest = z.object({
|
|
30
|
-
returnTo: z.string().optional().describe(
|
|
31
|
-
|
|
32
|
-
)
|
|
29
|
+
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."),
|
|
30
|
+
handoffId: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/, "Must be 1-64 URL-safe characters").describe("Names this sign-in attempt. Echoed back on the return URL so a browser that started more than one knows which secret this outcome belongs to."),
|
|
31
|
+
handoffChallenge: PkceValue.describe("Base64url SHA-256 of a random verifier this browser keeps. The finished sign-in is redeemed by presenting that verifier, so only the browser that started the flow can collect it.")
|
|
33
32
|
}).describe("Start of the X sign-in flow");
|
|
33
|
+
const ExchangeXLoginRequest = z.object({
|
|
34
|
+
ticket: z.string().min(1, "Ticket is required").describe("Single-use ticket from the return URL fragment"),
|
|
35
|
+
handoffVerifier: PkceValue.describe("The verifier whose challenge started this sign-in")
|
|
36
|
+
}).describe("Redemption of a finished X sign-in for a session");
|
|
34
37
|
const WalletLoginRequest = z.object({
|
|
35
38
|
method: z.literal("wallet").describe('Must be "wallet" for wallet authentication'),
|
|
36
39
|
address: EthereumAddress,
|
|
@@ -58,7 +61,10 @@ const ResetPasswordRequest = z.object({
|
|
|
58
61
|
token: z.string().min(1, "Token is required").describe("Password reset token"),
|
|
59
62
|
password: Password.describe("New password to set")
|
|
60
63
|
}).describe("Reset password using a password reset token");
|
|
61
|
-
const LoginRequest = z.discriminatedUnion("method", [
|
|
64
|
+
const LoginRequest = z.discriminatedUnion("method", [
|
|
65
|
+
WalletLoginRequest,
|
|
66
|
+
EmailLoginRequest
|
|
67
|
+
]);
|
|
62
68
|
const RefreshTokenRequest = z.object({
|
|
63
69
|
refreshToken: z.string().min(1, "Refresh token is required").describe("Refresh token")
|
|
64
70
|
}).describe("Refresh token request");
|
|
@@ -69,9 +75,7 @@ const LogoutRequest = z.object({
|
|
|
69
75
|
refreshToken: z.string().min(1, "Refresh token is required").describe("Refresh token to revoke")
|
|
70
76
|
}).describe("Logout and revoke refresh token");
|
|
71
77
|
const OauthInteractionConfirmRequest = z.object({
|
|
72
|
-
scopes: z.array(z.string()).default([]).describe(
|
|
73
|
-
"The scope set the user granted at consent (opaque to the AS; empty resolves to the read-only fail-safe)"
|
|
74
|
-
)
|
|
78
|
+
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)")
|
|
75
79
|
}).describe("Consent confirmation body \u2014 the granted scope set");
|
|
76
80
|
|
|
77
|
-
export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, StartXLinkRequest, StartXLoginRequest, VerifyEmailRequest, WalletLoginRequest };
|
|
81
|
+
export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ExchangeXLoginRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, StartXLinkRequest, StartXLoginRequest, VerifyEmailRequest, WalletLoginRequest };
|
package/dist/auth/response.js
CHANGED
|
@@ -26,7 +26,10 @@ const ResetPasswordResponse = z.void().describe("Successful password reset respo
|
|
|
26
26
|
const VerifyEmailResponse = z.object({
|
|
27
27
|
verified: z.literal(true).describe("Always true; the claim behind the token is now verified"),
|
|
28
28
|
email: z.string().describe("Email address the verified claim belongs to"),
|
|
29
|
-
flow: z.enum([
|
|
29
|
+
flow: z.enum([
|
|
30
|
+
"register",
|
|
31
|
+
"link"
|
|
32
|
+
]).describe("Claim flow the token was issued for"),
|
|
30
33
|
verifiedAt: z.string().describe("ISO-8601 timestamp of when the claim was verified")
|
|
31
34
|
}).describe("Successful email verification response");
|
|
32
35
|
const LinkEmailResponse = z.void().describe("Successful email verification response");
|
package/dist/common/array.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
function normalizeArray(val) {
|
|
2
4
|
if (!val) return void 0;
|
|
3
5
|
if (Array.isArray(val)) return val;
|
|
4
6
|
if (typeof val === "string") {
|
|
5
|
-
return val.includes(",") ? val.split(",").map((s) => s.trim()) : [
|
|
7
|
+
return val.includes(",") ? val.split(",").map((s) => s.trim()) : [
|
|
8
|
+
val
|
|
9
|
+
];
|
|
6
10
|
}
|
|
7
|
-
return [
|
|
11
|
+
return [
|
|
12
|
+
String(val)
|
|
13
|
+
];
|
|
8
14
|
}
|
|
15
|
+
__name(normalizeArray, "normalizeArray");
|
|
9
16
|
|
|
10
17
|
export { normalizeArray };
|
|
@@ -1,52 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const RefineMinimumOneSymbol = (basket, ctx) => {
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const RefineMinimumOneSymbol = /* @__PURE__ */ __name((basket, ctx) => {
|
|
4
4
|
if (basket.length < 1) {
|
|
5
5
|
ctx.addIssue({
|
|
6
6
|
code: "custom",
|
|
7
7
|
message: "At least one symbol is required."
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
};
|
|
11
|
-
const RefineMinimumTwoSymbols = (basket, ctx) => {
|
|
10
|
+
}, "RefineMinimumOneSymbol");
|
|
11
|
+
const RefineMinimumTwoSymbols = /* @__PURE__ */ __name((basket, ctx) => {
|
|
12
12
|
if (basket.length < 2) {
|
|
13
13
|
ctx.addIssue({
|
|
14
14
|
code: "custom",
|
|
15
15
|
message: "At least two symbols are required."
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
};
|
|
19
|
-
const RefineTwoUniqueSymbols = (pair, ctx) => {
|
|
18
|
+
}, "RefineMinimumTwoSymbols");
|
|
19
|
+
const RefineTwoUniqueSymbols = /* @__PURE__ */ __name((pair, ctx) => {
|
|
20
20
|
if (pair.symbol_a === pair.symbol_b) {
|
|
21
21
|
ctx.addIssue({
|
|
22
22
|
code: "custom",
|
|
23
23
|
message: "Symbols cannot be the same."
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
};
|
|
27
|
-
const RefineUniqueSymbols = (basket, ctx) => {
|
|
26
|
+
}, "RefineTwoUniqueSymbols");
|
|
27
|
+
const RefineUniqueSymbols = /* @__PURE__ */ __name((basket, ctx) => {
|
|
28
28
|
const symbols = basket.map((item) => item.symbol);
|
|
29
29
|
const uniqueSymbols = new Set(symbols);
|
|
30
30
|
if (symbols.length !== uniqueSymbols.size) {
|
|
31
31
|
const duplicates = symbols.filter((symbol, index) => symbols.indexOf(symbol) !== index);
|
|
32
32
|
ctx.addIssue({
|
|
33
33
|
code: "custom",
|
|
34
|
-
message: `Duplicate symbols found: ${[
|
|
35
|
-
|
|
34
|
+
message: `Duplicate symbols found: ${[
|
|
35
|
+
...new Set(duplicates)
|
|
36
|
+
].join(", ")}`,
|
|
37
|
+
path: [
|
|
38
|
+
"basket"
|
|
39
|
+
]
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
|
-
};
|
|
39
|
-
const RefineWeightingSum = (basket, ctx) => {
|
|
42
|
+
}, "RefineUniqueSymbols");
|
|
43
|
+
const RefineWeightingSum = /* @__PURE__ */ __name((basket, ctx) => {
|
|
40
44
|
const totalWeight = basket.reduce((acc, curr) => acc + curr.weight, 0);
|
|
41
45
|
if (Math.abs(totalWeight - 1) > 1e-9) {
|
|
42
46
|
ctx.addIssue({
|
|
43
47
|
code: "custom",
|
|
44
48
|
message: `The sum of weights must be exactly 1, but got ${totalWeight}`,
|
|
45
|
-
path: [
|
|
49
|
+
path: [
|
|
50
|
+
"basket"
|
|
51
|
+
]
|
|
46
52
|
});
|
|
47
53
|
}
|
|
48
|
-
};
|
|
49
|
-
const RefineMinimumOneBuyOneSell = (basket, ctx) => {
|
|
54
|
+
}, "RefineWeightingSum");
|
|
55
|
+
const RefineMinimumOneBuyOneSell = /* @__PURE__ */ __name((basket, ctx) => {
|
|
50
56
|
const buyCount = basket.filter((item) => item.side === "BUY").length;
|
|
51
57
|
const sellCount = basket.filter((item) => item.side === "SELL").length;
|
|
52
58
|
if (buyCount < 1 || sellCount < 1) {
|
|
@@ -55,14 +61,14 @@ const RefineMinimumOneBuyOneSell = (basket, ctx) => {
|
|
|
55
61
|
message: "At least one BUY and one SELL are required."
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
|
-
};
|
|
59
|
-
const RefineMinimumOneKeyValuePair = (data, ctx) => {
|
|
64
|
+
}, "RefineMinimumOneBuyOneSell");
|
|
65
|
+
const RefineMinimumOneKeyValuePair = /* @__PURE__ */ __name((data, ctx) => {
|
|
60
66
|
if (Object.keys(data).length < 1) {
|
|
61
67
|
ctx.addIssue({
|
|
62
68
|
code: "custom",
|
|
63
69
|
message: "Empty object is not allowed."
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
|
-
};
|
|
72
|
+
}, "RefineMinimumOneKeyValuePair");
|
|
67
73
|
|
|
68
74
|
export { RefineMinimumOneBuyOneSell, RefineMinimumOneKeyValuePair, RefineMinimumOneSymbol, RefineMinimumTwoSymbols, RefineTwoUniqueSymbols, RefineUniqueSymbols, RefineWeightingSum };
|
package/dist/common/request.js
CHANGED
|
@@ -2,22 +2,22 @@ import { z } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
const CursorFindParams = z.object({
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* The maximum number of items to retrieve.
|
|
6
|
+
*/
|
|
7
7
|
limit: z.coerce.number().int().positive().max(2e3).optional().default(20),
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
* Opaque pagination cursor returned by the API.
|
|
10
|
+
*/
|
|
11
11
|
cursor: z.string().optional()
|
|
12
12
|
});
|
|
13
13
|
const PaginationFindParams = z.object({
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
* The maximum number of items to retrieve.
|
|
16
|
+
*/
|
|
17
17
|
limit: z.coerce.number().int().positive().max(100).optional().default(20),
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
* The number of items to skip before retrieving the returned items.
|
|
20
|
+
*/
|
|
21
21
|
offset: z.coerce.number().int().min(0).optional().default(0)
|
|
22
22
|
});
|
|
23
23
|
|
package/dist/common/response.js
CHANGED
|
@@ -2,26 +2,26 @@ import { z } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
const PaginatedResponse = z.object({
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* The maximum number of items retrieved.
|
|
6
|
+
*/
|
|
7
7
|
limit: z.number(),
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
* The number of items to skip before retrieving the returned items.
|
|
10
|
+
*/
|
|
11
11
|
offset: z.number(),
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
* The total number of items.
|
|
14
|
+
*/
|
|
15
15
|
count: z.number()
|
|
16
16
|
});
|
|
17
17
|
const CursorResponse = z.object({
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
* The maximum number of items retrieved.
|
|
20
|
+
*/
|
|
21
21
|
limit: z.number(),
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
* The cursor to use for pagination.
|
|
24
|
+
*/
|
|
25
25
|
nextCursor: z.string().optional()
|
|
26
26
|
});
|
|
27
27
|
|
package/dist/common/schema.js
CHANGED
|
@@ -2,9 +2,16 @@ import z from 'zod';
|
|
|
2
2
|
|
|
3
3
|
const UnsignedDecimalString = z.string().regex(/^\d+(\.\d+)?$/, "Must be a valid decimal string");
|
|
4
4
|
const SignedDecimalString = z.string().regex(/^[+-]\d+(\.\d+)?$/, "Must be a valid signed decimal string").transform((val) => val);
|
|
5
|
-
const Side = z.enum([
|
|
5
|
+
const Side = z.enum([
|
|
6
|
+
"BUY",
|
|
7
|
+
"SELL"
|
|
8
|
+
], {
|
|
6
9
|
message: "Side must be either BUY or SELL"
|
|
7
10
|
});
|
|
8
|
-
const AssetWeight = z.number().positive({
|
|
11
|
+
const AssetWeight = z.number().positive({
|
|
12
|
+
message: "Weight must be greater than 0"
|
|
13
|
+
}).max(1, {
|
|
14
|
+
message: "Weight must be less than 1"
|
|
15
|
+
});
|
|
9
16
|
|
|
10
17
|
export { AssetWeight, Side, SignedDecimalString, UnsignedDecimalString };
|
|
@@ -2,29 +2,34 @@ import { z } from 'zod';
|
|
|
2
2
|
import { InstrumentId } from '../instrument';
|
|
3
3
|
import { UnsignedDecimalString, Side } from './schema';
|
|
4
4
|
|
|
5
|
-
const TradeLegMode = z.enum([
|
|
5
|
+
const TradeLegMode = z.enum([
|
|
6
|
+
"QUANTITY",
|
|
7
|
+
"USD"
|
|
8
|
+
]);
|
|
6
9
|
const TradeLeg = z.object({
|
|
7
10
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
* Instrument ID
|
|
12
|
+
*/
|
|
10
13
|
symbol: InstrumentId,
|
|
11
14
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
* Side
|
|
16
|
+
*/
|
|
14
17
|
side: Side,
|
|
15
18
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
* Mode to interpret the amount
|
|
20
|
+
*/
|
|
18
21
|
mode: TradeLegMode,
|
|
19
22
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
* Quantity or USD amount
|
|
24
|
+
*/
|
|
22
25
|
amount: UnsignedDecimalString,
|
|
23
26
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
* Reduce only flag
|
|
28
|
+
*/
|
|
26
29
|
reduceOnly: z.boolean()
|
|
27
30
|
});
|
|
28
|
-
const TradeLegPostOnly = TradeLeg.omit({
|
|
31
|
+
const TradeLegPostOnly = TradeLeg.omit({
|
|
32
|
+
reduceOnly: true
|
|
33
|
+
});
|
|
29
34
|
|
|
30
35
|
export { TradeLeg, TradeLegPostOnly };
|
package/dist/connector/index.js
CHANGED
|
@@ -5,129 +5,158 @@ import { InstrumentId } from '../instrument';
|
|
|
5
5
|
import { Order } from '../order';
|
|
6
6
|
import { Position } from '../position';
|
|
7
7
|
|
|
8
|
-
const ExecutionIntent = z.enum([
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const ExecutionIntent = z.enum([
|
|
9
|
+
"OPEN",
|
|
10
|
+
"CLOSE",
|
|
11
|
+
"ADJUST",
|
|
12
|
+
"REVERSE"
|
|
13
|
+
]);
|
|
14
|
+
const ExecutionOrderType = z.enum([
|
|
15
|
+
"MARKET"
|
|
16
|
+
]);
|
|
17
|
+
const ExecutionStatus = z.enum([
|
|
18
|
+
"IDLE",
|
|
19
|
+
"ACTIVE",
|
|
20
|
+
"COMPLETED",
|
|
21
|
+
"FAILED",
|
|
22
|
+
"CANCELLED"
|
|
23
|
+
]);
|
|
24
|
+
const ExecutionLegMode = z.enum([
|
|
25
|
+
"QUANTITY",
|
|
26
|
+
"USD"
|
|
27
|
+
]);
|
|
12
28
|
const ExecutionLeg = z.object({
|
|
13
29
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
* Instrument ID
|
|
31
|
+
*/
|
|
16
32
|
symbol: InstrumentId,
|
|
17
33
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
34
|
+
* Side
|
|
35
|
+
*/
|
|
20
36
|
side: Side,
|
|
21
37
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
* Mode to interpret the amount
|
|
39
|
+
*/
|
|
24
40
|
mode: ExecutionLegMode,
|
|
25
41
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
* Quantity or USD amount
|
|
43
|
+
*/
|
|
28
44
|
amount: UnsignedDecimalString,
|
|
29
45
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
* Reduce only flag
|
|
47
|
+
*/
|
|
32
48
|
reduceOnly: z.boolean()
|
|
33
49
|
});
|
|
34
50
|
const BaseExecution = z.object({
|
|
35
51
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
* Execution UUID
|
|
53
|
+
*/
|
|
38
54
|
id: z.uuid(),
|
|
39
55
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
* Connector
|
|
57
|
+
*/
|
|
42
58
|
connector: Connector,
|
|
43
59
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
* Intent
|
|
61
|
+
*/
|
|
46
62
|
intent: ExecutionIntent,
|
|
47
63
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
* Order type
|
|
65
|
+
*/
|
|
50
66
|
orderType: ExecutionOrderType,
|
|
51
67
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
* Status
|
|
69
|
+
*/
|
|
54
70
|
status: ExecutionStatus,
|
|
55
71
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
* Error message
|
|
73
|
+
*/
|
|
58
74
|
error: z.string().optional(),
|
|
59
75
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
* Created at timestamp
|
|
77
|
+
*/
|
|
62
78
|
createdAt: z.string(),
|
|
63
79
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
80
|
+
* Updated at timestamp
|
|
81
|
+
*/
|
|
66
82
|
updatedAt: z.string(),
|
|
67
83
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
* Orders
|
|
85
|
+
*/
|
|
70
86
|
orders: z.array(Order).optional()
|
|
71
87
|
});
|
|
72
88
|
const MarketOpenExecution = BaseExecution.extend({
|
|
73
89
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
90
|
+
* Intent
|
|
91
|
+
*/
|
|
76
92
|
intent: z.literal("OPEN"),
|
|
77
93
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
* Order type
|
|
95
|
+
*/
|
|
80
96
|
orderType: z.literal("MARKET"),
|
|
81
97
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
legs: z.tuple([
|
|
98
|
+
* Requested legs
|
|
99
|
+
*/
|
|
100
|
+
legs: z.tuple([
|
|
101
|
+
ExecutionLeg
|
|
102
|
+
]).rest(ExecutionLeg)
|
|
85
103
|
});
|
|
86
104
|
const MarketAdjustExecution = BaseExecution.extend({
|
|
87
105
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
* Intent
|
|
107
|
+
*/
|
|
90
108
|
intent: z.literal("ADJUST"),
|
|
91
109
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
110
|
+
* Order type
|
|
111
|
+
*/
|
|
94
112
|
orderType: z.literal("MARKET"),
|
|
95
113
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
position: Position.pick({
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
* Position
|
|
115
|
+
*/
|
|
116
|
+
position: Position.pick({
|
|
117
|
+
id: true,
|
|
118
|
+
exposure: true
|
|
119
|
+
}),
|
|
120
|
+
/**
|
|
121
|
+
* Requested legs
|
|
122
|
+
*/
|
|
123
|
+
legs: z.tuple([
|
|
124
|
+
ExecutionLeg
|
|
125
|
+
]).rest(ExecutionLeg)
|
|
103
126
|
});
|
|
104
127
|
const MarketCloseExecution = BaseExecution.extend({
|
|
105
128
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
* Intent
|
|
130
|
+
*/
|
|
108
131
|
intent: z.literal("CLOSE"),
|
|
109
132
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
133
|
+
* Order type
|
|
134
|
+
*/
|
|
112
135
|
orderType: z.literal("MARKET"),
|
|
113
136
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
position: Position.pick({
|
|
137
|
+
* Position
|
|
138
|
+
*/
|
|
139
|
+
position: Position.pick({
|
|
140
|
+
id: true,
|
|
141
|
+
exposure: true
|
|
142
|
+
})
|
|
117
143
|
});
|
|
118
144
|
const MarketReverseExecution = BaseExecution.extend({
|
|
119
145
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
146
|
+
* Intent
|
|
147
|
+
*/
|
|
122
148
|
intent: z.literal("REVERSE"),
|
|
123
149
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
150
|
+
* Order type
|
|
151
|
+
*/
|
|
126
152
|
orderType: z.literal("MARKET"),
|
|
127
153
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
position: Position.pick({
|
|
154
|
+
* Position
|
|
155
|
+
*/
|
|
156
|
+
position: Position.pick({
|
|
157
|
+
id: true,
|
|
158
|
+
exposure: true
|
|
159
|
+
})
|
|
131
160
|
});
|
|
132
161
|
const MarketExecution = z.discriminatedUnion("intent", [
|
|
133
162
|
MarketOpenExecution,
|
|
@@ -135,6 +164,8 @@ const MarketExecution = z.discriminatedUnion("intent", [
|
|
|
135
164
|
MarketCloseExecution,
|
|
136
165
|
MarketReverseExecution
|
|
137
166
|
]);
|
|
138
|
-
const Execution = z.discriminatedUnion("orderType", [
|
|
167
|
+
const Execution = z.discriminatedUnion("orderType", [
|
|
168
|
+
MarketExecution
|
|
169
|
+
]);
|
|
139
170
|
|
|
140
171
|
export { BaseExecution, Execution, ExecutionIntent, ExecutionLegMode, ExecutionOrderType, ExecutionStatus, MarketAdjustExecution, MarketCloseExecution, MarketExecution, MarketOpenExecution, MarketReverseExecution };
|
|
@@ -2,7 +2,11 @@ import { z } from 'zod';
|
|
|
2
2
|
import { normalizeArray, CursorFindParams } from '../common';
|
|
3
3
|
import { Connector } from '../connector';
|
|
4
4
|
|
|
5
|
-
const StatusEnum = z.enum([
|
|
5
|
+
const StatusEnum = z.enum([
|
|
6
|
+
"ACTIVE",
|
|
7
|
+
"COMPLETED",
|
|
8
|
+
"CANCELLED"
|
|
9
|
+
]);
|
|
6
10
|
const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
|
|
7
11
|
const ExecutionListParams = CursorFindParams.extend({
|
|
8
12
|
connector: Connector.optional(),
|
|
@@ -5,6 +5,8 @@ import { Execution } from './entities';
|
|
|
5
5
|
const ExecutionListResponse = CursorResponse.extend({
|
|
6
6
|
executions: z.array(Execution)
|
|
7
7
|
});
|
|
8
|
-
const GetExecutionResponse = z.object({
|
|
8
|
+
const GetExecutionResponse = z.object({
|
|
9
|
+
execution: Execution
|
|
10
|
+
});
|
|
9
11
|
|
|
10
12
|
export { ExecutionListResponse, GetExecutionResponse };
|