@pear-protocol/types 1.24.1 → 1.25.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/common/refinement.d.ts +0 -3
- package/dist/common/refinement.js +1 -11
- package/dist/ladder/payloads.js +2 -2
- package/dist/statistics/entities.d.ts +1 -0
- package/dist/statistics/entities.js +12 -0
- package/dist/statistics/queries.d.ts +2 -0
- package/dist/statistics/queries.js +2 -1
- package/dist/statistics/responses.d.ts +1 -0
- package/dist/trigger/payloads/conditions.js +2 -2
- package/package.json +1 -1
|
@@ -15,7 +15,4 @@ export declare const RefineUniqueSymbols: <T extends {
|
|
|
15
15
|
export declare const RefineWeightingSum: <T extends {
|
|
16
16
|
weight: number;
|
|
17
17
|
}[]>(basket: T, ctx: z.RefinementCtx) => void;
|
|
18
|
-
export declare const RefineMinimumOneBuyOneSell: <T extends {
|
|
19
|
-
side: "BUY" | "SELL";
|
|
20
|
-
}[]>(basket: T, ctx: z.RefinementCtx) => void;
|
|
21
18
|
export declare const RefineMinimumOneKeyValuePair: <T extends Record<string, unknown>>(data: T, ctx: z.RefinementCtx) => void;
|
|
@@ -52,16 +52,6 @@ const RefineWeightingSum = /* @__PURE__ */ __name((basket, ctx) => {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}, "RefineWeightingSum");
|
|
55
|
-
const RefineMinimumOneBuyOneSell = /* @__PURE__ */ __name((basket, ctx) => {
|
|
56
|
-
const buyCount = basket.filter((item) => item.side === "BUY").length;
|
|
57
|
-
const sellCount = basket.filter((item) => item.side === "SELL").length;
|
|
58
|
-
if (buyCount < 1 || sellCount < 1) {
|
|
59
|
-
ctx.addIssue({
|
|
60
|
-
code: "custom",
|
|
61
|
-
message: "At least one BUY and one SELL are required."
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}, "RefineMinimumOneBuyOneSell");
|
|
65
55
|
const RefineMinimumOneKeyValuePair = /* @__PURE__ */ __name((data, ctx) => {
|
|
66
56
|
if (Object.keys(data).length < 1) {
|
|
67
57
|
ctx.addIssue({
|
|
@@ -71,4 +61,4 @@ const RefineMinimumOneKeyValuePair = /* @__PURE__ */ __name((data, ctx) => {
|
|
|
71
61
|
}
|
|
72
62
|
}, "RefineMinimumOneKeyValuePair");
|
|
73
63
|
|
|
74
|
-
export {
|
|
64
|
+
export { RefineMinimumOneKeyValuePair, RefineMinimumOneSymbol, RefineMinimumTwoSymbols, RefineTwoUniqueSymbols, RefineUniqueSymbols, RefineWeightingSum };
|
package/dist/ladder/payloads.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ClientIdCode } from '../common/client-id';
|
|
3
|
-
import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum,
|
|
3
|
+
import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum, RefineTwoUniqueSymbols, RefineMinimumOneSymbol } from '../common/refinement';
|
|
4
4
|
import { AssetWeight, Side } from '../common/schema';
|
|
5
5
|
import { TradeLegPostOnly } from '../common/trade-legs';
|
|
6
6
|
import { InstrumentId } from '../instrument';
|
|
@@ -29,7 +29,7 @@ const WeightedRatioBasketItem = z.object({
|
|
|
29
29
|
side: Side,
|
|
30
30
|
weight: AssetWeight
|
|
31
31
|
});
|
|
32
|
-
const WeightedRatioBasket = z.array(WeightedRatioBasketItem).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum)
|
|
32
|
+
const WeightedRatioBasket = z.array(WeightedRatioBasketItem).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
|
|
33
33
|
const LadderRatioOpen = z.object({
|
|
34
34
|
type: z.literal("ratio"),
|
|
35
35
|
data: z.object({
|
|
@@ -17,6 +17,7 @@ export declare const LeaderboardRow: z.ZodObject<{
|
|
|
17
17
|
pearFee: z.ZodString;
|
|
18
18
|
tradeFee: z.ZodString;
|
|
19
19
|
totalTrades: z.ZodNumber;
|
|
20
|
+
roi: z.ZodOptional<z.ZodString>;
|
|
20
21
|
xHandle: z.ZodOptional<z.ZodString>;
|
|
21
22
|
xName: z.ZodOptional<z.ZodString>;
|
|
22
23
|
xAvatarUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -21,6 +21,18 @@ const LeaderboardRow = z.object({
|
|
|
21
21
|
pearFee: z.string(),
|
|
22
22
|
tradeFee: z.string(),
|
|
23
23
|
totalTrades: z.number(),
|
|
24
|
+
// The plain average of this account's per-position returns, as a ratio: "0.25" is +25%.
|
|
25
|
+
// Every position is weighted equally, so a small winner counts as much as a large one —
|
|
26
|
+
// this is a measure of the trader's decisions, not of the dollars those decisions moved.
|
|
27
|
+
//
|
|
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.
|
|
30
|
+
//
|
|
31
|
+
// Absent when the board could measure none of the account's positions — never "0", which
|
|
32
|
+
// 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.
|
|
35
|
+
roi: z.string().optional(),
|
|
24
36
|
// The trader's linked X account. Absent for an account whose owner has connected no X
|
|
25
37
|
// account, and absent for an anonymous caller: the board itself is public, but pairing a
|
|
26
38
|
// real name with a wallet address and a PnL for the open internet is a wider promise than
|
|
@@ -53,6 +53,7 @@ export declare const LeaderboardSortBy: z.ZodEnum<{
|
|
|
53
53
|
trades: "trades";
|
|
54
54
|
volume: "volume";
|
|
55
55
|
totalNetPnl: "totalNetPnl";
|
|
56
|
+
roi: "roi";
|
|
56
57
|
}>;
|
|
57
58
|
export type LeaderboardSortBy = z.infer<typeof LeaderboardSortBy>;
|
|
58
59
|
export declare const LEADERBOARD_MAX_LIMIT = 200;
|
|
@@ -70,6 +71,7 @@ export declare const LeaderboardQueryParams: z.ZodObject<{
|
|
|
70
71
|
trades: "trades";
|
|
71
72
|
volume: "volume";
|
|
72
73
|
totalNetPnl: "totalNetPnl";
|
|
74
|
+
roi: "roi";
|
|
73
75
|
}>>;
|
|
74
76
|
startDate: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<number>, z.ZodTransform<Date, number>>>;
|
|
75
77
|
endDate: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<number>, z.ZodTransform<Date, number>>>;
|
|
@@ -41,7 +41,8 @@ const StatisticsTotalsQueryParams = z.object({
|
|
|
41
41
|
const LeaderboardSortBy = z.enum([
|
|
42
42
|
"trades",
|
|
43
43
|
"totalNetPnl",
|
|
44
|
-
"volume"
|
|
44
|
+
"volume",
|
|
45
|
+
"roi"
|
|
45
46
|
]);
|
|
46
47
|
const LEADERBOARD_MAX_LIMIT = 200;
|
|
47
48
|
const UnixSeconds = z.coerce.number().int().min(0).transform((seconds) => new Date(seconds * 1e3));
|
|
@@ -18,6 +18,7 @@ export declare const LeaderboardResponse: z.ZodObject<{
|
|
|
18
18
|
pearFee: z.ZodString;
|
|
19
19
|
tradeFee: z.ZodString;
|
|
20
20
|
totalTrades: z.ZodNumber;
|
|
21
|
+
roi: z.ZodOptional<z.ZodString>;
|
|
21
22
|
xHandle: z.ZodOptional<z.ZodString>;
|
|
22
23
|
xName: z.ZodOptional<z.ZodString>;
|
|
23
24
|
xAvatarUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum,
|
|
2
|
+
import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum, RefineTwoUniqueSymbols } from '../../common/refinement';
|
|
3
3
|
import { AssetWeight, Side } from '../../common/schema';
|
|
4
4
|
import { Connector } from '../../connector';
|
|
5
5
|
import { InstrumentId } from '../../instrument';
|
|
@@ -19,7 +19,7 @@ const WeightedRatioBasketItem = z.object({
|
|
|
19
19
|
side: Side,
|
|
20
20
|
weight: AssetWeight
|
|
21
21
|
});
|
|
22
|
-
const WeightedRatioBasket = z.array(WeightedRatioBasketItem).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum)
|
|
22
|
+
const WeightedRatioBasket = z.array(WeightedRatioBasketItem).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
|
|
23
23
|
const RatioOpen = z.object({
|
|
24
24
|
type: z.literal("ratio"),
|
|
25
25
|
data: z.object({
|