@chainflip/utils 2.1.0 → 2.1.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,6 @@ const chainflipAssets = [
7
7
  "Wbtc",
8
8
  "Flip",
9
9
  "Eth",
10
- "Dot",
11
10
  "Btc",
12
11
  "ArbUsdc",
13
12
  "ArbUsdt",
@@ -19,16 +18,7 @@ const chainflipAssets = [
19
18
  "HubUsdt",
20
19
  "HubUsdc"
21
20
  ];
22
- const assetSymbols = [
23
- "USDC",
24
- "USDT",
25
- "WBTC",
26
- "FLIP",
27
- "DOT",
28
- "ETH",
29
- "BTC",
30
- "SOL"
31
- ];
21
+ const legacyChainflipAssets = ["Dot"];
32
22
  const priceAssets = [
33
23
  "Btc",
34
24
  "Eth",
@@ -38,17 +28,15 @@ const priceAssets = [
38
28
  "Usd",
39
29
  "Fine"
40
30
  ];
41
- /** @deprecated use `assetSymbols` instead */
42
- const rpcAssets = assetSymbols;
43
31
  const baseChainflipAssets = chainflipAssets.filter((asset) => asset !== "Usdc");
44
32
  const chainflipEvmChains = ["Ethereum", "Arbitrum"];
45
33
  const chainflipChains = [
46
34
  ...chainflipEvmChains,
47
35
  "Bitcoin",
48
- "Polkadot",
49
36
  "Solana",
50
37
  "Assethub"
51
38
  ];
39
+ const legacyChainflipChains = ["Polkadot"];
52
40
  const chainflipNetworks = [
53
41
  "backspin",
54
42
  "sisyphos",
@@ -58,11 +46,11 @@ const chainflipNetworks = [
58
46
  const addressTypes = [
59
47
  "Eth",
60
48
  "Btc",
61
- "Dot",
62
49
  "Arb",
63
50
  "Sol",
64
51
  "Hub"
65
52
  ];
53
+ const legacyAddressTypes = ["Dot"];
66
54
  function readAssetValue(map, asset) {
67
55
  return map[assetConstants[asset].chain][assetConstants[asset].symbol];
68
56
  }
@@ -70,100 +58,88 @@ const assetConstants = {
70
58
  Eth: {
71
59
  chain: "Ethereum",
72
60
  symbol: "ETH",
73
- rpcAsset: "ETH",
74
61
  decimals: 18
75
62
  },
76
63
  Flip: {
77
64
  chain: "Ethereum",
78
65
  symbol: "FLIP",
79
- rpcAsset: "FLIP",
80
66
  decimals: 18
81
67
  },
82
68
  Usdc: {
83
69
  chain: "Ethereum",
84
70
  symbol: "USDC",
85
- rpcAsset: "USDC",
86
71
  decimals: 6
87
72
  },
88
73
  Usdt: {
89
74
  chain: "Ethereum",
90
75
  symbol: "USDT",
91
- rpcAsset: "USDT",
92
76
  decimals: 6
93
77
  },
94
78
  Wbtc: {
95
79
  chain: "Ethereum",
96
80
  symbol: "WBTC",
97
- rpcAsset: "WBTC",
98
81
  decimals: 8
99
82
  },
100
- Dot: {
101
- chain: "Polkadot",
102
- symbol: "DOT",
103
- rpcAsset: "DOT",
104
- decimals: 10
105
- },
106
83
  Btc: {
107
84
  chain: "Bitcoin",
108
85
  symbol: "BTC",
109
- rpcAsset: "BTC",
110
86
  decimals: 8
111
87
  },
112
88
  ArbUsdc: {
113
89
  chain: "Arbitrum",
114
90
  symbol: "USDC",
115
- rpcAsset: "USDC",
116
91
  decimals: 6
117
92
  },
118
93
  ArbUsdt: {
119
94
  chain: "Arbitrum",
120
95
  symbol: "USDT",
121
- rpcAsset: "USDT",
122
96
  decimals: 6
123
97
  },
124
98
  ArbEth: {
125
99
  chain: "Arbitrum",
126
100
  symbol: "ETH",
127
- rpcAsset: "ETH",
128
101
  decimals: 18
129
102
  },
130
103
  Sol: {
131
104
  chain: "Solana",
132
105
  symbol: "SOL",
133
- rpcAsset: "SOL",
134
106
  decimals: 9
135
107
  },
136
108
  SolUsdc: {
137
109
  chain: "Solana",
138
110
  symbol: "USDC",
139
- rpcAsset: "USDC",
140
111
  decimals: 6
141
112
  },
142
113
  SolUsdt: {
143
114
  chain: "Solana",
144
115
  symbol: "USDT",
145
- rpcAsset: "USDT",
146
116
  decimals: 6
147
117
  },
148
118
  HubDot: {
149
119
  chain: "Assethub",
150
120
  symbol: "DOT",
151
- rpcAsset: "DOT",
152
121
  decimals: 10
153
122
  },
154
123
  HubUsdc: {
155
124
  chain: "Assethub",
156
125
  symbol: "USDC",
157
- rpcAsset: "USDC",
158
126
  decimals: 6
159
127
  },
160
128
  HubUsdt: {
161
129
  chain: "Assethub",
162
130
  symbol: "USDT",
163
- rpcAsset: "USDT",
164
131
  decimals: 6
165
132
  }
166
133
  };
134
+ const anyAssetConstants = {
135
+ ...assetConstants,
136
+ Dot: {
137
+ chain: "Polkadot",
138
+ symbol: "DOT",
139
+ decimals: 10
140
+ }
141
+ };
142
+ const assetSymbols = Object.values(assetConstants).map((a) => a.symbol).filter((s, i, arr) => arr.indexOf(s) === i);
167
143
  const chainConstants = {
168
144
  Ethereum: {
169
145
  chainflipAssets: [
@@ -289,10 +265,6 @@ const internalAssetToRpcAsset = {
289
265
  chain: "Ethereum",
290
266
  asset: "WBTC"
291
267
  },
292
- Dot: {
293
- chain: "Polkadot",
294
- asset: "DOT"
295
- },
296
268
  Btc: {
297
269
  chain: "Bitcoin",
298
270
  asset: "BTC"
@@ -334,9 +306,15 @@ const internalAssetToRpcAsset = {
334
306
  asset: "USDC"
335
307
  }
336
308
  };
309
+ const anyInternalAssetToRpcAsset = {
310
+ ...internalAssetToRpcAsset,
311
+ Dot: {
312
+ chain: "Polkadot",
313
+ asset: "DOT"
314
+ }
315
+ };
337
316
  const chainContractId = {
338
317
  Ethereum: 1,
339
- Polkadot: 2,
340
318
  Bitcoin: 3,
341
319
  Arbitrum: 4,
342
320
  Solana: 5,
@@ -346,7 +324,6 @@ const assetContractId = {
346
324
  Eth: 1,
347
325
  Flip: 2,
348
326
  Usdc: 3,
349
- Dot: 4,
350
327
  Usdt: 8,
351
328
  Btc: 5,
352
329
  ArbEth: 6,
@@ -390,6 +367,12 @@ function getInternalAsset(asset, assert = true) {
390
367
  if (assert) throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
391
368
  return null;
392
369
  }
370
+ function getAnyInternalAsset(asset, assert = true) {
371
+ switch (asset.chain) {
372
+ case "Polkadot": if (asset.asset === "DOT") return "Dot";
373
+ default: return getInternalAsset(asset, assert);
374
+ }
375
+ }
393
376
  function isValidAssetAndChain(assetAndChain) {
394
377
  return getInternalAsset(assetAndChain, false) !== null;
395
378
  }
@@ -418,7 +401,6 @@ const chainflipAssetToPriceAssetMap = {
418
401
  HubUsdc: "Usdc",
419
402
  Usdt: "Usdt",
420
403
  HubUsdt: "Usdt",
421
- Dot: null,
422
404
  Flip: null,
423
405
  HubDot: null,
424
406
  Wbtc: "Btc"
@@ -426,6 +408,8 @@ const chainflipAssetToPriceAssetMap = {
426
408
 
427
409
  //#endregion
428
410
  exports.addressTypes = addressTypes;
411
+ exports.anyAssetConstants = anyAssetConstants;
412
+ exports.anyInternalAssetToRpcAsset = anyInternalAssetToRpcAsset;
429
413
  exports.assetConstants = assetConstants;
430
414
  exports.assetContractId = assetContractId;
431
415
  exports.assetSymbols = assetSymbols;
@@ -437,10 +421,13 @@ exports.chainflipAssets = chainflipAssets;
437
421
  exports.chainflipChains = chainflipChains;
438
422
  exports.chainflipEvmChains = chainflipEvmChains;
439
423
  exports.chainflipNetworks = chainflipNetworks;
424
+ exports.getAnyInternalAsset = getAnyInternalAsset;
440
425
  exports.getInternalAsset = getInternalAsset;
441
426
  exports.getInternalAssets = getInternalAssets;
442
427
  exports.internalAssetToRpcAsset = internalAssetToRpcAsset;
443
428
  exports.isValidAssetAndChain = isValidAssetAndChain;
429
+ exports.legacyAddressTypes = legacyAddressTypes;
430
+ exports.legacyChainflipAssets = legacyChainflipAssets;
431
+ exports.legacyChainflipChains = legacyChainflipChains;
444
432
  exports.priceAssets = priceAssets;
445
- exports.readAssetValue = readAssetValue;
446
- exports.rpcAssets = rpcAssets;
433
+ exports.readAssetValue = readAssetValue;
@@ -1,43 +1,67 @@
1
1
  //#region src/chainflip.d.ts
2
- declare const chainflipAssets: readonly ["Usdc", "Usdt", "Wbtc", "Flip", "Eth", "Dot", "Btc", "ArbUsdc", "ArbUsdt", "ArbEth", "Sol", "SolUsdc", "SolUsdt", "HubDot", "HubUsdt", "HubUsdc"];
2
+ declare const chainflipAssets: readonly ["Usdc", "Usdt", "Wbtc", "Flip", "Eth", "Btc", "ArbUsdc", "ArbUsdt", "ArbEth", "Sol", "SolUsdc", "SolUsdt", "HubDot", "HubUsdt", "HubUsdc"];
3
+ declare const legacyChainflipAssets: readonly ["Dot"];
3
4
  type ChainflipAsset = (typeof chainflipAssets)[number];
4
- declare const assetSymbols: readonly ["USDC", "USDT", "WBTC", "FLIP", "DOT", "ETH", "BTC", "SOL"];
5
+ type LegacyChainflipAsset = (typeof legacyChainflipAssets)[number];
6
+ type AnyChainflipAsset = ChainflipAsset | LegacyChainflipAsset;
5
7
  declare const priceAssets: readonly ["Btc", "Eth", "Sol", "Usdc", "Usdt", "Usd", "Fine"];
6
8
  type PriceAsset = (typeof priceAssets)[number];
7
- /** @deprecated use `assetSymbols` instead */
8
- declare const rpcAssets: readonly ["USDC", "USDT", "WBTC", "FLIP", "DOT", "ETH", "BTC", "SOL"];
9
- type AssetSymbol = (typeof assetSymbols)[number];
10
- /** @deprecated use `AssetSymbol` instead */
11
- type RpcAsset = AssetSymbol;
12
9
  type BaseChainflipAsset = Exclude<ChainflipAsset, 'Usdc'>;
10
+ type AnyBaseChainflipAsset = Exclude<AnyChainflipAsset, 'Usdc'>;
11
+ type NonDeprecatedBaseChainflipAsset = Exclude<BaseChainflipAsset, LegacyChainflipAsset>;
13
12
  declare const baseChainflipAssets: BaseChainflipAsset[];
14
13
  declare const chainflipEvmChains: readonly ["Ethereum", "Arbitrum"];
15
14
  type ChainflipEvmChain = (typeof chainflipEvmChains)[number];
16
- declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Polkadot", "Solana", "Assethub"];
15
+ declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Solana", "Assethub"];
17
16
  type ChainflipChain = (typeof chainflipChains)[number];
17
+ declare const legacyChainflipChains: readonly ["Polkadot"];
18
+ type LegacyChainflipChain = (typeof legacyChainflipChains)[number];
19
+ type AnyChainflipChain = ChainflipChain | LegacyChainflipChain;
18
20
  declare const chainflipNetworks: readonly ["backspin", "sisyphos", "perseverance", "mainnet"];
19
21
  type ChainflipNetwork = (typeof chainflipNetworks)[number];
20
- declare const addressTypes: readonly ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
22
+ declare const addressTypes: readonly ["Eth", "Btc", "Arb", "Sol", "Hub"];
21
23
  type AddressType = (typeof addressTypes)[number];
22
- type AssetOfChain<C extends Exclude<ChainflipChain, 'Polkadot'>> = (typeof chainConstants)[C]['assets'][number];
23
- type ChainAssetMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in AssetOfChain<C>]: T } };
24
- type BaseChainAssetMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in Exclude<BaseChainflipAsset, 'Dot'> as Extract<(typeof assetConstants)[A], {
24
+ declare const legacyAddressTypes: readonly ["Dot"];
25
+ type LegacyAddressType = (typeof legacyAddressTypes)[number];
26
+ type AnyAddressType = AddressType | LegacyAddressType;
27
+ type AssetOfChain<C extends ChainflipChain> = (typeof chainConstants)[C]['assets'][number];
28
+ type AnyAssetOfChain<C extends AnyChainflipChain> = (typeof chainConstants)[C]['assets'][number];
29
+ type ChainAssetMap<T> = { [C in ChainflipChain]: { [A in AssetOfChain<C>]: T } };
30
+ type AnyChainAssetMap<T> = { [C in AnyChainflipChain]: { [A in AnyAssetOfChain<C>]: T } };
31
+ type BaseChainAssetMap<T> = { [C in ChainflipChain]: { [A in BaseChainflipAsset as Extract<(typeof assetConstants)[A], {
32
+ chain: C;
33
+ }>['symbol']]: T } };
34
+ type AnyBaseChainAssetMap<T> = { [C in AnyChainflipChain]: { [A in BaseChainflipAsset as Extract<(typeof anyAssetConstants)[A], {
25
35
  chain: C;
26
36
  }>['symbol']]: T } };
27
- type AssetAndChain = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in keyof ChainAssetMap<unknown>[C]]: {
37
+ type AssetAndChain = { [C in ChainflipChain]: { [A in keyof ChainAssetMap<unknown>[C]]: {
28
38
  chain: C;
29
39
  asset: A;
30
- } }[keyof ChainAssetMap<unknown>[C]] }[Exclude<ChainflipChain, 'Polkadot'>];
40
+ } }[keyof ChainAssetMap<unknown>[C]] }[ChainflipChain];
41
+ type AnyAssetAndChain = { [C in AnyChainflipChain]: { [A in keyof AnyChainAssetMap<unknown>[C]]: {
42
+ chain: C;
43
+ asset: A;
44
+ } }[keyof AnyChainAssetMap<unknown>[C]] }[AnyChainflipChain];
31
45
  type BaseAssetAndChain = Exclude<AssetAndChain, {
32
46
  chain: 'Ethereum';
33
47
  asset: 'USDC';
34
48
  }>;
35
- type ChainMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: T };
36
- type InternalAssetMap<T> = { [A in Exclude<ChainflipAsset, 'Dot'>]: T };
49
+ type AnyBaseAssetAndChain = Exclude<AnyAssetAndChain, {
50
+ chain: 'Ethereum';
51
+ asset: 'USDC';
52
+ }>;
53
+ type ChainMap<T> = { [C in ChainflipChain]: T };
54
+ type AnyChainMap<T> = { [C in AnyChainflipChain]: T };
55
+ type InternalAssetMap<T> = { [A in ChainflipAsset]: T };
56
+ type AnyInternalAssetMap<T> = { [A in AnyChainflipAsset]: T };
37
57
  type UncheckedAssetAndChain = {
38
58
  chain: ChainflipChain;
39
59
  asset: AssetSymbol;
40
60
  };
61
+ type AnyUncheckedAssetAndChain = {
62
+ chain: AnyChainflipChain;
63
+ asset: AssetSymbol;
64
+ };
41
65
  declare function readAssetValue<T>(map: ChainAssetMap<T>, asset: ChainflipAsset | BaseChainflipAsset): T;
42
66
  declare function readAssetValue<T>(map: BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
43
67
  declare function readAssetValue<T>(map: ChainAssetMap<T> | BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
@@ -45,100 +69,163 @@ declare const assetConstants: {
45
69
  readonly Eth: {
46
70
  readonly chain: "Ethereum";
47
71
  readonly symbol: "ETH";
48
- readonly rpcAsset: "ETH";
49
72
  readonly decimals: 18;
50
73
  };
51
74
  readonly Flip: {
52
75
  readonly chain: "Ethereum";
53
76
  readonly symbol: "FLIP";
54
- readonly rpcAsset: "FLIP";
55
77
  readonly decimals: 18;
56
78
  };
57
79
  readonly Usdc: {
58
80
  readonly chain: "Ethereum";
59
81
  readonly symbol: "USDC";
60
- readonly rpcAsset: "USDC";
61
82
  readonly decimals: 6;
62
83
  };
63
84
  readonly Usdt: {
64
85
  readonly chain: "Ethereum";
65
86
  readonly symbol: "USDT";
66
- readonly rpcAsset: "USDT";
67
87
  readonly decimals: 6;
68
88
  };
69
89
  readonly Wbtc: {
70
90
  readonly chain: "Ethereum";
71
91
  readonly symbol: "WBTC";
72
- readonly rpcAsset: "WBTC";
73
92
  readonly decimals: 8;
74
93
  };
94
+ readonly Btc: {
95
+ readonly chain: "Bitcoin";
96
+ readonly symbol: "BTC";
97
+ readonly decimals: 8;
98
+ };
99
+ readonly ArbUsdc: {
100
+ readonly chain: "Arbitrum";
101
+ readonly symbol: "USDC";
102
+ readonly decimals: 6;
103
+ };
104
+ readonly ArbUsdt: {
105
+ readonly chain: "Arbitrum";
106
+ readonly symbol: "USDT";
107
+ readonly decimals: 6;
108
+ };
109
+ readonly ArbEth: {
110
+ readonly chain: "Arbitrum";
111
+ readonly symbol: "ETH";
112
+ readonly decimals: 18;
113
+ };
114
+ readonly Sol: {
115
+ readonly chain: "Solana";
116
+ readonly symbol: "SOL";
117
+ readonly decimals: 9;
118
+ };
119
+ readonly SolUsdc: {
120
+ readonly chain: "Solana";
121
+ readonly symbol: "USDC";
122
+ readonly decimals: 6;
123
+ };
124
+ readonly SolUsdt: {
125
+ readonly chain: "Solana";
126
+ readonly symbol: "USDT";
127
+ readonly decimals: 6;
128
+ };
129
+ readonly HubDot: {
130
+ readonly chain: "Assethub";
131
+ readonly symbol: "DOT";
132
+ readonly decimals: 10;
133
+ };
134
+ readonly HubUsdc: {
135
+ readonly chain: "Assethub";
136
+ readonly symbol: "USDC";
137
+ readonly decimals: 6;
138
+ };
139
+ readonly HubUsdt: {
140
+ readonly chain: "Assethub";
141
+ readonly symbol: "USDT";
142
+ readonly decimals: 6;
143
+ };
144
+ };
145
+ declare const anyAssetConstants: {
75
146
  readonly Dot: {
76
147
  readonly chain: "Polkadot";
77
148
  readonly symbol: "DOT";
78
- readonly rpcAsset: "DOT";
79
149
  readonly decimals: 10;
80
150
  };
151
+ readonly Eth: {
152
+ readonly chain: "Ethereum";
153
+ readonly symbol: "ETH";
154
+ readonly decimals: 18;
155
+ };
156
+ readonly Flip: {
157
+ readonly chain: "Ethereum";
158
+ readonly symbol: "FLIP";
159
+ readonly decimals: 18;
160
+ };
161
+ readonly Usdc: {
162
+ readonly chain: "Ethereum";
163
+ readonly symbol: "USDC";
164
+ readonly decimals: 6;
165
+ };
166
+ readonly Usdt: {
167
+ readonly chain: "Ethereum";
168
+ readonly symbol: "USDT";
169
+ readonly decimals: 6;
170
+ };
171
+ readonly Wbtc: {
172
+ readonly chain: "Ethereum";
173
+ readonly symbol: "WBTC";
174
+ readonly decimals: 8;
175
+ };
81
176
  readonly Btc: {
82
177
  readonly chain: "Bitcoin";
83
178
  readonly symbol: "BTC";
84
- readonly rpcAsset: "BTC";
85
179
  readonly decimals: 8;
86
180
  };
87
181
  readonly ArbUsdc: {
88
182
  readonly chain: "Arbitrum";
89
183
  readonly symbol: "USDC";
90
- readonly rpcAsset: "USDC";
91
184
  readonly decimals: 6;
92
185
  };
93
186
  readonly ArbUsdt: {
94
187
  readonly chain: "Arbitrum";
95
188
  readonly symbol: "USDT";
96
- readonly rpcAsset: "USDT";
97
189
  readonly decimals: 6;
98
190
  };
99
191
  readonly ArbEth: {
100
192
  readonly chain: "Arbitrum";
101
193
  readonly symbol: "ETH";
102
- readonly rpcAsset: "ETH";
103
194
  readonly decimals: 18;
104
195
  };
105
196
  readonly Sol: {
106
197
  readonly chain: "Solana";
107
198
  readonly symbol: "SOL";
108
- readonly rpcAsset: "SOL";
109
199
  readonly decimals: 9;
110
200
  };
111
201
  readonly SolUsdc: {
112
202
  readonly chain: "Solana";
113
203
  readonly symbol: "USDC";
114
- readonly rpcAsset: "USDC";
115
204
  readonly decimals: 6;
116
205
  };
117
206
  readonly SolUsdt: {
118
207
  readonly chain: "Solana";
119
208
  readonly symbol: "USDT";
120
- readonly rpcAsset: "USDT";
121
209
  readonly decimals: 6;
122
210
  };
123
211
  readonly HubDot: {
124
212
  readonly chain: "Assethub";
125
213
  readonly symbol: "DOT";
126
- readonly rpcAsset: "DOT";
127
214
  readonly decimals: 10;
128
215
  };
129
216
  readonly HubUsdc: {
130
217
  readonly chain: "Assethub";
131
218
  readonly symbol: "USDC";
132
- readonly rpcAsset: "USDC";
133
219
  readonly decimals: 6;
134
220
  };
135
221
  readonly HubUsdt: {
136
222
  readonly chain: "Assethub";
137
223
  readonly symbol: "USDT";
138
- readonly rpcAsset: "USDT";
139
224
  readonly decimals: 6;
140
225
  };
141
226
  };
227
+ declare const assetSymbols: ("ETH" | "FLIP" | "USDC" | "USDT" | "WBTC" | "BTC" | "SOL" | "DOT")[];
228
+ type AssetSymbol = (typeof assetSymbols)[number];
142
229
  declare const chainConstants: {
143
230
  readonly Ethereum: {
144
231
  readonly chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt", "Wbtc"];
@@ -189,23 +276,18 @@ declare const chainConstants: {
189
276
  readonly blockTimeSeconds: 12;
190
277
  };
191
278
  };
192
- declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain> & {
193
- Dot: {
194
- chain: 'Polkadot';
195
- asset: 'DOT';
196
- };
197
- };
198
- declare const chainContractId: ChainMap<number> & {
199
- Polkadot: 2;
200
- };
201
- declare const assetContractId: InternalAssetMap<number> & {
202
- Dot: 4;
203
- };
279
+ declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
280
+ declare const anyInternalAssetToRpcAsset: AnyInternalAssetMap<AnyAssetAndChain>;
281
+ declare const chainContractId: ChainMap<number>;
282
+ declare const assetContractId: InternalAssetMap<number>;
204
283
  declare function getInternalAsset(asset: BaseAssetAndChain): BaseChainflipAsset;
205
284
  declare function getInternalAsset(asset: AssetAndChain): ChainflipAsset;
206
285
  declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
207
286
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
208
287
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
288
+ declare function getAnyInternalAsset(asset: AnyUncheckedAssetAndChain): AnyChainflipAsset;
289
+ declare function getAnyInternalAsset(asset: AnyUncheckedAssetAndChain, assert: true): AnyChainflipAsset;
290
+ declare function getAnyInternalAsset(asset: AnyUncheckedAssetAndChain, assert: boolean): AnyChainflipAsset | null;
209
291
  declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
210
292
  declare function getInternalAssets(data: {
211
293
  srcAsset: AssetSymbol;
@@ -236,4 +318,4 @@ declare function getInternalAssets(data: {
236
318
  };
237
319
  declare const chainflipAssetToPriceAssetMap: Record<ChainflipAsset, Exclude<PriceAsset, 'Usd'> | null>;
238
320
  //#endregion
239
- export { AddressType, AssetAndChain, AssetOfChain, AssetSymbol, BaseAssetAndChain, BaseChainAssetMap, BaseChainflipAsset, ChainAssetMap, ChainMap, ChainflipAsset, ChainflipChain, ChainflipEvmChain, ChainflipNetwork, InternalAssetMap, PriceAsset, RpcAsset, UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
321
+ export { AddressType, AnyAddressType, AnyAssetAndChain, AnyAssetOfChain, AnyBaseAssetAndChain, AnyBaseChainAssetMap, AnyBaseChainflipAsset, AnyChainAssetMap, AnyChainMap, AnyChainflipAsset, AnyChainflipChain, AnyInternalAssetMap, AnyUncheckedAssetAndChain, AssetAndChain, AssetOfChain, AssetSymbol, BaseAssetAndChain, BaseChainAssetMap, BaseChainflipAsset, ChainAssetMap, ChainMap, ChainflipAsset, ChainflipChain, ChainflipEvmChain, ChainflipNetwork, InternalAssetMap, LegacyAddressType, LegacyChainflipAsset, LegacyChainflipChain, NonDeprecatedBaseChainflipAsset, PriceAsset, UncheckedAssetAndChain, addressTypes, anyAssetConstants, anyInternalAssetToRpcAsset, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getAnyInternalAsset, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, legacyAddressTypes, legacyChainflipAssets, legacyChainflipChains, priceAssets, readAssetValue };
@@ -1,43 +1,67 @@
1
1
  //#region src/chainflip.d.ts
2
- declare const chainflipAssets: readonly ["Usdc", "Usdt", "Wbtc", "Flip", "Eth", "Dot", "Btc", "ArbUsdc", "ArbUsdt", "ArbEth", "Sol", "SolUsdc", "SolUsdt", "HubDot", "HubUsdt", "HubUsdc"];
2
+ declare const chainflipAssets: readonly ["Usdc", "Usdt", "Wbtc", "Flip", "Eth", "Btc", "ArbUsdc", "ArbUsdt", "ArbEth", "Sol", "SolUsdc", "SolUsdt", "HubDot", "HubUsdt", "HubUsdc"];
3
+ declare const legacyChainflipAssets: readonly ["Dot"];
3
4
  type ChainflipAsset = (typeof chainflipAssets)[number];
4
- declare const assetSymbols: readonly ["USDC", "USDT", "WBTC", "FLIP", "DOT", "ETH", "BTC", "SOL"];
5
+ type LegacyChainflipAsset = (typeof legacyChainflipAssets)[number];
6
+ type AnyChainflipAsset = ChainflipAsset | LegacyChainflipAsset;
5
7
  declare const priceAssets: readonly ["Btc", "Eth", "Sol", "Usdc", "Usdt", "Usd", "Fine"];
6
8
  type PriceAsset = (typeof priceAssets)[number];
7
- /** @deprecated use `assetSymbols` instead */
8
- declare const rpcAssets: readonly ["USDC", "USDT", "WBTC", "FLIP", "DOT", "ETH", "BTC", "SOL"];
9
- type AssetSymbol = (typeof assetSymbols)[number];
10
- /** @deprecated use `AssetSymbol` instead */
11
- type RpcAsset = AssetSymbol;
12
9
  type BaseChainflipAsset = Exclude<ChainflipAsset, 'Usdc'>;
10
+ type AnyBaseChainflipAsset = Exclude<AnyChainflipAsset, 'Usdc'>;
11
+ type NonDeprecatedBaseChainflipAsset = Exclude<BaseChainflipAsset, LegacyChainflipAsset>;
13
12
  declare const baseChainflipAssets: BaseChainflipAsset[];
14
13
  declare const chainflipEvmChains: readonly ["Ethereum", "Arbitrum"];
15
14
  type ChainflipEvmChain = (typeof chainflipEvmChains)[number];
16
- declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Polkadot", "Solana", "Assethub"];
15
+ declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Solana", "Assethub"];
17
16
  type ChainflipChain = (typeof chainflipChains)[number];
17
+ declare const legacyChainflipChains: readonly ["Polkadot"];
18
+ type LegacyChainflipChain = (typeof legacyChainflipChains)[number];
19
+ type AnyChainflipChain = ChainflipChain | LegacyChainflipChain;
18
20
  declare const chainflipNetworks: readonly ["backspin", "sisyphos", "perseverance", "mainnet"];
19
21
  type ChainflipNetwork = (typeof chainflipNetworks)[number];
20
- declare const addressTypes: readonly ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
22
+ declare const addressTypes: readonly ["Eth", "Btc", "Arb", "Sol", "Hub"];
21
23
  type AddressType = (typeof addressTypes)[number];
22
- type AssetOfChain<C extends Exclude<ChainflipChain, 'Polkadot'>> = (typeof chainConstants)[C]['assets'][number];
23
- type ChainAssetMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in AssetOfChain<C>]: T } };
24
- type BaseChainAssetMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in Exclude<BaseChainflipAsset, 'Dot'> as Extract<(typeof assetConstants)[A], {
24
+ declare const legacyAddressTypes: readonly ["Dot"];
25
+ type LegacyAddressType = (typeof legacyAddressTypes)[number];
26
+ type AnyAddressType = AddressType | LegacyAddressType;
27
+ type AssetOfChain<C extends ChainflipChain> = (typeof chainConstants)[C]['assets'][number];
28
+ type AnyAssetOfChain<C extends AnyChainflipChain> = (typeof chainConstants)[C]['assets'][number];
29
+ type ChainAssetMap<T> = { [C in ChainflipChain]: { [A in AssetOfChain<C>]: T } };
30
+ type AnyChainAssetMap<T> = { [C in AnyChainflipChain]: { [A in AnyAssetOfChain<C>]: T } };
31
+ type BaseChainAssetMap<T> = { [C in ChainflipChain]: { [A in BaseChainflipAsset as Extract<(typeof assetConstants)[A], {
32
+ chain: C;
33
+ }>['symbol']]: T } };
34
+ type AnyBaseChainAssetMap<T> = { [C in AnyChainflipChain]: { [A in BaseChainflipAsset as Extract<(typeof anyAssetConstants)[A], {
25
35
  chain: C;
26
36
  }>['symbol']]: T } };
27
- type AssetAndChain = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in keyof ChainAssetMap<unknown>[C]]: {
37
+ type AssetAndChain = { [C in ChainflipChain]: { [A in keyof ChainAssetMap<unknown>[C]]: {
28
38
  chain: C;
29
39
  asset: A;
30
- } }[keyof ChainAssetMap<unknown>[C]] }[Exclude<ChainflipChain, 'Polkadot'>];
40
+ } }[keyof ChainAssetMap<unknown>[C]] }[ChainflipChain];
41
+ type AnyAssetAndChain = { [C in AnyChainflipChain]: { [A in keyof AnyChainAssetMap<unknown>[C]]: {
42
+ chain: C;
43
+ asset: A;
44
+ } }[keyof AnyChainAssetMap<unknown>[C]] }[AnyChainflipChain];
31
45
  type BaseAssetAndChain = Exclude<AssetAndChain, {
32
46
  chain: 'Ethereum';
33
47
  asset: 'USDC';
34
48
  }>;
35
- type ChainMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: T };
36
- type InternalAssetMap<T> = { [A in Exclude<ChainflipAsset, 'Dot'>]: T };
49
+ type AnyBaseAssetAndChain = Exclude<AnyAssetAndChain, {
50
+ chain: 'Ethereum';
51
+ asset: 'USDC';
52
+ }>;
53
+ type ChainMap<T> = { [C in ChainflipChain]: T };
54
+ type AnyChainMap<T> = { [C in AnyChainflipChain]: T };
55
+ type InternalAssetMap<T> = { [A in ChainflipAsset]: T };
56
+ type AnyInternalAssetMap<T> = { [A in AnyChainflipAsset]: T };
37
57
  type UncheckedAssetAndChain = {
38
58
  chain: ChainflipChain;
39
59
  asset: AssetSymbol;
40
60
  };
61
+ type AnyUncheckedAssetAndChain = {
62
+ chain: AnyChainflipChain;
63
+ asset: AssetSymbol;
64
+ };
41
65
  declare function readAssetValue<T>(map: ChainAssetMap<T>, asset: ChainflipAsset | BaseChainflipAsset): T;
42
66
  declare function readAssetValue<T>(map: BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
43
67
  declare function readAssetValue<T>(map: ChainAssetMap<T> | BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
@@ -45,100 +69,163 @@ declare const assetConstants: {
45
69
  readonly Eth: {
46
70
  readonly chain: "Ethereum";
47
71
  readonly symbol: "ETH";
48
- readonly rpcAsset: "ETH";
49
72
  readonly decimals: 18;
50
73
  };
51
74
  readonly Flip: {
52
75
  readonly chain: "Ethereum";
53
76
  readonly symbol: "FLIP";
54
- readonly rpcAsset: "FLIP";
55
77
  readonly decimals: 18;
56
78
  };
57
79
  readonly Usdc: {
58
80
  readonly chain: "Ethereum";
59
81
  readonly symbol: "USDC";
60
- readonly rpcAsset: "USDC";
61
82
  readonly decimals: 6;
62
83
  };
63
84
  readonly Usdt: {
64
85
  readonly chain: "Ethereum";
65
86
  readonly symbol: "USDT";
66
- readonly rpcAsset: "USDT";
67
87
  readonly decimals: 6;
68
88
  };
69
89
  readonly Wbtc: {
70
90
  readonly chain: "Ethereum";
71
91
  readonly symbol: "WBTC";
72
- readonly rpcAsset: "WBTC";
73
92
  readonly decimals: 8;
74
93
  };
94
+ readonly Btc: {
95
+ readonly chain: "Bitcoin";
96
+ readonly symbol: "BTC";
97
+ readonly decimals: 8;
98
+ };
99
+ readonly ArbUsdc: {
100
+ readonly chain: "Arbitrum";
101
+ readonly symbol: "USDC";
102
+ readonly decimals: 6;
103
+ };
104
+ readonly ArbUsdt: {
105
+ readonly chain: "Arbitrum";
106
+ readonly symbol: "USDT";
107
+ readonly decimals: 6;
108
+ };
109
+ readonly ArbEth: {
110
+ readonly chain: "Arbitrum";
111
+ readonly symbol: "ETH";
112
+ readonly decimals: 18;
113
+ };
114
+ readonly Sol: {
115
+ readonly chain: "Solana";
116
+ readonly symbol: "SOL";
117
+ readonly decimals: 9;
118
+ };
119
+ readonly SolUsdc: {
120
+ readonly chain: "Solana";
121
+ readonly symbol: "USDC";
122
+ readonly decimals: 6;
123
+ };
124
+ readonly SolUsdt: {
125
+ readonly chain: "Solana";
126
+ readonly symbol: "USDT";
127
+ readonly decimals: 6;
128
+ };
129
+ readonly HubDot: {
130
+ readonly chain: "Assethub";
131
+ readonly symbol: "DOT";
132
+ readonly decimals: 10;
133
+ };
134
+ readonly HubUsdc: {
135
+ readonly chain: "Assethub";
136
+ readonly symbol: "USDC";
137
+ readonly decimals: 6;
138
+ };
139
+ readonly HubUsdt: {
140
+ readonly chain: "Assethub";
141
+ readonly symbol: "USDT";
142
+ readonly decimals: 6;
143
+ };
144
+ };
145
+ declare const anyAssetConstants: {
75
146
  readonly Dot: {
76
147
  readonly chain: "Polkadot";
77
148
  readonly symbol: "DOT";
78
- readonly rpcAsset: "DOT";
79
149
  readonly decimals: 10;
80
150
  };
151
+ readonly Eth: {
152
+ readonly chain: "Ethereum";
153
+ readonly symbol: "ETH";
154
+ readonly decimals: 18;
155
+ };
156
+ readonly Flip: {
157
+ readonly chain: "Ethereum";
158
+ readonly symbol: "FLIP";
159
+ readonly decimals: 18;
160
+ };
161
+ readonly Usdc: {
162
+ readonly chain: "Ethereum";
163
+ readonly symbol: "USDC";
164
+ readonly decimals: 6;
165
+ };
166
+ readonly Usdt: {
167
+ readonly chain: "Ethereum";
168
+ readonly symbol: "USDT";
169
+ readonly decimals: 6;
170
+ };
171
+ readonly Wbtc: {
172
+ readonly chain: "Ethereum";
173
+ readonly symbol: "WBTC";
174
+ readonly decimals: 8;
175
+ };
81
176
  readonly Btc: {
82
177
  readonly chain: "Bitcoin";
83
178
  readonly symbol: "BTC";
84
- readonly rpcAsset: "BTC";
85
179
  readonly decimals: 8;
86
180
  };
87
181
  readonly ArbUsdc: {
88
182
  readonly chain: "Arbitrum";
89
183
  readonly symbol: "USDC";
90
- readonly rpcAsset: "USDC";
91
184
  readonly decimals: 6;
92
185
  };
93
186
  readonly ArbUsdt: {
94
187
  readonly chain: "Arbitrum";
95
188
  readonly symbol: "USDT";
96
- readonly rpcAsset: "USDT";
97
189
  readonly decimals: 6;
98
190
  };
99
191
  readonly ArbEth: {
100
192
  readonly chain: "Arbitrum";
101
193
  readonly symbol: "ETH";
102
- readonly rpcAsset: "ETH";
103
194
  readonly decimals: 18;
104
195
  };
105
196
  readonly Sol: {
106
197
  readonly chain: "Solana";
107
198
  readonly symbol: "SOL";
108
- readonly rpcAsset: "SOL";
109
199
  readonly decimals: 9;
110
200
  };
111
201
  readonly SolUsdc: {
112
202
  readonly chain: "Solana";
113
203
  readonly symbol: "USDC";
114
- readonly rpcAsset: "USDC";
115
204
  readonly decimals: 6;
116
205
  };
117
206
  readonly SolUsdt: {
118
207
  readonly chain: "Solana";
119
208
  readonly symbol: "USDT";
120
- readonly rpcAsset: "USDT";
121
209
  readonly decimals: 6;
122
210
  };
123
211
  readonly HubDot: {
124
212
  readonly chain: "Assethub";
125
213
  readonly symbol: "DOT";
126
- readonly rpcAsset: "DOT";
127
214
  readonly decimals: 10;
128
215
  };
129
216
  readonly HubUsdc: {
130
217
  readonly chain: "Assethub";
131
218
  readonly symbol: "USDC";
132
- readonly rpcAsset: "USDC";
133
219
  readonly decimals: 6;
134
220
  };
135
221
  readonly HubUsdt: {
136
222
  readonly chain: "Assethub";
137
223
  readonly symbol: "USDT";
138
- readonly rpcAsset: "USDT";
139
224
  readonly decimals: 6;
140
225
  };
141
226
  };
227
+ declare const assetSymbols: ("ETH" | "FLIP" | "USDC" | "USDT" | "WBTC" | "BTC" | "SOL" | "DOT")[];
228
+ type AssetSymbol = (typeof assetSymbols)[number];
142
229
  declare const chainConstants: {
143
230
  readonly Ethereum: {
144
231
  readonly chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt", "Wbtc"];
@@ -189,23 +276,18 @@ declare const chainConstants: {
189
276
  readonly blockTimeSeconds: 12;
190
277
  };
191
278
  };
192
- declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain> & {
193
- Dot: {
194
- chain: 'Polkadot';
195
- asset: 'DOT';
196
- };
197
- };
198
- declare const chainContractId: ChainMap<number> & {
199
- Polkadot: 2;
200
- };
201
- declare const assetContractId: InternalAssetMap<number> & {
202
- Dot: 4;
203
- };
279
+ declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
280
+ declare const anyInternalAssetToRpcAsset: AnyInternalAssetMap<AnyAssetAndChain>;
281
+ declare const chainContractId: ChainMap<number>;
282
+ declare const assetContractId: InternalAssetMap<number>;
204
283
  declare function getInternalAsset(asset: BaseAssetAndChain): BaseChainflipAsset;
205
284
  declare function getInternalAsset(asset: AssetAndChain): ChainflipAsset;
206
285
  declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
207
286
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
208
287
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
288
+ declare function getAnyInternalAsset(asset: AnyUncheckedAssetAndChain): AnyChainflipAsset;
289
+ declare function getAnyInternalAsset(asset: AnyUncheckedAssetAndChain, assert: true): AnyChainflipAsset;
290
+ declare function getAnyInternalAsset(asset: AnyUncheckedAssetAndChain, assert: boolean): AnyChainflipAsset | null;
209
291
  declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
210
292
  declare function getInternalAssets(data: {
211
293
  srcAsset: AssetSymbol;
@@ -236,4 +318,4 @@ declare function getInternalAssets(data: {
236
318
  };
237
319
  declare const chainflipAssetToPriceAssetMap: Record<ChainflipAsset, Exclude<PriceAsset, 'Usd'> | null>;
238
320
  //#endregion
239
- export { AddressType, AssetAndChain, AssetOfChain, AssetSymbol, BaseAssetAndChain, BaseChainAssetMap, BaseChainflipAsset, ChainAssetMap, ChainMap, ChainflipAsset, ChainflipChain, ChainflipEvmChain, ChainflipNetwork, InternalAssetMap, PriceAsset, RpcAsset, UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
321
+ export { AddressType, AnyAddressType, AnyAssetAndChain, AnyAssetOfChain, AnyBaseAssetAndChain, AnyBaseChainAssetMap, AnyBaseChainflipAsset, AnyChainAssetMap, AnyChainMap, AnyChainflipAsset, AnyChainflipChain, AnyInternalAssetMap, AnyUncheckedAssetAndChain, AssetAndChain, AssetOfChain, AssetSymbol, BaseAssetAndChain, BaseChainAssetMap, BaseChainflipAsset, ChainAssetMap, ChainMap, ChainflipAsset, ChainflipChain, ChainflipEvmChain, ChainflipNetwork, InternalAssetMap, LegacyAddressType, LegacyChainflipAsset, LegacyChainflipChain, NonDeprecatedBaseChainflipAsset, PriceAsset, UncheckedAssetAndChain, addressTypes, anyAssetConstants, anyInternalAssetToRpcAsset, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getAnyInternalAsset, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, legacyAddressTypes, legacyChainflipAssets, legacyChainflipChains, priceAssets, readAssetValue };
@@ -5,7 +5,6 @@ const chainflipAssets = [
5
5
  "Wbtc",
6
6
  "Flip",
7
7
  "Eth",
8
- "Dot",
9
8
  "Btc",
10
9
  "ArbUsdc",
11
10
  "ArbUsdt",
@@ -17,16 +16,7 @@ const chainflipAssets = [
17
16
  "HubUsdt",
18
17
  "HubUsdc"
19
18
  ];
20
- const assetSymbols = [
21
- "USDC",
22
- "USDT",
23
- "WBTC",
24
- "FLIP",
25
- "DOT",
26
- "ETH",
27
- "BTC",
28
- "SOL"
29
- ];
19
+ const legacyChainflipAssets = ["Dot"];
30
20
  const priceAssets = [
31
21
  "Btc",
32
22
  "Eth",
@@ -36,17 +26,15 @@ const priceAssets = [
36
26
  "Usd",
37
27
  "Fine"
38
28
  ];
39
- /** @deprecated use `assetSymbols` instead */
40
- const rpcAssets = assetSymbols;
41
29
  const baseChainflipAssets = chainflipAssets.filter((asset) => asset !== "Usdc");
42
30
  const chainflipEvmChains = ["Ethereum", "Arbitrum"];
43
31
  const chainflipChains = [
44
32
  ...chainflipEvmChains,
45
33
  "Bitcoin",
46
- "Polkadot",
47
34
  "Solana",
48
35
  "Assethub"
49
36
  ];
37
+ const legacyChainflipChains = ["Polkadot"];
50
38
  const chainflipNetworks = [
51
39
  "backspin",
52
40
  "sisyphos",
@@ -56,11 +44,11 @@ const chainflipNetworks = [
56
44
  const addressTypes = [
57
45
  "Eth",
58
46
  "Btc",
59
- "Dot",
60
47
  "Arb",
61
48
  "Sol",
62
49
  "Hub"
63
50
  ];
51
+ const legacyAddressTypes = ["Dot"];
64
52
  function readAssetValue(map, asset) {
65
53
  return map[assetConstants[asset].chain][assetConstants[asset].symbol];
66
54
  }
@@ -68,100 +56,88 @@ const assetConstants = {
68
56
  Eth: {
69
57
  chain: "Ethereum",
70
58
  symbol: "ETH",
71
- rpcAsset: "ETH",
72
59
  decimals: 18
73
60
  },
74
61
  Flip: {
75
62
  chain: "Ethereum",
76
63
  symbol: "FLIP",
77
- rpcAsset: "FLIP",
78
64
  decimals: 18
79
65
  },
80
66
  Usdc: {
81
67
  chain: "Ethereum",
82
68
  symbol: "USDC",
83
- rpcAsset: "USDC",
84
69
  decimals: 6
85
70
  },
86
71
  Usdt: {
87
72
  chain: "Ethereum",
88
73
  symbol: "USDT",
89
- rpcAsset: "USDT",
90
74
  decimals: 6
91
75
  },
92
76
  Wbtc: {
93
77
  chain: "Ethereum",
94
78
  symbol: "WBTC",
95
- rpcAsset: "WBTC",
96
79
  decimals: 8
97
80
  },
98
- Dot: {
99
- chain: "Polkadot",
100
- symbol: "DOT",
101
- rpcAsset: "DOT",
102
- decimals: 10
103
- },
104
81
  Btc: {
105
82
  chain: "Bitcoin",
106
83
  symbol: "BTC",
107
- rpcAsset: "BTC",
108
84
  decimals: 8
109
85
  },
110
86
  ArbUsdc: {
111
87
  chain: "Arbitrum",
112
88
  symbol: "USDC",
113
- rpcAsset: "USDC",
114
89
  decimals: 6
115
90
  },
116
91
  ArbUsdt: {
117
92
  chain: "Arbitrum",
118
93
  symbol: "USDT",
119
- rpcAsset: "USDT",
120
94
  decimals: 6
121
95
  },
122
96
  ArbEth: {
123
97
  chain: "Arbitrum",
124
98
  symbol: "ETH",
125
- rpcAsset: "ETH",
126
99
  decimals: 18
127
100
  },
128
101
  Sol: {
129
102
  chain: "Solana",
130
103
  symbol: "SOL",
131
- rpcAsset: "SOL",
132
104
  decimals: 9
133
105
  },
134
106
  SolUsdc: {
135
107
  chain: "Solana",
136
108
  symbol: "USDC",
137
- rpcAsset: "USDC",
138
109
  decimals: 6
139
110
  },
140
111
  SolUsdt: {
141
112
  chain: "Solana",
142
113
  symbol: "USDT",
143
- rpcAsset: "USDT",
144
114
  decimals: 6
145
115
  },
146
116
  HubDot: {
147
117
  chain: "Assethub",
148
118
  symbol: "DOT",
149
- rpcAsset: "DOT",
150
119
  decimals: 10
151
120
  },
152
121
  HubUsdc: {
153
122
  chain: "Assethub",
154
123
  symbol: "USDC",
155
- rpcAsset: "USDC",
156
124
  decimals: 6
157
125
  },
158
126
  HubUsdt: {
159
127
  chain: "Assethub",
160
128
  symbol: "USDT",
161
- rpcAsset: "USDT",
162
129
  decimals: 6
163
130
  }
164
131
  };
132
+ const anyAssetConstants = {
133
+ ...assetConstants,
134
+ Dot: {
135
+ chain: "Polkadot",
136
+ symbol: "DOT",
137
+ decimals: 10
138
+ }
139
+ };
140
+ const assetSymbols = Object.values(assetConstants).map((a) => a.symbol).filter((s, i, arr) => arr.indexOf(s) === i);
165
141
  const chainConstants = {
166
142
  Ethereum: {
167
143
  chainflipAssets: [
@@ -287,10 +263,6 @@ const internalAssetToRpcAsset = {
287
263
  chain: "Ethereum",
288
264
  asset: "WBTC"
289
265
  },
290
- Dot: {
291
- chain: "Polkadot",
292
- asset: "DOT"
293
- },
294
266
  Btc: {
295
267
  chain: "Bitcoin",
296
268
  asset: "BTC"
@@ -332,9 +304,15 @@ const internalAssetToRpcAsset = {
332
304
  asset: "USDC"
333
305
  }
334
306
  };
307
+ const anyInternalAssetToRpcAsset = {
308
+ ...internalAssetToRpcAsset,
309
+ Dot: {
310
+ chain: "Polkadot",
311
+ asset: "DOT"
312
+ }
313
+ };
335
314
  const chainContractId = {
336
315
  Ethereum: 1,
337
- Polkadot: 2,
338
316
  Bitcoin: 3,
339
317
  Arbitrum: 4,
340
318
  Solana: 5,
@@ -344,7 +322,6 @@ const assetContractId = {
344
322
  Eth: 1,
345
323
  Flip: 2,
346
324
  Usdc: 3,
347
- Dot: 4,
348
325
  Usdt: 8,
349
326
  Btc: 5,
350
327
  ArbEth: 6,
@@ -388,6 +365,12 @@ function getInternalAsset(asset, assert = true) {
388
365
  if (assert) throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
389
366
  return null;
390
367
  }
368
+ function getAnyInternalAsset(asset, assert = true) {
369
+ switch (asset.chain) {
370
+ case "Polkadot": if (asset.asset === "DOT") return "Dot";
371
+ default: return getInternalAsset(asset, assert);
372
+ }
373
+ }
391
374
  function isValidAssetAndChain(assetAndChain) {
392
375
  return getInternalAsset(assetAndChain, false) !== null;
393
376
  }
@@ -416,11 +399,10 @@ const chainflipAssetToPriceAssetMap = {
416
399
  HubUsdc: "Usdc",
417
400
  Usdt: "Usdt",
418
401
  HubUsdt: "Usdt",
419
- Dot: null,
420
402
  Flip: null,
421
403
  HubDot: null,
422
404
  Wbtc: "Btc"
423
405
  };
424
406
 
425
407
  //#endregion
426
- export { addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
408
+ export { addressTypes, anyAssetConstants, anyInternalAssetToRpcAsset, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getAnyInternalAsset, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, legacyAddressTypes, legacyChainflipAssets, legacyChainflipChains, priceAssets, readAssetValue };
package/dist/tickMath.cjs CHANGED
@@ -13,11 +13,11 @@ const FULL_TICK_RANGE = {
13
13
  };
14
14
  const tickToRate = (tick, baseAsset) => {
15
15
  const baseRate = new bignumber_js.default(1.0001 ** tick);
16
- const rateDecimals = require_chainflip.assetConstants.Usdc.decimals - require_chainflip.assetConstants[baseAsset].decimals;
16
+ const rateDecimals = require_chainflip.anyAssetConstants.Usdc.decimals - require_chainflip.anyAssetConstants[baseAsset].decimals;
17
17
  return baseRate.shiftedBy(-rateDecimals).toNumber();
18
18
  };
19
19
  const rateToTick = (rate, baseAsset) => {
20
- const rateDecimals = require_chainflip.assetConstants.Usdc.decimals - require_chainflip.assetConstants[baseAsset].decimals;
20
+ const rateDecimals = require_chainflip.anyAssetConstants.Usdc.decimals - require_chainflip.anyAssetConstants[baseAsset].decimals;
21
21
  const rawRate = new bignumber_js.default(rate).shiftedBy(rateDecimals);
22
22
  let tick = Math.log(rawRate.toNumber()) / Math.log(1.0001);
23
23
  tick = Math.round(tick * 1e6) / 1e6;
@@ -1,4 +1,4 @@
1
- import { ChainflipAsset } from "./chainflip.cjs";
1
+ import { AnyChainflipAsset } from "./chainflip.cjs";
2
2
  import BigNumber from "bignumber.js";
3
3
 
4
4
  //#region src/tickMath.d.ts
@@ -8,8 +8,8 @@ declare const FULL_TICK_RANGE: {
8
8
  start: number;
9
9
  end: number;
10
10
  };
11
- declare const tickToRate: (tick: number, baseAsset: ChainflipAsset) => number;
12
- declare const rateToTick: (rate: BigNumber.Value, baseAsset: ChainflipAsset) => number;
11
+ declare const tickToRate: (tick: number, baseAsset: AnyChainflipAsset) => number;
12
+ declare const rateToTick: (rate: BigNumber.Value, baseAsset: AnyChainflipAsset) => number;
13
13
  declare const sqrtPriceX96ToPrice: (amount: string) => BigNumber;
14
14
  declare const priceX128ToPrice: (amount: string) => BigNumber;
15
15
  //#endregion
@@ -1,4 +1,4 @@
1
- import { ChainflipAsset } from "./chainflip.mjs";
1
+ import { AnyChainflipAsset } from "./chainflip.mjs";
2
2
  import BigNumber from "bignumber.js";
3
3
 
4
4
  //#region src/tickMath.d.ts
@@ -8,8 +8,8 @@ declare const FULL_TICK_RANGE: {
8
8
  start: number;
9
9
  end: number;
10
10
  };
11
- declare const tickToRate: (tick: number, baseAsset: ChainflipAsset) => number;
12
- declare const rateToTick: (rate: BigNumber.Value, baseAsset: ChainflipAsset) => number;
11
+ declare const tickToRate: (tick: number, baseAsset: AnyChainflipAsset) => number;
12
+ declare const rateToTick: (rate: BigNumber.Value, baseAsset: AnyChainflipAsset) => number;
13
13
  declare const sqrtPriceX96ToPrice: (amount: string) => BigNumber;
14
14
  declare const priceX128ToPrice: (amount: string) => BigNumber;
15
15
  //#endregion
package/dist/tickMath.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { assetConstants } from "./chainflip.mjs";
1
+ import { anyAssetConstants } from "./chainflip.mjs";
2
2
  import BigNumber from "bignumber.js";
3
3
 
4
4
  //#region src/tickMath.ts
@@ -10,11 +10,11 @@ const FULL_TICK_RANGE = {
10
10
  };
11
11
  const tickToRate = (tick, baseAsset) => {
12
12
  const baseRate = new BigNumber(1.0001 ** tick);
13
- const rateDecimals = assetConstants.Usdc.decimals - assetConstants[baseAsset].decimals;
13
+ const rateDecimals = anyAssetConstants.Usdc.decimals - anyAssetConstants[baseAsset].decimals;
14
14
  return baseRate.shiftedBy(-rateDecimals).toNumber();
15
15
  };
16
16
  const rateToTick = (rate, baseAsset) => {
17
- const rateDecimals = assetConstants.Usdc.decimals - assetConstants[baseAsset].decimals;
17
+ const rateDecimals = anyAssetConstants.Usdc.decimals - anyAssetConstants[baseAsset].decimals;
18
18
  const rawRate = new BigNumber(rate).shiftedBy(rateDecimals);
19
19
  let tick = Math.log(rawRate.toNumber()) / Math.log(1.0001);
20
20
  tick = Math.round(tick * 1e6) / 1e6;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "2.1.0",
3
+ "version": "2.1.2-beta.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",