@chainflip/rpc 2.0.6-wbtc-dev.4 → 2.0.7-wbtc-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parsers.mjs CHANGED
@@ -1,761 +1,752 @@
1
- // src/parsers.ts
1
+ import { z } from "zod";
2
2
  import { bytesToHex } from "@chainflip/utils/bytes";
3
3
  import { priceAssets } from "@chainflip/utils/chainflip";
4
4
  import { isUndefined } from "@chainflip/utils/guard";
5
5
  import { isHex } from "@chainflip/utils/string";
6
- import { z } from "zod";
7
- var accountId = z.string().refine((val) => val.startsWith("cF"));
8
- var hexString = z.string().refine(isHex, { message: "Invalid hex string" });
9
- var u256 = hexString.transform((value) => BigInt(value));
10
- var numericString = z.string().regex(/^[0-9]+$/);
11
- var numberOrHex = z.union([z.number(), u256, numericString]).transform((n) => BigInt(n));
12
- var chainAssetMapFactory = (parser, _defaultValue) => z.object({
13
- Bitcoin: z.object({ BTC: parser }),
14
- Ethereum: z.object({ ETH: parser, USDC: parser, FLIP: parser, USDT: parser, WBTC: parser }),
15
- Polkadot: z.object({ DOT: parser }),
16
- Arbitrum: z.object({ ETH: parser, USDC: parser, USDT: parser }),
17
- Solana: z.object({ SOL: parser, USDC: parser, USDT: parser }),
18
- Assethub: z.object({ DOT: parser, USDC: parser, USDT: parser })
19
- }).omit({ Polkadot: true });
20
- var chainBaseAssetMapFactory = (parser, _defaultValue) => z.object({
21
- Bitcoin: z.object({ BTC: parser }),
22
- Ethereum: z.object({ ETH: parser, FLIP: parser, USDT: parser, WBTC: parser }),
23
- Polkadot: z.object({ DOT: parser }),
24
- Arbitrum: z.object({ ETH: parser, USDC: parser, USDT: parser }),
25
- Solana: z.object({ SOL: parser, USDC: parser, USDT: parser }),
26
- Assethub: z.object({ DOT: parser, USDC: parser, USDT: parser })
27
- }).omit({ Polkadot: true });
28
- var chainMapFactory = (parser, _defaultValue) => z.object({
29
- Bitcoin: parser,
30
- Ethereum: parser,
31
- Polkadot: parser,
32
- Arbitrum: parser,
33
- Solana: parser,
34
- Assethub: parser
35
- }).omit({ Polkadot: true });
36
- var rpcAssetSchema = z.union([
37
- z.object({ chain: z.literal("Bitcoin"), asset: z.literal("BTC") }),
38
- z.object({ chain: z.literal("Polkadot"), asset: z.literal("DOT") }),
39
- z.object({ chain: z.literal("Ethereum"), asset: z.literal("FLIP") }),
40
- z.object({ chain: z.literal("Ethereum"), asset: z.literal("ETH") }),
41
- z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDC") }),
42
- z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDT") }),
43
- z.object({ chain: z.literal("Ethereum"), asset: z.literal("WBTC") }),
44
- z.object({ chain: z.literal("Arbitrum"), asset: z.literal("ETH") }),
45
- z.object({ chain: z.literal("Arbitrum"), asset: z.literal("USDC") }),
46
- z.object({ chain: z.literal("Arbitrum"), asset: z.literal("USDT") }),
47
- z.object({ chain: z.literal("Solana"), asset: z.literal("SOL") }),
48
- z.object({ chain: z.literal("Solana"), asset: z.literal("USDC") }),
49
- z.object({ chain: z.literal("Solana"), asset: z.literal("USDT") }),
50
- z.object({ chain: z.literal("Assethub"), asset: z.literal("DOT") }),
51
- z.object({ chain: z.literal("Assethub"), asset: z.literal("USDC") }),
52
- z.object({ chain: z.literal("Assethub"), asset: z.literal("USDT") })
6
+
7
+ //#region src/parsers.ts
8
+ const accountId = z.string().refine((val) => val.startsWith("cF"));
9
+ const hexString = z.string().refine(isHex, { message: "Invalid hex string" });
10
+ const u256 = hexString.transform((value) => BigInt(value));
11
+ const numericString = z.string().regex(/^[0-9]+$/);
12
+ const numberOrHex = z.union([
13
+ z.number(),
14
+ u256,
15
+ numericString
16
+ ]).transform((n) => BigInt(n));
17
+ const chainAssetMapFactory = (parser, defaultValue) => z.object({
18
+ Bitcoin: z.object({ BTC: parser }),
19
+ Ethereum: z.object({
20
+ ETH: parser,
21
+ USDC: parser,
22
+ FLIP: parser,
23
+ USDT: parser,
24
+ WBTC: parser.default(defaultValue)
25
+ }),
26
+ Arbitrum: z.object({
27
+ ETH: parser,
28
+ USDC: parser,
29
+ USDT: parser.default(defaultValue)
30
+ }),
31
+ Solana: z.object({
32
+ SOL: parser,
33
+ USDC: parser,
34
+ USDT: parser.default(defaultValue)
35
+ }),
36
+ Assethub: z.object({
37
+ DOT: parser,
38
+ USDC: parser,
39
+ USDT: parser
40
+ })
41
+ });
42
+ const chainBaseAssetMapFactory = (parser, defaultValue) => z.object({
43
+ Bitcoin: z.object({ BTC: parser }),
44
+ Ethereum: z.object({
45
+ ETH: parser,
46
+ FLIP: parser,
47
+ USDT: parser,
48
+ WBTC: parser.default(defaultValue)
49
+ }),
50
+ Arbitrum: z.object({
51
+ ETH: parser,
52
+ USDC: parser,
53
+ USDT: parser.default(defaultValue)
54
+ }),
55
+ Solana: z.object({
56
+ SOL: parser,
57
+ USDC: parser,
58
+ USDT: parser.default(defaultValue)
59
+ }),
60
+ Assethub: z.object({
61
+ DOT: parser,
62
+ USDC: parser,
63
+ USDT: parser
64
+ })
65
+ });
66
+ const chainMapFactory = (parser, _defaultValue) => z.object({
67
+ Bitcoin: parser,
68
+ Ethereum: parser,
69
+ Arbitrum: parser,
70
+ Solana: parser,
71
+ Assethub: parser
72
+ });
73
+ const rpcAssetSchema = z.union([
74
+ z.object({
75
+ chain: z.literal("Bitcoin"),
76
+ asset: z.literal("BTC")
77
+ }),
78
+ z.object({
79
+ chain: z.literal("Polkadot"),
80
+ asset: z.literal("DOT")
81
+ }),
82
+ z.object({
83
+ chain: z.literal("Ethereum"),
84
+ asset: z.literal("FLIP")
85
+ }),
86
+ z.object({
87
+ chain: z.literal("Ethereum"),
88
+ asset: z.literal("ETH")
89
+ }),
90
+ z.object({
91
+ chain: z.literal("Ethereum"),
92
+ asset: z.literal("USDC")
93
+ }),
94
+ z.object({
95
+ chain: z.literal("Ethereum"),
96
+ asset: z.literal("USDT")
97
+ }),
98
+ z.object({
99
+ chain: z.literal("Ethereum"),
100
+ asset: z.literal("WBTC")
101
+ }),
102
+ z.object({
103
+ chain: z.literal("Arbitrum"),
104
+ asset: z.literal("ETH")
105
+ }),
106
+ z.object({
107
+ chain: z.literal("Arbitrum"),
108
+ asset: z.literal("USDC")
109
+ }),
110
+ z.object({
111
+ chain: z.literal("Arbitrum"),
112
+ asset: z.literal("USDT")
113
+ }),
114
+ z.object({
115
+ chain: z.literal("Solana"),
116
+ asset: z.literal("SOL")
117
+ }),
118
+ z.object({
119
+ chain: z.literal("Solana"),
120
+ asset: z.literal("USDC")
121
+ }),
122
+ z.object({
123
+ chain: z.literal("Solana"),
124
+ asset: z.literal("USDT")
125
+ }),
126
+ z.object({
127
+ chain: z.literal("Assethub"),
128
+ asset: z.literal("DOT")
129
+ }),
130
+ z.object({
131
+ chain: z.literal("Assethub"),
132
+ asset: z.literal("USDC")
133
+ }),
134
+ z.object({
135
+ chain: z.literal("Assethub"),
136
+ asset: z.literal("USDT")
137
+ })
53
138
  ]);
54
- var networkFee = z.object({
55
- standard_rate_and_minimum: z.object({
56
- rate: numberOrHex,
57
- minimum: numberOrHex
58
- }),
59
- rates: chainAssetMapFactory(numberOrHex, 0)
60
- });
61
- var networkFees = z.object({
62
- regular_network_fee: networkFee,
63
- internal_swap_network_fee: networkFee
64
- });
65
- var rename = (mapping) => (obj) => Object.fromEntries(
66
- Object.entries(obj).map(([key, value]) => [
67
- key in mapping ? mapping[key] : key,
68
- value
69
- ])
70
- );
71
- var rpcBaseResponse = z.object({
72
- id: z.string(),
73
- jsonrpc: z.literal("2.0")
74
- });
75
- var notUndefined = z.any().refine((v) => !isUndefined(v), { message: "Value must not be undefined" });
76
- var rpcSuccessResponse = rpcBaseResponse.extend({ result: notUndefined });
77
- var rpcErrorResponse = rpcBaseResponse.extend({
78
- error: z.object({ code: z.number(), message: z.string() })
79
- });
80
- var rpcResponse = z.union([rpcSuccessResponse, rpcErrorResponse]);
81
- var cfSwapRate = z.object({
82
- intermediary: numberOrHex.nullable(),
83
- output: numberOrHex
84
- });
85
- var fee = z.intersection(rpcAssetSchema, z.object({ amount: numberOrHex }));
86
- var cfSwapRateV2 = z.object({
87
- egress_fee: fee,
88
- ingress_fee: fee,
89
- intermediary: u256.nullable(),
90
- network_fee: fee,
91
- output: u256
92
- });
93
- var cfSwapRateV3 = cfSwapRateV2.extend({
94
- broker_commission: fee
95
- });
96
- var chainGetBlockHash = hexString;
97
- var stateGetMetadata = hexString;
98
- var stateGetRuntimeVersion = z.object({
99
- specName: z.string(),
100
- implName: z.string(),
101
- authoringVersion: z.number(),
102
- specVersion: z.number(),
103
- implVersion: z.number(),
104
- apis: z.array(z.tuple([hexString, z.number()])),
105
- transactionVersion: z.number(),
106
- stateVersion: z.number()
107
- });
108
- var cfIngressEgressEnvironment = z.object({
109
- minimum_deposit_amounts: chainAssetMapFactory(numberOrHex, 0),
110
- ingress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
111
- egress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
112
- witness_safety_margins: chainMapFactory(z.number().nullable(), null),
113
- egress_dust_limits: chainAssetMapFactory(numberOrHex, 0),
114
- channel_opening_fees: chainMapFactory(numberOrHex, 0),
115
- ingress_delays: chainMapFactory(z.number(), 0).optional(),
116
- // TODO(1.12): remove after all networks upgraded
117
- boost_delays: chainMapFactory(z.number(), 0).optional()
118
- // TODO(1.12): remove after all networks upgraded
139
+ const networkFee = z.object({
140
+ standard_rate_and_minimum: z.object({
141
+ rate: numberOrHex,
142
+ minimum: numberOrHex
143
+ }),
144
+ rates: chainAssetMapFactory(numberOrHex, 0)
145
+ });
146
+ const networkFees = z.object({
147
+ regular_network_fee: networkFee,
148
+ internal_swap_network_fee: networkFee
149
+ });
150
+ const rename = (mapping) => (obj) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key in mapping ? mapping[key] : key, value]));
151
+ const rpcBaseResponse = z.object({
152
+ id: z.string(),
153
+ jsonrpc: z.literal("2.0")
154
+ });
155
+ const notUndefined = z.any().refine((v) => !isUndefined(v), { message: "Value must not be undefined" });
156
+ const rpcSuccessResponse = rpcBaseResponse.extend({ result: notUndefined });
157
+ const rpcErrorResponse = rpcBaseResponse.extend({ error: z.object({
158
+ code: z.number(),
159
+ message: z.string()
160
+ }) });
161
+ const rpcResponse = z.union([rpcSuccessResponse, rpcErrorResponse]);
162
+ const cfSwapRate = z.object({
163
+ intermediary: numberOrHex.nullable(),
164
+ output: numberOrHex
165
+ });
166
+ const fee = z.intersection(rpcAssetSchema, z.object({ amount: numberOrHex }));
167
+ const cfSwapRateV2 = z.object({
168
+ egress_fee: fee,
169
+ ingress_fee: fee,
170
+ intermediary: u256.nullable(),
171
+ network_fee: fee,
172
+ output: u256
173
+ });
174
+ const cfSwapRateV3 = cfSwapRateV2.extend({ broker_commission: fee });
175
+ const chainGetBlockHash = hexString;
176
+ const stateGetMetadata = hexString;
177
+ const stateGetRuntimeVersion = z.object({
178
+ specName: z.string(),
179
+ implName: z.string(),
180
+ authoringVersion: z.number(),
181
+ specVersion: z.number(),
182
+ implVersion: z.number(),
183
+ apis: z.array(z.tuple([hexString, z.number()])),
184
+ transactionVersion: z.number(),
185
+ stateVersion: z.number()
186
+ });
187
+ const cfIngressEgressEnvironment = z.object({
188
+ minimum_deposit_amounts: chainAssetMapFactory(numberOrHex, 0),
189
+ ingress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
190
+ egress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
191
+ witness_safety_margins: chainMapFactory(z.number().nullable(), null),
192
+ egress_dust_limits: chainAssetMapFactory(numberOrHex, 0),
193
+ channel_opening_fees: chainMapFactory(numberOrHex, 0),
194
+ ingress_delays: chainMapFactory(z.number(), 0).optional(),
195
+ boost_delays: chainMapFactory(z.number(), 0).optional()
119
196
  }).transform(rename({ egress_dust_limits: "minimum_egress_amounts" }));
120
- var cfSwappingEnvironment = z.object({
121
- maximum_swap_amounts: chainAssetMapFactory(numberOrHex.nullable(), null),
122
- network_fee_hundredth_pips: z.number(),
123
- swap_retry_delay_blocks: z.number().optional(),
124
- max_swap_retry_duration_blocks: z.number().optional(),
125
- max_swap_request_duration_blocks: z.number().optional(),
126
- minimum_chunk_size: chainAssetMapFactory(numberOrHex.nullable(), null).optional(),
127
- network_fees: networkFees
128
- });
129
- var cfFundingEnvironment = z.object({
130
- redemption_tax: numberOrHex,
131
- minimum_funding_amount: numberOrHex
132
- });
133
- var defaultFeeInfo = () => ({
134
- limit_order_fee_hundredth_pips: 0,
135
- range_order_fee_hundredth_pips: 0,
136
- range_order_total_fees_earned: { base: "0x0", quote: "0x0" },
137
- limit_order_total_fees_earned: { base: "0x0", quote: "0x0" },
138
- range_total_swap_inputs: { base: "0x0", quote: "0x0" },
139
- limit_total_swap_inputs: { base: "0x0", quote: "0x0" },
140
- quote_asset: { chain: "Ethereum", asset: "USDC" }
141
- });
142
- var cfPoolsEnvironment = z.object({
143
- fees: chainBaseAssetMapFactory(
144
- z.object({
145
- limit_order_fee_hundredth_pips: z.number(),
146
- range_order_fee_hundredth_pips: z.number(),
147
- range_order_total_fees_earned: z.object({ base: u256, quote: u256 }),
148
- limit_order_total_fees_earned: z.object({ base: u256, quote: u256 }),
149
- range_total_swap_inputs: z.object({ base: u256, quote: u256 }),
150
- limit_total_swap_inputs: z.object({ base: u256, quote: u256 }),
151
- quote_asset: z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDC") })
152
- }).nullable().transform((info) => info ?? defaultFeeInfo()),
153
- defaultFeeInfo()
154
- )
155
- });
156
- var cfEnvironment = z.object({
157
- ingress_egress: cfIngressEgressEnvironment,
158
- swapping: cfSwappingEnvironment,
159
- funding: cfFundingEnvironment,
160
- pools: cfPoolsEnvironment
161
- });
162
- var cfBoostPoolsDepth = z.array(
163
- z.intersection(rpcAssetSchema, z.object({ tier: z.number(), available_amount: u256 }))
164
- );
165
- var orderInfoSchema = z.object({
166
- depth: numberOrHex,
167
- price: numberOrHex.nullable()
168
- });
169
- var assetInfoSchema = z.object({
170
- limit_orders: orderInfoSchema,
171
- range_orders: orderInfoSchema
172
- });
173
- var cfPoolDepth = z.object({
174
- asks: assetInfoSchema,
175
- bids: assetInfoSchema
197
+ const cfSwappingEnvironment = z.object({
198
+ maximum_swap_amounts: chainAssetMapFactory(numberOrHex.nullable(), null),
199
+ network_fee_hundredth_pips: z.number(),
200
+ swap_retry_delay_blocks: z.number().optional(),
201
+ max_swap_retry_duration_blocks: z.number().optional(),
202
+ max_swap_request_duration_blocks: z.number().optional(),
203
+ minimum_chunk_size: chainAssetMapFactory(numberOrHex.nullable(), null).optional(),
204
+ network_fees: networkFees
205
+ });
206
+ const cfFundingEnvironment = z.object({
207
+ redemption_tax: numberOrHex,
208
+ minimum_funding_amount: numberOrHex
209
+ });
210
+ const defaultFeeInfo = () => ({
211
+ limit_order_fee_hundredth_pips: 0,
212
+ range_order_fee_hundredth_pips: 0,
213
+ range_order_total_fees_earned: {
214
+ base: "0x0",
215
+ quote: "0x0"
216
+ },
217
+ limit_order_total_fees_earned: {
218
+ base: "0x0",
219
+ quote: "0x0"
220
+ },
221
+ range_total_swap_inputs: {
222
+ base: "0x0",
223
+ quote: "0x0"
224
+ },
225
+ limit_total_swap_inputs: {
226
+ base: "0x0",
227
+ quote: "0x0"
228
+ },
229
+ quote_asset: {
230
+ chain: "Ethereum",
231
+ asset: "USDC"
232
+ }
233
+ });
234
+ const cfPoolsEnvironment = z.object({ fees: chainBaseAssetMapFactory(z.object({
235
+ limit_order_fee_hundredth_pips: z.number(),
236
+ range_order_fee_hundredth_pips: z.number(),
237
+ range_order_total_fees_earned: z.object({
238
+ base: u256,
239
+ quote: u256
240
+ }),
241
+ limit_order_total_fees_earned: z.object({
242
+ base: u256,
243
+ quote: u256
244
+ }),
245
+ range_total_swap_inputs: z.object({
246
+ base: u256,
247
+ quote: u256
248
+ }),
249
+ limit_total_swap_inputs: z.object({
250
+ base: u256,
251
+ quote: u256
252
+ }),
253
+ quote_asset: z.object({
254
+ chain: z.literal("Ethereum"),
255
+ asset: z.literal("USDC")
256
+ })
257
+ }).nullable().transform((info) => info ?? defaultFeeInfo()), defaultFeeInfo()) });
258
+ const cfEnvironment = z.object({
259
+ ingress_egress: cfIngressEgressEnvironment,
260
+ swapping: cfSwappingEnvironment,
261
+ funding: cfFundingEnvironment,
262
+ pools: cfPoolsEnvironment
263
+ });
264
+ const cfBoostPoolsDepth = z.array(z.intersection(rpcAssetSchema, z.object({
265
+ tier: z.number(),
266
+ available_amount: u256
267
+ })));
268
+ const orderInfoSchema = z.object({
269
+ depth: numberOrHex,
270
+ price: numberOrHex.nullable()
271
+ });
272
+ const assetInfoSchema = z.object({
273
+ limit_orders: orderInfoSchema,
274
+ range_orders: orderInfoSchema
275
+ });
276
+ const cfPoolDepth = z.object({
277
+ asks: assetInfoSchema,
278
+ bids: assetInfoSchema
176
279
  }).nullable();
177
- var cfSupportedAssets = z.array(z.object({ chain: z.string(), asset: z.string() })).transform(
178
- (assets) => assets.filter((asset) => rpcAssetSchema.safeParse(asset).success)
179
- );
180
- var brokerRequestSwapDepositAddress = z.object({
181
- address: z.string(),
182
- issued_block: z.number(),
183
- channel_id: z.number(),
184
- source_chain_expiry_block: numberOrHex,
185
- channel_opening_fee: u256
186
- });
187
- var brokerRequestAccountCreationDepositAddress = z.object({
188
- issued_block: z.number(),
189
- channel_id: z.number(),
190
- address: z.string(),
191
- requested_for: accountId,
192
- deposit_chain_expiry_block: numberOrHex,
193
- channel_opening_fee: u256,
194
- refund_address: z.string()
195
- });
196
- var evmBrokerRequestSwapParameterEncoding = z.object({
197
- to: hexString,
198
- calldata: hexString,
199
- value: numberOrHex,
200
- source_token_address: hexString.optional()
201
- });
202
- var requestSwapParameterEncoding = z.discriminatedUnion("chain", [
203
- z.object({
204
- chain: z.literal("Bitcoin"),
205
- nulldata_payload: hexString,
206
- deposit_address: z.string()
207
- }),
208
- evmBrokerRequestSwapParameterEncoding.extend({
209
- chain: z.literal("Ethereum")
210
- }),
211
- evmBrokerRequestSwapParameterEncoding.extend({
212
- chain: z.literal("Arbitrum")
213
- }),
214
- z.object({
215
- chain: z.literal("Solana"),
216
- program_id: z.string(),
217
- data: hexString,
218
- accounts: z.array(
219
- z.object({
220
- pubkey: z.string(),
221
- is_signer: z.boolean(),
222
- is_writable: z.boolean()
223
- })
224
- )
225
- })
280
+ const cfSupportedAssets = z.array(z.object({
281
+ chain: z.string(),
282
+ asset: z.string()
283
+ })).transform((assets) => assets.filter((asset) => rpcAssetSchema.safeParse(asset).success));
284
+ const brokerRequestSwapDepositAddress = z.object({
285
+ address: z.string(),
286
+ issued_block: z.number(),
287
+ channel_id: z.number(),
288
+ source_chain_expiry_block: numberOrHex,
289
+ channel_opening_fee: u256
290
+ });
291
+ const brokerRequestAccountCreationDepositAddress = z.object({
292
+ issued_block: z.number(),
293
+ channel_id: z.number(),
294
+ address: z.string(),
295
+ requested_for: accountId,
296
+ deposit_chain_expiry_block: numberOrHex,
297
+ channel_opening_fee: u256,
298
+ refund_address: z.string()
299
+ });
300
+ const evmBrokerRequestSwapParameterEncoding = z.object({
301
+ to: hexString,
302
+ calldata: hexString,
303
+ value: numberOrHex,
304
+ source_token_address: hexString.optional()
305
+ });
306
+ const requestSwapParameterEncoding = z.discriminatedUnion("chain", [
307
+ z.object({
308
+ chain: z.literal("Bitcoin"),
309
+ nulldata_payload: hexString,
310
+ deposit_address: z.string()
311
+ }),
312
+ evmBrokerRequestSwapParameterEncoding.extend({ chain: z.literal("Ethereum") }),
313
+ evmBrokerRequestSwapParameterEncoding.extend({ chain: z.literal("Arbitrum") }),
314
+ z.object({
315
+ chain: z.literal("Solana"),
316
+ program_id: z.string(),
317
+ data: hexString,
318
+ accounts: z.array(z.object({
319
+ pubkey: z.string(),
320
+ is_signer: z.boolean(),
321
+ is_writable: z.boolean()
322
+ }))
323
+ })
226
324
  ]);
227
- var delegationStatus = z.object({
228
- operator: accountId,
229
- bid: numberOrHex
230
- });
231
- var accountInfoCommon = {
232
- vanity_name: z.string().optional(),
233
- flip_balance: numberOrHex,
234
- asset_balances: chainAssetMapFactory(numberOrHex, 0),
235
- bond: numberOrHex,
236
- estimated_redeemable_balance: numberOrHex,
237
- bound_redeem_address: hexString.optional(),
238
- restricted_balances: z.record(hexString, numberOrHex).optional(),
239
- current_delegation_status: delegationStatus.optional(),
240
- upcoming_delegation_status: delegationStatus.optional()
325
+ const delegationStatus = z.object({
326
+ operator: accountId,
327
+ bid: numberOrHex
328
+ });
329
+ const accountInfoCommon = {
330
+ vanity_name: z.string().optional(),
331
+ flip_balance: numberOrHex,
332
+ asset_balances: chainAssetMapFactory(numberOrHex, 0),
333
+ bond: numberOrHex,
334
+ estimated_redeemable_balance: numberOrHex,
335
+ bound_redeem_address: hexString.optional(),
336
+ restricted_balances: z.record(hexString, numberOrHex).optional(),
337
+ current_delegation_status: delegationStatus.optional(),
338
+ upcoming_delegation_status: delegationStatus.optional()
241
339
  };
242
- var unregistered = z.object({
243
- role: z.literal("unregistered"),
244
- ...accountInfoCommon
245
- });
246
- var broker = z.object({
247
- role: z.literal("broker"),
248
- ...accountInfoCommon,
249
- earned_fees: chainAssetMapFactory(numberOrHex, 0),
250
- btc_vault_deposit_address: z.string().nullable().optional(),
251
- affiliates: z.array(z.object({ account_id: accountId, short_id: z.number(), withdrawal_address: hexString })).optional().default([])
252
- });
253
- var operator = z.object({
254
- role: z.literal("operator"),
255
- ...accountInfoCommon,
256
- managed_validators: z.record(accountId, numberOrHex),
257
- delegators: z.record(accountId, numberOrHex),
258
- settings: z.object({
259
- fee_bps: z.number(),
260
- delegation_acceptance: z.enum(["Allow", "Deny"])
261
- }),
262
- allowed: z.array(accountId).optional().default([]),
263
- blocked: z.array(accountId).optional().default([]),
264
- active_delegation: z.object({
265
- operator: accountId,
266
- validators: z.record(accountId, numberOrHex),
267
- delegators: z.record(accountId, numberOrHex),
268
- delegation_fee_bps: z.number()
269
- }).optional()
270
- });
271
- var boostBalances = z.array(
272
- z.object({
273
- fee_tier: z.number(),
274
- total_balance: u256,
275
- available_balance: u256,
276
- in_use_balance: u256,
277
- is_withdrawing: z.boolean()
278
- })
279
- );
280
- var liquidityProvider = z.object({
281
- role: z.literal("liquidity_provider"),
282
- ...accountInfoCommon,
283
- refund_addresses: chainMapFactory(z.string().nullable(), null),
284
- earned_fees: chainAssetMapFactory(numberOrHex, 0),
285
- boost_balances: chainAssetMapFactory(boostBalances, []),
286
- lending_positions: z.array(
287
- z.intersection(
288
- rpcAssetSchema,
289
- z.object({
290
- total_amount: numberOrHex,
291
- available_amount: numberOrHex
292
- })
293
- )
294
- ).optional(),
295
- collateral_balances: z.array(
296
- z.intersection(
297
- rpcAssetSchema,
298
- z.object({
299
- amount: numberOrHex
300
- })
301
- )
302
- ).optional()
303
- });
304
- var validator = z.object({
305
- role: z.literal("validator"),
306
- ...accountInfoCommon,
307
- last_heartbeat: z.number(),
308
- reputation_points: z.number(),
309
- keyholder_epochs: z.array(z.number()),
310
- is_current_authority: z.boolean(),
311
- is_current_backup: z.boolean(),
312
- is_qualified: z.boolean(),
313
- is_online: z.boolean(),
314
- is_bidding: z.boolean(),
315
- apy_bp: z.number().nullable(),
316
- operator: accountId.optional()
317
- });
318
- var cfAccountInfo = z.discriminatedUnion("role", [unregistered, broker, operator, liquidityProvider, validator]).transform((account) => {
319
- switch (account.role) {
320
- case "broker":
321
- case "validator":
322
- case "unregistered":
323
- case "liquidity_provider":
324
- return account;
325
- case "operator": {
326
- const { managed_validators, delegators, settings, ...rest } = account;
327
- return {
328
- ...rest,
329
- upcoming_delegation: {
330
- validators: managed_validators,
331
- delegators,
332
- delegation_fee_bps: settings.fee_bps,
333
- delegation_acceptance: settings.delegation_acceptance
334
- }
335
- };
336
- }
337
- }
338
- });
339
- var cfAccounts = z.array(z.tuple([accountId, z.string()]));
340
- var cfPoolPriceV2 = z.object({
341
- sell: numberOrHex.nullable(),
342
- buy: numberOrHex.nullable(),
343
- range_order: numberOrHex,
344
- base_asset: rpcAssetSchema,
345
- quote_asset: rpcAssetSchema
346
- });
347
- var orderId = numberOrHex.transform((n) => String(n));
348
- var limitOrder = z.object({
349
- id: orderId,
350
- tick: z.number(),
351
- sell_amount: numberOrHex,
352
- fees_earned: numberOrHex,
353
- original_sell_amount: numberOrHex,
354
- lp: z.string()
355
- });
356
- var ask = limitOrder.transform((order) => ({
357
- ...order,
358
- type: "ask"
340
+ const unregistered = z.object({
341
+ role: z.literal("unregistered"),
342
+ ...accountInfoCommon
343
+ });
344
+ const broker = z.object({
345
+ role: z.literal("broker"),
346
+ ...accountInfoCommon,
347
+ earned_fees: chainAssetMapFactory(numberOrHex, 0),
348
+ btc_vault_deposit_address: z.string().nullable().optional(),
349
+ affiliates: z.array(z.object({
350
+ account_id: accountId,
351
+ short_id: z.number(),
352
+ withdrawal_address: hexString
353
+ })).optional().default([])
354
+ });
355
+ const operator = z.object({
356
+ role: z.literal("operator"),
357
+ ...accountInfoCommon,
358
+ managed_validators: z.record(accountId, numberOrHex),
359
+ delegators: z.record(accountId, numberOrHex),
360
+ settings: z.object({
361
+ fee_bps: z.number(),
362
+ delegation_acceptance: z.enum(["Allow", "Deny"])
363
+ }),
364
+ allowed: z.array(accountId).optional().default([]),
365
+ blocked: z.array(accountId).optional().default([]),
366
+ active_delegation: z.object({
367
+ operator: accountId,
368
+ validators: z.record(accountId, numberOrHex),
369
+ delegators: z.record(accountId, numberOrHex),
370
+ delegation_fee_bps: z.number()
371
+ }).optional()
372
+ });
373
+ const boostBalances = z.array(z.object({
374
+ fee_tier: z.number(),
375
+ total_balance: u256,
376
+ available_balance: u256,
377
+ in_use_balance: u256,
378
+ is_withdrawing: z.boolean()
379
+ }));
380
+ const liquidityProvider = z.object({
381
+ role: z.literal("liquidity_provider"),
382
+ ...accountInfoCommon,
383
+ refund_addresses: chainMapFactory(z.string().nullable(), null),
384
+ earned_fees: chainAssetMapFactory(numberOrHex, 0),
385
+ boost_balances: chainAssetMapFactory(boostBalances, []),
386
+ lending_positions: z.array(z.intersection(rpcAssetSchema, z.object({
387
+ total_amount: numberOrHex,
388
+ available_amount: numberOrHex
389
+ }))).optional(),
390
+ collateral_balances: z.array(z.intersection(rpcAssetSchema, z.object({ amount: numberOrHex }))).optional()
391
+ });
392
+ const validator = z.object({
393
+ role: z.literal("validator"),
394
+ ...accountInfoCommon,
395
+ last_heartbeat: z.number(),
396
+ reputation_points: z.number(),
397
+ keyholder_epochs: z.array(z.number()),
398
+ is_current_authority: z.boolean(),
399
+ is_current_backup: z.boolean(),
400
+ is_qualified: z.boolean(),
401
+ is_online: z.boolean(),
402
+ is_bidding: z.boolean(),
403
+ apy_bp: z.number().nullable(),
404
+ operator: accountId.optional()
405
+ });
406
+ const cfAccountInfo = z.discriminatedUnion("role", [
407
+ unregistered,
408
+ broker,
409
+ operator,
410
+ liquidityProvider,
411
+ validator
412
+ ]).transform((account) => {
413
+ switch (account.role) {
414
+ case "broker":
415
+ case "validator":
416
+ case "unregistered":
417
+ case "liquidity_provider": return account;
418
+ case "operator": {
419
+ const { managed_validators, delegators, settings, ...rest } = account;
420
+ return {
421
+ ...rest,
422
+ upcoming_delegation: {
423
+ validators: managed_validators,
424
+ delegators,
425
+ delegation_fee_bps: settings.fee_bps,
426
+ delegation_acceptance: settings.delegation_acceptance
427
+ }
428
+ };
429
+ }
430
+ }
431
+ });
432
+ const cfAccounts = z.array(z.tuple([accountId, z.string()]));
433
+ const cfPoolPriceV2 = z.object({
434
+ sell: numberOrHex.nullable(),
435
+ buy: numberOrHex.nullable(),
436
+ range_order: numberOrHex,
437
+ base_asset: rpcAssetSchema,
438
+ quote_asset: rpcAssetSchema
439
+ });
440
+ const orderId = numberOrHex.transform((n) => String(n));
441
+ const limitOrder = z.object({
442
+ id: orderId,
443
+ tick: z.number(),
444
+ sell_amount: numberOrHex,
445
+ fees_earned: numberOrHex,
446
+ original_sell_amount: numberOrHex,
447
+ lp: z.string()
448
+ });
449
+ const ask = limitOrder.transform((order) => ({
450
+ ...order,
451
+ type: "ask"
452
+ }));
453
+ const bid = limitOrder.transform((order) => ({
454
+ ...order,
455
+ type: "bid"
359
456
  }));
360
- var bid = limitOrder.transform((order) => ({
361
- ...order,
362
- type: "bid"
457
+ const rangeOrder = z.object({
458
+ id: orderId,
459
+ range: z.object({
460
+ start: z.number(),
461
+ end: z.number()
462
+ }),
463
+ liquidity: numberOrHex,
464
+ fees_earned: z.object({
465
+ base: numberOrHex,
466
+ quote: numberOrHex
467
+ }),
468
+ lp: z.string()
469
+ }).transform((order) => ({
470
+ ...order,
471
+ type: "range"
363
472
  }));
364
- var rangeOrder = z.object({
365
- id: orderId,
366
- range: z.object({ start: z.number(), end: z.number() }),
367
- liquidity: numberOrHex,
368
- fees_earned: z.object({ base: numberOrHex, quote: numberOrHex }),
369
- lp: z.string()
370
- }).transform((order) => ({ ...order, type: "range" }));
371
- var cfPoolOrders = z.object({
372
- limit_orders: z.object({
373
- asks: z.array(ask),
374
- bids: z.array(bid)
375
- }),
376
- range_orders: z.array(rangeOrder)
377
- });
378
- var boostPoolAmount = z.object({
379
- account_id: z.string(),
380
- amount: u256
381
- });
382
- var cfBoostPoolDetails = z.array(
383
- z.intersection(
384
- rpcAssetSchema,
385
- z.object({
386
- fee_tier: z.number(),
387
- available_amounts: z.array(boostPoolAmount),
388
- deposits_pending_finalization: z.array(
389
- z.object({
390
- deposit_id: numberOrHex,
391
- owed_amounts: z.array(boostPoolAmount)
392
- })
393
- ),
394
- pending_withdrawals: z.array(
395
- z.object({
396
- account_id: z.string(),
397
- pending_deposits: z.array(numberOrHex)
398
- })
399
- ),
400
- network_fee_deduction_percent: z.number().optional()
401
- })
402
- )
403
- );
404
- var cfBoostPoolPendingFees = z.array(
405
- z.intersection(
406
- rpcAssetSchema,
407
- z.object({
408
- fee_tier: z.number(),
409
- pending_fees: z.array(
410
- z.object({
411
- deposit_id: z.number().transform(BigInt),
412
- fees: z.array(boostPoolAmount)
413
- })
414
- )
415
- })
416
- )
417
- );
418
- var lpTotalBalances = chainAssetMapFactory(numberOrHex, 0);
419
- var cfFailedCallEvm = z.object({
420
- contract: hexString,
421
- data: z.string()
422
- });
423
- var range = (parser) => z.tuple([parser, parser]);
424
- var cfAuctionState = z.object({
425
- epoch_duration: z.number(),
426
- current_epoch_started_at: z.number(),
427
- redemption_period_as_percentage: z.number(),
428
- min_funding: numberOrHex,
429
- auction_size_range: range(z.number()),
430
- min_active_bid: numberOrHex.nullable(),
431
- min_bid: numberOrHex
473
+ const cfPoolOrders = z.object({
474
+ limit_orders: z.object({
475
+ asks: z.array(ask),
476
+ bids: z.array(bid)
477
+ }),
478
+ range_orders: z.array(rangeOrder)
479
+ });
480
+ const boostPoolAmount = z.object({
481
+ account_id: z.string(),
482
+ amount: u256
483
+ });
484
+ const cfBoostPoolDetails = z.array(z.intersection(rpcAssetSchema, z.object({
485
+ fee_tier: z.number(),
486
+ available_amounts: z.array(boostPoolAmount),
487
+ deposits_pending_finalization: z.array(z.object({
488
+ deposit_id: numberOrHex,
489
+ owed_amounts: z.array(boostPoolAmount)
490
+ })),
491
+ pending_withdrawals: z.array(z.object({
492
+ account_id: z.string(),
493
+ pending_deposits: z.array(numberOrHex)
494
+ })),
495
+ network_fee_deduction_percent: z.number().optional()
496
+ })));
497
+ const cfBoostPoolPendingFees = z.array(z.intersection(rpcAssetSchema, z.object({
498
+ fee_tier: z.number(),
499
+ pending_fees: z.array(z.object({
500
+ deposit_id: z.number().transform(BigInt),
501
+ fees: z.array(boostPoolAmount)
502
+ }))
503
+ })));
504
+ const lpTotalBalances = chainAssetMapFactory(numberOrHex, 0);
505
+ const cfFailedCallEvm = z.object({
506
+ contract: hexString,
507
+ data: z.string()
508
+ });
509
+ const range = (parser) => z.tuple([parser, parser]);
510
+ const cfAuctionState = z.object({
511
+ epoch_duration: z.number(),
512
+ current_epoch_started_at: z.number(),
513
+ redemption_period_as_percentage: z.number(),
514
+ min_funding: numberOrHex,
515
+ auction_size_range: range(z.number()),
516
+ min_active_bid: numberOrHex.nullable(),
517
+ min_bid: numberOrHex
432
518
  }).transform(rename({ epoch_duration: "epoch_duration_blocks" }));
433
- var cfMonitoringSimulateAuction = z.object({
434
- auction_outcome: z.object({
435
- winners: z.array(accountId),
436
- bond: numberOrHex
437
- }),
438
- operators_info: z.record(
439
- accountId,
440
- z.object({
441
- operator: accountId,
442
- validators: z.record(accountId, numberOrHex),
443
- delegators: z.record(accountId, numberOrHex),
444
- delegation_fee_bps: z.number()
445
- })
446
- ),
447
- new_validators: z.array(accountId),
448
- current_mab: numberOrHex
449
- });
450
- var cfFlipSuppy = range(numberOrHex).transform(([totalIssuance, offchainFunds]) => ({
451
- totalIssuance,
452
- offchainFunds
519
+ const cfMonitoringSimulateAuction = z.object({
520
+ auction_outcome: z.object({
521
+ winners: z.array(accountId),
522
+ bond: numberOrHex
523
+ }),
524
+ operators_info: z.record(accountId, z.object({
525
+ operator: accountId,
526
+ validators: z.record(accountId, numberOrHex),
527
+ delegators: z.record(accountId, numberOrHex),
528
+ delegation_fee_bps: z.number()
529
+ })),
530
+ new_validators: z.array(accountId),
531
+ current_mab: numberOrHex
532
+ });
533
+ const cfFlipSuppy = range(numberOrHex).transform(([totalIssuance, offchainFunds]) => ({
534
+ totalIssuance,
535
+ offchainFunds
453
536
  }));
454
- var ethereumAddress = z.string().transform((address) => `0x${address}`);
455
- var cfPoolOrderbook = z.object({
456
- bids: z.array(z.object({ amount: u256, sqrt_price: u256 })),
457
- asks: z.array(z.object({ amount: u256, sqrt_price: u256 }))
458
- });
459
- var cfTradingStrategy = z.object({
460
- lp_id: z.string(),
461
- strategy_id: z.string(),
462
- strategy: z.union([
463
- z.object({
464
- TickZeroCentered: z.object({
465
- spread_tick: z.number(),
466
- base_asset: rpcAssetSchema
467
- })
468
- }),
469
- z.object({
470
- SimpleBuySell: z.object({
471
- buy_tick: z.number(),
472
- sell_tick: z.number(),
473
- base_asset: rpcAssetSchema
474
- })
475
- }),
476
- z.object({
477
- InventoryBased: z.object({
478
- min_buy_tick: z.number(),
479
- max_buy_tick: z.number(),
480
- min_sell_tick: z.number(),
481
- max_sell_tick: z.number(),
482
- base_asset: rpcAssetSchema
483
- })
484
- })
485
- ]),
486
- balance: z.array(z.tuple([rpcAssetSchema, numberOrHex]))
487
- });
488
- var cfGetTradingStrategies = z.array(cfTradingStrategy).default([]);
489
- var cfGetTradingStrategyLimits = z.object({
490
- minimum_deployment_amount: chainAssetMapFactory(z.number().nullable(), null),
491
- minimum_added_funds_amount: chainAssetMapFactory(z.number().nullable(), null)
492
- });
493
- var cfAvailablePools = z.array(
494
- z.object({
495
- base: rpcAssetSchema.refine(
496
- (a) => a.chain !== "Ethereum" || a.asset !== "USDC"
497
- ),
498
- quote: z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDC") })
499
- })
500
- );
501
- var cfOraclePrices = z.array(
502
- z.object({
503
- price: numberOrHex,
504
- updated_at_oracle_timestamp: z.number(),
505
- updated_at_statechain_block: z.number(),
506
- base_asset: z.enum(priceAssets),
507
- quote_asset: z.enum(priceAssets)
508
- })
509
- );
510
- var broadcastPalletSafeModeStatuses = z.object({
511
- retry_enabled: z.boolean(),
512
- egress_witnessing_enabled: z.boolean()
513
- });
514
- var ingressEgressPalletSafeModeStatuses = z.object({
515
- boost_deposits_enabled: z.boolean(),
516
- deposit_channel_creation_enabled: z.boolean(),
517
- deposit_channel_witnessing_enabled: z.boolean(),
518
- vault_deposit_witnessing_enabled: z.boolean()
519
- });
520
- var cfSafeModeStatuses = z.object({
521
- emissions: z.object({
522
- emissions_sync_enabled: z.boolean()
523
- }),
524
- funding: z.object({
525
- redeem_enabled: z.boolean()
526
- }),
527
- swapping: z.object({
528
- swaps_enabled: z.boolean(),
529
- withdrawals_enabled: z.boolean(),
530
- broker_registration_enabled: z.boolean()
531
- }),
532
- liquidity_provider: z.object({
533
- deposit_enabled: z.boolean(),
534
- withdrawal_enabled: z.boolean(),
535
- internal_swaps_enabled: z.boolean()
536
- }),
537
- validator: z.object({
538
- authority_rotation_enabled: z.boolean(),
539
- start_bidding_enabled: z.boolean(),
540
- stop_bidding_enabled: z.boolean()
541
- }),
542
- pools: z.object({
543
- range_order_update_enabled: z.boolean(),
544
- limit_order_update_enabled: z.boolean()
545
- }),
546
- trading_strategies: z.object({
547
- strategy_updates_enabled: z.boolean(),
548
- strategy_closure_enabled: z.boolean(),
549
- strategy_execution_enabled: z.boolean()
550
- }),
551
- reputation: z.object({
552
- reporting_enabled: z.boolean()
553
- }),
554
- asset_balances: z.object({
555
- reconciliation_enabled: z.boolean()
556
- }),
557
- threshold_signature_evm: z.object({
558
- slashing_enabled: z.boolean()
559
- }),
560
- threshold_signature_bitcoin: z.object({
561
- slashing_enabled: z.boolean()
562
- }),
563
- threshold_signature_polkadot: z.object({
564
- slashing_enabled: z.boolean()
565
- }),
566
- threshold_signature_solana: z.object({
567
- slashing_enabled: z.boolean()
568
- }),
569
- lending_pools: z.object({
570
- add_boost_funds_enabled: z.boolean(),
571
- stop_boosting_enabled: z.boolean(),
572
- // TODO(1.12): remove `optional` after all networks upgraded
573
- borrowing_enabled: z.array(rpcAssetSchema).optional(),
574
- add_lender_funds_enabled: z.array(rpcAssetSchema).optional(),
575
- withdraw_lender_funds_enabled: z.array(rpcAssetSchema).optional(),
576
- add_collateral_enabled: z.array(rpcAssetSchema).optional(),
577
- remove_collateral_enabled: z.array(rpcAssetSchema).optional()
578
- }),
579
- broadcast_ethereum: broadcastPalletSafeModeStatuses,
580
- broadcast_bitcoin: broadcastPalletSafeModeStatuses,
581
- broadcast_polkadot: broadcastPalletSafeModeStatuses,
582
- broadcast_arbitrum: broadcastPalletSafeModeStatuses,
583
- broadcast_solana: broadcastPalletSafeModeStatuses,
584
- broadcast_assethub: broadcastPalletSafeModeStatuses,
585
- ingress_egress_ethereum: ingressEgressPalletSafeModeStatuses,
586
- ingress_egress_bitcoin: ingressEgressPalletSafeModeStatuses,
587
- ingress_egress_polkadot: ingressEgressPalletSafeModeStatuses,
588
- ingress_egress_arbitrum: ingressEgressPalletSafeModeStatuses,
589
- ingress_egress_solana: ingressEgressPalletSafeModeStatuses,
590
- ingress_egress_assethub: ingressEgressPalletSafeModeStatuses,
591
- witnesser: z.enum(["CodeRed", "CodeGreen", "CodeAmber"]),
592
- elections_generic: z.object({
593
- oracle_price_elections: z.boolean()
594
- })
595
- });
596
- var cfLendingPools = z.array(
597
- z.object({
598
- asset: rpcAssetSchema,
599
- total_amount: numberOrHex,
600
- available_amount: numberOrHex,
601
- utilisation_rate: z.number(),
602
- current_interest_rate: z.number(),
603
- origination_fee: z.number(),
604
- liquidation_fee: z.number(),
605
- interest_rate_curve: z.object({
606
- interest_at_zero_utilisation: z.number(),
607
- junction_utilisation: z.number(),
608
- interest_at_junction_utilisation: z.number(),
609
- interest_at_max_utilisation: z.number()
610
- })
611
- })
612
- );
613
- var cfLendingConfig = z.object({
614
- ltv_thresholds: z.object({
615
- target: z.number(),
616
- topup: z.number().nullable(),
617
- soft_liquidation: z.number(),
618
- soft_liquidation_abort: z.number(),
619
- hard_liquidation: z.number(),
620
- hard_liquidation_abort: z.number(),
621
- low_ltv: z.number().nullable()
622
- }),
623
- network_fee_contributions: z.object({
624
- extra_interest: z.number(),
625
- low_ltv_penalty_max: z.number().nullable(),
626
- from_origination_fee: z.number(),
627
- from_liquidation_fee: z.number()
628
- }),
629
- fee_swap_interval_blocks: z.number(),
630
- interest_payment_interval_blocks: z.number(),
631
- fee_swap_threshold_usd: numberOrHex,
632
- interest_collection_threshold_usd: numberOrHex,
633
- soft_liquidation_swap_chunk_size_usd: numberOrHex,
634
- hard_liquidation_swap_chunk_size_usd: numberOrHex,
635
- soft_liquidation_max_oracle_slippage: z.number(),
636
- hard_liquidation_max_oracle_slippage: z.number(),
637
- fee_swap_max_oracle_slippage: z.number(),
638
- minimum_loan_amount_usd: numberOrHex,
639
- minimum_supply_amount_usd: numberOrHex,
640
- minimum_update_loan_amount_usd: numberOrHex,
641
- minimum_update_collateral_amount_usd: numberOrHex
642
- });
643
- var cfLoanAccount = z.object({
644
- account: accountId,
645
- collateral_topup_asset: rpcAssetSchema.nullable(),
646
- ltv_ratio: numberOrHex.nullable(),
647
- collateral: z.array(
648
- z.intersection(
649
- rpcAssetSchema,
650
- z.object({
651
- amount: numberOrHex
652
- })
653
- )
654
- ),
655
- loans: z.array(
656
- z.object({
657
- loan_id: z.number(),
658
- asset: rpcAssetSchema,
659
- principal_amount: numberOrHex
660
- })
661
- ),
662
- liquidation_status: z.object({
663
- liquidation_swaps: z.array(
664
- z.object({
665
- swap_request_id: z.number(),
666
- loan_id: z.number()
667
- })
668
- ),
669
- liquidation_type: z.enum(["SoftVoluntary", "Soft", "Hard"])
670
- }).nullable()
671
- });
672
- var cfLoanAccounts = z.array(cfLoanAccount);
673
- var cfLendingPoolSupplyBalances = z.array(
674
- z.intersection(
675
- rpcAssetSchema,
676
- z.object({
677
- positions: z.array(
678
- z.object({
679
- lp_id: accountId,
680
- total_amount: numberOrHex
681
- })
682
- )
683
- })
684
- )
685
- );
686
- var cfVaultAddresses = z.object({
687
- ethereum: z.object({ Eth: z.array(z.number()).length(20).transform(bytesToHex) }),
688
- arbitrum: z.object({ Arb: z.array(z.number()).length(20).transform(bytesToHex) }),
689
- bitcoin: z.array(
690
- z.tuple([
691
- accountId,
692
- z.object({
693
- Btc: z.array(z.number()).transform((bytes) => new TextDecoder().decode(new Uint8Array(bytes)))
694
- })
695
- ])
696
- )
537
+ const ethereumAddress = z.string().transform((address) => `0x${address}`);
538
+ const cfPoolOrderbook = z.object({
539
+ bids: z.array(z.object({
540
+ amount: u256,
541
+ sqrt_price: u256
542
+ })),
543
+ asks: z.array(z.object({
544
+ amount: u256,
545
+ sqrt_price: u256
546
+ }))
547
+ });
548
+ const cfTradingStrategy = z.object({
549
+ lp_id: z.string(),
550
+ strategy_id: z.string(),
551
+ strategy: z.union([
552
+ z.object({ TickZeroCentered: z.object({
553
+ spread_tick: z.number(),
554
+ base_asset: rpcAssetSchema
555
+ }) }),
556
+ z.object({ SimpleBuySell: z.object({
557
+ buy_tick: z.number(),
558
+ sell_tick: z.number(),
559
+ base_asset: rpcAssetSchema
560
+ }) }),
561
+ z.object({ InventoryBased: z.object({
562
+ min_buy_tick: z.number(),
563
+ max_buy_tick: z.number(),
564
+ min_sell_tick: z.number(),
565
+ max_sell_tick: z.number(),
566
+ base_asset: rpcAssetSchema
567
+ }) })
568
+ ]),
569
+ balance: z.array(z.tuple([rpcAssetSchema, numberOrHex]))
570
+ });
571
+ const cfGetTradingStrategies = z.array(cfTradingStrategy).default([]);
572
+ const cfGetTradingStrategyLimits = z.object({
573
+ minimum_deployment_amount: chainAssetMapFactory(z.number().nullable(), null),
574
+ minimum_added_funds_amount: chainAssetMapFactory(z.number().nullable(), null)
575
+ });
576
+ const cfAvailablePools = z.array(z.object({
577
+ base: rpcAssetSchema.refine((a) => a.chain !== "Ethereum" || a.asset !== "USDC"),
578
+ quote: z.object({
579
+ chain: z.literal("Ethereum"),
580
+ asset: z.literal("USDC")
581
+ })
582
+ }));
583
+ const cfOraclePrices = z.array(z.object({
584
+ price: numberOrHex,
585
+ updated_at_oracle_timestamp: z.number(),
586
+ updated_at_statechain_block: z.number(),
587
+ base_asset: z.enum(priceAssets),
588
+ quote_asset: z.enum(priceAssets),
589
+ price_status: z.enum([
590
+ "UpToDate",
591
+ "Stale",
592
+ "MaybeStale"
593
+ ]).optional()
594
+ }));
595
+ const broadcastPalletSafeModeStatuses = z.object({
596
+ retry_enabled: z.boolean(),
597
+ egress_witnessing_enabled: z.boolean()
598
+ });
599
+ const ingressEgressPalletSafeModeStatuses = z.object({
600
+ boost_deposits_enabled: z.boolean(),
601
+ deposit_channel_creation_enabled: z.boolean(),
602
+ deposit_channel_witnessing_enabled: z.boolean(),
603
+ vault_deposit_witnessing_enabled: z.boolean()
604
+ });
605
+ const cfSafeModeStatuses = z.object({
606
+ emissions: z.object({ emissions_sync_enabled: z.boolean() }),
607
+ funding: z.object({ redeem_enabled: z.boolean() }),
608
+ swapping: z.object({
609
+ swaps_enabled: z.boolean(),
610
+ withdrawals_enabled: z.boolean(),
611
+ broker_registration_enabled: z.boolean()
612
+ }),
613
+ liquidity_provider: z.object({
614
+ deposit_enabled: z.boolean(),
615
+ withdrawal_enabled: z.boolean(),
616
+ internal_swaps_enabled: z.boolean()
617
+ }),
618
+ validator: z.object({
619
+ authority_rotation_enabled: z.boolean(),
620
+ start_bidding_enabled: z.boolean(),
621
+ stop_bidding_enabled: z.boolean()
622
+ }),
623
+ pools: z.object({
624
+ range_order_update_enabled: z.boolean(),
625
+ limit_order_update_enabled: z.boolean()
626
+ }),
627
+ trading_strategies: z.object({
628
+ strategy_updates_enabled: z.boolean(),
629
+ strategy_closure_enabled: z.boolean(),
630
+ strategy_execution_enabled: z.boolean()
631
+ }),
632
+ reputation: z.object({ reporting_enabled: z.boolean() }),
633
+ asset_balances: z.object({ reconciliation_enabled: z.boolean() }),
634
+ threshold_signature_evm: z.object({ slashing_enabled: z.boolean() }),
635
+ threshold_signature_bitcoin: z.object({ slashing_enabled: z.boolean() }),
636
+ threshold_signature_polkadot: z.object({ slashing_enabled: z.boolean() }),
637
+ threshold_signature_solana: z.object({ slashing_enabled: z.boolean() }),
638
+ lending_pools: z.object({
639
+ add_boost_funds_enabled: z.boolean(),
640
+ stop_boosting_enabled: z.boolean(),
641
+ borrowing_enabled: z.array(rpcAssetSchema).optional(),
642
+ add_lender_funds_enabled: z.array(rpcAssetSchema).optional(),
643
+ withdraw_lender_funds_enabled: z.array(rpcAssetSchema).optional(),
644
+ add_collateral_enabled: z.array(rpcAssetSchema).optional(),
645
+ remove_collateral_enabled: z.array(rpcAssetSchema).optional()
646
+ }),
647
+ broadcast_ethereum: broadcastPalletSafeModeStatuses,
648
+ broadcast_bitcoin: broadcastPalletSafeModeStatuses,
649
+ broadcast_polkadot: broadcastPalletSafeModeStatuses,
650
+ broadcast_arbitrum: broadcastPalletSafeModeStatuses,
651
+ broadcast_solana: broadcastPalletSafeModeStatuses,
652
+ broadcast_assethub: broadcastPalletSafeModeStatuses,
653
+ ingress_egress_ethereum: ingressEgressPalletSafeModeStatuses,
654
+ ingress_egress_bitcoin: ingressEgressPalletSafeModeStatuses,
655
+ ingress_egress_polkadot: ingressEgressPalletSafeModeStatuses,
656
+ ingress_egress_arbitrum: ingressEgressPalletSafeModeStatuses,
657
+ ingress_egress_solana: ingressEgressPalletSafeModeStatuses,
658
+ ingress_egress_assethub: ingressEgressPalletSafeModeStatuses,
659
+ witnesser: z.enum([
660
+ "CodeRed",
661
+ "CodeGreen",
662
+ "CodeAmber"
663
+ ]),
664
+ elections_generic: z.object({ oracle_price_elections: z.boolean() })
665
+ });
666
+ const cfLendingPools = z.array(z.object({
667
+ asset: rpcAssetSchema,
668
+ total_amount: numberOrHex,
669
+ available_amount: numberOrHex,
670
+ utilisation_rate: z.number(),
671
+ current_interest_rate: z.number(),
672
+ origination_fee: z.number(),
673
+ liquidation_fee: z.number(),
674
+ interest_rate_curve: z.object({
675
+ interest_at_zero_utilisation: z.number(),
676
+ junction_utilisation: z.number(),
677
+ interest_at_junction_utilisation: z.number(),
678
+ interest_at_max_utilisation: z.number()
679
+ })
680
+ }));
681
+ const cfLendingConfig = z.object({
682
+ ltv_thresholds: z.object({
683
+ target: z.number(),
684
+ topup: z.number().nullable(),
685
+ soft_liquidation: z.number(),
686
+ soft_liquidation_abort: z.number(),
687
+ hard_liquidation: z.number(),
688
+ hard_liquidation_abort: z.number(),
689
+ low_ltv: z.number().nullable()
690
+ }),
691
+ network_fee_contributions: z.object({
692
+ extra_interest: z.number(),
693
+ low_ltv_penalty_max: z.number().nullable(),
694
+ from_origination_fee: z.number(),
695
+ from_liquidation_fee: z.number()
696
+ }),
697
+ fee_swap_interval_blocks: z.number(),
698
+ interest_payment_interval_blocks: z.number(),
699
+ fee_swap_threshold_usd: numberOrHex,
700
+ interest_collection_threshold_usd: numberOrHex,
701
+ soft_liquidation_swap_chunk_size_usd: numberOrHex,
702
+ hard_liquidation_swap_chunk_size_usd: numberOrHex,
703
+ soft_liquidation_max_oracle_slippage: z.number(),
704
+ hard_liquidation_max_oracle_slippage: z.number(),
705
+ fee_swap_max_oracle_slippage: z.number(),
706
+ minimum_loan_amount_usd: numberOrHex,
707
+ minimum_supply_amount_usd: numberOrHex,
708
+ minimum_update_loan_amount_usd: numberOrHex,
709
+ minimum_update_collateral_amount_usd: numberOrHex
710
+ });
711
+ const cfLoanAccount = z.object({
712
+ account: accountId,
713
+ collateral_topup_asset: rpcAssetSchema.nullable(),
714
+ ltv_ratio: numberOrHex.nullable(),
715
+ collateral: z.array(z.intersection(rpcAssetSchema, z.object({ amount: numberOrHex }))),
716
+ loans: z.array(z.object({
717
+ loan_id: z.number(),
718
+ asset: rpcAssetSchema,
719
+ principal_amount: numberOrHex
720
+ })),
721
+ liquidation_status: z.object({
722
+ liquidation_swaps: z.array(z.object({
723
+ swap_request_id: z.number(),
724
+ loan_id: z.number()
725
+ })),
726
+ liquidation_type: z.enum([
727
+ "SoftVoluntary",
728
+ "Soft",
729
+ "Hard"
730
+ ])
731
+ }).nullable()
732
+ });
733
+ const cfLoanAccounts = z.array(cfLoanAccount);
734
+ const cfLendingPoolSupplyBalances = z.array(z.intersection(rpcAssetSchema, z.object({ positions: z.array(z.object({
735
+ lp_id: accountId,
736
+ total_amount: numberOrHex
737
+ })) })));
738
+ const cfVaultAddresses = z.object({
739
+ ethereum: z.object({ Eth: z.array(z.number()).length(20).transform(bytesToHex) }),
740
+ arbitrum: z.object({ Arb: z.array(z.number()).length(20).transform(bytesToHex) }),
741
+ bitcoin: z.array(z.tuple([accountId, z.object({ Btc: z.array(z.number()).transform((bytes) => new TextDecoder().decode(new Uint8Array(bytes))) })]))
697
742
  }).transform(({ ethereum, arbitrum, bitcoin }) => {
698
- const bitcoinAddresses = new Map(
699
- bitcoin.map(([brokerId, { Btc }]) => [brokerId, Btc])
700
- );
701
- return {
702
- Ethereum: ethereum.Eth,
703
- Arbitrum: arbitrum.Arb,
704
- Bitcoin: bitcoinAddresses
705
- };
706
- });
707
- export {
708
- accountInfoCommon,
709
- broker,
710
- brokerRequestAccountCreationDepositAddress,
711
- brokerRequestSwapDepositAddress,
712
- cfAccountInfo,
713
- cfAccounts,
714
- cfAuctionState,
715
- cfAvailablePools,
716
- cfBoostPoolDetails,
717
- cfBoostPoolPendingFees,
718
- cfBoostPoolsDepth,
719
- cfEnvironment,
720
- cfFailedCallEvm,
721
- cfFlipSuppy,
722
- cfFundingEnvironment,
723
- cfGetTradingStrategies,
724
- cfGetTradingStrategyLimits,
725
- cfIngressEgressEnvironment,
726
- cfLendingConfig,
727
- cfLendingPoolSupplyBalances,
728
- cfLendingPools,
729
- cfLoanAccount,
730
- cfLoanAccounts,
731
- cfMonitoringSimulateAuction,
732
- cfOraclePrices,
733
- cfPoolDepth,
734
- cfPoolOrderbook,
735
- cfPoolOrders,
736
- cfPoolPriceV2,
737
- cfPoolsEnvironment,
738
- cfSafeModeStatuses,
739
- cfSupportedAssets,
740
- cfSwapRate,
741
- cfSwapRateV2,
742
- cfSwapRateV3,
743
- cfSwappingEnvironment,
744
- cfTradingStrategy,
745
- cfVaultAddresses,
746
- chainGetBlockHash,
747
- ethereumAddress,
748
- hexString,
749
- liquidityProvider,
750
- lpTotalBalances,
751
- numberOrHex,
752
- numericString,
753
- operator,
754
- requestSwapParameterEncoding,
755
- rpcResponse,
756
- stateGetMetadata,
757
- stateGetRuntimeVersion,
758
- u256,
759
- unregistered,
760
- validator
761
- };
743
+ const bitcoinAddresses = new Map(bitcoin.map(([brokerId, { Btc }]) => [brokerId, Btc]));
744
+ return {
745
+ Ethereum: ethereum.Eth,
746
+ Arbitrum: arbitrum.Arb,
747
+ Bitcoin: bitcoinAddresses
748
+ };
749
+ });
750
+
751
+ //#endregion
752
+ export { accountInfoCommon, broker, brokerRequestAccountCreationDepositAddress, brokerRequestSwapDepositAddress, cfAccountInfo, cfAccounts, cfAuctionState, cfAvailablePools, cfBoostPoolDetails, cfBoostPoolPendingFees, cfBoostPoolsDepth, cfEnvironment, cfFailedCallEvm, cfFlipSuppy, cfFundingEnvironment, cfGetTradingStrategies, cfGetTradingStrategyLimits, cfIngressEgressEnvironment, cfLendingConfig, cfLendingPoolSupplyBalances, cfLendingPools, cfLoanAccount, cfLoanAccounts, cfMonitoringSimulateAuction, cfOraclePrices, cfPoolDepth, cfPoolOrderbook, cfPoolOrders, cfPoolPriceV2, cfPoolsEnvironment, cfSafeModeStatuses, cfSupportedAssets, cfSwapRate, cfSwapRateV2, cfSwapRateV3, cfSwappingEnvironment, cfTradingStrategy, cfVaultAddresses, chainGetBlockHash, ethereumAddress, hexString, liquidityProvider, lpTotalBalances, numberOrHex, numericString, operator, requestSwapParameterEncoding, rpcResponse, stateGetMetadata, stateGetRuntimeVersion, u256, unregistered, validator };