@polyester/sdk 0.4.4 → 0.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/CHANGELOG.md +20 -0
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/heatmap/heatmap.schemas.d.ts +13 -13
- package/dist/services/market-overview/market-overview.schemas.d.ts +3 -3
- package/dist/services/orderbook/orderbook.codecs.js +22 -1
- package/dist/services/orderbook/orderbook.codecs.js.map +1 -1
- package/dist/services/orderbook/orderbook.d.ts +5 -1
- package/dist/services/orderbook/orderbook.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.js +13 -7
- package/dist/services/orderbook/orderbook.js.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -5
- package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +13 -13
- package/dist/smart-account/index.d.ts +2 -2
- package/dist/smart-account/index.js +2 -2
- package/dist/smart-account/smart-account.d.ts +22 -2
- package/dist/smart-account/smart-account.d.ts.map +1 -1
- package/dist/smart-account/smart-account.js +62 -19
- package/dist/smart-account/smart-account.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @polyester/sdk
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - `sendPolyesterUserOperation` now prepares the operation in a single pass, halving the network round-trips before the wallet signature prompt appears. Gas estimation errors now propagate instead of triggering a silent resend.
|
|
8
|
+
|
|
9
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - `sendPolyesterUserOperation` accepts a new `onWalletSignatureRequested` callback that fires right before the wallet is asked to sign, so UIs can show an accurate "confirm in your wallet" state.
|
|
10
|
+
|
|
11
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - New `warmPolyesterSmartAccountClient` helper pre-fetches the gas price and warms RPC connections ahead of a submission. The smart account client now caches gas prices, for 10 seconds by default, configurable via the new `options.gasPriceCacheTtlMs` setting.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#66](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/66) [`e8a5721`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/e8a5721b57be7ebd0b7edf80c4ed85919fccdb0a) Thanks [@huntabyte](https://github.com/huntabyte)! - The smart account client polls for UserOperation receipts every second instead of every 4 seconds, configurable via the new `options.pollingIntervalMs` setting.
|
|
16
|
+
|
|
17
|
+
## 0.4.5
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#64](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/64) [`354cfd2`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/354cfd29d21c44a4b82203938c3c10d4848e3943) Thanks [@huntabyte](https://github.com/huntabyte)! - fix(orderbook): stop `orderbook.createSubscription()` from subscribing to order-book delta channels that have no publisher. The backend only publishes `public:spot:orderbook:deltas:depth:{depth}:...` for depths `1, 20, 50, 200, 500`, but the REST snapshot accepts `1, 5, 10, 20, 50, 100, 200, 500, 1000`. Passing one of the REST-only depths (for example `depth: 10`) subscribed successfully and then never delivered a publication, leaving the book permanently empty with no `onError`. Requested depths now ride the smallest published channel depth that covers them and are sliced back down locally, so every documented depth delivers updates.
|
|
22
|
+
|
|
3
23
|
## 0.4.4
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ type TimestampInit = {
|
|
|
11
11
|
};
|
|
12
12
|
declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
13
13
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
14
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "
|
|
14
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
|
|
15
15
|
readonly tsSec: v.BigintSchema<undefined>;
|
|
16
16
|
readonly open: v.BigintSchema<undefined>;
|
|
17
17
|
readonly high: v.BigintSchema<undefined>;
|
|
@@ -21,7 +21,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
21
21
|
readonly isClosed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
22
22
|
}, undefined>, v.TransformAction<{
|
|
23
23
|
symbolId: number;
|
|
24
|
-
timeframe: DecodedEnum<"1d" | "
|
|
24
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
25
25
|
tsSec: bigint;
|
|
26
26
|
open: bigint;
|
|
27
27
|
high: bigint;
|
|
@@ -31,7 +31,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
31
31
|
isClosed: boolean;
|
|
32
32
|
}, {
|
|
33
33
|
symbolId: number;
|
|
34
|
-
timeframe: DecodedEnum<"1d" | "
|
|
34
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
35
35
|
time: number;
|
|
36
36
|
open: string;
|
|
37
37
|
high: string;
|
|
@@ -43,7 +43,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
43
43
|
declare const createCandleRowIntSchema: typeof createCandleRowSchema;
|
|
44
44
|
declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
45
45
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
46
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "
|
|
46
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
|
|
47
47
|
readonly tsSec: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
48
48
|
readonly open: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
49
49
|
readonly high: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
@@ -59,7 +59,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
59
59
|
readonly nextPageToken: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
60
60
|
}, undefined>, v.TransformAction<{
|
|
61
61
|
symbolId: number;
|
|
62
|
-
timeframe: DecodedEnum<"1d" | "
|
|
62
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
63
63
|
tsSec: bigint[];
|
|
64
64
|
open: bigint[];
|
|
65
65
|
high: bigint[];
|
|
@@ -75,7 +75,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
75
75
|
nextPageToken: string;
|
|
76
76
|
}, {
|
|
77
77
|
symbolId: number;
|
|
78
|
-
timeframe: DecodedEnum<"1d" | "
|
|
78
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
79
79
|
time: number[];
|
|
80
80
|
open: string[];
|
|
81
81
|
high: string[];
|
|
@@ -94,7 +94,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
94
94
|
}>]>;
|
|
95
95
|
declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
96
96
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
97
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "
|
|
97
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
|
|
98
98
|
readonly tsSec: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
99
99
|
readonly open: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
100
100
|
readonly high: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
@@ -110,7 +110,7 @@ declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithP
|
|
|
110
110
|
readonly nextPageToken: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
111
111
|
}, undefined>, v.TransformAction<{
|
|
112
112
|
symbolId: number;
|
|
113
|
-
timeframe: DecodedEnum<"1d" | "
|
|
113
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
114
114
|
tsSec: bigint[];
|
|
115
115
|
open: bigint[];
|
|
116
116
|
high: bigint[];
|
|
@@ -126,7 +126,7 @@ declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithP
|
|
|
126
126
|
nextPageToken: string;
|
|
127
127
|
}, {
|
|
128
128
|
symbolId: number;
|
|
129
|
-
timeframe: DecodedEnum<"1d" | "
|
|
129
|
+
timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
|
|
130
130
|
tsSec: number[];
|
|
131
131
|
open: string[];
|
|
132
132
|
high: string[];
|
|
@@ -149,7 +149,7 @@ type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema
|
|
|
149
149
|
type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;
|
|
150
150
|
declare function createListCandlesInputSchema(): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
151
151
|
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
152
|
-
readonly timeframe: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "12h", "1d", "1w", "1mo"], undefined>, v.TransformAction<"1d" | "
|
|
152
|
+
readonly timeframe: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "12h", "1d", "1w", "1mo"], undefined>, v.TransformAction<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo", Timeframe$1.SEC_1 | Timeframe$1.MIN_1 | Timeframe$1.MIN_5 | Timeframe$1.MIN_15 | Timeframe$1.MIN_30 | Timeframe$1.HOUR_1 | Timeframe$1.HOUR_4 | Timeframe$1.DAY_1 | Timeframe$1.HOUR_12 | Timeframe$1.WEEK_1 | Timeframe$1.MONTH_1>]>;
|
|
153
153
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 10000, undefined>]>, undefined>;
|
|
154
154
|
readonly includeIncomplete: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
155
155
|
readonly includeReference: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
@@ -13,8 +13,8 @@ type TimestampInit = {
|
|
|
13
13
|
};
|
|
14
14
|
declare const GetOrderbookHeatmapInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
15
15
|
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
16
|
-
readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"
|
|
17
|
-
readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 |
|
|
16
|
+
readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"1h" | "1m" | "1s" | "5m", HeatmapInterval>]>;
|
|
17
|
+
readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100, HeatmapDepth>]>;
|
|
18
18
|
readonly quantityMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["close", "peak"], undefined>, "close">, v.TransformAction<"close" | "peak", HeatmapQuantityMode>]>;
|
|
19
19
|
readonly limit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 20000, undefined>]>;
|
|
20
20
|
readonly startTsSec: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>, v.TransformAction<number, bigint>]>, undefined>;
|
|
@@ -122,7 +122,7 @@ declare function convertHeatmapDeltaBucket(bucket: OrderbookHeatmapDeltaBucketRa
|
|
|
122
122
|
type OrderbookHeatmapDeltaBucket = ReturnType<typeof convertHeatmapDeltaBucket>;
|
|
123
123
|
declare const OrderbookHeatmapLiveBucketRawSchema: v.ObjectSchema<{
|
|
124
124
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
125
|
-
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"
|
|
125
|
+
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
|
|
126
126
|
readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
127
127
|
readonly isFinal: v.BooleanSchema<undefined>;
|
|
128
128
|
readonly bids: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -142,7 +142,7 @@ declare const OrderbookHeatmapLiveBucketRawSchema: v.ObjectSchema<{
|
|
|
142
142
|
type OrderbookHeatmapLiveBucketRaw = v.InferOutput<typeof OrderbookHeatmapLiveBucketRawSchema>;
|
|
143
143
|
declare function convertHeatmapLiveBucket(bucket: OrderbookHeatmapLiveBucketRaw, scales: SdkScales): {
|
|
144
144
|
symbolId: number;
|
|
145
|
-
interval: DecodedEnum<"
|
|
145
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
146
146
|
tsSec: number;
|
|
147
147
|
isFinal: boolean;
|
|
148
148
|
bids: {
|
|
@@ -226,8 +226,8 @@ declare function convertHeatmapDeltaChain(chain: OrderbookHeatmapDeltaChainRaw,
|
|
|
226
226
|
type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;
|
|
227
227
|
declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
228
228
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
229
|
-
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"
|
|
230
|
-
readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 |
|
|
229
|
+
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
|
|
230
|
+
readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100>]>;
|
|
231
231
|
readonly chain: v.OptionalSchema<v.ObjectSchema<{
|
|
232
232
|
readonly baseKeyframe: v.OptionalSchema<v.ObjectSchema<{
|
|
233
233
|
readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
@@ -267,7 +267,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
267
267
|
readonly quantityMode: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"close" | "peak">>]>;
|
|
268
268
|
readonly liveBucket: v.OptionalSchema<v.ObjectSchema<{
|
|
269
269
|
readonly symbolId: v.NumberSchema<undefined>;
|
|
270
|
-
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"
|
|
270
|
+
readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
|
|
271
271
|
readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
272
272
|
readonly isFinal: v.BooleanSchema<undefined>;
|
|
273
273
|
readonly bids: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -286,8 +286,8 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
286
286
|
}, undefined>, undefined>;
|
|
287
287
|
}, undefined>, v.TransformAction<{
|
|
288
288
|
symbolId: number;
|
|
289
|
-
interval: DecodedEnum<"
|
|
290
|
-
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 |
|
|
289
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
290
|
+
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
|
|
291
291
|
chain?: {
|
|
292
292
|
baseKeyframe?: {
|
|
293
293
|
tsSec: number;
|
|
@@ -327,7 +327,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
327
327
|
quantityMode: DecodedEnum<"close" | "peak">;
|
|
328
328
|
liveBucket?: {
|
|
329
329
|
symbolId: number;
|
|
330
|
-
interval: DecodedEnum<"
|
|
330
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
331
331
|
tsSec: number;
|
|
332
332
|
isFinal: boolean;
|
|
333
333
|
bids?: {
|
|
@@ -346,8 +346,8 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
346
346
|
} | undefined;
|
|
347
347
|
}, {
|
|
348
348
|
symbolId: number;
|
|
349
|
-
interval: DecodedEnum<"
|
|
350
|
-
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 |
|
|
349
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
350
|
+
depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
|
|
351
351
|
chain: {
|
|
352
352
|
baseKeyframe: {
|
|
353
353
|
tsSec: number;
|
|
@@ -387,7 +387,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
|
|
|
387
387
|
quantityMode: DecodedEnum<"close" | "peak">;
|
|
388
388
|
liveBucket: {
|
|
389
389
|
symbolId: number;
|
|
390
|
-
interval: DecodedEnum<"
|
|
390
|
+
interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
|
|
391
391
|
tsSec: number;
|
|
392
392
|
isFinal: boolean;
|
|
393
393
|
bids: {
|
|
@@ -30,7 +30,7 @@ declare function createMarketOverviewSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
30
30
|
readonly bestAskTicks: v.BigintSchema<undefined>;
|
|
31
31
|
readonly bestAskQtyScaled: v.BigintSchema<undefined>;
|
|
32
32
|
readonly sparklines: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
33
|
-
readonly interval: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SparklineInterval, undefined>, v.TransformAction<SparklineInterval, "unspecified" | "
|
|
33
|
+
readonly interval: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SparklineInterval, undefined>, v.TransformAction<SparklineInterval, "unspecified" | "1h" | "24h" | "1w" | "1m">]>;
|
|
34
34
|
readonly closeTicks: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
|
|
35
35
|
}, undefined>, undefined>, readonly []>;
|
|
36
36
|
readonly indexPriceTicks: v.BigintSchema<undefined>;
|
|
@@ -50,7 +50,7 @@ declare function createMarketOverviewSchema(scales: SdkScales): v.SchemaWithPipe
|
|
|
50
50
|
bestAskTicks: bigint;
|
|
51
51
|
bestAskQtyScaled: bigint;
|
|
52
52
|
sparklines: {
|
|
53
|
-
interval: "unspecified" | "
|
|
53
|
+
interval: "unspecified" | "1h" | "24h" | "1w" | "1m";
|
|
54
54
|
closeTicks: bigint[];
|
|
55
55
|
}[];
|
|
56
56
|
indexPriceTicks: bigint;
|
|
@@ -80,7 +80,7 @@ declare const ListMarketOverviewInputSchema: v.ObjectSchema<{
|
|
|
80
80
|
readonly orderBy: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["change_24h_bps", "volume_24h_quote", "last_price", "date_added"], undefined>, "volume_24h_quote">, v.TransformAction<"change_24h_bps" | "volume_24h_quote" | "last_price" | "date_added", MarketOrderBy.ORDER_BY_CHANGE_24H_BPS | MarketOrderBy.ORDER_BY_VOLUME_24H_QUOTE | MarketOrderBy.ORDER_BY_LAST_PRICE | MarketOrderBy.ORDER_BY_DATE_ADDED>]>;
|
|
81
81
|
readonly sort: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["asc", "desc"], undefined>, "desc">, v.TransformAction<"asc" | "desc", SortDirection.SORT_ASC | SortDirection.SORT_DESC>]>;
|
|
82
82
|
readonly includeSparklines: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
83
|
-
readonly sparklineIntervals: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["1h", "24h", "1w", "1m"], undefined>, undefined>, readonly ["24h"]>, v.TransformAction<("
|
|
83
|
+
readonly sparklineIntervals: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["1h", "24h", "1w", "1m"], undefined>, undefined>, readonly ["24h"]>, v.TransformAction<("1h" | "24h" | "1w" | "1m")[], (SparklineInterval.SPARKLINE_1H | SparklineInterval.SPARKLINE_24H | SparklineInterval.SPARKLINE_1W | SparklineInterval.SPARKLINE_1M)[]>]>;
|
|
84
84
|
}, undefined>;
|
|
85
85
|
type ListMarketOverviewInput = v.InferInput<typeof ListMarketOverviewInputSchema>;
|
|
86
86
|
//#endregion
|
|
@@ -39,7 +39,28 @@ function normalizeOrderbookDepth(depth) {
|
|
|
39
39
|
protoDepth: DepthCodec.inputToProto[levels]
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Depths for which the backend publishes `public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto`
|
|
44
|
+
* channels. Narrower than ORDERBOOK_SUPPORTED_DEPTHS, which is the set the REST snapshot accepts:
|
|
45
|
+
* subscribing to a depth outside this set succeeds and then never delivers a publication, so the book
|
|
46
|
+
* silently stays empty.
|
|
47
|
+
*/
|
|
48
|
+
const ORDERBOOK_WS_DEPTHS = [
|
|
49
|
+
1,
|
|
50
|
+
20,
|
|
51
|
+
50,
|
|
52
|
+
200,
|
|
53
|
+
500
|
|
54
|
+
];
|
|
55
|
+
/**
|
|
56
|
+
* Smallest published channel depth that covers `depth`, so a request for an unpublished depth rides a
|
|
57
|
+
* deeper feed and is sliced back down locally instead of subscribing to a channel with no publisher.
|
|
58
|
+
*/
|
|
59
|
+
function orderbookWsChannelDepth(depth) {
|
|
60
|
+
for (const d of ORDERBOOK_WS_DEPTHS) if (d >= depth) return d;
|
|
61
|
+
return 500;
|
|
62
|
+
}
|
|
42
63
|
//#endregion
|
|
43
|
-
export { DepthCodec, ORDERBOOK_SUPPORTED_DEPTHS, normalizeOrderbookDepth };
|
|
64
|
+
export { DepthCodec, ORDERBOOK_SUPPORTED_DEPTHS, ORDERBOOK_WS_DEPTHS, normalizeOrderbookDepth, orderbookWsChannelDepth };
|
|
44
65
|
|
|
45
66
|
//# sourceMappingURL=orderbook.codecs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderbook.codecs.js","names":[],"sources":["../../../src/services/orderbook/orderbook.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\n\nexport const ORDERBOOK_SUPPORTED_DEPTHS = [1, 5, 10, 20, 50, 100, 200, 500, 1000] as const;\n\nexport type OrderbookSupportedDepth = (typeof ORDERBOOK_SUPPORTED_DEPTHS)[number];\n\nexport type NormalizedOrderbookDepth = {\n levels: OrderbookSupportedDepth;\n protoDepth: Proto.Depth;\n};\n\nexport const DepthCodec = {\n inputToProto: {\n 1: Proto.Depth.DEPTH_1,\n 5: Proto.Depth.DEPTH_5,\n 10: Proto.Depth.DEPTH_10,\n 20: Proto.Depth.DEPTH_20,\n 50: Proto.Depth.DEPTH_50,\n 100: Proto.Depth.DEPTH_100,\n 200: Proto.Depth.DEPTH_200,\n 500: Proto.Depth.DEPTH_500,\n 1000: Proto.Depth.DEPTH_1000,\n } satisfies Record<OrderbookSupportedDepth, Proto.Depth>,\n supportedDepths: ORDERBOOK_SUPPORTED_DEPTHS,\n} as const;\n\nexport function normalizeOrderbookDepth(depth: number): NormalizedOrderbookDepth {\n if (depth in DepthCodec.inputToProto) {\n const levels = depth as OrderbookSupportedDepth;\n return { levels, protoDepth: DepthCodec.inputToProto[levels] };\n }\n\n const levels = DepthCodec.supportedDepths.reduce((prev, curr) =>\n Math.abs(curr - depth) < Math.abs(prev - depth) ? curr : prev,\n );\n return { levels, protoDepth: DepthCodec.inputToProto[levels] };\n}\n"],"mappings":";;AAEA,MAAa,6BAA6B;CAAC;CAAG;CAAG;CAAI;CAAI;CAAI;CAAK;CAAK;CAAK;AAAI;AAShF,MAAa,aAAa;CACtB,cAAc;EACV,GAAA;EACA,GAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;CACJ;CACA,iBAAiB;AACrB;AAEA,SAAgB,wBAAwB,OAAyC;CAC7E,IAAI,SAAS,WAAW,cAAc;EAClC,MAAM,SAAS;EACf,OAAO;GAAE;GAAQ,YAAY,WAAW,aAAa;EAAQ;CACjE;CAEA,MAAM,SAAS,WAAW,gBAAgB,QAAQ,MAAM,SACpD,KAAK,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,IAAI,OAAO,IAC7D;CACA,OAAO;EAAE;EAAQ,YAAY,WAAW,aAAa;CAAQ;AACjE"}
|
|
1
|
+
{"version":3,"file":"orderbook.codecs.js","names":[],"sources":["../../../src/services/orderbook/orderbook.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\n\nexport const ORDERBOOK_SUPPORTED_DEPTHS = [1, 5, 10, 20, 50, 100, 200, 500, 1000] as const;\n\nexport type OrderbookSupportedDepth = (typeof ORDERBOOK_SUPPORTED_DEPTHS)[number];\n\nexport type NormalizedOrderbookDepth = {\n levels: OrderbookSupportedDepth;\n protoDepth: Proto.Depth;\n};\n\nexport const DepthCodec = {\n inputToProto: {\n 1: Proto.Depth.DEPTH_1,\n 5: Proto.Depth.DEPTH_5,\n 10: Proto.Depth.DEPTH_10,\n 20: Proto.Depth.DEPTH_20,\n 50: Proto.Depth.DEPTH_50,\n 100: Proto.Depth.DEPTH_100,\n 200: Proto.Depth.DEPTH_200,\n 500: Proto.Depth.DEPTH_500,\n 1000: Proto.Depth.DEPTH_1000,\n } satisfies Record<OrderbookSupportedDepth, Proto.Depth>,\n supportedDepths: ORDERBOOK_SUPPORTED_DEPTHS,\n} as const;\n\nexport function normalizeOrderbookDepth(depth: number): NormalizedOrderbookDepth {\n if (depth in DepthCodec.inputToProto) {\n const levels = depth as OrderbookSupportedDepth;\n return { levels, protoDepth: DepthCodec.inputToProto[levels] };\n }\n\n const levels = DepthCodec.supportedDepths.reduce((prev, curr) =>\n Math.abs(curr - depth) < Math.abs(prev - depth) ? curr : prev,\n );\n return { levels, protoDepth: DepthCodec.inputToProto[levels] };\n}\n\n/**\n * Depths for which the backend publishes `public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto`\n * channels. Narrower than ORDERBOOK_SUPPORTED_DEPTHS, which is the set the REST snapshot accepts:\n * subscribing to a depth outside this set succeeds and then never delivers a publication, so the book\n * silently stays empty.\n */\nexport const ORDERBOOK_WS_DEPTHS = [1, 20, 50, 200, 500] as const;\n\nexport type OrderbookWsDepth = (typeof ORDERBOOK_WS_DEPTHS)[number];\n\n/**\n * Smallest published channel depth that covers `depth`, so a request for an unpublished depth rides a\n * deeper feed and is sliced back down locally instead of subscribing to a channel with no publisher.\n */\nexport function orderbookWsChannelDepth(depth: number): OrderbookWsDepth {\n for (const d of ORDERBOOK_WS_DEPTHS) if (d >= depth) return d;\n return 500;\n}\n"],"mappings":";;AAEA,MAAa,6BAA6B;CAAC;CAAG;CAAG;CAAI;CAAI;CAAI;CAAK;CAAK;CAAK;AAAI;AAShF,MAAa,aAAa;CACtB,cAAc;EACV,GAAA;EACA,GAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;CACJ;CACA,iBAAiB;AACrB;AAEA,SAAgB,wBAAwB,OAAyC;CAC7E,IAAI,SAAS,WAAW,cAAc;EAClC,MAAM,SAAS;EACf,OAAO;GAAE;GAAQ,YAAY,WAAW,aAAa;EAAQ;CACjE;CAEA,MAAM,SAAS,WAAW,gBAAgB,QAAQ,MAAM,SACpD,KAAK,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,IAAI,OAAO,IAC7D;CACA,OAAO;EAAE;EAAQ,YAAY,WAAW,aAAa;CAAQ;AACjE;;;;;;;AAQA,MAAa,sBAAsB;CAAC;CAAG;CAAI;CAAI;CAAK;AAAG;;;;;AAQvD,SAAgB,wBAAwB,OAAiC;CACrE,KAAK,MAAM,KAAK,qBAAqB,IAAI,KAAK,OAAO,OAAO;CAC5D,OAAO;AACX"}
|
|
@@ -33,7 +33,11 @@ declare class OrderbookService {
|
|
|
33
33
|
*/
|
|
34
34
|
subscribe(input: SubscribeOrderbookInput): () => void;
|
|
35
35
|
/**
|
|
36
|
-
* Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies sequence-checked updates, and refetches on gaps or reconnects. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.
|
|
36
|
+
* Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies sequence-checked updates, and refetches on observed sequence gaps or reconnects. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.
|
|
37
|
+
*
|
|
38
|
+
* `depth` is clamped to [1, 500] and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.
|
|
39
|
+
*
|
|
40
|
+
* Refetching is driven by observed sequence gaps and reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.
|
|
37
41
|
*/
|
|
38
42
|
createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription;
|
|
39
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderbook.d.ts","names":[],"sources":["../../../src/services/orderbook/orderbook.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"orderbook.d.ts","names":[],"sources":["../../../src/services/orderbook/orderbook.ts"],"mappings":";;;;;;;;UAgCU,gCAAgC,mBAAmB;EACzD;EACA;EACA;EACA;;UAGa,gCAAgC,mBAAmB;UAEnD;EACb;EACA,YAAY;;UAGC,yCAET,yBACA,KAAK;;;;cAOA;;EAKG,YAAA,WAAW,WAAW,UAAU,mBAAmB,QAAQ;;;;EASjE,IACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAmBX,UAAU,OAAO;;;;;;;;EAWjB,mBAAmB,OAAO,mCAAmC"}
|
|
@@ -5,6 +5,7 @@ import { createReadyGate, decimalInputToScaled } from "../../shared/decimal-surf
|
|
|
5
5
|
import { isResourceNotFoundError } from "../../utils/errors.js";
|
|
6
6
|
import { snapshotThenStream } from "../../realtime/snapshot-then-stream.js";
|
|
7
7
|
import { GetOrderBookResponseSchema, OrderBookDeltaSchema, OrderbookService as OrderbookService$1 } from "../../gen/orderbook/v1/orderbook_pb.js";
|
|
8
|
+
import { orderbookWsChannelDepth } from "./orderbook.codecs.js";
|
|
8
9
|
import { GetOrderbookInputSchema, createOrderbookDataSchema, formatOrderbookLevel } from "./orderbook.schemas.js";
|
|
9
10
|
import { toBig } from "../../utils/u128.js";
|
|
10
11
|
import { create } from "@bufbuild/protobuf";
|
|
@@ -48,12 +49,17 @@ var OrderbookService = class {
|
|
|
48
49
|
return this.createSubscription(input).unsubscribe;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
|
-
* Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies sequence-checked updates, and refetches on gaps or reconnects. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.
|
|
52
|
+
* Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies sequence-checked updates, and refetches on observed sequence gaps or reconnects. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.
|
|
53
|
+
*
|
|
54
|
+
* `depth` is clamped to [1, 500] and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.
|
|
55
|
+
*
|
|
56
|
+
* Refetching is driven by observed sequence gaps and reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.
|
|
52
57
|
*/
|
|
53
58
|
createSubscription(input) {
|
|
54
59
|
const symbolId = parse(v.pipe(v.number(), v.integer(), v.gtValue(0)), input.symbolId);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
60
|
+
const requestedDepth = Math.min(500, Math.max(1, Math.trunc(input.depth ?? 50)));
|
|
61
|
+
const channelDepth = orderbookWsChannelDepth(requestedDepth);
|
|
62
|
+
const channel = `public:spot:orderbook:deltas:depth:${channelDepth}:${symbolId}:proto`;
|
|
57
63
|
const client = this.#client;
|
|
58
64
|
const scales = this.#scales;
|
|
59
65
|
const gate = createReadyGate(() => scales.ready(), (error) => input.onError?.(publicationHandlerErrorContext(channel, error)));
|
|
@@ -99,10 +105,10 @@ var OrderbookService = class {
|
|
|
99
105
|
gate.run(() => {
|
|
100
106
|
input.onEvent({
|
|
101
107
|
symbol: input.symbol,
|
|
102
|
-
depth:
|
|
108
|
+
depth: requestedDepth,
|
|
103
109
|
bookSeq: currentBookSeq.toString(),
|
|
104
|
-
bids: sideToUIBucketed(bidsMap, "bids",
|
|
105
|
-
asks: sideToUIBucketed(asksMap, "asks",
|
|
110
|
+
bids: sideToUIBucketed(bidsMap, "bids", requestedDepth, bucketTicks),
|
|
111
|
+
asks: sideToUIBucketed(asksMap, "asks", requestedDepth, bucketTicks)
|
|
106
112
|
});
|
|
107
113
|
});
|
|
108
114
|
}
|
|
@@ -118,7 +124,7 @@ var OrderbookService = class {
|
|
|
118
124
|
async function inputServiceFetch() {
|
|
119
125
|
const validated = parse(GetOrderbookInputSchema, {
|
|
120
126
|
symbol: input.symbol,
|
|
121
|
-
depth:
|
|
127
|
+
depth: channelDepth
|
|
122
128
|
});
|
|
123
129
|
try {
|
|
124
130
|
return await client.getOrderBook({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderbook.js","names":["#client","Proto.OrderbookService","#realtime","#scales","Proto.GetOrderBookResponseSchema","Proto.OrderBookDeltaSchema"],"sources":["../../../src/services/orderbook/orderbook.ts"],"sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\nimport { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport {\n snapshotThenStream,\n type SnapshotThenStreamSubscription,\n} from \"../../realtime/snapshot-then-stream.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n createReadyGate,\n decimalInputToScaled,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n formatOrderbookLevel,\n GetOrderbookInputSchema,\n createOrderbookDataSchema,\n type OrderbookLevel,\n type OrderbookData,\n} from \"./orderbook.schemas.js\";\nimport { toBig } from \"../../utils/u128.js\";\nimport { isResourceNotFoundError } from \"../../utils/errors.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\n\ninterface SubscribeOrderbookInput extends BaseSubscribeInput<OrderbookData> {\n symbol: string;\n symbolId: number;\n depth?: number;\n bucket?: string | null;\n}\n\nexport interface OrderbookStreamHandlers extends BaseSubscribeInput<OrderbookData> {}\n\nexport interface OrderbookSubscription {\n unsubscribe: () => void;\n setBucket: (bucket: string | null | undefined) => void;\n}\n\nexport interface CreateOrderbookSubscriptionInput\n extends\n OrderbookStreamHandlers,\n Pick<SubscribeOrderbookInput, \"symbol\" | \"symbolId\" | \"depth\" | \"bucket\"> {}\n\ntype BookSide = Map<bigint, bigint>;\n\n/**\n * Reads spot order book snapshots and maintains realtime local order book state from public delta channels.\n */\nexport class OrderbookService {\n #client: Client<typeof Proto.OrderbookService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transport: Transport, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.OrderbookService, transport);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Fetches a spot order book depth snapshot for a symbol and requested depth, returning best bids and asks with the backend book sequence.\n */\n async get(\n input: v.InferInput<typeof GetOrderbookInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookData> {\n const validated = parse(GetOrderbookInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.getOrderBook(\n { symbol: validated.symbol, depth: validated.protoDepth },\n toConnectCallOptions(options),\n );\n return parse(createOrderbookDataSchema(this.#scales, validated.symbol), {\n symbol: validated.symbol,\n depth: validated.depth,\n bookSeq: res.bookSeq,\n bids: res.bids,\n asks: res.asks,\n });\n }\n\n /**\n * Subscribes to the managed order book stream for a symbol and forwards reconstructed snapshots to onEvent. This is a convenience wrapper around createSubscription().unsubscribe.\n */\n subscribe(input: SubscribeOrderbookInput): () => void {\n return this.createSubscription(input).unsubscribe;\n }\n\n /**\n * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies sequence-checked updates, and refetches on gaps or reconnects. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.\n */\n createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription {\n const symbolId = parse(v.pipe(v.number(), v.integer(), v.gtValue(0)), input.symbolId);\n const wsDepth = Math.min(500, Math.max(1, Math.trunc(input.depth ?? 50)));\n const channel = `public:spot:orderbook:deltas:depth:${wsDepth}:${symbolId}:proto`;\n\n const client = this.#client;\n const scales = this.#scales;\n const gate = createReadyGate(\n () => scales.ready(),\n (error) => input.onError?.(publicationHandlerErrorContext(channel, error)),\n );\n\n let bidsMap: BookSide = new Map();\n let asksMap: BookSide = new Map();\n let currentBookSeq = 0n;\n let bucketTicks: bigint | null = null;\n let stream: SnapshotThenStreamSubscription | undefined;\n\n function levelsToMap(levels: Proto.PriceLevel[] | undefined): BookSide {\n const map: BookSide = new Map();\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) continue;\n map.set(l.priceTicks, l.qtyScaled);\n }\n return map;\n }\n\n function applySideDelta(map: BookSide, levels: Proto.PriceLevel[] | undefined): void {\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) map.delete(l.priceTicks);\n else map.set(l.priceTicks, l.qtyScaled);\n }\n }\n\n function sideToUI(map: BookSide, side: \"bids\" | \"asks\", limit: number): OrderbookLevel[] {\n const entries = Array.from(map.entries());\n entries.sort(([pa], [pb]) => {\n if (pa === pb) return 0;\n return side === \"bids\" ? (pa > pb ? -1 : 1) : pa < pb ? -1 : 1;\n });\n return entries\n .slice(0, limit)\n .map(([priceTicks, qtyScaled]) =>\n formatOrderbookLevel({ priceTicks, qtyScaled }, scales, symbolId),\n );\n }\n\n function sideToUIBucketed(\n map: BookSide,\n side: \"bids\" | \"asks\",\n limit: number,\n bucket: bigint | null,\n ): OrderbookLevel[] {\n if (!bucket || bucket <= 0n) return sideToUI(map, side, limit);\n\n const agg: BookSide = new Map();\n for (const [priceTicks, qtyScaled] of map.entries()) {\n if (qtyScaled <= 0n) continue;\n const bucketPrice = (priceTicks / bucket) * bucket;\n agg.set(bucketPrice, (agg.get(bucketPrice) ?? 0n) + qtyScaled);\n }\n return sideToUI(agg, side, limit);\n }\n\n function emit(): void {\n gate.run(() => {\n input.onEvent({\n symbol: input.symbol,\n depth: wsDepth,\n bookSeq: currentBookSeq.toString(),\n bids: sideToUIBucketed(bidsMap, \"bids\", wsDepth, bucketTicks),\n asks: sideToUIBucketed(asksMap, \"asks\", wsDepth, bucketTicks),\n });\n });\n }\n\n function setBucket(bucket: string | null | undefined): void {\n if (!bucket) {\n bucketTicks = null;\n } else {\n try {\n bucketTicks = decimalInputToScaled(\"bucket\", bucket, scales.price());\n } catch {\n bucketTicks = null;\n }\n }\n if (stream?.isReady()) emit();\n }\n\n async function inputServiceFetch(): Promise<Proto.GetOrderBookResponse> {\n const validated = parse(GetOrderbookInputSchema, {\n symbol: input.symbol,\n depth: wsDepth,\n });\n try {\n return await client.getOrderBook({\n symbol: validated.symbol,\n depth: validated.protoDepth,\n });\n } catch (error: unknown) {\n if (!isResourceNotFoundError(error)) throw error;\n\n return create(Proto.GetOrderBookResponseSchema, {\n bookSeq: 0n,\n bids: [],\n asks: [],\n });\n }\n }\n\n function handleDelta(delta: Proto.OrderBookDelta): void {\n if (delta.reset) {\n bidsMap.clear();\n asksMap.clear();\n currentBookSeq = 0n;\n }\n\n if (currentBookSeq !== 0n && delta.bookSeqStart > currentBookSeq + 1n) {\n stream?.refreshSnapshot();\n return;\n }\n\n if (delta.bookSeqEnd <= currentBookSeq) return;\n\n applySideDelta(bidsMap, delta.bids);\n applySideDelta(asksMap, delta.asks);\n\n currentBookSeq = delta.bookSeqEnd > currentBookSeq ? delta.bookSeqEnd : currentBookSeq;\n emit();\n }\n\n setBucket(input.bucket);\n stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.OrderBookDeltaSchema,\n maxBufferedPublications: 200,\n snapshotErrorLog: \"Failed to fetch orderbook\",\n fetchSnapshot: inputServiceFetch,\n readPublication: (delta) => [delta],\n applySnapshot: (snapshot, bufferedDeltas) => {\n bidsMap = levelsToMap(snapshot.bids);\n asksMap = levelsToMap(snapshot.asks);\n currentBookSeq = toBig(snapshot.bookSeq);\n emit();\n for (const delta of bufferedDeltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n applyLivePublications: (deltas) => {\n for (const delta of deltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n onOpen: input.onOpen,\n onClose: input.onClose,\n onError: input.onError,\n });\n\n function dispose(): void {\n stream?.unsubscribe();\n }\n\n return { unsubscribe: dispose, setBucket };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,WAAsB,UAA6B,QAAmB;EAC9E,KAAKA,UAAU,aAAaC,oBAAwB,SAAS;EAC7D,KAAKC,YAAY;EACjB,KAAKC,UAAU;CACnB;;;;CAKA,MAAM,IACF,OACA,SACsB;EACtB,MAAM,YAAY,MAAM,yBAAyB,KAAK;EACtD,MAAM,KAAKA,QAAQ,MAAM;EACzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,aAC3B;GAAE,QAAQ,UAAU;GAAQ,OAAO,UAAU;EAAW,GACxD,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,0BAA0B,KAAKG,SAAS,UAAU,MAAM,GAAG;GACpE,QAAQ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,GAAG,MAAM;IAE3C,OAAO,OAAOC,4BAAkC;KAC5C,SAAS;KACT,MAAM,CAAC;KACP,MAAM,CAAC;IACX,CAAC;GACL;EACJ;EAEA,SAAS,YAAY,OAAmC;GACpD,IAAI,MAAM,OAAO;IACb,QAAQ,MAAM;IACd,QAAQ,MAAM;IACd,iBAAiB;GACrB;GAEA,IAAI,mBAAmB,MAAM,MAAM,eAAe,iBAAiB,IAAI;IACnE,QAAQ,gBAAgB;IACxB;GACJ;GAEA,IAAI,MAAM,cAAc,gBAAgB;GAExC,eAAe,SAAS,MAAM,IAAI;GAClC,eAAe,SAAS,MAAM,IAAI;GAElC,iBAAiB,MAAM,aAAa,iBAAiB,MAAM,aAAa;GACxE,KAAK;EACT;EAEA,UAAU,MAAM,MAAM;EACtB,SAAS,mBAAmB;GACxB,UAAU,KAAKF;GACf;GACA,QAAQG;GACR,yBAAyB;GACzB,kBAAkB;GAClB,eAAe;GACf,kBAAkB,UAAU,CAAC,KAAK;GAClC,gBAAgB,UAAU,mBAAmB;IACzC,UAAU,YAAY,SAAS,IAAI;IACnC,UAAU,YAAY,SAAS,IAAI;IACnC,iBAAiB,MAAM,SAAS,OAAO;IACvC,KAAK;IACL,KAAK,MAAM,SAAS,gBAAgB;KAChC,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,wBAAwB,WAAW;IAC/B,KAAK,MAAM,SAAS,QAAQ;KACxB,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,SAAS,MAAM;EACnB,CAAC;EAED,SAAS,UAAgB;GACrB,QAAQ,YAAY;EACxB;EAEA,OAAO;GAAE,aAAa;GAAS;EAAU;CAC7C;AACJ"}
|
|
1
|
+
{"version":3,"file":"orderbook.js","names":["#client","Proto.OrderbookService","#realtime","#scales","Proto.GetOrderBookResponseSchema","Proto.OrderBookDeltaSchema"],"sources":["../../../src/services/orderbook/orderbook.ts"],"sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\nimport { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport {\n snapshotThenStream,\n type SnapshotThenStreamSubscription,\n} from \"../../realtime/snapshot-then-stream.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n createReadyGate,\n decimalInputToScaled,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n formatOrderbookLevel,\n GetOrderbookInputSchema,\n createOrderbookDataSchema,\n type OrderbookLevel,\n type OrderbookData,\n} from \"./orderbook.schemas.js\";\nimport { orderbookWsChannelDepth } from \"./orderbook.codecs.js\";\nimport { toBig } from \"../../utils/u128.js\";\nimport { isResourceNotFoundError } from \"../../utils/errors.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\n\ninterface SubscribeOrderbookInput extends BaseSubscribeInput<OrderbookData> {\n symbol: string;\n symbolId: number;\n depth?: number;\n bucket?: string | null;\n}\n\nexport interface OrderbookStreamHandlers extends BaseSubscribeInput<OrderbookData> {}\n\nexport interface OrderbookSubscription {\n unsubscribe: () => void;\n setBucket: (bucket: string | null | undefined) => void;\n}\n\nexport interface CreateOrderbookSubscriptionInput\n extends\n OrderbookStreamHandlers,\n Pick<SubscribeOrderbookInput, \"symbol\" | \"symbolId\" | \"depth\" | \"bucket\"> {}\n\ntype BookSide = Map<bigint, bigint>;\n\n/**\n * Reads spot order book snapshots and maintains realtime local order book state from public delta channels.\n */\nexport class OrderbookService {\n #client: Client<typeof Proto.OrderbookService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transport: Transport, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.OrderbookService, transport);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Fetches a spot order book depth snapshot for a symbol and requested depth, returning best bids and asks with the backend book sequence.\n */\n async get(\n input: v.InferInput<typeof GetOrderbookInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookData> {\n const validated = parse(GetOrderbookInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.getOrderBook(\n { symbol: validated.symbol, depth: validated.protoDepth },\n toConnectCallOptions(options),\n );\n return parse(createOrderbookDataSchema(this.#scales, validated.symbol), {\n symbol: validated.symbol,\n depth: validated.depth,\n bookSeq: res.bookSeq,\n bids: res.bids,\n asks: res.asks,\n });\n }\n\n /**\n * Subscribes to the managed order book stream for a symbol and forwards reconstructed snapshots to onEvent. This is a convenience wrapper around createSubscription().unsubscribe.\n */\n subscribe(input: SubscribeOrderbookInput): () => void {\n return this.createSubscription(input).unsubscribe;\n }\n\n /**\n * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies sequence-checked updates, and refetches on observed sequence gaps or reconnects. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.\n *\n * `depth` is clamped to [1, 500] and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.\n *\n * Refetching is driven by observed sequence gaps and reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.\n */\n createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription {\n const symbolId = parse(v.pipe(v.number(), v.integer(), v.gtValue(0)), input.symbolId);\n const requestedDepth = Math.min(500, Math.max(1, Math.trunc(input.depth ?? 50)));\n const channelDepth = orderbookWsChannelDepth(requestedDepth);\n const channel = `public:spot:orderbook:deltas:depth:${channelDepth}:${symbolId}:proto`;\n\n const client = this.#client;\n const scales = this.#scales;\n const gate = createReadyGate(\n () => scales.ready(),\n (error) => input.onError?.(publicationHandlerErrorContext(channel, error)),\n );\n\n let bidsMap: BookSide = new Map();\n let asksMap: BookSide = new Map();\n let currentBookSeq = 0n;\n let bucketTicks: bigint | null = null;\n let stream: SnapshotThenStreamSubscription | undefined;\n\n function levelsToMap(levels: Proto.PriceLevel[] | undefined): BookSide {\n const map: BookSide = new Map();\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) continue;\n map.set(l.priceTicks, l.qtyScaled);\n }\n return map;\n }\n\n function applySideDelta(map: BookSide, levels: Proto.PriceLevel[] | undefined): void {\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) map.delete(l.priceTicks);\n else map.set(l.priceTicks, l.qtyScaled);\n }\n }\n\n function sideToUI(map: BookSide, side: \"bids\" | \"asks\", limit: number): OrderbookLevel[] {\n const entries = Array.from(map.entries());\n entries.sort(([pa], [pb]) => {\n if (pa === pb) return 0;\n return side === \"bids\" ? (pa > pb ? -1 : 1) : pa < pb ? -1 : 1;\n });\n return entries\n .slice(0, limit)\n .map(([priceTicks, qtyScaled]) =>\n formatOrderbookLevel({ priceTicks, qtyScaled }, scales, symbolId),\n );\n }\n\n function sideToUIBucketed(\n map: BookSide,\n side: \"bids\" | \"asks\",\n limit: number,\n bucket: bigint | null,\n ): OrderbookLevel[] {\n if (!bucket || bucket <= 0n) return sideToUI(map, side, limit);\n\n const agg: BookSide = new Map();\n for (const [priceTicks, qtyScaled] of map.entries()) {\n if (qtyScaled <= 0n) continue;\n const bucketPrice = (priceTicks / bucket) * bucket;\n agg.set(bucketPrice, (agg.get(bucketPrice) ?? 0n) + qtyScaled);\n }\n return sideToUI(agg, side, limit);\n }\n\n function emit(): void {\n gate.run(() => {\n input.onEvent({\n symbol: input.symbol,\n depth: requestedDepth,\n bookSeq: currentBookSeq.toString(),\n bids: sideToUIBucketed(bidsMap, \"bids\", requestedDepth, bucketTicks),\n asks: sideToUIBucketed(asksMap, \"asks\", requestedDepth, bucketTicks),\n });\n });\n }\n\n function setBucket(bucket: string | null | undefined): void {\n if (!bucket) {\n bucketTicks = null;\n } else {\n try {\n bucketTicks = decimalInputToScaled(\"bucket\", bucket, scales.price());\n } catch {\n bucketTicks = null;\n }\n }\n if (stream?.isReady()) emit();\n }\n\n async function inputServiceFetch(): Promise<Proto.GetOrderBookResponse> {\n const validated = parse(GetOrderbookInputSchema, {\n symbol: input.symbol,\n depth: channelDepth,\n });\n try {\n return await client.getOrderBook({\n symbol: validated.symbol,\n depth: validated.protoDepth,\n });\n } catch (error: unknown) {\n if (!isResourceNotFoundError(error)) throw error;\n\n return create(Proto.GetOrderBookResponseSchema, {\n bookSeq: 0n,\n bids: [],\n asks: [],\n });\n }\n }\n\n function handleDelta(delta: Proto.OrderBookDelta): void {\n if (delta.reset) {\n bidsMap.clear();\n asksMap.clear();\n currentBookSeq = 0n;\n }\n\n if (currentBookSeq !== 0n && delta.bookSeqStart > currentBookSeq + 1n) {\n stream?.refreshSnapshot();\n return;\n }\n\n if (delta.bookSeqEnd <= currentBookSeq) return;\n\n applySideDelta(bidsMap, delta.bids);\n applySideDelta(asksMap, delta.asks);\n\n currentBookSeq = delta.bookSeqEnd > currentBookSeq ? delta.bookSeqEnd : currentBookSeq;\n emit();\n }\n\n setBucket(input.bucket);\n stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.OrderBookDeltaSchema,\n maxBufferedPublications: 200,\n snapshotErrorLog: \"Failed to fetch orderbook\",\n fetchSnapshot: inputServiceFetch,\n readPublication: (delta) => [delta],\n applySnapshot: (snapshot, bufferedDeltas) => {\n bidsMap = levelsToMap(snapshot.bids);\n asksMap = levelsToMap(snapshot.asks);\n currentBookSeq = toBig(snapshot.bookSeq);\n emit();\n for (const delta of bufferedDeltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n applyLivePublications: (deltas) => {\n for (const delta of deltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n onOpen: input.onOpen,\n onClose: input.onClose,\n onError: input.onError,\n });\n\n function dispose(): void {\n stream?.unsubscribe();\n }\n\n return { unsubscribe: dispose, setBucket };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,WAAsB,UAA6B,QAAmB;EAC9E,KAAKA,UAAU,aAAaC,oBAAwB,SAAS;EAC7D,KAAKC,YAAY;EACjB,KAAKC,UAAU;CACnB;;;;CAKA,MAAM,IACF,OACA,SACsB;EACtB,MAAM,YAAY,MAAM,yBAAyB,KAAK;EACtD,MAAM,KAAKA,QAAQ,MAAM;EACzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,aAC3B;GAAE,QAAQ,UAAU;GAAQ,OAAO,UAAU;EAAW,GACxD,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,0BAA0B,KAAKG,SAAS,UAAU,MAAM,GAAG;GACpE,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,SAAS,IAAI;GACb,MAAM,IAAI;GACV,MAAM,IAAI;EACd,CAAC;CACL;;;;CAKA,UAAU,OAA4C;EAClD,OAAO,KAAK,mBAAmB,KAAK,CAAC,CAAC;CAC1C;;;;;;;;CASA,mBAAmB,OAAgE;EAC/E,MAAM,WAAW,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,MAAM,QAAQ;EACpF,MAAM,iBAAiB,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC;EAC/E,MAAM,eAAe,wBAAwB,cAAc;EAC3D,MAAM,UAAU,sCAAsC,aAAa,GAAG,SAAS;EAE/E,MAAM,SAAS,KAAKH;EACpB,MAAM,SAAS,KAAKG;EACpB,MAAM,OAAO,sBACH,OAAO,MAAM,IAClB,UAAU,MAAM,UAAU,+BAA+B,SAAS,KAAK,CAAC,CAC7E;EA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AAC,KAAK;GAClC,gBAAgB,UAAU,mBAAmB;IACzC,UAAU,YAAY,SAAS,IAAI;IACnC,UAAU,YAAY,SAAS,IAAI;IACnC,iBAAiB,MAAM,SAAS,OAAO;IACvC,KAAK;IACL,KAAK,MAAM,SAAS,gBAAgB;KAChC,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,wBAAwB,WAAW;IAC/B,KAAK,MAAM,SAAS,QAAQ;KACxB,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,SAAS,MAAM;EACnB,CAAC;EAED,SAAS,UAAgB;GACrB,QAAQ,YAAY;EACxB;EAEA,OAAO;GAAE,aAAa;GAAS;EAAU;CAC7C;AACJ"}
|
|
@@ -11,7 +11,7 @@ declare const GetOrderbookInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
11
11
|
depth: number;
|
|
12
12
|
}, {
|
|
13
13
|
symbol: string;
|
|
14
|
-
depth: 5 | 10 | 20 | 1 | 200 |
|
|
14
|
+
depth: 5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100;
|
|
15
15
|
protoDepth: Depth;
|
|
16
16
|
}>]>;
|
|
17
17
|
type GetOrderbookInput = v.InferInput<typeof GetOrderbookInputSchema>;
|
|
@@ -40,7 +40,7 @@ type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;
|
|
|
40
40
|
declare const OrderHistoryInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
41
41
|
readonly includeAttachedRisk: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
42
42
|
readonly includeAttachedRiskState: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
43
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"
|
|
43
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"FILLED" | "CANCELED" | "REJECTED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
|
|
44
44
|
readonly startTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
45
45
|
readonly endTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
46
46
|
readonly symbolId: v.OptionalSchema<v.ArraySchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
@@ -176,7 +176,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
176
176
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
177
177
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
178
178
|
readonly role: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountRole$1, undefined>, v.TransformAction<SubaccountRole$1, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
179
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "
|
|
179
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "accepted" | "declined" | "cancelled">]>;
|
|
180
180
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
181
181
|
readonly seconds: v.BigintSchema<undefined>;
|
|
182
182
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -203,7 +203,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
203
203
|
granteeAccountId: string;
|
|
204
204
|
inviterAccountId: string;
|
|
205
205
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
206
|
-
status: "unspecified" | "pending" | "
|
|
206
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
207
207
|
createdAt?: number | undefined;
|
|
208
208
|
respondedAt?: number | undefined;
|
|
209
209
|
granteeUsername: string;
|
|
@@ -221,7 +221,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
221
221
|
granteeAccountId: string;
|
|
222
222
|
inviterAccountId: string;
|
|
223
223
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
224
|
-
status: "unspecified" | "pending" | "
|
|
224
|
+
status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
|
|
225
225
|
createdAt?: number | undefined;
|
|
226
226
|
respondedAt?: number | undefined;
|
|
227
227
|
granteeUsername: string;
|
|
@@ -243,8 +243,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
243
243
|
seconds: bigint;
|
|
244
244
|
nanos: number;
|
|
245
245
|
} | undefined, number | undefined>]>;
|
|
246
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
247
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "
|
|
246
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
|
|
247
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "failed" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
248
248
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
249
249
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
250
250
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -787,7 +787,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
|
|
|
787
787
|
declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
788
788
|
readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
789
789
|
readonly symbol: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>;
|
|
790
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("
|
|
790
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
|
|
791
791
|
readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
|
|
792
792
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
|
|
793
793
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -31,62 +31,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
|
|
|
31
31
|
type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
|
|
32
32
|
declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
33
33
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
34
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
34
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
35
35
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
36
36
|
}, undefined>, v.TransformAction<{
|
|
37
37
|
triggerId: string;
|
|
38
|
-
status: "unspecified" | "
|
|
38
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
39
39
|
tsNs: bigint;
|
|
40
40
|
}, {
|
|
41
41
|
ts: number;
|
|
42
42
|
tsNs: string;
|
|
43
43
|
triggerId: string;
|
|
44
|
-
status: "unspecified" | "
|
|
44
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
45
45
|
}>]>;
|
|
46
46
|
type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
|
|
47
47
|
declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
48
48
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
49
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
49
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
50
50
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
51
51
|
}, undefined>, v.TransformAction<{
|
|
52
52
|
triggerId: string;
|
|
53
|
-
status: "unspecified" | "
|
|
53
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
54
54
|
tsNs: bigint;
|
|
55
55
|
}, {
|
|
56
56
|
ts: number;
|
|
57
57
|
tsNs: string;
|
|
58
58
|
triggerId: string;
|
|
59
|
-
status: "unspecified" | "
|
|
59
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
60
60
|
}>]>;
|
|
61
61
|
type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
|
|
62
62
|
declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
63
63
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
64
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
64
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
65
65
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
66
66
|
}, undefined>, v.TransformAction<{
|
|
67
67
|
triggerId: string;
|
|
68
|
-
status: "unspecified" | "
|
|
68
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
69
69
|
tsNs: bigint;
|
|
70
70
|
}, {
|
|
71
71
|
ts: number;
|
|
72
72
|
tsNs: string;
|
|
73
73
|
triggerId: string;
|
|
74
|
-
status: "unspecified" | "
|
|
74
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
75
75
|
}>]>;
|
|
76
76
|
type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
|
|
77
77
|
declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
78
78
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
79
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "
|
|
79
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused">]>;
|
|
80
80
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
81
81
|
}, undefined>, v.TransformAction<{
|
|
82
82
|
triggerId: string;
|
|
83
|
-
status: "unspecified" | "
|
|
83
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
84
84
|
tsNs: bigint;
|
|
85
85
|
}, {
|
|
86
86
|
ts: number;
|
|
87
87
|
tsNs: string;
|
|
88
88
|
triggerId: string;
|
|
89
|
-
status: "unspecified" | "
|
|
89
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
90
90
|
}>]>;
|
|
91
91
|
type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
|
|
92
92
|
type StopDetailsOutput = {
|
|
@@ -507,7 +507,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
507
507
|
subaccountId: string;
|
|
508
508
|
symbolId: number;
|
|
509
509
|
symbol: string;
|
|
510
|
-
status: "unspecified" | "
|
|
510
|
+
status: "unspecified" | "cancelled" | "created" | "failed" | "completed" | "armed" | "running" | "paused";
|
|
511
511
|
parentOrderId: string | undefined;
|
|
512
512
|
qty: string;
|
|
513
513
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateSmartAccountParams, PolyesterSmartAccountClient, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation } from "./smart-account.js";
|
|
2
|
-
export { type CreateSmartAccountParams, type PolyesterSmartAccountClient, type PredictPolyesterSmartAccountAddressParams, type SafeSmartAccountInstance, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
1
|
+
import { CreateSmartAccountParams, PolyesterSmartAccountClient, PolyesterSmartAccountClientOptions, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, SendPolyesterUserOperationOptions, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient } from "./smart-account.js";
|
|
2
|
+
export { type CreateSmartAccountParams, type PolyesterSmartAccountClient, type PolyesterSmartAccountClientOptions, type PredictPolyesterSmartAccountAddressParams, type SafeSmartAccountInstance, type SendPolyesterUserOperationOptions, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation } from "./smart-account.js";
|
|
2
|
-
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
1
|
+
import { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient } from "./smart-account.js";
|
|
2
|
+
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
@@ -20,11 +20,18 @@ declare function predictPolyesterSmartAccountAddress({ environment, ownerAddress
|
|
|
20
20
|
* Creates a Polyester smart account instance.
|
|
21
21
|
*/
|
|
22
22
|
declare function createPolyesterSmartAccount({ environment, owner, saltNonce, publicClient }: CreateSmartAccountParams): Promise<SafeSmartAccountInstance>;
|
|
23
|
+
interface PolyesterSmartAccountClientOptions {
|
|
24
|
+
/** How long a fetched gas price is reused, in milliseconds. Defaults to 10s. */
|
|
25
|
+
gasPriceCacheTtlMs?: number;
|
|
26
|
+
/** How often to poll for UserOperation receipts, in milliseconds. Defaults to 1s. */
|
|
27
|
+
pollingIntervalMs?: number;
|
|
28
|
+
}
|
|
23
29
|
/**
|
|
24
30
|
* Creates a viem client bound to a Polyester smart account.
|
|
25
31
|
*/
|
|
26
32
|
declare function createPolyesterSmartAccountClient(account: SafeSmartAccountInstance, params: {
|
|
27
33
|
environment: PolyesterEnvironment;
|
|
34
|
+
options?: PolyesterSmartAccountClientOptions;
|
|
28
35
|
}): import("permissionless").SmartAccountClient<import("viem").HttpTransport<undefined, false>, import("viem").Chain, (object & {
|
|
29
36
|
client: import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, {
|
|
30
37
|
address: Address;
|
|
@@ -3087,7 +3094,20 @@ declare function createPolyesterSmartAccountClient(account: SafeSmartAccountInst
|
|
|
3087
3094
|
isDeployed: () => Promise<boolean>;
|
|
3088
3095
|
type: "smart";
|
|
3089
3096
|
}), undefined, undefined>;
|
|
3090
|
-
|
|
3097
|
+
/**
|
|
3098
|
+
* Warms the network path for an upcoming submission: primes the gas-price
|
|
3099
|
+
* cache and opens connections to the RPC endpoint. Never throws; the nonce is
|
|
3100
|
+
* intentionally not cached — fetching it here is connection warm-up only.
|
|
3101
|
+
*/
|
|
3102
|
+
declare function warmPolyesterSmartAccountClient(client: PolyesterSmartAccountClient): Promise<void>;
|
|
3103
|
+
interface SendPolyesterUserOperationOptions {
|
|
3104
|
+
/**
|
|
3105
|
+
* Fires once per submission, immediately before the wallet is asked to
|
|
3106
|
+
* sign the fully prepared operation — the prepare→sign boundary.
|
|
3107
|
+
*/
|
|
3108
|
+
onWalletSignatureRequested?: () => void;
|
|
3109
|
+
}
|
|
3110
|
+
declare function sendPolyesterUserOperation(client: PolyesterSmartAccountClient, parameters: Parameters<PolyesterSmartAccountClient["sendUserOperation"]>[0], options?: SendPolyesterUserOperationOptions): Promise<Awaited<ReturnType<PolyesterSmartAccountClient["sendUserOperation"]>>>;
|
|
3091
3111
|
//#endregion
|
|
3092
|
-
export { CreateSmartAccountParams, PolyesterSmartAccountClient, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
3112
|
+
export { CreateSmartAccountParams, PolyesterSmartAccountClient, PolyesterSmartAccountClientOptions, PredictPolyesterSmartAccountAddressParams, SafeSmartAccountInstance, SendPolyesterUserOperationOptions, createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
3093
3113
|
//# sourceMappingURL=smart-account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-account.d.ts","names":[],"sources":["../../src/smart-account/smart-account.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"smart-account.d.ts","names":[],"sources":["../../src/smart-account/smart-account.ts"],"mappings":";;;;KAUY,2BAA2B,QAAQ,kBAAkB;KACrD,8BAA8B,kBAAkB;UAiB3C;EACb,aAAa;EACb,OAAO;EACP;EACA,eAAe;;UAGF;EACb,aAAa;EACb,cAAc;EACd;;iBAGY,sCACZ,aACA,cACA,aACD,4CAA4C;;;;iBAuBzB,8BAClB,aACA,OACA,WACA,gBACD,2BAA2B,QAAQ;UAuBrB;;EAEb;;EAEA;;;;;iBAMY,kCACZ,SAAS,0BACT;EACI,aAAa;EACb,UAAU;6BACb,kCAAA,gDAAA;;;;;;;;;;;IA9EL,kBAAA,kCAAA,sCAAA,0CAAA,sCAAA,0BAAA,oBAAA,WAAA,iBAAA,WAAA,gBAAA,aAAA,aAAA;MAEmB,aAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;iBA6Bb,gCAClB,QAAQ,8BACT;UA2Cc;;;;;EAKb;;iBAGkB,2BAClB,QAAQ,6BACR,YAAY,WAAW,sDACvB,UAAS,oCACV,QAAQ,QAAQ,WAAW"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { predictSafeAddress } from "../account-signer/predict-safe-address.js";
|
|
2
2
|
import { createPublicClient, http } from "viem";
|
|
3
|
+
import { estimateUserOperationGas, prepareUserOperation } from "viem/account-abstraction";
|
|
3
4
|
import { createSmartAccountClient } from "permissionless";
|
|
4
5
|
import { toSafeSmartAccount } from "permissionless/accounts";
|
|
5
6
|
import { createPimlicoClient } from "permissionless/clients/pimlico";
|
|
6
7
|
//#region src/smart-account/smart-account.ts
|
|
7
8
|
const smartAccountEnvironmentFingerprints = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
const smartAccountClientGasPricePrimers = /* @__PURE__ */ new WeakMap();
|
|
8
10
|
const USER_OPERATION_GAS_BUFFER_BPS = 2000n;
|
|
9
11
|
const USER_OPERATION_MIN_GAS_BUFFER = 50000n;
|
|
12
|
+
const USER_OPERATION_GAS_PRICE_TTL_MS = 1e4;
|
|
13
|
+
const USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS = 1e3;
|
|
10
14
|
function predictPolyesterSmartAccountAddress({ environment, ownerAddress, saltNonce = 0n }) {
|
|
11
15
|
const { safeProxyFactoryAddress, safeSingletonAddress, safeModuleSetupAddress, safe4337ModuleAddress, multiSendAddress } = environment.accountAbstraction.safe;
|
|
12
16
|
return predictSafeAddress({
|
|
@@ -42,7 +46,8 @@ async function createPolyesterSmartAccount({ environment, owner, saltNonce, publ
|
|
|
42
46
|
* Creates a viem client bound to a Polyester smart account.
|
|
43
47
|
*/
|
|
44
48
|
function createPolyesterSmartAccountClient(account, params) {
|
|
45
|
-
const { environment } = params;
|
|
49
|
+
const { environment, options } = params;
|
|
50
|
+
const { gasPriceCacheTtlMs = USER_OPERATION_GAS_PRICE_TTL_MS, pollingIntervalMs = USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS } = options ?? {};
|
|
46
51
|
const accountEnvironmentFingerprint = smartAccountEnvironmentFingerprints.get(account);
|
|
47
52
|
if (accountEnvironmentFingerprint && accountEnvironmentFingerprint !== environment.fingerprint) throw new Error("Smart account environment does not match client environment.");
|
|
48
53
|
const paymaster = createPimlicoClient({
|
|
@@ -50,13 +55,52 @@ function createPolyesterSmartAccountClient(account, params) {
|
|
|
50
55
|
transport: http(environment.accountAbstraction.paymasterUrl),
|
|
51
56
|
entryPoint: environment.accountAbstraction.entryPoint
|
|
52
57
|
});
|
|
53
|
-
|
|
58
|
+
let cachedGasPrice;
|
|
59
|
+
const getGasPrice = () => {
|
|
60
|
+
if (!cachedGasPrice || Date.now() - cachedGasPrice.fetchedAt >= gasPriceCacheTtlMs) {
|
|
61
|
+
const result = paymaster.getUserOperationGasPrice();
|
|
62
|
+
const entry = {
|
|
63
|
+
fetchedAt: Date.now(),
|
|
64
|
+
result
|
|
65
|
+
};
|
|
66
|
+
cachedGasPrice = entry;
|
|
67
|
+
result.catch(() => {
|
|
68
|
+
if (cachedGasPrice === entry) cachedGasPrice = void 0;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return cachedGasPrice.result;
|
|
72
|
+
};
|
|
73
|
+
const client = createSmartAccountClient({
|
|
54
74
|
account,
|
|
55
75
|
chain: environment.chain,
|
|
56
76
|
paymaster,
|
|
57
77
|
bundlerTransport: http(environment.accountAbstraction.bundlerUrl),
|
|
58
|
-
|
|
78
|
+
pollingInterval: pollingIntervalMs,
|
|
79
|
+
userOperation: {
|
|
80
|
+
estimateFeesPerGas: async () => (await getGasPrice()).fast,
|
|
81
|
+
prepareUserOperation: (prepareClient, prepareParameters) => {
|
|
82
|
+
const bufferingClient = {
|
|
83
|
+
...prepareClient,
|
|
84
|
+
estimateUserOperationGas: async (estimateParameters) => bufferPolyesterUserOperationGas(await estimateUserOperationGas(prepareClient, estimateParameters))
|
|
85
|
+
};
|
|
86
|
+
return prepareUserOperation(bufferingClient, prepareParameters);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
59
89
|
});
|
|
90
|
+
smartAccountClientGasPricePrimers.set(client, getGasPrice);
|
|
91
|
+
return client;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Warms the network path for an upcoming submission: primes the gas-price
|
|
95
|
+
* cache and opens connections to the RPC endpoint. Never throws; the nonce is
|
|
96
|
+
* intentionally not cached — fetching it here is connection warm-up only.
|
|
97
|
+
*/
|
|
98
|
+
async function warmPolyesterSmartAccountClient(client) {
|
|
99
|
+
await Promise.allSettled([
|
|
100
|
+
smartAccountClientGasPricePrimers.get(client)?.(),
|
|
101
|
+
client.account.getNonce(),
|
|
102
|
+
client.account.isDeployed()
|
|
103
|
+
]);
|
|
60
104
|
}
|
|
61
105
|
function addUserOperationGasBuffer(gas) {
|
|
62
106
|
const percentBuffer = gas * USER_OPERATION_GAS_BUFFER_BPS / 10000n;
|
|
@@ -72,23 +116,22 @@ function bufferPolyesterUserOperationGas(gas) {
|
|
|
72
116
|
...typeof gas.paymasterVerificationGasLimit === "bigint" ? { paymasterVerificationGasLimit: addUserOperationGasBuffer(gas.paymasterVerificationGasLimit) } : {}
|
|
73
117
|
};
|
|
74
118
|
}
|
|
75
|
-
async function sendPolyesterUserOperation(client, parameters) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
119
|
+
async function sendPolyesterUserOperation(client, parameters, options = {}) {
|
|
120
|
+
const { onWalletSignatureRequested } = options;
|
|
121
|
+
if (!onWalletSignatureRequested) return client.sendUserOperation(parameters);
|
|
122
|
+
const account = parameters.account ?? client.account;
|
|
123
|
+
return client.sendUserOperation({
|
|
124
|
+
...parameters,
|
|
125
|
+
account: {
|
|
126
|
+
...account,
|
|
127
|
+
signUserOperation: (userOperation) => {
|
|
128
|
+
onWalletSignatureRequested();
|
|
129
|
+
return account.signUserOperation(userOperation);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
90
133
|
}
|
|
91
134
|
//#endregion
|
|
92
|
-
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation };
|
|
135
|
+
export { createPolyesterSmartAccount, createPolyesterSmartAccountClient, predictPolyesterSmartAccountAddress, sendPolyesterUserOperation, warmPolyesterSmartAccountClient };
|
|
93
136
|
|
|
94
137
|
//# sourceMappingURL=smart-account.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-account.js","names":[],"sources":["../../src/smart-account/smart-account.ts"],"sourcesContent":["import type { Address, LocalAccount, PublicClient } from \"viem\";\nimport { createPublicClient, http } from \"viem\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { toSafeSmartAccount } from \"permissionless/accounts\";\nimport { createPimlicoClient } from \"permissionless/clients/pimlico\";\nimport type { PolyesterEnvironment } from \"../environment.js\";\nimport { predictSafeAddress } from \"../account-signer/predict-safe-address.js\";\n\nexport type SafeSmartAccountInstance = Awaited<ReturnType<typeof toSafeSmartAccount>>;\nexport type PolyesterSmartAccountClient = ReturnType<typeof createPolyesterSmartAccountClient>;\n\nconst smartAccountEnvironmentFingerprints = new WeakMap<SafeSmartAccountInstance, string>();\nconst USER_OPERATION_GAS_BUFFER_BPS = 2_000n;\nconst USER_OPERATION_MIN_GAS_BUFFER = 50_000n;\n\ntype PolyesterUserOperationGas = {\n callGasLimit?: bigint;\n preVerificationGas?: bigint;\n verificationGasLimit?: bigint;\n paymasterPostOpGasLimit?: bigint;\n paymasterVerificationGasLimit?: bigint;\n};\n\nexport interface CreateSmartAccountParams {\n environment: PolyesterEnvironment;\n owner: LocalAccount;\n saltNonce?: bigint;\n publicClient?: PublicClient;\n}\n\nexport interface PredictPolyesterSmartAccountAddressParams {\n environment: PolyesterEnvironment;\n ownerAddress: Address;\n saltNonce?: bigint;\n}\n\nexport function predictPolyesterSmartAccountAddress({\n environment,\n ownerAddress,\n saltNonce = 0n,\n}: PredictPolyesterSmartAccountAddressParams): Address {\n const {\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n } = environment.accountAbstraction.safe;\n\n return predictSafeAddress({\n owners: [ownerAddress],\n saltNonce,\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n });\n}\n\n/**\n * Creates a Polyester smart account instance.\n */\nexport async function createPolyesterSmartAccount({\n environment,\n owner,\n saltNonce,\n publicClient,\n}: CreateSmartAccountParams): Promise<SafeSmartAccountInstance> {\n const client =\n publicClient ??\n createPublicClient({\n chain: environment.chain,\n transport: http(environment.rpcUrl),\n });\n\n if (client.chain?.id && client.chain.id !== environment.chain.id) {\n throw new Error(\"Smart account public client chain does not match environment.\");\n }\n\n const account = await toSafeSmartAccount({\n client,\n owners: [owner],\n saltNonce,\n entryPoint: environment.accountAbstraction.entryPoint,\n ...environment.accountAbstraction.safe,\n });\n smartAccountEnvironmentFingerprints.set(account, environment.fingerprint);\n return account;\n}\n\n/**\n * Creates a viem client bound to a Polyester smart account.\n */\nexport function createPolyesterSmartAccountClient(\n account: SafeSmartAccountInstance,\n params: { environment: PolyesterEnvironment },\n) {\n const { environment } = params;\n const accountEnvironmentFingerprint = smartAccountEnvironmentFingerprints.get(account);\n if (\n accountEnvironmentFingerprint &&\n accountEnvironmentFingerprint !== environment.fingerprint\n ) {\n throw new Error(\"Smart account environment does not match client environment.\");\n }\n\n const paymaster = createPimlicoClient({\n chain: environment.chain,\n transport: http(environment.accountAbstraction.paymasterUrl),\n entryPoint: environment.accountAbstraction.entryPoint,\n });\n\n return createSmartAccountClient({\n account,\n chain: environment.chain,\n paymaster,\n bundlerTransport: http(environment.accountAbstraction.bundlerUrl),\n userOperation: {\n estimateFeesPerGas: async () => (await paymaster.getUserOperationGasPrice()).fast,\n },\n });\n}\n\nfunction addUserOperationGasBuffer(gas: bigint): bigint {\n const percentBuffer = (gas * USER_OPERATION_GAS_BUFFER_BPS) / 10_000n;\n return (\n gas +\n (percentBuffer > USER_OPERATION_MIN_GAS_BUFFER\n ? percentBuffer\n : USER_OPERATION_MIN_GAS_BUFFER)\n );\n}\n\nfunction bufferPolyesterUserOperationGas<T extends PolyesterUserOperationGas>(gas: T): T {\n return {\n ...gas,\n ...(typeof gas.callGasLimit === \"bigint\"\n ? { callGasLimit: addUserOperationGasBuffer(gas.callGasLimit) }\n : {}),\n ...(typeof gas.preVerificationGas === \"bigint\"\n ? { preVerificationGas: addUserOperationGasBuffer(gas.preVerificationGas) }\n : {}),\n ...(typeof gas.verificationGasLimit === \"bigint\"\n ? { verificationGasLimit: addUserOperationGasBuffer(gas.verificationGasLimit) }\n : {}),\n ...(typeof gas.paymasterPostOpGasLimit === \"bigint\"\n ? { paymasterPostOpGasLimit: addUserOperationGasBuffer(gas.paymasterPostOpGasLimit) }\n : {}),\n ...(typeof gas.paymasterVerificationGasLimit === \"bigint\"\n ? {\n paymasterVerificationGasLimit: addUserOperationGasBuffer(\n gas.paymasterVerificationGasLimit,\n ),\n }\n : {}),\n };\n}\n\nexport async function sendPolyesterUserOperation(\n client: PolyesterSmartAccountClient,\n parameters: Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0],\n): Promise<Awaited<ReturnType<PolyesterSmartAccountClient[\"sendUserOperation\"]>>> {\n try {\n const gas = await client.estimateUserOperationGas({\n callGasLimit: 0n,\n preVerificationGas: 0n,\n verificationGasLimit: 0n,\n ...parameters,\n } as Parameters<PolyesterSmartAccountClient[\"estimateUserOperationGas\"]>[0]);\n return client.sendUserOperation({\n ...parameters,\n ...bufferPolyesterUserOperationGas(gas),\n } as Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0]);\n } catch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AS,0BAA0B,KAAqB;CACpD,MAAM,gBAAiB,MAAM,gCAAiC;CAC9D,OACI,OACC,gBAAgB,gCACX,gBACA;AAEd;AAEA,SAAS,gCAAqE,KAAW;CACrF,OAAO;EACH,GAAG;EACH,GAAI,OAAO,IAAI,iBAAiB,WAC1B,EAAE,cAAc,0BAA0B,IAAI,YAAY,EAAE,IAC5D,CAAC;EACP,GAAI,OAAO,IAAI,uBAAuB,WAChC,EAAE,oBAAoB,0BAA0B,IAAI,kBAAkB,EAAE,IACxE,CAAC;EACP,GAAI,OAAO,IAAI,yBAAyB,WAClC,EAAE,sBAAsB,0BAA0B,IAAI,oBAAoB,EAAE,IAC5E,CAAC;EACP,GAAI,OAAO,IAAI,4BAA4B,WACrC,EAAE,yBAAyB,0BAA0B,IAAI,uBAAuB,EAAE,IAClF,CAAC;EACP,GAAI,OAAO,IAAI,kCAAkC,WAC3C,EACI,+BAA+B,0BAC3B,IAAI,6BACR,EACJ,IACA,CAAC;CACX;AACJ;AAEA,eAAsB,2BAClB,QACA,YAC8E;CAC9E,IAAI;EACA,MAAM,MAAM,MAAM,OAAO,yBAAyB;GAC9C,cAAc;GACd,oBAAoB;GACpB,sBAAsB;GACtB,GAAG;EACP,CAA2E;EAC3E,OAAO,OAAO,kBAAkB;GAC5B,GAAG;GACH,GAAG,gCAAgC,GAAG;EAC1C,CAAoE;CACxE,QAAQ;EACJ,OAAO,OAAO,kBAAkB,UAAU;CAC9C;AACJ"}
|
|
1
|
+
{"version":3,"file":"smart-account.js","names":[],"sources":["../../src/smart-account/smart-account.ts"],"sourcesContent":["import type { Address, LocalAccount, PublicClient } from \"viem\";\nimport { createPublicClient, http } from \"viem\";\nimport type { EstimateUserOperationGasParameters } from \"viem/account-abstraction\";\nimport { estimateUserOperationGas, prepareUserOperation } from \"viem/account-abstraction\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport { toSafeSmartAccount } from \"permissionless/accounts\";\nimport { createPimlicoClient } from \"permissionless/clients/pimlico\";\nimport type { PolyesterEnvironment } from \"../environment.js\";\nimport { predictSafeAddress } from \"../account-signer/predict-safe-address.js\";\n\nexport type SafeSmartAccountInstance = Awaited<ReturnType<typeof toSafeSmartAccount>>;\nexport type PolyesterSmartAccountClient = ReturnType<typeof createPolyesterSmartAccountClient>;\n\nconst smartAccountEnvironmentFingerprints = new WeakMap<SafeSmartAccountInstance, string>();\nconst smartAccountClientGasPricePrimers = new WeakMap<object, () => Promise<unknown>>();\nconst USER_OPERATION_GAS_BUFFER_BPS = 2_000n;\nconst USER_OPERATION_MIN_GAS_BUFFER = 50_000n;\nconst USER_OPERATION_GAS_PRICE_TTL_MS = 10_000;\nconst USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS = 1_000;\n\ntype PolyesterUserOperationGas = {\n callGasLimit?: bigint;\n preVerificationGas?: bigint;\n verificationGasLimit?: bigint;\n paymasterPostOpGasLimit?: bigint;\n paymasterVerificationGasLimit?: bigint;\n};\n\nexport interface CreateSmartAccountParams {\n environment: PolyesterEnvironment;\n owner: LocalAccount;\n saltNonce?: bigint;\n publicClient?: PublicClient;\n}\n\nexport interface PredictPolyesterSmartAccountAddressParams {\n environment: PolyesterEnvironment;\n ownerAddress: Address;\n saltNonce?: bigint;\n}\n\nexport function predictPolyesterSmartAccountAddress({\n environment,\n ownerAddress,\n saltNonce = 0n,\n}: PredictPolyesterSmartAccountAddressParams): Address {\n const {\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n } = environment.accountAbstraction.safe;\n\n return predictSafeAddress({\n owners: [ownerAddress],\n saltNonce,\n safeProxyFactoryAddress,\n safeSingletonAddress,\n safeModuleSetupAddress,\n safe4337ModuleAddress,\n multiSendAddress,\n });\n}\n\n/**\n * Creates a Polyester smart account instance.\n */\nexport async function createPolyesterSmartAccount({\n environment,\n owner,\n saltNonce,\n publicClient,\n}: CreateSmartAccountParams): Promise<SafeSmartAccountInstance> {\n const client =\n publicClient ??\n createPublicClient({\n chain: environment.chain,\n transport: http(environment.rpcUrl),\n });\n\n if (client.chain?.id && client.chain.id !== environment.chain.id) {\n throw new Error(\"Smart account public client chain does not match environment.\");\n }\n\n const account = await toSafeSmartAccount({\n client,\n owners: [owner],\n saltNonce,\n entryPoint: environment.accountAbstraction.entryPoint,\n ...environment.accountAbstraction.safe,\n });\n smartAccountEnvironmentFingerprints.set(account, environment.fingerprint);\n return account;\n}\n\nexport interface PolyesterSmartAccountClientOptions {\n /** How long a fetched gas price is reused, in milliseconds. Defaults to 10s. */\n gasPriceCacheTtlMs?: number;\n /** How often to poll for UserOperation receipts, in milliseconds. Defaults to 1s. */\n pollingIntervalMs?: number;\n}\n\n/**\n * Creates a viem client bound to a Polyester smart account.\n */\nexport function createPolyesterSmartAccountClient(\n account: SafeSmartAccountInstance,\n params: {\n environment: PolyesterEnvironment;\n options?: PolyesterSmartAccountClientOptions;\n },\n) {\n const { environment, options } = params;\n const {\n gasPriceCacheTtlMs = USER_OPERATION_GAS_PRICE_TTL_MS,\n pollingIntervalMs = USER_OPERATION_RECEIPT_POLLING_INTERVAL_MS,\n } = options ?? {};\n const accountEnvironmentFingerprint = smartAccountEnvironmentFingerprints.get(account);\n if (\n accountEnvironmentFingerprint &&\n accountEnvironmentFingerprint !== environment.fingerprint\n ) {\n throw new Error(\"Smart account environment does not match client environment.\");\n }\n\n const paymaster = createPimlicoClient({\n chain: environment.chain,\n transport: http(environment.accountAbstraction.paymasterUrl),\n entryPoint: environment.accountAbstraction.entryPoint,\n });\n\n let cachedGasPrice:\n | { fetchedAt: number; result: ReturnType<typeof paymaster.getUserOperationGasPrice> }\n | undefined;\n const getGasPrice = () => {\n if (!cachedGasPrice || Date.now() - cachedGasPrice.fetchedAt >= gasPriceCacheTtlMs) {\n const result = paymaster.getUserOperationGasPrice();\n const entry = { fetchedAt: Date.now(), result };\n cachedGasPrice = entry;\n result.catch(() => {\n if (cachedGasPrice === entry) cachedGasPrice = undefined;\n });\n }\n return cachedGasPrice.result;\n };\n\n const client = createSmartAccountClient({\n account,\n chain: environment.chain,\n paymaster,\n bundlerTransport: http(environment.accountAbstraction.bundlerUrl),\n pollingInterval: pollingIntervalMs,\n userOperation: {\n estimateFeesPerGas: async () => (await getGasPrice()).fast,\n // Single prepare pass: viem resolves gas estimation via\n // `getAction(client, estimateUserOperationGas, ...)`, so handing\n // `prepareUserOperation` a client whose estimate action buffers the\n // result makes the buffered limits flow into `pm_getPaymasterData`\n // before signing — the sponsorship signature commits to them.\n prepareUserOperation: (prepareClient, prepareParameters) => {\n const bufferingClient = {\n ...prepareClient,\n estimateUserOperationGas: async (\n estimateParameters: EstimateUserOperationGasParameters,\n ) =>\n bufferPolyesterUserOperationGas(\n await estimateUserOperationGas(prepareClient, estimateParameters),\n ),\n };\n return prepareUserOperation(\n bufferingClient as typeof prepareClient,\n prepareParameters as Parameters<typeof prepareUserOperation>[1],\n );\n },\n },\n });\n smartAccountClientGasPricePrimers.set(client, getGasPrice);\n return client;\n}\n\n/**\n * Warms the network path for an upcoming submission: primes the gas-price\n * cache and opens connections to the RPC endpoint. Never throws; the nonce is\n * intentionally not cached — fetching it here is connection warm-up only.\n */\nexport async function warmPolyesterSmartAccountClient(\n client: PolyesterSmartAccountClient,\n): Promise<void> {\n await Promise.allSettled([\n smartAccountClientGasPricePrimers.get(client)?.(),\n client.account.getNonce(),\n client.account.isDeployed(),\n ]);\n}\n\nfunction addUserOperationGasBuffer(gas: bigint): bigint {\n const percentBuffer = (gas * USER_OPERATION_GAS_BUFFER_BPS) / 10_000n;\n return (\n gas +\n (percentBuffer > USER_OPERATION_MIN_GAS_BUFFER\n ? percentBuffer\n : USER_OPERATION_MIN_GAS_BUFFER)\n );\n}\n\nfunction bufferPolyesterUserOperationGas<T extends PolyesterUserOperationGas>(gas: T): T {\n return {\n ...gas,\n ...(typeof gas.callGasLimit === \"bigint\"\n ? { callGasLimit: addUserOperationGasBuffer(gas.callGasLimit) }\n : {}),\n ...(typeof gas.preVerificationGas === \"bigint\"\n ? { preVerificationGas: addUserOperationGasBuffer(gas.preVerificationGas) }\n : {}),\n ...(typeof gas.verificationGasLimit === \"bigint\"\n ? { verificationGasLimit: addUserOperationGasBuffer(gas.verificationGasLimit) }\n : {}),\n ...(typeof gas.paymasterPostOpGasLimit === \"bigint\"\n ? { paymasterPostOpGasLimit: addUserOperationGasBuffer(gas.paymasterPostOpGasLimit) }\n : {}),\n ...(typeof gas.paymasterVerificationGasLimit === \"bigint\"\n ? {\n paymasterVerificationGasLimit: addUserOperationGasBuffer(\n gas.paymasterVerificationGasLimit,\n ),\n }\n : {}),\n };\n}\n\nexport interface SendPolyesterUserOperationOptions {\n /**\n * Fires once per submission, immediately before the wallet is asked to\n * sign the fully prepared operation — the prepare→sign boundary.\n */\n onWalletSignatureRequested?: () => void;\n}\n\nexport async function sendPolyesterUserOperation(\n client: PolyesterSmartAccountClient,\n parameters: Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0],\n options: SendPolyesterUserOperationOptions = {},\n): Promise<Awaited<ReturnType<PolyesterSmartAccountClient[\"sendUserOperation\"]>>> {\n const { onWalletSignatureRequested } = options;\n if (!onWalletSignatureRequested) return client.sendUserOperation(parameters);\n\n const account =\n (parameters as { account?: SafeSmartAccountInstance }).account ?? client.account;\n return client.sendUserOperation({\n ...parameters,\n account: {\n ...account,\n signUserOperation: (\n userOperation: Parameters<SafeSmartAccountInstance[\"signUserOperation\"]>[0],\n ) => {\n onWalletSignatureRequested();\n return account.signUserOperation(userOperation);\n },\n },\n } as Parameters<PolyesterSmartAccountClient[\"sendUserOperation\"]>[0]);\n}\n"],"mappings":";;;;;;;AAaA,MAAM,sDAAsC,IAAI,QAA0C;AAC1F,MAAM,oDAAoC,IAAI,QAAwC;AACtF,MAAM,gCAAgC;AACtC,MAAM,gCAAgC;AACtC,MAAM,kCAAkC;AACxC,MAAM,6CAA6C;AAuBnD,SAAgB,oCAAoC,EAChD,aACA,cACA,YAAY,MACuC;CACnD,MAAM,EACF,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