@chainflip/rpc 1.6.3 → 1.6.4
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 +6 -7
- package/dist/Client.d.cts +1 -1
- package/dist/Client.d.ts +1 -1
- package/dist/{Client.mjs → Client.js} +3 -4
- package/dist/HttpClient.cjs +3 -4
- package/dist/HttpClient.d.cts +1 -1
- package/dist/HttpClient.d.ts +1 -1
- package/dist/{HttpClient.mjs → HttpClient.js} +3 -4
- package/dist/WsClient.cjs +9 -10
- package/dist/WsClient.d.cts +1 -1
- package/dist/WsClient.d.ts +1 -1
- package/dist/{WsClient.mjs → WsClient.js} +6 -7
- package/dist/common.cjs +17 -30
- package/dist/common.d.cts +1725 -12105
- package/dist/common.d.ts +1725 -12105
- package/dist/{common.mjs → common.js} +3 -16
- package/dist/constants.cjs +2 -3
- package/dist/{constants.mjs → constants.js} +2 -3
- package/dist/index.cjs +5 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -0
- package/dist/parsers.cjs +37 -212
- package/dist/parsers.d.cts +376 -12098
- package/dist/parsers.d.ts +376 -12098
- package/dist/parsers.js +113 -0
- package/dist/types.d.cts +3 -20
- package/dist/types.d.ts +3 -20
- package/package.json +1 -1
- package/dist/index.mjs +0 -10
- package/dist/parsers.mjs +0 -288
- /package/dist/{types.mjs → types.js} +0 -0
package/dist/parsers.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { isNotNullish } from "@chainflip/utils/guard";
|
|
2
|
+
import { isHex } from "@chainflip/utils/string";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
const hexString = z.string().refine(isHex, { message: "Invalid hex string" });
|
|
5
|
+
const u256 = hexString.transform((value) => BigInt(value));
|
|
6
|
+
const numberOrHex = z.union([z.number().transform((n) => BigInt(n)), u256]);
|
|
7
|
+
const chainAssetMapFactory = (parser) => z.object({
|
|
8
|
+
Bitcoin: z.object({ BTC: parser }),
|
|
9
|
+
Ethereum: z.object({ ETH: parser, USDC: parser, FLIP: parser, USDT: parser }),
|
|
10
|
+
Polkadot: z.object({ DOT: parser }),
|
|
11
|
+
Arbitrum: z.object({ ETH: parser, USDC: parser })
|
|
12
|
+
});
|
|
13
|
+
const chainMapFactory = (parser) => z.object({ Bitcoin: parser, Ethereum: parser, Polkadot: parser, Arbitrum: parser });
|
|
14
|
+
const rpcAssetSchema = z.union([
|
|
15
|
+
z.object({ chain: z.literal("Bitcoin"), asset: z.literal("BTC") }),
|
|
16
|
+
z.object({ chain: z.literal("Polkadot"), asset: z.literal("DOT") }),
|
|
17
|
+
z.object({ chain: z.literal("Ethereum"), asset: z.literal("FLIP") }),
|
|
18
|
+
z.object({ chain: z.literal("Ethereum"), asset: z.literal("ETH") }),
|
|
19
|
+
z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDC") }),
|
|
20
|
+
z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDT") }),
|
|
21
|
+
z.object({ chain: z.literal("Arbitrum"), asset: z.literal("ETH") }),
|
|
22
|
+
z.object({ chain: z.literal("Arbitrum"), asset: z.literal("USDC") })
|
|
23
|
+
]);
|
|
24
|
+
const rename = (mapping) => (obj) => Object.fromEntries(
|
|
25
|
+
Object.entries(obj).map(([key, value]) => [
|
|
26
|
+
key in mapping ? mapping[key] : key,
|
|
27
|
+
value
|
|
28
|
+
])
|
|
29
|
+
);
|
|
30
|
+
const rpcBaseResponse = z.object({
|
|
31
|
+
id: z.union([z.string(), z.number()]),
|
|
32
|
+
jsonrpc: z.literal("2.0")
|
|
33
|
+
});
|
|
34
|
+
const nonNullish = z.any().refine(isNotNullish, { message: "Value must not be null or undefined" });
|
|
35
|
+
const rpcSuccessResponse = rpcBaseResponse.extend({ result: nonNullish });
|
|
36
|
+
const rpcErrorResponse = rpcBaseResponse.extend({
|
|
37
|
+
error: z.object({ code: z.number(), message: z.string() })
|
|
38
|
+
});
|
|
39
|
+
const rpcResponse = z.union([rpcSuccessResponse, rpcErrorResponse]);
|
|
40
|
+
const cfSwapRate = z.object({
|
|
41
|
+
intermediary: numberOrHex.nullable(),
|
|
42
|
+
output: numberOrHex
|
|
43
|
+
});
|
|
44
|
+
const fee = z.intersection(rpcAssetSchema, z.object({ amount: numberOrHex }));
|
|
45
|
+
const cfSwapRateV2 = z.object({
|
|
46
|
+
egress_fee: fee,
|
|
47
|
+
ingress_fee: fee,
|
|
48
|
+
intermediary: u256.nullable(),
|
|
49
|
+
network_fee: fee,
|
|
50
|
+
output: u256
|
|
51
|
+
});
|
|
52
|
+
const chainGetBlockHash = hexString;
|
|
53
|
+
const stateGetMetadata = hexString;
|
|
54
|
+
const stateGetRuntimeVersion = z.object({
|
|
55
|
+
specName: z.string(),
|
|
56
|
+
implName: z.string(),
|
|
57
|
+
authoringVersion: z.number(),
|
|
58
|
+
specVersion: z.number(),
|
|
59
|
+
implVersion: z.number(),
|
|
60
|
+
apis: z.array(z.tuple([hexString, z.number()])),
|
|
61
|
+
transactionVersion: z.number(),
|
|
62
|
+
stateVersion: z.number()
|
|
63
|
+
});
|
|
64
|
+
const cfIngressEgressEnvironment = z.object({
|
|
65
|
+
minimum_deposit_amounts: chainAssetMapFactory(numberOrHex),
|
|
66
|
+
ingress_fees: chainAssetMapFactory(numberOrHex.nullable()),
|
|
67
|
+
egress_fees: chainAssetMapFactory(numberOrHex.nullable()),
|
|
68
|
+
witness_safety_margins: chainMapFactory(z.number().nullable()),
|
|
69
|
+
egress_dust_limits: chainAssetMapFactory(numberOrHex),
|
|
70
|
+
channel_opening_fees: chainMapFactory(numberOrHex)
|
|
71
|
+
}).transform(rename({ egress_dust_limits: "minimum_egress_amounts" }));
|
|
72
|
+
const cfSwappingEnvironment = z.object({
|
|
73
|
+
maximum_swap_amounts: chainAssetMapFactory(numberOrHex.nullable()),
|
|
74
|
+
network_fee_hundredth_pips: z.number()
|
|
75
|
+
});
|
|
76
|
+
const cfFundingEnvironment = z.object({
|
|
77
|
+
redemption_tax: numberOrHex,
|
|
78
|
+
minimum_funding_amount: numberOrHex
|
|
79
|
+
});
|
|
80
|
+
const cfEnvironment = z.object({
|
|
81
|
+
ingress_egress: cfIngressEgressEnvironment,
|
|
82
|
+
swapping: cfSwappingEnvironment,
|
|
83
|
+
funding: cfFundingEnvironment
|
|
84
|
+
});
|
|
85
|
+
const cfBoostPoolsDepth = z.array(
|
|
86
|
+
z.intersection(rpcAssetSchema, z.object({ tier: z.number(), available_amount: u256 }))
|
|
87
|
+
);
|
|
88
|
+
const cfSupportedAsssets = z.array(rpcAssetSchema);
|
|
89
|
+
const brokerRequestSwapDepositAddress = z.object({
|
|
90
|
+
address: z.string(),
|
|
91
|
+
issued_block: z.number(),
|
|
92
|
+
channel_id: z.number(),
|
|
93
|
+
source_chain_expiry_block: numberOrHex,
|
|
94
|
+
channel_opening_fee: u256
|
|
95
|
+
});
|
|
96
|
+
export {
|
|
97
|
+
brokerRequestSwapDepositAddress,
|
|
98
|
+
cfBoostPoolsDepth,
|
|
99
|
+
cfEnvironment,
|
|
100
|
+
cfFundingEnvironment,
|
|
101
|
+
cfIngressEgressEnvironment,
|
|
102
|
+
cfSupportedAsssets,
|
|
103
|
+
cfSwapRate,
|
|
104
|
+
cfSwapRateV2,
|
|
105
|
+
cfSwappingEnvironment,
|
|
106
|
+
chainGetBlockHash,
|
|
107
|
+
hexString,
|
|
108
|
+
numberOrHex,
|
|
109
|
+
rpcResponse,
|
|
110
|
+
stateGetMetadata,
|
|
111
|
+
stateGetRuntimeVersion,
|
|
112
|
+
u256
|
|
113
|
+
};
|
package/dist/types.d.cts
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { RpcResult, RpcResponse } from './common.cjs';
|
|
3
2
|
export { RpcMethod, RpcRequest as RpcParams } from './common.cjs';
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import 'zod';
|
|
4
|
+
import './parsers.cjs';
|
|
6
5
|
import '@chainflip/utils/types';
|
|
7
6
|
|
|
8
|
-
type CfAccountInfo = RpcResult<'cf_account_info'>;
|
|
9
|
-
type CfBoostPoolDetails = RpcResult<'cf_boost_pool_details'>;
|
|
10
|
-
type CfBoostPoolPendingFees = RpcResult<'cf_boost_pool_pending_fees'>;
|
|
11
7
|
type CfBoostPoolsDepth = RpcResult<'cf_boost_pools_depth'>;
|
|
12
8
|
type CfEnvironment = RpcResult<'cf_environment'>;
|
|
13
9
|
type CfFundingEnvironment = RpcResult<'cf_funding_environment'>;
|
|
14
10
|
type CfIngressEgressEnvironment = RpcResult<'cf_ingress_egress_environment'>;
|
|
15
|
-
type CfPoolOrders = RpcResult<'cf_pool_orders'>;
|
|
16
|
-
type CfPoolPriceV2 = RpcResult<'cf_pool_price_v2'>;
|
|
17
|
-
type CfPoolsEnvironment = RpcResult<'cf_pools_environment'>;
|
|
18
11
|
type CfSupportedAssets = RpcResult<'cf_supported_assets'>;
|
|
19
12
|
type CfSwappingEnvironment = RpcResult<'cf_swapping_environment'>;
|
|
20
13
|
type CfSwapRate = RpcResult<'cf_swap_rate'>;
|
|
21
14
|
type CfSwapRateV2 = RpcResult<'cf_swap_rate_v2'>;
|
|
22
|
-
type CfAccountInfoResponse = RpcResponse<'cf_account_info'>;
|
|
23
|
-
type CfBoostPoolDetailsResponse = RpcResponse<'cf_boost_pool_details'>;
|
|
24
|
-
type CfBoostPoolPendingFeesResponse = RpcResponse<'cf_boost_pool_pending_fees'>;
|
|
25
15
|
type CfBoostPoolsDepthResponse = RpcResponse<'cf_boost_pools_depth'>;
|
|
26
16
|
type CfEnvironmentResponse = RpcResponse<'cf_environment'>;
|
|
27
17
|
type CfFundingEnvironmentResponse = RpcResponse<'cf_funding_environment'>;
|
|
28
18
|
type CfIngressEgressEnvironmentResponse = RpcResponse<'cf_ingress_egress_environment'>;
|
|
29
|
-
type CfPoolOrdersResponse = RpcResponse<'cf_pool_orders'>;
|
|
30
|
-
type CfPoolPriceV2Response = RpcResponse<'cf_pool_price_v2'>;
|
|
31
|
-
type CfPoolsEnvironmentResponse = RpcResponse<'cf_pools_environment'>;
|
|
32
19
|
type CfSupportedAssetsResponse = RpcResponse<'cf_supported_assets'>;
|
|
33
20
|
type CfSwappingEnvironmentResponse = RpcResponse<'cf_swapping_environment'>;
|
|
34
21
|
type CfSwapRateResponse = RpcResponse<'cf_swap_rate'>;
|
|
35
22
|
type CfSwapRateV2Response = RpcResponse<'cf_swap_rate_v2'>;
|
|
36
|
-
type CfUnregisteredAccount = z.output<typeof unregistered>;
|
|
37
|
-
type CfBrokerAccount = z.output<typeof broker>;
|
|
38
|
-
type CfValidatorAccount = z.output<typeof validator>;
|
|
39
|
-
type CfLiquidityProviderAccount = z.output<typeof liquidityProvider>;
|
|
40
23
|
|
|
41
|
-
export { type
|
|
24
|
+
export { type CfBoostPoolsDepth, type CfBoostPoolsDepthResponse, type CfEnvironment, type CfEnvironmentResponse, type CfFundingEnvironment, type CfFundingEnvironmentResponse, type CfIngressEgressEnvironment, type CfIngressEgressEnvironmentResponse, type CfSupportedAssets, type CfSupportedAssetsResponse, type CfSwapRate, type CfSwapRateResponse, type CfSwapRateV2, type CfSwapRateV2Response, type CfSwappingEnvironment, type CfSwappingEnvironmentResponse, RpcResult };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { RpcResult, RpcResponse } from './common.js';
|
|
3
2
|
export { RpcMethod, RpcRequest as RpcParams } from './common.js';
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import 'zod';
|
|
4
|
+
import './parsers.js';
|
|
6
5
|
import '@chainflip/utils/types';
|
|
7
6
|
|
|
8
|
-
type CfAccountInfo = RpcResult<'cf_account_info'>;
|
|
9
|
-
type CfBoostPoolDetails = RpcResult<'cf_boost_pool_details'>;
|
|
10
|
-
type CfBoostPoolPendingFees = RpcResult<'cf_boost_pool_pending_fees'>;
|
|
11
7
|
type CfBoostPoolsDepth = RpcResult<'cf_boost_pools_depth'>;
|
|
12
8
|
type CfEnvironment = RpcResult<'cf_environment'>;
|
|
13
9
|
type CfFundingEnvironment = RpcResult<'cf_funding_environment'>;
|
|
14
10
|
type CfIngressEgressEnvironment = RpcResult<'cf_ingress_egress_environment'>;
|
|
15
|
-
type CfPoolOrders = RpcResult<'cf_pool_orders'>;
|
|
16
|
-
type CfPoolPriceV2 = RpcResult<'cf_pool_price_v2'>;
|
|
17
|
-
type CfPoolsEnvironment = RpcResult<'cf_pools_environment'>;
|
|
18
11
|
type CfSupportedAssets = RpcResult<'cf_supported_assets'>;
|
|
19
12
|
type CfSwappingEnvironment = RpcResult<'cf_swapping_environment'>;
|
|
20
13
|
type CfSwapRate = RpcResult<'cf_swap_rate'>;
|
|
21
14
|
type CfSwapRateV2 = RpcResult<'cf_swap_rate_v2'>;
|
|
22
|
-
type CfAccountInfoResponse = RpcResponse<'cf_account_info'>;
|
|
23
|
-
type CfBoostPoolDetailsResponse = RpcResponse<'cf_boost_pool_details'>;
|
|
24
|
-
type CfBoostPoolPendingFeesResponse = RpcResponse<'cf_boost_pool_pending_fees'>;
|
|
25
15
|
type CfBoostPoolsDepthResponse = RpcResponse<'cf_boost_pools_depth'>;
|
|
26
16
|
type CfEnvironmentResponse = RpcResponse<'cf_environment'>;
|
|
27
17
|
type CfFundingEnvironmentResponse = RpcResponse<'cf_funding_environment'>;
|
|
28
18
|
type CfIngressEgressEnvironmentResponse = RpcResponse<'cf_ingress_egress_environment'>;
|
|
29
|
-
type CfPoolOrdersResponse = RpcResponse<'cf_pool_orders'>;
|
|
30
|
-
type CfPoolPriceV2Response = RpcResponse<'cf_pool_price_v2'>;
|
|
31
|
-
type CfPoolsEnvironmentResponse = RpcResponse<'cf_pools_environment'>;
|
|
32
19
|
type CfSupportedAssetsResponse = RpcResponse<'cf_supported_assets'>;
|
|
33
20
|
type CfSwappingEnvironmentResponse = RpcResponse<'cf_swapping_environment'>;
|
|
34
21
|
type CfSwapRateResponse = RpcResponse<'cf_swap_rate'>;
|
|
35
22
|
type CfSwapRateV2Response = RpcResponse<'cf_swap_rate_v2'>;
|
|
36
|
-
type CfUnregisteredAccount = z.output<typeof unregistered>;
|
|
37
|
-
type CfBrokerAccount = z.output<typeof broker>;
|
|
38
|
-
type CfValidatorAccount = z.output<typeof validator>;
|
|
39
|
-
type CfLiquidityProviderAccount = z.output<typeof liquidityProvider>;
|
|
40
23
|
|
|
41
|
-
export { type
|
|
24
|
+
export { type CfBoostPoolsDepth, type CfBoostPoolsDepthResponse, type CfEnvironment, type CfEnvironmentResponse, type CfFundingEnvironment, type CfFundingEnvironmentResponse, type CfIngressEgressEnvironment, type CfIngressEgressEnvironmentResponse, type CfSupportedAssets, type CfSupportedAssetsResponse, type CfSwapRate, type CfSwapRateResponse, type CfSwapRateV2, type CfSwapRateV2Response, type CfSwappingEnvironment, type CfSwappingEnvironmentResponse, RpcResult };
|
package/package.json
CHANGED
package/dist/index.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import { default as default2 } from "./HttpClient.mjs";
|
|
3
|
-
import { default as default3 } from "./WsClient.mjs";
|
|
4
|
-
export * from "./types.mjs";
|
|
5
|
-
import * as constants from "./constants.mjs";
|
|
6
|
-
export {
|
|
7
|
-
default2 as HttpClient,
|
|
8
|
-
default3 as WsClient,
|
|
9
|
-
constants
|
|
10
|
-
};
|
package/dist/parsers.mjs
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
// src/parsers.ts
|
|
2
|
-
import { isNotNullish } from "@chainflip/utils/guard";
|
|
3
|
-
import { isHex } from "@chainflip/utils/string";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
var hexString = z.string().refine(isHex, { message: "Invalid hex string" });
|
|
6
|
-
var u256 = hexString.transform((value) => BigInt(value));
|
|
7
|
-
var numberOrHex = z.union([z.number().transform((n) => BigInt(n)), u256]);
|
|
8
|
-
var chainAssetMapFactory = (parser, defaultValue) => z.object({
|
|
9
|
-
Bitcoin: z.object({ BTC: parser }),
|
|
10
|
-
Ethereum: z.object({ ETH: parser, USDC: parser, FLIP: parser, USDT: parser }),
|
|
11
|
-
Polkadot: z.object({ DOT: parser }),
|
|
12
|
-
Arbitrum: z.object({ ETH: parser, USDC: parser }),
|
|
13
|
-
Solana: z.object({ SOL: parser.default(defaultValue), USDC: parser.default(defaultValue) }).default({ SOL: defaultValue, USDC: defaultValue })
|
|
14
|
-
});
|
|
15
|
-
var chainBaseAssetMapFactory = (parser, defaultValue) => z.object({
|
|
16
|
-
Bitcoin: z.object({ BTC: parser }),
|
|
17
|
-
Ethereum: z.object({ ETH: parser, FLIP: parser, USDT: parser }),
|
|
18
|
-
Polkadot: z.object({ DOT: parser }),
|
|
19
|
-
Arbitrum: z.object({ ETH: parser, USDC: parser }),
|
|
20
|
-
Solana: z.object({ SOL: parser.default(defaultValue), USDC: parser.default(defaultValue) }).default({ SOL: defaultValue, USDC: defaultValue })
|
|
21
|
-
});
|
|
22
|
-
var chainMapFactory = (parser, defaultValue) => z.object({
|
|
23
|
-
Bitcoin: parser,
|
|
24
|
-
Ethereum: parser,
|
|
25
|
-
Polkadot: parser,
|
|
26
|
-
Arbitrum: parser,
|
|
27
|
-
Solana: parser.default(defaultValue)
|
|
28
|
-
});
|
|
29
|
-
var rpcAssetSchema = z.union([
|
|
30
|
-
z.object({ chain: z.literal("Bitcoin"), asset: z.literal("BTC") }),
|
|
31
|
-
z.object({ chain: z.literal("Polkadot"), asset: z.literal("DOT") }),
|
|
32
|
-
z.object({ chain: z.literal("Ethereum"), asset: z.literal("FLIP") }),
|
|
33
|
-
z.object({ chain: z.literal("Ethereum"), asset: z.literal("ETH") }),
|
|
34
|
-
z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDC") }),
|
|
35
|
-
z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDT") }),
|
|
36
|
-
z.object({ chain: z.literal("Arbitrum"), asset: z.literal("ETH") }),
|
|
37
|
-
z.object({ chain: z.literal("Arbitrum"), asset: z.literal("USDC") }),
|
|
38
|
-
z.object({ chain: z.literal("Solana"), asset: z.literal("SOL") }),
|
|
39
|
-
z.object({ chain: z.literal("Solana"), asset: z.literal("USDC") })
|
|
40
|
-
]);
|
|
41
|
-
var rename = (mapping) => (obj) => Object.fromEntries(
|
|
42
|
-
Object.entries(obj).map(([key, value]) => [
|
|
43
|
-
key in mapping ? mapping[key] : key,
|
|
44
|
-
value
|
|
45
|
-
])
|
|
46
|
-
);
|
|
47
|
-
var rpcBaseResponse = z.object({
|
|
48
|
-
id: z.union([z.string(), z.number()]),
|
|
49
|
-
jsonrpc: z.literal("2.0")
|
|
50
|
-
});
|
|
51
|
-
var nonNullish = z.any().refine(isNotNullish, { message: "Value must not be null or undefined" });
|
|
52
|
-
var rpcSuccessResponse = rpcBaseResponse.extend({ result: nonNullish });
|
|
53
|
-
var rpcErrorResponse = rpcBaseResponse.extend({
|
|
54
|
-
error: z.object({ code: z.number(), message: z.string() })
|
|
55
|
-
});
|
|
56
|
-
var rpcResponse = z.union([rpcSuccessResponse, rpcErrorResponse]);
|
|
57
|
-
var cfSwapRate = z.object({
|
|
58
|
-
intermediary: numberOrHex.nullable(),
|
|
59
|
-
output: numberOrHex
|
|
60
|
-
});
|
|
61
|
-
var fee = z.intersection(rpcAssetSchema, z.object({ amount: numberOrHex }));
|
|
62
|
-
var cfSwapRateV2 = z.object({
|
|
63
|
-
egress_fee: fee,
|
|
64
|
-
ingress_fee: fee,
|
|
65
|
-
intermediary: u256.nullable(),
|
|
66
|
-
network_fee: fee,
|
|
67
|
-
output: u256
|
|
68
|
-
});
|
|
69
|
-
var chainGetBlockHash = hexString;
|
|
70
|
-
var stateGetMetadata = hexString;
|
|
71
|
-
var stateGetRuntimeVersion = z.object({
|
|
72
|
-
specName: z.string(),
|
|
73
|
-
implName: z.string(),
|
|
74
|
-
authoringVersion: z.number(),
|
|
75
|
-
specVersion: z.number(),
|
|
76
|
-
implVersion: z.number(),
|
|
77
|
-
apis: z.array(z.tuple([hexString, z.number()])),
|
|
78
|
-
transactionVersion: z.number(),
|
|
79
|
-
stateVersion: z.number()
|
|
80
|
-
});
|
|
81
|
-
var cfIngressEgressEnvironment = z.object({
|
|
82
|
-
minimum_deposit_amounts: chainAssetMapFactory(numberOrHex, 0),
|
|
83
|
-
ingress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
84
|
-
egress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
85
|
-
witness_safety_margins: chainMapFactory(z.number().nullable(), null),
|
|
86
|
-
egress_dust_limits: chainAssetMapFactory(numberOrHex, 0),
|
|
87
|
-
channel_opening_fees: chainMapFactory(numberOrHex, 0),
|
|
88
|
-
// TODO(1.6): no longer optional
|
|
89
|
-
max_swap_retry_duration_blocks: chainMapFactory(z.number(), 0).optional().default({ Arbitrum: 0, Bitcoin: 0, Ethereum: 0, Polkadot: 0, Solana: 0 })
|
|
90
|
-
}).transform(rename({ egress_dust_limits: "minimum_egress_amounts" }));
|
|
91
|
-
var cfSwappingEnvironment = z.object({
|
|
92
|
-
maximum_swap_amounts: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
93
|
-
network_fee_hundredth_pips: z.number()
|
|
94
|
-
});
|
|
95
|
-
var cfFundingEnvironment = z.object({
|
|
96
|
-
redemption_tax: numberOrHex,
|
|
97
|
-
minimum_funding_amount: numberOrHex
|
|
98
|
-
});
|
|
99
|
-
var defaultFeeInfo = {
|
|
100
|
-
limit_order_fee_hundredth_pips: 0,
|
|
101
|
-
range_order_fee_hundredth_pips: 0,
|
|
102
|
-
range_order_total_fees_earned: { base: "0x0", quote: "0x0" },
|
|
103
|
-
limit_order_total_fees_earned: { base: "0x0", quote: "0x0" },
|
|
104
|
-
range_total_swap_inputs: { base: "0x0", quote: "0x0" },
|
|
105
|
-
limit_total_swap_inputs: { base: "0x0", quote: "0x0" },
|
|
106
|
-
quote_asset: { chain: "Ethereum", asset: "USDC" }
|
|
107
|
-
};
|
|
108
|
-
var cfPoolsEnvironment = z.object({
|
|
109
|
-
fees: chainBaseAssetMapFactory(
|
|
110
|
-
z.object({
|
|
111
|
-
limit_order_fee_hundredth_pips: z.number(),
|
|
112
|
-
range_order_fee_hundredth_pips: z.number(),
|
|
113
|
-
range_order_total_fees_earned: z.object({ base: u256, quote: u256 }),
|
|
114
|
-
limit_order_total_fees_earned: z.object({ base: u256, quote: u256 }),
|
|
115
|
-
range_total_swap_inputs: z.object({ base: u256, quote: u256 }),
|
|
116
|
-
limit_total_swap_inputs: z.object({ base: u256, quote: u256 }),
|
|
117
|
-
quote_asset: z.object({ chain: z.literal("Ethereum"), asset: z.literal("USDC") })
|
|
118
|
-
}).nullable().transform((info) => info ?? structuredClone(defaultFeeInfo)),
|
|
119
|
-
structuredClone(defaultFeeInfo)
|
|
120
|
-
)
|
|
121
|
-
});
|
|
122
|
-
var cfEnvironment = z.object({
|
|
123
|
-
ingress_egress: cfIngressEgressEnvironment,
|
|
124
|
-
swapping: cfSwappingEnvironment,
|
|
125
|
-
funding: cfFundingEnvironment,
|
|
126
|
-
pools: cfPoolsEnvironment
|
|
127
|
-
});
|
|
128
|
-
var cfBoostPoolsDepth = z.array(
|
|
129
|
-
z.intersection(rpcAssetSchema, z.object({ tier: z.number(), available_amount: u256 }))
|
|
130
|
-
);
|
|
131
|
-
var cfSupportedAsssets = z.array(z.object({ chain: z.string(), asset: z.string() })).transform(
|
|
132
|
-
(assets) => assets.filter((asset) => rpcAssetSchema.safeParse(asset).success)
|
|
133
|
-
);
|
|
134
|
-
var brokerRequestSwapDepositAddress = z.object({
|
|
135
|
-
address: z.string(),
|
|
136
|
-
issued_block: z.number(),
|
|
137
|
-
channel_id: z.number(),
|
|
138
|
-
source_chain_expiry_block: numberOrHex,
|
|
139
|
-
channel_opening_fee: u256
|
|
140
|
-
});
|
|
141
|
-
var unregistered = z.object({
|
|
142
|
-
role: z.literal("unregistered"),
|
|
143
|
-
flip_balance: numberOrHex
|
|
144
|
-
});
|
|
145
|
-
var broker = z.object({
|
|
146
|
-
role: z.literal("broker"),
|
|
147
|
-
flip_balance: numberOrHex,
|
|
148
|
-
earned_fees: chainAssetMapFactory(numberOrHex, 0)
|
|
149
|
-
});
|
|
150
|
-
var boostBalances = z.array(
|
|
151
|
-
z.object({
|
|
152
|
-
fee_tier: z.number(),
|
|
153
|
-
total_balance: u256,
|
|
154
|
-
available_balance: u256,
|
|
155
|
-
in_use_balance: u256,
|
|
156
|
-
is_withdrawing: z.boolean()
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
var liquidityProvider = z.object({
|
|
160
|
-
role: z.literal("liquidity_provider"),
|
|
161
|
-
balances: chainAssetMapFactory(numberOrHex, "0x0"),
|
|
162
|
-
refund_addresses: chainMapFactory(z.string().nullable(), null),
|
|
163
|
-
flip_balance: numberOrHex,
|
|
164
|
-
earned_fees: chainAssetMapFactory(numberOrHex, 0),
|
|
165
|
-
boost_balances: chainAssetMapFactory(boostBalances, [])
|
|
166
|
-
});
|
|
167
|
-
var validator = z.object({
|
|
168
|
-
role: z.literal("validator"),
|
|
169
|
-
flip_balance: numberOrHex,
|
|
170
|
-
bond: numberOrHex,
|
|
171
|
-
last_heartbeat: z.number(),
|
|
172
|
-
reputation_points: z.number(),
|
|
173
|
-
keyholder_epochs: z.array(z.number()),
|
|
174
|
-
is_current_authority: z.boolean(),
|
|
175
|
-
is_current_backup: z.boolean(),
|
|
176
|
-
is_qualified: z.boolean(),
|
|
177
|
-
is_online: z.boolean(),
|
|
178
|
-
is_bidding: z.boolean(),
|
|
179
|
-
bound_redeem_address: hexString.nullable(),
|
|
180
|
-
apy_bp: z.number().nullable(),
|
|
181
|
-
restricted_balances: z.record(hexString, numberOrHex)
|
|
182
|
-
});
|
|
183
|
-
var cfAccountInfo = z.union([unregistered, broker, liquidityProvider, validator]);
|
|
184
|
-
var cfPoolPriceV2 = z.object({
|
|
185
|
-
sell: numberOrHex.nullable(),
|
|
186
|
-
buy: numberOrHex.nullable(),
|
|
187
|
-
range_order: numberOrHex,
|
|
188
|
-
base_asset: rpcAssetSchema,
|
|
189
|
-
quote_asset: rpcAssetSchema
|
|
190
|
-
});
|
|
191
|
-
var orderId = numberOrHex.transform((n) => String(n));
|
|
192
|
-
var limitOrder = z.object({
|
|
193
|
-
id: orderId,
|
|
194
|
-
tick: z.number(),
|
|
195
|
-
sell_amount: numberOrHex,
|
|
196
|
-
fees_earned: numberOrHex,
|
|
197
|
-
original_sell_amount: numberOrHex,
|
|
198
|
-
lp: z.string()
|
|
199
|
-
});
|
|
200
|
-
var ask = limitOrder.transform((order) => ({
|
|
201
|
-
...order,
|
|
202
|
-
type: "ask"
|
|
203
|
-
}));
|
|
204
|
-
var bid = limitOrder.transform((order) => ({
|
|
205
|
-
...order,
|
|
206
|
-
type: "bid"
|
|
207
|
-
}));
|
|
208
|
-
var rangeOrder = z.object({
|
|
209
|
-
id: orderId,
|
|
210
|
-
range: z.object({ start: z.number(), end: z.number() }),
|
|
211
|
-
liquidity: numberOrHex,
|
|
212
|
-
fees_earned: z.object({ base: numberOrHex, quote: numberOrHex }),
|
|
213
|
-
lp: z.string()
|
|
214
|
-
}).transform((order) => ({ ...order, type: "range" }));
|
|
215
|
-
var cfPoolOrders = z.object({
|
|
216
|
-
limit_orders: z.object({
|
|
217
|
-
asks: z.array(ask),
|
|
218
|
-
bids: z.array(bid)
|
|
219
|
-
}),
|
|
220
|
-
range_orders: z.array(rangeOrder)
|
|
221
|
-
});
|
|
222
|
-
var boostPoolAmount = z.object({
|
|
223
|
-
account_id: z.string(),
|
|
224
|
-
amount: u256
|
|
225
|
-
});
|
|
226
|
-
var cfBoostPoolDetails = z.array(
|
|
227
|
-
z.intersection(
|
|
228
|
-
rpcAssetSchema,
|
|
229
|
-
z.object({
|
|
230
|
-
fee_tier: z.number(),
|
|
231
|
-
available_amounts: z.array(boostPoolAmount),
|
|
232
|
-
deposits_pending_finalization: z.array(
|
|
233
|
-
z.object({
|
|
234
|
-
deposit_id: z.number().transform(BigInt),
|
|
235
|
-
owed_amounts: z.array(boostPoolAmount)
|
|
236
|
-
})
|
|
237
|
-
),
|
|
238
|
-
pending_withdrawals: z.array(
|
|
239
|
-
z.object({
|
|
240
|
-
account_id: z.string(),
|
|
241
|
-
pending_deposits: z.array(z.bigint())
|
|
242
|
-
})
|
|
243
|
-
)
|
|
244
|
-
})
|
|
245
|
-
)
|
|
246
|
-
);
|
|
247
|
-
var cfBoostPoolPendingFees = z.array(
|
|
248
|
-
z.intersection(
|
|
249
|
-
rpcAssetSchema,
|
|
250
|
-
z.object({
|
|
251
|
-
fee_tier: z.number(),
|
|
252
|
-
pending_fees: z.array(
|
|
253
|
-
z.object({
|
|
254
|
-
deposit_id: z.number().transform(BigInt),
|
|
255
|
-
fees: z.array(boostPoolAmount)
|
|
256
|
-
})
|
|
257
|
-
)
|
|
258
|
-
})
|
|
259
|
-
)
|
|
260
|
-
);
|
|
261
|
-
export {
|
|
262
|
-
broker,
|
|
263
|
-
brokerRequestSwapDepositAddress,
|
|
264
|
-
cfAccountInfo,
|
|
265
|
-
cfBoostPoolDetails,
|
|
266
|
-
cfBoostPoolPendingFees,
|
|
267
|
-
cfBoostPoolsDepth,
|
|
268
|
-
cfEnvironment,
|
|
269
|
-
cfFundingEnvironment,
|
|
270
|
-
cfIngressEgressEnvironment,
|
|
271
|
-
cfPoolOrders,
|
|
272
|
-
cfPoolPriceV2,
|
|
273
|
-
cfPoolsEnvironment,
|
|
274
|
-
cfSupportedAsssets,
|
|
275
|
-
cfSwapRate,
|
|
276
|
-
cfSwapRateV2,
|
|
277
|
-
cfSwappingEnvironment,
|
|
278
|
-
chainGetBlockHash,
|
|
279
|
-
hexString,
|
|
280
|
-
liquidityProvider,
|
|
281
|
-
numberOrHex,
|
|
282
|
-
rpcResponse,
|
|
283
|
-
stateGetMetadata,
|
|
284
|
-
stateGetRuntimeVersion,
|
|
285
|
-
u256,
|
|
286
|
-
unregistered,
|
|
287
|
-
validator
|
|
288
|
-
};
|
|
File without changes
|