@pear-protocol/types 1.4.0 → 1.5.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.
- package/dist/bundle.d.ts +1 -0
- package/dist/bundle.js +1 -0
- package/dist/common/schema.d.ts +2 -0
- package/dist/common/schema.js +2 -1
- package/dist/saved-baskets/entities.d.ts +32 -0
- package/dist/saved-baskets/entities.js +18 -0
- package/dist/saved-baskets/index.d.ts +3 -0
- package/dist/saved-baskets/index.js +3 -0
- package/dist/saved-baskets/payloads.d.ts +39 -0
- package/dist/saved-baskets/payloads.js +16 -0
- package/dist/saved-baskets/responses.d.ts +73 -0
- package/dist/saved-baskets/responses.js +14 -0
- package/dist/trigger/payloads/conditions.js +1 -2
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
package/dist/bundle.js
CHANGED
package/dist/common/schema.d.ts
CHANGED
package/dist/common/schema.js
CHANGED
|
@@ -6,5 +6,6 @@ const Leverage = z.int({ message: "Leverage must be an integer" }).positive({ me
|
|
|
6
6
|
const Side = z.enum(["BUY", "SELL"], {
|
|
7
7
|
message: "Side must be either BUY or SELL"
|
|
8
8
|
});
|
|
9
|
+
const AssetWeight = z.number().positive({ message: "Weight must be greater than 0" }).max(1, { message: "Weight must be less than 1" });
|
|
9
10
|
|
|
10
|
-
export { Leverage, Side, SignedDecimalString, UnsignedDecimalString };
|
|
11
|
+
export { AssetWeight, Leverage, Side, SignedDecimalString, UnsignedDecimalString };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SavedBasketLeg: z.ZodObject<{
|
|
3
|
+
symbol: z.ZodString;
|
|
4
|
+
side: z.ZodEnum<{
|
|
5
|
+
BUY: "BUY";
|
|
6
|
+
SELL: "SELL";
|
|
7
|
+
}>;
|
|
8
|
+
weight: z.ZodNumber;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const SavedBasket: z.ZodObject<{
|
|
11
|
+
id: z.ZodUUID;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
legs: z.ZodTuple<[z.ZodObject<{
|
|
14
|
+
symbol: z.ZodString;
|
|
15
|
+
side: z.ZodEnum<{
|
|
16
|
+
BUY: "BUY";
|
|
17
|
+
SELL: "SELL";
|
|
18
|
+
}>;
|
|
19
|
+
weight: z.ZodNumber;
|
|
20
|
+
}, z.core.$strip>], z.ZodObject<{
|
|
21
|
+
symbol: z.ZodString;
|
|
22
|
+
side: z.ZodEnum<{
|
|
23
|
+
BUY: "BUY";
|
|
24
|
+
SELL: "SELL";
|
|
25
|
+
}>;
|
|
26
|
+
weight: z.ZodNumber;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
createdAt: z.ZodString;
|
|
29
|
+
updatedAt: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type SavedBasketLeg = z.infer<typeof SavedBasketLeg>;
|
|
32
|
+
export type SavedBasket = z.infer<typeof SavedBasket>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Side, AssetWeight } from '../common/schema';
|
|
3
|
+
import { InstrumentId } from '../instrument';
|
|
4
|
+
|
|
5
|
+
const SavedBasketLeg = z.object({
|
|
6
|
+
symbol: InstrumentId,
|
|
7
|
+
side: Side,
|
|
8
|
+
weight: AssetWeight.describe("Share of total gross notional as a fraction (legs sum to 1)")
|
|
9
|
+
});
|
|
10
|
+
const SavedBasket = z.object({
|
|
11
|
+
id: z.uuid(),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
legs: z.tuple([SavedBasketLeg]).rest(SavedBasketLeg),
|
|
14
|
+
createdAt: z.string(),
|
|
15
|
+
updatedAt: z.string()
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { SavedBasket, SavedBasketLeg };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CreateSavedBasketPayload: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
legs: z.ZodTuple<[z.ZodObject<{
|
|
5
|
+
symbol: z.ZodString;
|
|
6
|
+
side: z.ZodEnum<{
|
|
7
|
+
BUY: "BUY";
|
|
8
|
+
SELL: "SELL";
|
|
9
|
+
}>;
|
|
10
|
+
weight: z.ZodNumber;
|
|
11
|
+
}, z.core.$strip>], z.ZodObject<{
|
|
12
|
+
symbol: z.ZodString;
|
|
13
|
+
side: z.ZodEnum<{
|
|
14
|
+
BUY: "BUY";
|
|
15
|
+
SELL: "SELL";
|
|
16
|
+
}>;
|
|
17
|
+
weight: z.ZodNumber;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const UpdateSavedBasketPayload: z.ZodObject<{
|
|
21
|
+
name: z.ZodOptional<z.ZodString>;
|
|
22
|
+
legs: z.ZodOptional<z.ZodTuple<[z.ZodObject<{
|
|
23
|
+
symbol: z.ZodString;
|
|
24
|
+
side: z.ZodEnum<{
|
|
25
|
+
BUY: "BUY";
|
|
26
|
+
SELL: "SELL";
|
|
27
|
+
}>;
|
|
28
|
+
weight: z.ZodNumber;
|
|
29
|
+
}, z.core.$strip>], z.ZodObject<{
|
|
30
|
+
symbol: z.ZodString;
|
|
31
|
+
side: z.ZodEnum<{
|
|
32
|
+
BUY: "BUY";
|
|
33
|
+
SELL: "SELL";
|
|
34
|
+
}>;
|
|
35
|
+
weight: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type CreateSavedBasketPayload = z.infer<typeof CreateSavedBasketPayload>;
|
|
39
|
+
export type UpdateSavedBasketPayload = z.infer<typeof UpdateSavedBasketPayload>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { RefineUniqueSymbols, RefineWeightingSum } from '../common/refinement';
|
|
3
|
+
import { SavedBasketLeg } from './entities';
|
|
4
|
+
|
|
5
|
+
const SavedBasketName = z.string().trim().min(1, "Name is required").max(48).describe("Display name, unique per trade account (case-insensitive)");
|
|
6
|
+
const SavedBasketLegs = z.tuple([SavedBasketLeg]).rest(SavedBasketLeg).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).refine((value) => value.length <= 20, "Basket must have at most 20 legs").describe("At least one leg, up to 20");
|
|
7
|
+
const CreateSavedBasketPayload = z.object({
|
|
8
|
+
name: SavedBasketName,
|
|
9
|
+
legs: SavedBasketLegs
|
|
10
|
+
}).describe("Save the current basket under a name");
|
|
11
|
+
const UpdateSavedBasketPayload = z.object({
|
|
12
|
+
name: SavedBasketName.optional(),
|
|
13
|
+
legs: SavedBasketLegs.optional()
|
|
14
|
+
}).refine((value) => value.name !== void 0 || value.legs !== void 0, "Provide a name or legs to update").describe("Rename a saved basket and/or replace its legs");
|
|
15
|
+
|
|
16
|
+
export { CreateSavedBasketPayload, UpdateSavedBasketPayload };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SavedBasketListResponse: z.ZodObject<{
|
|
3
|
+
baskets: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodUUID;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
legs: z.ZodTuple<[z.ZodObject<{
|
|
7
|
+
symbol: z.ZodString;
|
|
8
|
+
side: z.ZodEnum<{
|
|
9
|
+
BUY: "BUY";
|
|
10
|
+
SELL: "SELL";
|
|
11
|
+
}>;
|
|
12
|
+
weight: z.ZodNumber;
|
|
13
|
+
}, z.core.$strip>], z.ZodObject<{
|
|
14
|
+
symbol: z.ZodString;
|
|
15
|
+
side: z.ZodEnum<{
|
|
16
|
+
BUY: "BUY";
|
|
17
|
+
SELL: "SELL";
|
|
18
|
+
}>;
|
|
19
|
+
weight: z.ZodNumber;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
createdAt: z.ZodString;
|
|
22
|
+
updatedAt: z.ZodString;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type SavedBasketListResponse = z.output<typeof SavedBasketListResponse>;
|
|
26
|
+
export declare const CreateSavedBasketResponse: z.ZodObject<{
|
|
27
|
+
basket: z.ZodObject<{
|
|
28
|
+
id: z.ZodUUID;
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
legs: z.ZodTuple<[z.ZodObject<{
|
|
31
|
+
symbol: z.ZodString;
|
|
32
|
+
side: z.ZodEnum<{
|
|
33
|
+
BUY: "BUY";
|
|
34
|
+
SELL: "SELL";
|
|
35
|
+
}>;
|
|
36
|
+
weight: z.ZodNumber;
|
|
37
|
+
}, z.core.$strip>], z.ZodObject<{
|
|
38
|
+
symbol: z.ZodString;
|
|
39
|
+
side: z.ZodEnum<{
|
|
40
|
+
BUY: "BUY";
|
|
41
|
+
SELL: "SELL";
|
|
42
|
+
}>;
|
|
43
|
+
weight: z.ZodNumber;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
createdAt: z.ZodString;
|
|
46
|
+
updatedAt: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type CreateSavedBasketResponse = z.output<typeof CreateSavedBasketResponse>;
|
|
50
|
+
export declare const UpdateSavedBasketResponse: z.ZodObject<{
|
|
51
|
+
basket: z.ZodObject<{
|
|
52
|
+
id: z.ZodUUID;
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
legs: z.ZodTuple<[z.ZodObject<{
|
|
55
|
+
symbol: z.ZodString;
|
|
56
|
+
side: z.ZodEnum<{
|
|
57
|
+
BUY: "BUY";
|
|
58
|
+
SELL: "SELL";
|
|
59
|
+
}>;
|
|
60
|
+
weight: z.ZodNumber;
|
|
61
|
+
}, z.core.$strip>], z.ZodObject<{
|
|
62
|
+
symbol: z.ZodString;
|
|
63
|
+
side: z.ZodEnum<{
|
|
64
|
+
BUY: "BUY";
|
|
65
|
+
SELL: "SELL";
|
|
66
|
+
}>;
|
|
67
|
+
weight: z.ZodNumber;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
createdAt: z.ZodString;
|
|
70
|
+
updatedAt: z.ZodString;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type UpdateSavedBasketResponse = z.output<typeof UpdateSavedBasketResponse>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SavedBasket } from './entities';
|
|
3
|
+
|
|
4
|
+
const SavedBasketListResponse = z.object({
|
|
5
|
+
baskets: z.array(SavedBasket)
|
|
6
|
+
});
|
|
7
|
+
const CreateSavedBasketResponse = z.object({
|
|
8
|
+
basket: SavedBasket
|
|
9
|
+
});
|
|
10
|
+
const UpdateSavedBasketResponse = z.object({
|
|
11
|
+
basket: SavedBasket
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { CreateSavedBasketResponse, SavedBasketListResponse, UpdateSavedBasketResponse };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum, RefineMinimumOneBuyOneSell, RefineTwoUniqueSymbols } from '../../common/refinement';
|
|
3
|
-
import { Side } from '../../common/schema';
|
|
3
|
+
import { AssetWeight, Side } from '../../common/schema';
|
|
4
4
|
import { Connector } from '../../connector';
|
|
5
5
|
import { InstrumentId } from '../../instrument';
|
|
6
6
|
import { MetricTrack } from '../common';
|
|
@@ -11,7 +11,6 @@ const TriggerThreshold = z.number().positive({
|
|
|
11
11
|
const PriceSource = z.enum(["mid", "mark"], {
|
|
12
12
|
message: "Price source must be mid or mark"
|
|
13
13
|
});
|
|
14
|
-
const AssetWeight = z.number().positive({ message: "Weight must be greater than 0" }).max(1, { message: "Weight must be less than 1" });
|
|
15
14
|
const WeightedRatioBasketItem = z.object({
|
|
16
15
|
symbol: InstrumentId,
|
|
17
16
|
side: Side,
|