@chainflip/rpc 2.0.7 → 2.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Client.cjs +88 -91
- package/dist/Client.d.cts +30 -33
- package/dist/Client.d.mts +40 -0
- package/dist/Client.mjs +87 -90
- package/dist/HttpClient.cjs +33 -32
- package/dist/HttpClient.d.cts +5 -10
- package/dist/HttpClient.d.mts +9 -0
- package/dist/HttpClient.mjs +32 -31
- package/dist/WsClient.cjs +119 -124
- package/dist/WsClient.d.cts +22 -24
- package/dist/WsClient.d.mts +26 -0
- package/dist/WsClient.mjs +117 -122
- package/dist/_virtual/rolldown_runtime.cjs +19 -0
- package/dist/_virtual/rolldown_runtime.mjs +18 -0
- package/dist/common.cjs +55 -98
- package/dist/common.d.cts +30509 -26329
- package/dist/common.d.mts +31128 -0
- package/dist/common.mjs +54 -98
- package/dist/constants.cjs +16 -7
- package/dist/constants.d.cts +11 -1
- package/dist/constants.d.mts +11 -0
- package/dist/constants.mjs +12 -9
- package/dist/index.cjs +12 -10
- package/dist/index.d.cts +7 -11
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +5 -10
- package/dist/parsers.cjs +794 -750
- package/dist/parsers.d.cts +36279 -31216
- package/dist/parsers.d.mts +37053 -0
- package/dist/parsers.mjs +738 -746
- package/dist/types.cjs +0 -1
- package/dist/types.d.cts +6 -9
- package/dist/{types.d.ts → types.d.mts} +6 -9
- package/dist/types.mjs +1 -0
- package/package.json +6 -6
- package/dist/Client.d.ts +0 -43
- package/dist/HttpClient.d.ts +0 -13
- package/dist/WsClient.d.ts +0 -27
- package/dist/common.d.ts +0 -26948
- package/dist/constants-jLrn-AnI.d.cts +0 -13
- package/dist/constants-jLrn-AnI.d.ts +0 -13
- package/dist/constants.d.ts +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/parsers.d.ts +0 -31990
package/dist/parsers.mjs
CHANGED
|
@@ -1,760 +1,752 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
})
|
|
50
138
|
]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
egress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
109
|
-
witness_safety_margins: chainMapFactory(z.number().nullable(), null),
|
|
110
|
-
egress_dust_limits: chainAssetMapFactory(numberOrHex, 0),
|
|
111
|
-
channel_opening_fees: chainMapFactory(numberOrHex, 0),
|
|
112
|
-
ingress_delays: chainMapFactory(z.number(), 0).optional(),
|
|
113
|
-
// TODO(1.12): remove after all networks upgraded
|
|
114
|
-
boost_delays: chainMapFactory(z.number(), 0).optional()
|
|
115
|
-
// 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()
|
|
116
196
|
}).transform(rename({ egress_dust_limits: "minimum_egress_amounts" }));
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
|
173
279
|
}).nullable();
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
is_signer: z.boolean(),
|
|
219
|
-
is_writable: z.boolean()
|
|
220
|
-
})
|
|
221
|
-
)
|
|
222
|
-
})
|
|
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
|
+
})
|
|
223
324
|
]);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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()
|
|
238
339
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
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"
|
|
356
456
|
}));
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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"
|
|
360
472
|
}));
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
})
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
pending_fees: z.array(
|
|
407
|
-
z.object({
|
|
408
|
-
deposit_id: z.number().transform(BigInt),
|
|
409
|
-
fees: z.array(boostPoolAmount)
|
|
410
|
-
})
|
|
411
|
-
)
|
|
412
|
-
})
|
|
413
|
-
)
|
|
414
|
-
);
|
|
415
|
-
var lpTotalBalances = chainAssetMapFactory(numberOrHex, 0);
|
|
416
|
-
var cfFailedCallEvm = z.object({
|
|
417
|
-
contract: hexString,
|
|
418
|
-
data: z.string()
|
|
419
|
-
});
|
|
420
|
-
var range = (parser) => z.tuple([parser, parser]);
|
|
421
|
-
var cfAuctionState = z.object({
|
|
422
|
-
epoch_duration: z.number(),
|
|
423
|
-
current_epoch_started_at: z.number(),
|
|
424
|
-
redemption_period_as_percentage: z.number(),
|
|
425
|
-
min_funding: numberOrHex,
|
|
426
|
-
auction_size_range: range(z.number()),
|
|
427
|
-
min_active_bid: numberOrHex.nullable(),
|
|
428
|
-
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
|
|
429
518
|
}).transform(rename({ epoch_duration: "epoch_duration_blocks" }));
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
var cfFlipSuppy = range(numberOrHex).transform(([totalIssuance, offchainFunds]) => ({
|
|
448
|
-
totalIssuance,
|
|
449
|
-
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
|
|
450
536
|
}));
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
);
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
)
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
loan_id: z.number(),
|
|
657
|
-
asset: rpcAssetSchema,
|
|
658
|
-
principal_amount: numberOrHex
|
|
659
|
-
})
|
|
660
|
-
),
|
|
661
|
-
liquidation_status: z.object({
|
|
662
|
-
liquidation_swaps: z.array(
|
|
663
|
-
z.object({
|
|
664
|
-
swap_request_id: z.number(),
|
|
665
|
-
loan_id: z.number()
|
|
666
|
-
})
|
|
667
|
-
),
|
|
668
|
-
liquidation_type: z.enum(["SoftVoluntary", "Soft", "Hard"])
|
|
669
|
-
}).nullable()
|
|
670
|
-
});
|
|
671
|
-
var cfLoanAccounts = z.array(cfLoanAccount);
|
|
672
|
-
var cfLendingPoolSupplyBalances = z.array(
|
|
673
|
-
z.intersection(
|
|
674
|
-
rpcAssetSchema,
|
|
675
|
-
z.object({
|
|
676
|
-
positions: z.array(
|
|
677
|
-
z.object({
|
|
678
|
-
lp_id: accountId,
|
|
679
|
-
total_amount: numberOrHex
|
|
680
|
-
})
|
|
681
|
-
)
|
|
682
|
-
})
|
|
683
|
-
)
|
|
684
|
-
);
|
|
685
|
-
var cfVaultAddresses = z.object({
|
|
686
|
-
ethereum: z.object({ Eth: z.array(z.number()).length(20).transform(bytesToHex) }),
|
|
687
|
-
arbitrum: z.object({ Arb: z.array(z.number()).length(20).transform(bytesToHex) }),
|
|
688
|
-
bitcoin: z.array(
|
|
689
|
-
z.tuple([
|
|
690
|
-
accountId,
|
|
691
|
-
z.object({
|
|
692
|
-
Btc: z.array(z.number()).transform((bytes) => new TextDecoder().decode(new Uint8Array(bytes)))
|
|
693
|
-
})
|
|
694
|
-
])
|
|
695
|
-
)
|
|
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))) })]))
|
|
696
742
|
}).transform(({ ethereum, arbitrum, bitcoin }) => {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
export {
|
|
707
|
-
accountInfoCommon,
|
|
708
|
-
broker,
|
|
709
|
-
brokerRequestAccountCreationDepositAddress,
|
|
710
|
-
brokerRequestSwapDepositAddress,
|
|
711
|
-
cfAccountInfo,
|
|
712
|
-
cfAccounts,
|
|
713
|
-
cfAuctionState,
|
|
714
|
-
cfAvailablePools,
|
|
715
|
-
cfBoostPoolDetails,
|
|
716
|
-
cfBoostPoolPendingFees,
|
|
717
|
-
cfBoostPoolsDepth,
|
|
718
|
-
cfEnvironment,
|
|
719
|
-
cfFailedCallEvm,
|
|
720
|
-
cfFlipSuppy,
|
|
721
|
-
cfFundingEnvironment,
|
|
722
|
-
cfGetTradingStrategies,
|
|
723
|
-
cfGetTradingStrategyLimits,
|
|
724
|
-
cfIngressEgressEnvironment,
|
|
725
|
-
cfLendingConfig,
|
|
726
|
-
cfLendingPoolSupplyBalances,
|
|
727
|
-
cfLendingPools,
|
|
728
|
-
cfLoanAccount,
|
|
729
|
-
cfLoanAccounts,
|
|
730
|
-
cfMonitoringSimulateAuction,
|
|
731
|
-
cfOraclePrices,
|
|
732
|
-
cfPoolDepth,
|
|
733
|
-
cfPoolOrderbook,
|
|
734
|
-
cfPoolOrders,
|
|
735
|
-
cfPoolPriceV2,
|
|
736
|
-
cfPoolsEnvironment,
|
|
737
|
-
cfSafeModeStatuses,
|
|
738
|
-
cfSupportedAssets,
|
|
739
|
-
cfSwapRate,
|
|
740
|
-
cfSwapRateV2,
|
|
741
|
-
cfSwapRateV3,
|
|
742
|
-
cfSwappingEnvironment,
|
|
743
|
-
cfTradingStrategy,
|
|
744
|
-
cfVaultAddresses,
|
|
745
|
-
chainGetBlockHash,
|
|
746
|
-
ethereumAddress,
|
|
747
|
-
hexString,
|
|
748
|
-
liquidityProvider,
|
|
749
|
-
lpTotalBalances,
|
|
750
|
-
numberOrHex,
|
|
751
|
-
numericString,
|
|
752
|
-
operator,
|
|
753
|
-
requestSwapParameterEncoding,
|
|
754
|
-
rpcResponse,
|
|
755
|
-
stateGetMetadata,
|
|
756
|
-
stateGetRuntimeVersion,
|
|
757
|
-
u256,
|
|
758
|
-
unregistered,
|
|
759
|
-
validator
|
|
760
|
-
};
|
|
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 };
|