@pear-protocol/types 1.16.0 → 1.17.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/instrument/entities.d.ts +19 -0
- package/dist/instrument/entities.js +12 -1
- package/dist/instrument/responses.d.ts +10 -0
- package/dist/instrument/responses.js +1 -1
- package/dist/leverage/payloads.d.ts +2 -2
- package/dist/market/entities.d.ts +23 -2
- package/dist/market/entities.js +13 -3
- package/dist/market/index.d.ts +1 -0
- package/dist/market/index.js +1 -0
- package/dist/market/payloads.d.ts +22 -0
- package/dist/market/payloads.js +11 -0
- package/dist/market/responses.d.ts +16 -2
- package/dist/market/responses.js +5 -2
- package/dist/notification/entities.d.ts +292 -34
- package/dist/notification/entities.js +72 -15
- package/dist/notification/responses.d.ts +144 -16
- package/dist/position/entities.d.ts +227 -0
- package/dist/position/entities.js +141 -1
- package/dist/position/queries.d.ts +16 -0
- package/dist/position/queries.js +25 -1
- package/dist/position/responses.d.ts +106 -0
- package/dist/position/responses.js +5 -2
- package/dist/rebalance/entities.d.ts +48 -9
- package/dist/rebalance/entities.js +33 -4
- package/dist/rebalance/responses.d.ts +70 -18
- package/dist/statistics/queries.d.ts +4 -2
- package/dist/statistics/queries.js +8 -2
- package/dist/users/payloads.d.ts +8 -0
- package/dist/users/payloads.js +9 -1
- package/dist/users/response.d.ts +5 -0
- package/dist/users/response.js +5 -1
- package/package.json +1 -1
|
@@ -7,6 +7,15 @@ export declare const InstrumentType: z.ZodEnum<{
|
|
|
7
7
|
hip3: "hip3";
|
|
8
8
|
}>;
|
|
9
9
|
export type InstrumentType = z.infer<typeof InstrumentType>;
|
|
10
|
+
/**
|
|
11
|
+
* The margin modes a market offers. Distinct from the account-level `MarginMode`, which is the user's choice.
|
|
12
|
+
*/
|
|
13
|
+
export declare const InstrumentMarginMode: z.ZodEnum<{
|
|
14
|
+
any: "any";
|
|
15
|
+
isolated: "isolated";
|
|
16
|
+
cross: "cross";
|
|
17
|
+
}>;
|
|
18
|
+
export type InstrumentMarginMode = z.infer<typeof InstrumentMarginMode>;
|
|
10
19
|
export declare const InstrumentTradeabilityStatus: z.ZodEnum<{
|
|
11
20
|
tradable: "tradable";
|
|
12
21
|
reduce_only: "reduce_only";
|
|
@@ -41,6 +50,11 @@ export declare const Instrument: z.ZodObject<{
|
|
|
41
50
|
hip3: "hip3";
|
|
42
51
|
}>;
|
|
43
52
|
leverage: z.ZodInt;
|
|
53
|
+
marginMode: z.ZodEnum<{
|
|
54
|
+
any: "any";
|
|
55
|
+
isolated: "isolated";
|
|
56
|
+
cross: "cross";
|
|
57
|
+
}>;
|
|
44
58
|
precision: z.ZodObject<{
|
|
45
59
|
quantity: z.ZodObject<{
|
|
46
60
|
decimals: z.ZodInt;
|
|
@@ -70,6 +84,11 @@ export type Instrument = z.output<typeof Instrument>;
|
|
|
70
84
|
export declare const InstrumentLite: z.ZodObject<{
|
|
71
85
|
id: z.ZodString;
|
|
72
86
|
base: z.ZodString;
|
|
87
|
+
marginMode: z.ZodEnum<{
|
|
88
|
+
any: "any";
|
|
89
|
+
isolated: "isolated";
|
|
90
|
+
cross: "cross";
|
|
91
|
+
}>;
|
|
73
92
|
precision: z.ZodObject<{
|
|
74
93
|
quantity: z.ZodObject<{
|
|
75
94
|
contractSize: z.ZodNumber;
|
|
@@ -4,6 +4,7 @@ import { InstrumentPrecision } from '../instrument-precision';
|
|
|
4
4
|
|
|
5
5
|
const InstrumentId = z.string().trim().min(1, "Instrument ID is required").max(64, "Instrument ID must be at most 64 characters").regex(/^[^\s][^\s]*$/, "Instrument ID contains invalid characters");
|
|
6
6
|
const InstrumentType = z.enum(["spot", "perp", "hip3"]);
|
|
7
|
+
const InstrumentMarginMode = z.enum(["isolated", "cross", "any"]);
|
|
7
8
|
const InstrumentTradeabilityStatus = z.enum(["tradable", "reduce_only", "not_tradable"]);
|
|
8
9
|
const InstrumentTradeabilityReason = z.string().nullable();
|
|
9
10
|
const InstrumentTradeability = z.object({
|
|
@@ -45,6 +46,11 @@ const Instrument = z.object({
|
|
|
45
46
|
* @example 1
|
|
46
47
|
*/
|
|
47
48
|
leverage: z.int().min(1),
|
|
49
|
+
/**
|
|
50
|
+
* The margin modes this market offers, not the mode selected for an account.
|
|
51
|
+
* `isolated` and `cross` mean the venue permits only that mode; `any` means the user chooses.
|
|
52
|
+
*/
|
|
53
|
+
marginMode: InstrumentMarginMode,
|
|
48
54
|
/**
|
|
49
55
|
* The precision of the instrument.
|
|
50
56
|
*/
|
|
@@ -66,6 +72,11 @@ const InstrumentLite = z.object({
|
|
|
66
72
|
* @example "BTC"
|
|
67
73
|
*/
|
|
68
74
|
base: z.string(),
|
|
75
|
+
/**
|
|
76
|
+
* The margin modes this market offers, not the mode selected for an account.
|
|
77
|
+
* `isolated` and `cross` mean the venue permits only that mode; `any` means the user chooses.
|
|
78
|
+
*/
|
|
79
|
+
marginMode: InstrumentMarginMode,
|
|
69
80
|
/**
|
|
70
81
|
* Minimal precision — only the contract size the syncer needs for BASE-unit normalization.
|
|
71
82
|
*/
|
|
@@ -76,4 +87,4 @@ const InstrumentLite = z.object({
|
|
|
76
87
|
})
|
|
77
88
|
});
|
|
78
89
|
|
|
79
|
-
export { Instrument, InstrumentId, InstrumentLite, InstrumentTradeability, InstrumentTradeabilityReason, InstrumentTradeabilityStatus, InstrumentType };
|
|
90
|
+
export { Instrument, InstrumentId, InstrumentLite, InstrumentMarginMode, InstrumentTradeability, InstrumentTradeabilityReason, InstrumentTradeabilityStatus, InstrumentType };
|
|
@@ -17,6 +17,11 @@ export declare const InstrumentListResponse: z.ZodObject<{
|
|
|
17
17
|
hip3: "hip3";
|
|
18
18
|
}>;
|
|
19
19
|
leverage: z.ZodInt;
|
|
20
|
+
marginMode: z.ZodEnum<{
|
|
21
|
+
any: "any";
|
|
22
|
+
isolated: "isolated";
|
|
23
|
+
cross: "cross";
|
|
24
|
+
}>;
|
|
20
25
|
precision: z.ZodObject<{
|
|
21
26
|
quantity: z.ZodObject<{
|
|
22
27
|
decimals: z.ZodInt;
|
|
@@ -52,6 +57,11 @@ export declare const InstrumentListLiteResponse: z.ZodObject<{
|
|
|
52
57
|
instruments: z.ZodArray<z.ZodObject<{
|
|
53
58
|
id: z.ZodString;
|
|
54
59
|
base: z.ZodString;
|
|
60
|
+
marginMode: z.ZodEnum<{
|
|
61
|
+
any: "any";
|
|
62
|
+
isolated: "isolated";
|
|
63
|
+
cross: "cross";
|
|
64
|
+
}>;
|
|
55
65
|
precision: z.ZodObject<{
|
|
56
66
|
quantity: z.ZodObject<{
|
|
57
67
|
contractSize: z.ZodNumber;
|
|
@@ -12,7 +12,7 @@ const InstrumentSymbolToIdMapResponse = z.object({
|
|
|
12
12
|
});
|
|
13
13
|
const InstrumentListLiteResponse = z.object({
|
|
14
14
|
/**
|
|
15
|
-
* The list of instruments, trimmed to the
|
|
15
|
+
* The list of instruments, trimmed to the lightweight consumer fields.
|
|
16
16
|
*/
|
|
17
17
|
instruments: z.array(InstrumentLite)
|
|
18
18
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const MarginMode: z.ZodEnum<{
|
|
3
|
-
cross: "cross";
|
|
4
3
|
isolated: "isolated";
|
|
4
|
+
cross: "cross";
|
|
5
5
|
}>;
|
|
6
6
|
export type MarginMode = z.infer<typeof MarginMode>;
|
|
7
7
|
export declare const SetLeverage: z.ZodObject<{
|
|
8
8
|
symbol: z.ZodString;
|
|
9
9
|
leverage: z.ZodInt;
|
|
10
10
|
marginMode: z.ZodOptional<z.ZodEnum<{
|
|
11
|
-
cross: "cross";
|
|
12
11
|
isolated: "isolated";
|
|
12
|
+
cross: "cross";
|
|
13
13
|
}>>;
|
|
14
14
|
}, z.core.$strip>;
|
|
15
15
|
export type SetLeverage = z.infer<typeof SetLeverage>;
|
|
@@ -37,8 +37,14 @@ export declare const BasketMarket: z.ZodObject<{
|
|
|
37
37
|
}>;
|
|
38
38
|
basketKey: z.ZodString;
|
|
39
39
|
displaySymbol: z.ZodString;
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
symbol: z.ZodString;
|
|
43
|
+
side: z.ZodEnum<{
|
|
44
|
+
BUY: "BUY";
|
|
45
|
+
SELL: "SELL";
|
|
46
|
+
}>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
42
48
|
price: z.ZodString;
|
|
43
49
|
priceChange24h: z.ZodString;
|
|
44
50
|
weightRatio: z.ZodString;
|
|
@@ -58,6 +64,21 @@ export declare const BasketMarket: z.ZodObject<{
|
|
|
58
64
|
hasMaterializedStats: z.ZodBoolean;
|
|
59
65
|
}, z.core.$strip>;
|
|
60
66
|
export type BasketMarket = z.output<typeof BasketMarket>;
|
|
67
|
+
/**
|
|
68
|
+
* How many positions — and how many distinct traders — have ever opened one requested
|
|
69
|
+
* basket, with its key echoed back so a row needs no positional matching.
|
|
70
|
+
*
|
|
71
|
+
* Both numbers are cumulative counters bumped when an open completes and never
|
|
72
|
+
* decremented, so they read as the basket's popularity, not its live open interest,
|
|
73
|
+
* and they are best-effort: a bump lost to a failure is accepted. `traders` is
|
|
74
|
+
* distinct per venue: a trader who opened the basket on two venues counts on each.
|
|
75
|
+
*/
|
|
76
|
+
export declare const MarketBasketPositionCounts: z.ZodObject<{
|
|
77
|
+
basketKey: z.ZodString;
|
|
78
|
+
opened: z.ZodNumber;
|
|
79
|
+
traders: z.ZodNumber;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export type MarketBasketPositionCounts = z.output<typeof MarketBasketPositionCounts>;
|
|
61
82
|
export declare const MarketTotals: z.ZodObject<{
|
|
62
83
|
markets: z.ZodNumber;
|
|
63
84
|
volume24h: z.ZodString;
|
package/dist/market/entities.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { Side } from '../common/schema';
|
|
2
3
|
import { Connector } from '../connector';
|
|
3
4
|
import { InstrumentTradeability, InstrumentId } from '../instrument';
|
|
4
5
|
|
|
@@ -16,12 +17,16 @@ const Market = z.object({
|
|
|
16
17
|
tradeability: InstrumentTradeability,
|
|
17
18
|
updatedAt: z.number()
|
|
18
19
|
});
|
|
20
|
+
const BasketMarketLeg = z.object({
|
|
21
|
+
id: InstrumentId,
|
|
22
|
+
symbol: z.string().min(1),
|
|
23
|
+
side: Side
|
|
24
|
+
});
|
|
19
25
|
const BasketMarket = z.object({
|
|
20
26
|
connector: Connector,
|
|
21
27
|
basketKey: z.string(),
|
|
22
28
|
displaySymbol: z.string(),
|
|
23
|
-
|
|
24
|
-
shortInstrumentIds: z.array(InstrumentId),
|
|
29
|
+
legs: z.array(BasketMarketLeg),
|
|
25
30
|
price: z.string(),
|
|
26
31
|
priceChange24h: z.string(),
|
|
27
32
|
weightRatio: z.string(),
|
|
@@ -33,10 +38,15 @@ const BasketMarket = z.object({
|
|
|
33
38
|
updatedAt: z.number(),
|
|
34
39
|
hasMaterializedStats: z.boolean()
|
|
35
40
|
});
|
|
41
|
+
const MarketBasketPositionCounts = z.object({
|
|
42
|
+
basketKey: z.string(),
|
|
43
|
+
opened: z.number(),
|
|
44
|
+
traders: z.number()
|
|
45
|
+
});
|
|
36
46
|
const MarketTotals = z.object({
|
|
37
47
|
markets: z.number(),
|
|
38
48
|
volume24h: z.string(),
|
|
39
49
|
openInterest: z.string()
|
|
40
50
|
});
|
|
41
51
|
|
|
42
|
-
export { BasketMarket, Market, MarketTotals };
|
|
52
|
+
export { BasketMarket, Market, MarketBasketPositionCounts, MarketTotals };
|
package/dist/market/index.d.ts
CHANGED
package/dist/market/index.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const MARKET_BASKET_POSITION_COUNTS_MAX_BASKETS = 500;
|
|
3
|
+
/**
|
|
4
|
+
* Count the positions that hold each of these baskets, named by their canonical keys.
|
|
5
|
+
*
|
|
6
|
+
* A key spells instrument ids, so it is venue-specific wherever venues name the same
|
|
7
|
+
* asset differently; counts are summed over the connectors in scope that stored the
|
|
8
|
+
* key. An absent `connector` puts every venue in scope; an empty list is rejected
|
|
9
|
+
* rather than read as one, since it states no venue at all.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MarketBasketPositionCountsPayload: z.ZodObject<{
|
|
12
|
+
connector: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
13
|
+
hyperliquid: "hyperliquid";
|
|
14
|
+
binance: "binance";
|
|
15
|
+
bybit: "bybit";
|
|
16
|
+
okx: "okx";
|
|
17
|
+
lighter: "lighter";
|
|
18
|
+
}>>>;
|
|
19
|
+
basketKeys: z.ZodArray<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type MarketBasketPositionCountsPayloadInput = z.input<typeof MarketBasketPositionCountsPayload>;
|
|
22
|
+
export type MarketBasketPositionCountsPayload = z.output<typeof MarketBasketPositionCountsPayload>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Connector } from '../connector';
|
|
3
|
+
|
|
4
|
+
const MARKET_BASKET_POSITION_COUNTS_MAX_BASKETS = 500;
|
|
5
|
+
const BasketKey = z.string().regex(/^[0-9a-f]{64}$/, "A basket key is 64 lowercase hex characters \u2014 see deriveBasketKey in @pear-protocol/utils");
|
|
6
|
+
const MarketBasketPositionCountsPayload = z.object({
|
|
7
|
+
connector: z.array(Connector).min(1, "Name at least one connector, or omit the field for every venue").optional().describe("Absent means every connector, summed"),
|
|
8
|
+
basketKeys: z.array(BasketKey).min(1, "At least one basket key is required").max(MARKET_BASKET_POSITION_COUNTS_MAX_BASKETS, "Too many basket keys in one request").describe("Canonical basket keys, as /markets/baskets reports them")
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export { MARKET_BASKET_POSITION_COUNTS_MAX_BASKETS, MarketBasketPositionCountsPayload };
|
|
@@ -48,8 +48,14 @@ export declare const MarketBasketsResponse: z.ZodObject<{
|
|
|
48
48
|
}>;
|
|
49
49
|
basketKey: z.ZodString;
|
|
50
50
|
displaySymbol: z.ZodString;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
symbol: z.ZodString;
|
|
54
|
+
side: z.ZodEnum<{
|
|
55
|
+
BUY: "BUY";
|
|
56
|
+
SELL: "SELL";
|
|
57
|
+
}>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
53
59
|
price: z.ZodString;
|
|
54
60
|
priceChange24h: z.ZodString;
|
|
55
61
|
weightRatio: z.ZodString;
|
|
@@ -70,3 +76,11 @@ export declare const MarketBasketsResponse: z.ZodObject<{
|
|
|
70
76
|
}, z.core.$strip>>;
|
|
71
77
|
}, z.core.$strip>;
|
|
72
78
|
export type MarketBasketsResponse = z.output<typeof MarketBasketsResponse>;
|
|
79
|
+
export declare const MarketBasketPositionCountsResponse: z.ZodObject<{
|
|
80
|
+
counts: z.ZodArray<z.ZodObject<{
|
|
81
|
+
basketKey: z.ZodString;
|
|
82
|
+
opened: z.ZodNumber;
|
|
83
|
+
traders: z.ZodNumber;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export type MarketBasketPositionCountsResponse = z.output<typeof MarketBasketPositionCountsResponse>;
|
package/dist/market/responses.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { MarketTotals, Market, BasketMarket } from './entities';
|
|
2
|
+
import { MarketTotals, Market, BasketMarket, MarketBasketPositionCounts } from './entities';
|
|
3
3
|
|
|
4
4
|
const MarketsResponse = z.object({
|
|
5
5
|
markets: z.array(Market),
|
|
@@ -11,5 +11,8 @@ const MarketBasketsResponse = z.object({
|
|
|
11
11
|
count: z.number(),
|
|
12
12
|
markets: z.array(BasketMarket)
|
|
13
13
|
});
|
|
14
|
+
const MarketBasketPositionCountsResponse = z.object({
|
|
15
|
+
counts: z.array(MarketBasketPositionCounts)
|
|
16
|
+
});
|
|
14
17
|
|
|
15
|
-
export { MarketBasketsResponse, MarketsResponse };
|
|
18
|
+
export { MarketBasketPositionCountsResponse, MarketBasketsResponse, MarketsResponse };
|