@chainflip/utils 0.8.2 → 0.8.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/base58.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  CHARSET,
3
3
  decode,
4
4
  encode
5
- } from "./chunk-HOUVS5DD.js";
6
- import "./chunk-W23CNAUU.js";
5
+ } from "./chunk-3P6TXYEI.js";
6
+ import "./chunk-XGNPN5CY.js";
7
7
  import "./chunk-ZHIKNZLU.js";
8
8
  import "./chunk-HBIFE4XN.js";
9
9
  export {
package/dist/bytes.cjs CHANGED
@@ -88,14 +88,11 @@ var decodeBytesWithCharset = (input, charset) => {
88
88
  const bytes = input.split("").map((char) => charMap[char]);
89
89
  return new Uint8Array(convertBase(bytes, charset.length, 256));
90
90
  };
91
- var addPrefix = (input) => {
92
- const [, bytes] = /^(?:0x)?([a-f\d]*)$/i.exec(input) || [];
93
- assert(bytes, "Invalid hex string");
94
- return `0x${bytes}`;
95
- };
96
91
  function reverseBytes(input) {
97
- const reversed = bytesToHex(hexToBytes(addPrefix(input)).reverse());
98
- return input.startsWith("0x") ? reversed : reversed.slice(2);
92
+ const bytes = /^(?:0x)?([\da-f]+)$/gi.exec(input)?.[1];
93
+ assert(bytes && bytes.length % 2 === 0 && bytes.length > 0, "Invalid hex string");
94
+ const reversed = bytes.match(/.{2}/g).reverse().join("");
95
+ return input.startsWith("0x") ? `0x${reversed}` : reversed;
99
96
  }
100
97
  // Annotate the CommonJS export names for ESM import in node:
101
98
  0 && (module.exports = {
package/dist/bytes.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  encodeBytesWithCharset,
5
5
  hexToBytes,
6
6
  reverseBytes
7
- } from "./chunk-W23CNAUU.js";
7
+ } from "./chunk-XGNPN5CY.js";
8
8
  import "./chunk-ZHIKNZLU.js";
9
9
  import "./chunk-HBIFE4XN.js";
10
10
  export {
@@ -23,6 +23,7 @@ __export(chainflip_exports, {
23
23
  addressTypes: () => addressTypes,
24
24
  assetConstants: () => assetConstants,
25
25
  assetContractId: () => assetContractId,
26
+ assetSymbols: () => assetSymbols,
26
27
  baseChainflipAssets: () => baseChainflipAssets,
27
28
  chainConstants: () => chainConstants,
28
29
  chainContractId: () => chainContractId,
@@ -59,7 +60,8 @@ var chainflipAssets = [
59
60
  "HubUsdt",
60
61
  "HubUsdc"
61
62
  ];
62
- var rpcAssets = ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
63
+ var assetSymbols = ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
64
+ var rpcAssets = assetSymbols;
63
65
  var baseChainflipAssets = chainflipAssets.filter(
64
66
  (asset) => asset !== "Usdc"
65
67
  );
@@ -75,113 +77,132 @@ var chainflipNetworks = ["backspin", "sisyphos", "perseverance", "mainnet"];
75
77
  var addressTypes = ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
76
78
  function readAssetValue(map, asset) {
77
79
  const chainValues = map[assetConstants[asset].chain];
78
- return chainValues[assetConstants[asset].rpcAsset];
80
+ return chainValues[assetConstants[asset].symbol];
79
81
  }
80
82
  var assetConstants = {
81
83
  Eth: {
82
84
  chain: "Ethereum",
85
+ symbol: "ETH",
83
86
  rpcAsset: "ETH",
84
87
  decimals: 18
85
88
  },
86
89
  Flip: {
87
90
  chain: "Ethereum",
91
+ symbol: "FLIP",
88
92
  rpcAsset: "FLIP",
89
93
  decimals: 18
90
94
  },
91
95
  Usdc: {
92
96
  chain: "Ethereum",
97
+ symbol: "USDC",
93
98
  rpcAsset: "USDC",
94
99
  decimals: 6
95
100
  },
96
101
  Usdt: {
97
102
  chain: "Ethereum",
103
+ symbol: "USDT",
98
104
  rpcAsset: "USDT",
99
105
  decimals: 6
100
106
  },
101
107
  Dot: {
102
108
  chain: "Polkadot",
109
+ symbol: "DOT",
103
110
  rpcAsset: "DOT",
104
111
  decimals: 10
105
112
  },
106
113
  Btc: {
107
114
  chain: "Bitcoin",
115
+ symbol: "BTC",
108
116
  rpcAsset: "BTC",
109
117
  decimals: 8
110
118
  },
111
119
  ArbUsdc: {
112
120
  chain: "Arbitrum",
121
+ symbol: "USDC",
113
122
  rpcAsset: "USDC",
114
123
  decimals: 6
115
124
  },
116
125
  ArbEth: {
117
126
  chain: "Arbitrum",
127
+ symbol: "ETH",
118
128
  rpcAsset: "ETH",
119
129
  decimals: 18
120
130
  },
121
131
  Sol: {
122
132
  chain: "Solana",
133
+ symbol: "SOL",
123
134
  rpcAsset: "SOL",
124
135
  decimals: 9
125
136
  },
126
137
  SolUsdc: {
127
138
  chain: "Solana",
139
+ symbol: "USDC",
128
140
  rpcAsset: "USDC",
129
141
  decimals: 6
130
142
  },
131
143
  HubDot: {
132
144
  chain: "Assethub",
145
+ symbol: "DOT",
133
146
  rpcAsset: "DOT",
134
147
  decimals: 10
135
148
  },
136
149
  HubUsdc: {
137
150
  chain: "Assethub",
151
+ symbol: "USDC",
138
152
  rpcAsset: "USDC",
139
153
  decimals: 6
140
154
  },
141
155
  HubUsdt: {
142
156
  chain: "Assethub",
157
+ symbol: "USDT",
143
158
  rpcAsset: "USDT",
144
159
  decimals: 6
145
160
  }
146
161
  };
147
162
  var chainConstants = {
148
163
  Ethereum: {
149
- assets: ["Eth", "Flip", "Usdc", "Usdt"],
164
+ chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt"],
165
+ assets: ["ETH", "FLIP", "USDC", "USDT"],
150
166
  rpcAssets: ["ETH", "FLIP", "USDC", "USDT"],
151
167
  gasAsset: "Eth",
152
168
  addressType: "Eth",
153
169
  blockTimeSeconds: 12
154
170
  },
155
171
  Polkadot: {
156
- assets: ["Dot"],
172
+ chainflipAssets: ["Dot"],
173
+ assets: ["DOT"],
157
174
  rpcAssets: ["DOT"],
158
175
  gasAsset: "Dot",
159
176
  addressType: "Dot",
160
177
  blockTimeSeconds: 6
161
178
  },
162
179
  Bitcoin: {
163
- assets: ["Btc"],
180
+ chainflipAssets: ["Btc"],
181
+ assets: ["BTC"],
164
182
  rpcAssets: ["BTC"],
165
183
  gasAsset: "Btc",
166
184
  addressType: "Btc",
167
185
  blockTimeSeconds: 10 * 60
168
186
  },
169
187
  Arbitrum: {
170
- assets: ["ArbUsdc", "ArbEth"],
188
+ chainflipAssets: ["ArbUsdc", "ArbEth"],
189
+ assets: ["USDC", "ETH"],
171
190
  rpcAssets: ["USDC", "ETH"],
172
191
  gasAsset: "ArbEth",
173
192
  addressType: "Arb",
174
193
  blockTimeSeconds: 0.26
175
194
  },
176
195
  Solana: {
177
- assets: ["Sol", "SolUsdc"],
196
+ chainflipAssets: ["Sol", "SolUsdc"],
197
+ assets: ["SOL", "USDC"],
178
198
  rpcAssets: ["SOL", "USDC"],
179
199
  gasAsset: "Sol",
180
200
  addressType: "Sol",
181
201
  blockTimeSeconds: 0.8
182
202
  },
183
203
  Assethub: {
184
- assets: ["HubDot", "HubUsdt", "HubUsdc"],
204
+ chainflipAssets: ["HubDot", "HubUsdt", "HubUsdc"],
205
+ assets: ["DOT", "USDT", "USDC"],
185
206
  rpcAssets: ["DOT", "USDT", "USDC"],
186
207
  gasAsset: "HubDot",
187
208
  addressType: "Hub",
@@ -229,7 +250,7 @@ var assetContractId = {
229
250
  function isValidAssetAndChain(assetAndChain) {
230
251
  const { asset, chain } = assetAndChain;
231
252
  if (!(chain in chainConstants)) return false;
232
- const validAssets = chainConstants[chain].rpcAssets;
253
+ const validAssets = chainConstants[chain].assets;
233
254
  return validAssets.includes(asset);
234
255
  }
235
256
  function getInternalAsset(asset, assert = true) {
@@ -285,6 +306,7 @@ function getInternalAssets({
285
306
  addressTypes,
286
307
  assetConstants,
287
308
  assetContractId,
309
+ assetSymbols,
288
310
  baseChainflipAssets,
289
311
  chainConstants,
290
312
  chainContractId,
@@ -1,7 +1,11 @@
1
1
  declare const chainflipAssets: readonly ["Usdc", "Usdt", "Flip", "Eth", "Dot", "Btc", "ArbUsdc", "ArbEth", "Sol", "SolUsdc", "HubDot", "HubUsdt", "HubUsdc"];
2
2
  type ChainflipAsset = (typeof chainflipAssets)[number];
3
+ declare const assetSymbols: readonly ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
4
+ /** @deprecated use `assetSymbols` instead */
3
5
  declare const rpcAssets: readonly ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
4
- type RpcAsset = (typeof rpcAssets)[number];
6
+ type AssetSymbol = (typeof assetSymbols)[number];
7
+ /** @deprecated use `AssetSymbol` instead */
8
+ type RpcAsset = AssetSymbol;
5
9
  type BaseChainflipAsset = Exclude<ChainflipAsset, 'Usdc'>;
6
10
  declare const baseChainflipAssets: BaseChainflipAsset[];
7
11
  declare const chainflipEvmChains: readonly ["Ethereum", "Arbitrum"];
@@ -15,12 +19,14 @@ type AddressType = (typeof addressTypes)[number];
15
19
  type AssetOfChain<C extends ChainflipChain> = (typeof chainConstants)[C]['assets'][number];
16
20
  type ChainAssetMap<T> = {
17
21
  [C in ChainflipChain]: {
18
- [A in (typeof assetConstants)[AssetOfChain<C>]['rpcAsset']]: T;
22
+ [A in AssetOfChain<C>]: T;
19
23
  };
20
24
  };
21
25
  type BaseChainAssetMap<T> = {
22
26
  [C in ChainflipChain]: {
23
- [A in (typeof assetConstants)[Exclude<AssetOfChain<C>, 'Usdc'>]['rpcAsset']]: T;
27
+ [A in BaseChainflipAsset as Extract<(typeof assetConstants)[A], {
28
+ chain: C;
29
+ }>['symbol']]: T;
24
30
  };
25
31
  };
26
32
  type AssetAndChain = {
@@ -29,9 +35,15 @@ type AssetAndChain = {
29
35
  asset: keyof ChainAssetMap<unknown>[C];
30
36
  };
31
37
  }[ChainflipChain];
38
+ type ChainMap<T> = {
39
+ [C in ChainflipChain]: T;
40
+ };
41
+ type InternalAssetMap<T> = {
42
+ [A in ChainflipAsset]: T;
43
+ };
32
44
  type UncheckedAssetAndChain = {
33
45
  chain: ChainflipChain;
34
- asset: RpcAsset;
46
+ asset: AssetSymbol;
35
47
  };
36
48
  declare function readAssetValue<T>(map: ChainAssetMap<T>, asset: ChainflipAsset | BaseChainflipAsset): T;
37
49
  declare function readAssetValue<T>(map: BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
@@ -39,147 +51,166 @@ declare function readAssetValue<T>(map: ChainAssetMap<T> | BaseChainAssetMap<T>,
39
51
  declare const assetConstants: {
40
52
  readonly Eth: {
41
53
  readonly chain: "Ethereum";
54
+ readonly symbol: "ETH";
42
55
  readonly rpcAsset: "ETH";
43
56
  readonly decimals: 18;
44
57
  };
45
58
  readonly Flip: {
46
59
  readonly chain: "Ethereum";
60
+ readonly symbol: "FLIP";
47
61
  readonly rpcAsset: "FLIP";
48
62
  readonly decimals: 18;
49
63
  };
50
64
  readonly Usdc: {
51
65
  readonly chain: "Ethereum";
66
+ readonly symbol: "USDC";
52
67
  readonly rpcAsset: "USDC";
53
68
  readonly decimals: 6;
54
69
  };
55
70
  readonly Usdt: {
56
71
  readonly chain: "Ethereum";
72
+ readonly symbol: "USDT";
57
73
  readonly rpcAsset: "USDT";
58
74
  readonly decimals: 6;
59
75
  };
60
76
  readonly Dot: {
61
77
  readonly chain: "Polkadot";
78
+ readonly symbol: "DOT";
62
79
  readonly rpcAsset: "DOT";
63
80
  readonly decimals: 10;
64
81
  };
65
82
  readonly Btc: {
66
83
  readonly chain: "Bitcoin";
84
+ readonly symbol: "BTC";
67
85
  readonly rpcAsset: "BTC";
68
86
  readonly decimals: 8;
69
87
  };
70
88
  readonly ArbUsdc: {
71
89
  readonly chain: "Arbitrum";
90
+ readonly symbol: "USDC";
72
91
  readonly rpcAsset: "USDC";
73
92
  readonly decimals: 6;
74
93
  };
75
94
  readonly ArbEth: {
76
95
  readonly chain: "Arbitrum";
96
+ readonly symbol: "ETH";
77
97
  readonly rpcAsset: "ETH";
78
98
  readonly decimals: 18;
79
99
  };
80
100
  readonly Sol: {
81
101
  readonly chain: "Solana";
102
+ readonly symbol: "SOL";
82
103
  readonly rpcAsset: "SOL";
83
104
  readonly decimals: 9;
84
105
  };
85
106
  readonly SolUsdc: {
86
107
  readonly chain: "Solana";
108
+ readonly symbol: "USDC";
87
109
  readonly rpcAsset: "USDC";
88
110
  readonly decimals: 6;
89
111
  };
90
112
  readonly HubDot: {
91
113
  readonly chain: "Assethub";
114
+ readonly symbol: "DOT";
92
115
  readonly rpcAsset: "DOT";
93
116
  readonly decimals: 10;
94
117
  };
95
118
  readonly HubUsdc: {
96
119
  readonly chain: "Assethub";
120
+ readonly symbol: "USDC";
97
121
  readonly rpcAsset: "USDC";
98
122
  readonly decimals: 6;
99
123
  };
100
124
  readonly HubUsdt: {
101
125
  readonly chain: "Assethub";
126
+ readonly symbol: "USDT";
102
127
  readonly rpcAsset: "USDT";
103
128
  readonly decimals: 6;
104
129
  };
105
130
  };
106
131
  declare const chainConstants: {
107
132
  readonly Ethereum: {
108
- readonly assets: ["Eth", "Flip", "Usdc", "Usdt"];
133
+ readonly chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt"];
134
+ readonly assets: ["ETH", "FLIP", "USDC", "USDT"];
109
135
  readonly rpcAssets: ["ETH", "FLIP", "USDC", "USDT"];
110
136
  readonly gasAsset: "Eth";
111
137
  readonly addressType: "Eth";
112
138
  readonly blockTimeSeconds: 12;
113
139
  };
114
140
  readonly Polkadot: {
115
- readonly assets: ["Dot"];
141
+ readonly chainflipAssets: ["Dot"];
142
+ readonly assets: ["DOT"];
116
143
  readonly rpcAssets: ["DOT"];
117
144
  readonly gasAsset: "Dot";
118
145
  readonly addressType: "Dot";
119
146
  readonly blockTimeSeconds: 6;
120
147
  };
121
148
  readonly Bitcoin: {
122
- readonly assets: ["Btc"];
149
+ readonly chainflipAssets: ["Btc"];
150
+ readonly assets: ["BTC"];
123
151
  readonly rpcAssets: ["BTC"];
124
152
  readonly gasAsset: "Btc";
125
153
  readonly addressType: "Btc";
126
154
  readonly blockTimeSeconds: number;
127
155
  };
128
156
  readonly Arbitrum: {
129
- readonly assets: ["ArbUsdc", "ArbEth"];
157
+ readonly chainflipAssets: ["ArbUsdc", "ArbEth"];
158
+ readonly assets: ["USDC", "ETH"];
130
159
  readonly rpcAssets: ["USDC", "ETH"];
131
160
  readonly gasAsset: "ArbEth";
132
161
  readonly addressType: "Arb";
133
162
  readonly blockTimeSeconds: 0.26;
134
163
  };
135
164
  readonly Solana: {
136
- readonly assets: ["Sol", "SolUsdc"];
165
+ readonly chainflipAssets: ["Sol", "SolUsdc"];
166
+ readonly assets: ["SOL", "USDC"];
137
167
  readonly rpcAssets: ["SOL", "USDC"];
138
168
  readonly gasAsset: "Sol";
139
169
  readonly addressType: "Sol";
140
170
  readonly blockTimeSeconds: 0.8;
141
171
  };
142
172
  readonly Assethub: {
143
- readonly assets: ["HubDot", "HubUsdt", "HubUsdc"];
173
+ readonly chainflipAssets: ["HubDot", "HubUsdt", "HubUsdc"];
174
+ readonly assets: ["DOT", "USDT", "USDC"];
144
175
  readonly rpcAssets: ["DOT", "USDT", "USDC"];
145
176
  readonly gasAsset: "HubDot";
146
177
  readonly addressType: "Hub";
147
178
  readonly blockTimeSeconds: 12;
148
179
  };
149
180
  };
150
- declare const internalAssetToRpcAsset: Record<ChainflipAsset, AssetAndChain>;
151
- declare const chainContractId: Record<ChainflipChain, number>;
152
- declare const assetContractId: Record<ChainflipAsset, number>;
181
+ declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
182
+ declare const chainContractId: ChainMap<number>;
183
+ declare const assetContractId: InternalAssetMap<number>;
153
184
  declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
154
185
  declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
155
186
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
156
187
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
157
188
  declare function getInternalAssets(data: {
158
- srcAsset: RpcAsset;
189
+ srcAsset: AssetSymbol;
159
190
  srcChain: ChainflipChain;
160
- destAsset: RpcAsset;
191
+ destAsset: AssetSymbol;
161
192
  destChain: ChainflipChain;
162
193
  }): {
163
194
  srcAsset: ChainflipAsset;
164
195
  destAsset: ChainflipAsset;
165
196
  };
166
197
  declare function getInternalAssets(data: {
167
- srcAsset: RpcAsset;
198
+ srcAsset: AssetSymbol;
168
199
  srcChain: ChainflipChain;
169
- destAsset: RpcAsset;
200
+ destAsset: AssetSymbol;
170
201
  destChain: ChainflipChain;
171
202
  }, assert: true): {
172
203
  srcAsset: ChainflipAsset;
173
204
  destAsset: ChainflipAsset;
174
205
  };
175
206
  declare function getInternalAssets(data: {
176
- srcAsset: RpcAsset;
207
+ srcAsset: AssetSymbol;
177
208
  srcChain: ChainflipChain;
178
- destAsset: RpcAsset;
209
+ destAsset: AssetSymbol;
179
210
  destChain: ChainflipChain;
180
211
  }, assert: boolean): {
181
212
  srcAsset: ChainflipAsset | null;
182
213
  destAsset: ChainflipAsset | null;
183
214
  };
184
215
 
185
- export { type AddressType, type AssetAndChain, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
216
+ export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
@@ -1,7 +1,11 @@
1
1
  declare const chainflipAssets: readonly ["Usdc", "Usdt", "Flip", "Eth", "Dot", "Btc", "ArbUsdc", "ArbEth", "Sol", "SolUsdc", "HubDot", "HubUsdt", "HubUsdc"];
2
2
  type ChainflipAsset = (typeof chainflipAssets)[number];
3
+ declare const assetSymbols: readonly ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
4
+ /** @deprecated use `assetSymbols` instead */
3
5
  declare const rpcAssets: readonly ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
4
- type RpcAsset = (typeof rpcAssets)[number];
6
+ type AssetSymbol = (typeof assetSymbols)[number];
7
+ /** @deprecated use `AssetSymbol` instead */
8
+ type RpcAsset = AssetSymbol;
5
9
  type BaseChainflipAsset = Exclude<ChainflipAsset, 'Usdc'>;
6
10
  declare const baseChainflipAssets: BaseChainflipAsset[];
7
11
  declare const chainflipEvmChains: readonly ["Ethereum", "Arbitrum"];
@@ -15,12 +19,14 @@ type AddressType = (typeof addressTypes)[number];
15
19
  type AssetOfChain<C extends ChainflipChain> = (typeof chainConstants)[C]['assets'][number];
16
20
  type ChainAssetMap<T> = {
17
21
  [C in ChainflipChain]: {
18
- [A in (typeof assetConstants)[AssetOfChain<C>]['rpcAsset']]: T;
22
+ [A in AssetOfChain<C>]: T;
19
23
  };
20
24
  };
21
25
  type BaseChainAssetMap<T> = {
22
26
  [C in ChainflipChain]: {
23
- [A in (typeof assetConstants)[Exclude<AssetOfChain<C>, 'Usdc'>]['rpcAsset']]: T;
27
+ [A in BaseChainflipAsset as Extract<(typeof assetConstants)[A], {
28
+ chain: C;
29
+ }>['symbol']]: T;
24
30
  };
25
31
  };
26
32
  type AssetAndChain = {
@@ -29,9 +35,15 @@ type AssetAndChain = {
29
35
  asset: keyof ChainAssetMap<unknown>[C];
30
36
  };
31
37
  }[ChainflipChain];
38
+ type ChainMap<T> = {
39
+ [C in ChainflipChain]: T;
40
+ };
41
+ type InternalAssetMap<T> = {
42
+ [A in ChainflipAsset]: T;
43
+ };
32
44
  type UncheckedAssetAndChain = {
33
45
  chain: ChainflipChain;
34
- asset: RpcAsset;
46
+ asset: AssetSymbol;
35
47
  };
36
48
  declare function readAssetValue<T>(map: ChainAssetMap<T>, asset: ChainflipAsset | BaseChainflipAsset): T;
37
49
  declare function readAssetValue<T>(map: BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
@@ -39,147 +51,166 @@ declare function readAssetValue<T>(map: ChainAssetMap<T> | BaseChainAssetMap<T>,
39
51
  declare const assetConstants: {
40
52
  readonly Eth: {
41
53
  readonly chain: "Ethereum";
54
+ readonly symbol: "ETH";
42
55
  readonly rpcAsset: "ETH";
43
56
  readonly decimals: 18;
44
57
  };
45
58
  readonly Flip: {
46
59
  readonly chain: "Ethereum";
60
+ readonly symbol: "FLIP";
47
61
  readonly rpcAsset: "FLIP";
48
62
  readonly decimals: 18;
49
63
  };
50
64
  readonly Usdc: {
51
65
  readonly chain: "Ethereum";
66
+ readonly symbol: "USDC";
52
67
  readonly rpcAsset: "USDC";
53
68
  readonly decimals: 6;
54
69
  };
55
70
  readonly Usdt: {
56
71
  readonly chain: "Ethereum";
72
+ readonly symbol: "USDT";
57
73
  readonly rpcAsset: "USDT";
58
74
  readonly decimals: 6;
59
75
  };
60
76
  readonly Dot: {
61
77
  readonly chain: "Polkadot";
78
+ readonly symbol: "DOT";
62
79
  readonly rpcAsset: "DOT";
63
80
  readonly decimals: 10;
64
81
  };
65
82
  readonly Btc: {
66
83
  readonly chain: "Bitcoin";
84
+ readonly symbol: "BTC";
67
85
  readonly rpcAsset: "BTC";
68
86
  readonly decimals: 8;
69
87
  };
70
88
  readonly ArbUsdc: {
71
89
  readonly chain: "Arbitrum";
90
+ readonly symbol: "USDC";
72
91
  readonly rpcAsset: "USDC";
73
92
  readonly decimals: 6;
74
93
  };
75
94
  readonly ArbEth: {
76
95
  readonly chain: "Arbitrum";
96
+ readonly symbol: "ETH";
77
97
  readonly rpcAsset: "ETH";
78
98
  readonly decimals: 18;
79
99
  };
80
100
  readonly Sol: {
81
101
  readonly chain: "Solana";
102
+ readonly symbol: "SOL";
82
103
  readonly rpcAsset: "SOL";
83
104
  readonly decimals: 9;
84
105
  };
85
106
  readonly SolUsdc: {
86
107
  readonly chain: "Solana";
108
+ readonly symbol: "USDC";
87
109
  readonly rpcAsset: "USDC";
88
110
  readonly decimals: 6;
89
111
  };
90
112
  readonly HubDot: {
91
113
  readonly chain: "Assethub";
114
+ readonly symbol: "DOT";
92
115
  readonly rpcAsset: "DOT";
93
116
  readonly decimals: 10;
94
117
  };
95
118
  readonly HubUsdc: {
96
119
  readonly chain: "Assethub";
120
+ readonly symbol: "USDC";
97
121
  readonly rpcAsset: "USDC";
98
122
  readonly decimals: 6;
99
123
  };
100
124
  readonly HubUsdt: {
101
125
  readonly chain: "Assethub";
126
+ readonly symbol: "USDT";
102
127
  readonly rpcAsset: "USDT";
103
128
  readonly decimals: 6;
104
129
  };
105
130
  };
106
131
  declare const chainConstants: {
107
132
  readonly Ethereum: {
108
- readonly assets: ["Eth", "Flip", "Usdc", "Usdt"];
133
+ readonly chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt"];
134
+ readonly assets: ["ETH", "FLIP", "USDC", "USDT"];
109
135
  readonly rpcAssets: ["ETH", "FLIP", "USDC", "USDT"];
110
136
  readonly gasAsset: "Eth";
111
137
  readonly addressType: "Eth";
112
138
  readonly blockTimeSeconds: 12;
113
139
  };
114
140
  readonly Polkadot: {
115
- readonly assets: ["Dot"];
141
+ readonly chainflipAssets: ["Dot"];
142
+ readonly assets: ["DOT"];
116
143
  readonly rpcAssets: ["DOT"];
117
144
  readonly gasAsset: "Dot";
118
145
  readonly addressType: "Dot";
119
146
  readonly blockTimeSeconds: 6;
120
147
  };
121
148
  readonly Bitcoin: {
122
- readonly assets: ["Btc"];
149
+ readonly chainflipAssets: ["Btc"];
150
+ readonly assets: ["BTC"];
123
151
  readonly rpcAssets: ["BTC"];
124
152
  readonly gasAsset: "Btc";
125
153
  readonly addressType: "Btc";
126
154
  readonly blockTimeSeconds: number;
127
155
  };
128
156
  readonly Arbitrum: {
129
- readonly assets: ["ArbUsdc", "ArbEth"];
157
+ readonly chainflipAssets: ["ArbUsdc", "ArbEth"];
158
+ readonly assets: ["USDC", "ETH"];
130
159
  readonly rpcAssets: ["USDC", "ETH"];
131
160
  readonly gasAsset: "ArbEth";
132
161
  readonly addressType: "Arb";
133
162
  readonly blockTimeSeconds: 0.26;
134
163
  };
135
164
  readonly Solana: {
136
- readonly assets: ["Sol", "SolUsdc"];
165
+ readonly chainflipAssets: ["Sol", "SolUsdc"];
166
+ readonly assets: ["SOL", "USDC"];
137
167
  readonly rpcAssets: ["SOL", "USDC"];
138
168
  readonly gasAsset: "Sol";
139
169
  readonly addressType: "Sol";
140
170
  readonly blockTimeSeconds: 0.8;
141
171
  };
142
172
  readonly Assethub: {
143
- readonly assets: ["HubDot", "HubUsdt", "HubUsdc"];
173
+ readonly chainflipAssets: ["HubDot", "HubUsdt", "HubUsdc"];
174
+ readonly assets: ["DOT", "USDT", "USDC"];
144
175
  readonly rpcAssets: ["DOT", "USDT", "USDC"];
145
176
  readonly gasAsset: "HubDot";
146
177
  readonly addressType: "Hub";
147
178
  readonly blockTimeSeconds: 12;
148
179
  };
149
180
  };
150
- declare const internalAssetToRpcAsset: Record<ChainflipAsset, AssetAndChain>;
151
- declare const chainContractId: Record<ChainflipChain, number>;
152
- declare const assetContractId: Record<ChainflipAsset, number>;
181
+ declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
182
+ declare const chainContractId: ChainMap<number>;
183
+ declare const assetContractId: InternalAssetMap<number>;
153
184
  declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
154
185
  declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
155
186
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
156
187
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
157
188
  declare function getInternalAssets(data: {
158
- srcAsset: RpcAsset;
189
+ srcAsset: AssetSymbol;
159
190
  srcChain: ChainflipChain;
160
- destAsset: RpcAsset;
191
+ destAsset: AssetSymbol;
161
192
  destChain: ChainflipChain;
162
193
  }): {
163
194
  srcAsset: ChainflipAsset;
164
195
  destAsset: ChainflipAsset;
165
196
  };
166
197
  declare function getInternalAssets(data: {
167
- srcAsset: RpcAsset;
198
+ srcAsset: AssetSymbol;
168
199
  srcChain: ChainflipChain;
169
- destAsset: RpcAsset;
200
+ destAsset: AssetSymbol;
170
201
  destChain: ChainflipChain;
171
202
  }, assert: true): {
172
203
  srcAsset: ChainflipAsset;
173
204
  destAsset: ChainflipAsset;
174
205
  };
175
206
  declare function getInternalAssets(data: {
176
- srcAsset: RpcAsset;
207
+ srcAsset: AssetSymbol;
177
208
  srcChain: ChainflipChain;
178
- destAsset: RpcAsset;
209
+ destAsset: AssetSymbol;
179
210
  destChain: ChainflipChain;
180
211
  }, assert: boolean): {
181
212
  srcAsset: ChainflipAsset | null;
182
213
  destAsset: ChainflipAsset | null;
183
214
  };
184
215
 
185
- export { type AddressType, type AssetAndChain, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
216
+ export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
package/dist/chainflip.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  addressTypes,
3
3
  assetConstants,
4
4
  assetContractId,
5
+ assetSymbols,
5
6
  baseChainflipAssets,
6
7
  chainConstants,
7
8
  chainContractId,
@@ -15,11 +16,12 @@ import {
15
16
  isValidAssetAndChain,
16
17
  readAssetValue,
17
18
  rpcAssets
18
- } from "./chunk-3IZHLINB.js";
19
+ } from "./chunk-6LZGVCU6.js";
19
20
  export {
20
21
  addressTypes,
21
22
  assetConstants,
22
23
  assetContractId,
24
+ assetSymbols,
23
25
  baseChainflipAssets,
24
26
  chainConstants,
25
27
  chainContractId,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  decodeBytesWithCharset,
3
3
  encodeBytesWithCharset
4
- } from "./chunk-W23CNAUU.js";
4
+ } from "./chunk-XGNPN5CY.js";
5
5
 
6
6
  // src/base58.ts
7
7
  var CHARSET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@@ -20,7 +20,8 @@ var chainflipAssets = [
20
20
  "HubUsdt",
21
21
  "HubUsdc"
22
22
  ];
23
- var rpcAssets = ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
23
+ var assetSymbols = ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
24
+ var rpcAssets = assetSymbols;
24
25
  var baseChainflipAssets = chainflipAssets.filter(
25
26
  (asset) => asset !== "Usdc"
26
27
  );
@@ -36,113 +37,132 @@ var chainflipNetworks = ["backspin", "sisyphos", "perseverance", "mainnet"];
36
37
  var addressTypes = ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
37
38
  function readAssetValue(map, asset) {
38
39
  const chainValues = map[assetConstants[asset].chain];
39
- return chainValues[assetConstants[asset].rpcAsset];
40
+ return chainValues[assetConstants[asset].symbol];
40
41
  }
41
42
  var assetConstants = {
42
43
  Eth: {
43
44
  chain: "Ethereum",
45
+ symbol: "ETH",
44
46
  rpcAsset: "ETH",
45
47
  decimals: 18
46
48
  },
47
49
  Flip: {
48
50
  chain: "Ethereum",
51
+ symbol: "FLIP",
49
52
  rpcAsset: "FLIP",
50
53
  decimals: 18
51
54
  },
52
55
  Usdc: {
53
56
  chain: "Ethereum",
57
+ symbol: "USDC",
54
58
  rpcAsset: "USDC",
55
59
  decimals: 6
56
60
  },
57
61
  Usdt: {
58
62
  chain: "Ethereum",
63
+ symbol: "USDT",
59
64
  rpcAsset: "USDT",
60
65
  decimals: 6
61
66
  },
62
67
  Dot: {
63
68
  chain: "Polkadot",
69
+ symbol: "DOT",
64
70
  rpcAsset: "DOT",
65
71
  decimals: 10
66
72
  },
67
73
  Btc: {
68
74
  chain: "Bitcoin",
75
+ symbol: "BTC",
69
76
  rpcAsset: "BTC",
70
77
  decimals: 8
71
78
  },
72
79
  ArbUsdc: {
73
80
  chain: "Arbitrum",
81
+ symbol: "USDC",
74
82
  rpcAsset: "USDC",
75
83
  decimals: 6
76
84
  },
77
85
  ArbEth: {
78
86
  chain: "Arbitrum",
87
+ symbol: "ETH",
79
88
  rpcAsset: "ETH",
80
89
  decimals: 18
81
90
  },
82
91
  Sol: {
83
92
  chain: "Solana",
93
+ symbol: "SOL",
84
94
  rpcAsset: "SOL",
85
95
  decimals: 9
86
96
  },
87
97
  SolUsdc: {
88
98
  chain: "Solana",
99
+ symbol: "USDC",
89
100
  rpcAsset: "USDC",
90
101
  decimals: 6
91
102
  },
92
103
  HubDot: {
93
104
  chain: "Assethub",
105
+ symbol: "DOT",
94
106
  rpcAsset: "DOT",
95
107
  decimals: 10
96
108
  },
97
109
  HubUsdc: {
98
110
  chain: "Assethub",
111
+ symbol: "USDC",
99
112
  rpcAsset: "USDC",
100
113
  decimals: 6
101
114
  },
102
115
  HubUsdt: {
103
116
  chain: "Assethub",
117
+ symbol: "USDT",
104
118
  rpcAsset: "USDT",
105
119
  decimals: 6
106
120
  }
107
121
  };
108
122
  var chainConstants = {
109
123
  Ethereum: {
110
- assets: ["Eth", "Flip", "Usdc", "Usdt"],
124
+ chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt"],
125
+ assets: ["ETH", "FLIP", "USDC", "USDT"],
111
126
  rpcAssets: ["ETH", "FLIP", "USDC", "USDT"],
112
127
  gasAsset: "Eth",
113
128
  addressType: "Eth",
114
129
  blockTimeSeconds: 12
115
130
  },
116
131
  Polkadot: {
117
- assets: ["Dot"],
132
+ chainflipAssets: ["Dot"],
133
+ assets: ["DOT"],
118
134
  rpcAssets: ["DOT"],
119
135
  gasAsset: "Dot",
120
136
  addressType: "Dot",
121
137
  blockTimeSeconds: 6
122
138
  },
123
139
  Bitcoin: {
124
- assets: ["Btc"],
140
+ chainflipAssets: ["Btc"],
141
+ assets: ["BTC"],
125
142
  rpcAssets: ["BTC"],
126
143
  gasAsset: "Btc",
127
144
  addressType: "Btc",
128
145
  blockTimeSeconds: 10 * 60
129
146
  },
130
147
  Arbitrum: {
131
- assets: ["ArbUsdc", "ArbEth"],
148
+ chainflipAssets: ["ArbUsdc", "ArbEth"],
149
+ assets: ["USDC", "ETH"],
132
150
  rpcAssets: ["USDC", "ETH"],
133
151
  gasAsset: "ArbEth",
134
152
  addressType: "Arb",
135
153
  blockTimeSeconds: 0.26
136
154
  },
137
155
  Solana: {
138
- assets: ["Sol", "SolUsdc"],
156
+ chainflipAssets: ["Sol", "SolUsdc"],
157
+ assets: ["SOL", "USDC"],
139
158
  rpcAssets: ["SOL", "USDC"],
140
159
  gasAsset: "Sol",
141
160
  addressType: "Sol",
142
161
  blockTimeSeconds: 0.8
143
162
  },
144
163
  Assethub: {
145
- assets: ["HubDot", "HubUsdt", "HubUsdc"],
164
+ chainflipAssets: ["HubDot", "HubUsdt", "HubUsdc"],
165
+ assets: ["DOT", "USDT", "USDC"],
146
166
  rpcAssets: ["DOT", "USDT", "USDC"],
147
167
  gasAsset: "HubDot",
148
168
  addressType: "Hub",
@@ -190,7 +210,7 @@ var assetContractId = {
190
210
  function isValidAssetAndChain(assetAndChain) {
191
211
  const { asset, chain } = assetAndChain;
192
212
  if (!(chain in chainConstants)) return false;
193
- const validAssets = chainConstants[chain].rpcAssets;
213
+ const validAssets = chainConstants[chain].assets;
194
214
  return validAssets.includes(asset);
195
215
  }
196
216
  function getInternalAsset(asset, assert = true) {
@@ -244,6 +264,7 @@ function getInternalAssets({
244
264
 
245
265
  export {
246
266
  chainflipAssets,
267
+ assetSymbols,
247
268
  rpcAssets,
248
269
  baseChainflipAssets,
249
270
  chainflipEvmChains,
@@ -45,14 +45,11 @@ var decodeBytesWithCharset = (input, charset) => {
45
45
  const bytes = input.split("").map((char) => charMap[char]);
46
46
  return new Uint8Array(convertBase(bytes, charset.length, 256));
47
47
  };
48
- var addPrefix = (input) => {
49
- const [, bytes] = /^(?:0x)?([a-f\d]*)$/i.exec(input) || [];
50
- assert(bytes, "Invalid hex string");
51
- return `0x${bytes}`;
52
- };
53
48
  function reverseBytes(input) {
54
- const reversed = bytesToHex(hexToBytes(addPrefix(input)).reverse());
55
- return input.startsWith("0x") ? reversed : reversed.slice(2);
49
+ const bytes = /^(?:0x)?([\da-f]+)$/gi.exec(input)?.[1];
50
+ assert(bytes && bytes.length % 2 === 0 && bytes.length > 0, "Invalid hex string");
51
+ const reversed = bytes.match(/.{2}/g).reverse().join("");
52
+ return input.startsWith("0x") ? `0x${reversed}` : reversed;
56
53
  }
57
54
 
58
55
  export {
package/dist/ss58.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  decode,
3
3
  encode
4
- } from "./chunk-HOUVS5DD.js";
4
+ } from "./chunk-3P6TXYEI.js";
5
5
  import {
6
6
  bytesToHex,
7
7
  hexToBytes
8
- } from "./chunk-W23CNAUU.js";
8
+ } from "./chunk-XGNPN5CY.js";
9
9
  import {
10
10
  assert
11
11
  } from "./chunk-ZHIKNZLU.js";
package/dist/string.cjs CHANGED
@@ -22,6 +22,7 @@ var string_exports = {};
22
22
  __export(string_exports, {
23
23
  abbreviate: () => abbreviate,
24
24
  capitalize: () => capitalize,
25
+ isBytes: () => isBytes,
25
26
  isHex: () => isHex,
26
27
  isInteger: () => isInteger,
27
28
  split: () => split,
@@ -38,6 +39,7 @@ var split = (str, delimiter) => str.split(delimiter);
38
39
  var capitalize = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
39
40
  var uncapitalize = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
40
41
  var isHex = (str) => /^0x[\da-f]+$/i.test(str);
42
+ var isBytes = (str) => /^(0x)?[\da-f]*$/i.test(str) && str.length % 2 === 0;
41
43
  var abbreviate = (text, showLength = 4, space = false) => {
42
44
  if (typeof text !== "string") return "";
43
45
  const leftPart = text.slice(0, showLength);
@@ -56,6 +58,7 @@ var truncateString = (string, numCharacters = 20, ellipsis = true) => {
56
58
  0 && (module.exports = {
57
59
  abbreviate,
58
60
  capitalize,
61
+ isBytes,
59
62
  isHex,
60
63
  isInteger,
61
64
  split,
package/dist/string.d.cts CHANGED
@@ -9,7 +9,8 @@ declare const split: <const T extends string, D extends string>(str: T, delimite
9
9
  declare const capitalize: <const T extends string>(str: T) => Capitalize<T>;
10
10
  declare const uncapitalize: <const T extends string>(str: T) => Uncapitalize<T>;
11
11
  declare const isHex: (str: string) => str is HexString;
12
+ declare const isBytes: (str: string) => boolean;
12
13
  declare const abbreviate: (text: string | undefined | null, showLength?: number, space?: boolean) => string;
13
14
  declare const truncateString: (string: string, numCharacters?: number, ellipsis?: boolean) => string;
14
15
 
15
- export { abbreviate, capitalize, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
16
+ export { abbreviate, capitalize, isBytes, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
package/dist/string.d.ts CHANGED
@@ -9,7 +9,8 @@ declare const split: <const T extends string, D extends string>(str: T, delimite
9
9
  declare const capitalize: <const T extends string>(str: T) => Capitalize<T>;
10
10
  declare const uncapitalize: <const T extends string>(str: T) => Uncapitalize<T>;
11
11
  declare const isHex: (str: string) => str is HexString;
12
+ declare const isBytes: (str: string) => boolean;
12
13
  declare const abbreviate: (text: string | undefined | null, showLength?: number, space?: boolean) => string;
13
14
  declare const truncateString: (string: string, numCharacters?: number, ellipsis?: boolean) => string;
14
15
 
15
- export { abbreviate, capitalize, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
16
+ export { abbreviate, capitalize, isBytes, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
package/dist/string.js CHANGED
@@ -6,6 +6,7 @@ var split = (str, delimiter) => str.split(delimiter);
6
6
  var capitalize = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
7
7
  var uncapitalize = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
8
8
  var isHex = (str) => /^0x[\da-f]+$/i.test(str);
9
+ var isBytes = (str) => /^(0x)?[\da-f]*$/i.test(str) && str.length % 2 === 0;
9
10
  var abbreviate = (text, showLength = 4, space = false) => {
10
11
  if (typeof text !== "string") return "";
11
12
  const leftPart = text.slice(0, showLength);
@@ -23,6 +24,7 @@ var truncateString = (string, numCharacters = 20, ellipsis = true) => {
23
24
  export {
24
25
  abbreviate,
25
26
  capitalize,
27
+ isBytes,
26
28
  isHex,
27
29
  isInteger,
28
30
  split,
package/dist/tickMath.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/tickMath.ts
@@ -29,7 +39,7 @@ __export(tickMath_exports, {
29
39
  tickToRate: () => tickToRate
30
40
  });
31
41
  module.exports = __toCommonJS(tickMath_exports);
32
- var import_bignumber = require("bignumber.js");
42
+ var import_bignumber = __toESM(require("bignumber.js"), 1);
33
43
 
34
44
  // src/chainflip.ts
35
45
  var chainflipAssets = [
@@ -67,108 +77,127 @@ var chainflipChains = [
67
77
  var assetConstants = {
68
78
  Eth: {
69
79
  chain: "Ethereum",
80
+ symbol: "ETH",
70
81
  rpcAsset: "ETH",
71
82
  decimals: 18
72
83
  },
73
84
  Flip: {
74
85
  chain: "Ethereum",
86
+ symbol: "FLIP",
75
87
  rpcAsset: "FLIP",
76
88
  decimals: 18
77
89
  },
78
90
  Usdc: {
79
91
  chain: "Ethereum",
92
+ symbol: "USDC",
80
93
  rpcAsset: "USDC",
81
94
  decimals: 6
82
95
  },
83
96
  Usdt: {
84
97
  chain: "Ethereum",
98
+ symbol: "USDT",
85
99
  rpcAsset: "USDT",
86
100
  decimals: 6
87
101
  },
88
102
  Dot: {
89
103
  chain: "Polkadot",
104
+ symbol: "DOT",
90
105
  rpcAsset: "DOT",
91
106
  decimals: 10
92
107
  },
93
108
  Btc: {
94
109
  chain: "Bitcoin",
110
+ symbol: "BTC",
95
111
  rpcAsset: "BTC",
96
112
  decimals: 8
97
113
  },
98
114
  ArbUsdc: {
99
115
  chain: "Arbitrum",
116
+ symbol: "USDC",
100
117
  rpcAsset: "USDC",
101
118
  decimals: 6
102
119
  },
103
120
  ArbEth: {
104
121
  chain: "Arbitrum",
122
+ symbol: "ETH",
105
123
  rpcAsset: "ETH",
106
124
  decimals: 18
107
125
  },
108
126
  Sol: {
109
127
  chain: "Solana",
128
+ symbol: "SOL",
110
129
  rpcAsset: "SOL",
111
130
  decimals: 9
112
131
  },
113
132
  SolUsdc: {
114
133
  chain: "Solana",
134
+ symbol: "USDC",
115
135
  rpcAsset: "USDC",
116
136
  decimals: 6
117
137
  },
118
138
  HubDot: {
119
139
  chain: "Assethub",
140
+ symbol: "DOT",
120
141
  rpcAsset: "DOT",
121
142
  decimals: 10
122
143
  },
123
144
  HubUsdc: {
124
145
  chain: "Assethub",
146
+ symbol: "USDC",
125
147
  rpcAsset: "USDC",
126
148
  decimals: 6
127
149
  },
128
150
  HubUsdt: {
129
151
  chain: "Assethub",
152
+ symbol: "USDT",
130
153
  rpcAsset: "USDT",
131
154
  decimals: 6
132
155
  }
133
156
  };
134
157
  var chainConstants = {
135
158
  Ethereum: {
136
- assets: ["Eth", "Flip", "Usdc", "Usdt"],
159
+ chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt"],
160
+ assets: ["ETH", "FLIP", "USDC", "USDT"],
137
161
  rpcAssets: ["ETH", "FLIP", "USDC", "USDT"],
138
162
  gasAsset: "Eth",
139
163
  addressType: "Eth",
140
164
  blockTimeSeconds: 12
141
165
  },
142
166
  Polkadot: {
143
- assets: ["Dot"],
167
+ chainflipAssets: ["Dot"],
168
+ assets: ["DOT"],
144
169
  rpcAssets: ["DOT"],
145
170
  gasAsset: "Dot",
146
171
  addressType: "Dot",
147
172
  blockTimeSeconds: 6
148
173
  },
149
174
  Bitcoin: {
150
- assets: ["Btc"],
175
+ chainflipAssets: ["Btc"],
176
+ assets: ["BTC"],
151
177
  rpcAssets: ["BTC"],
152
178
  gasAsset: "Btc",
153
179
  addressType: "Btc",
154
180
  blockTimeSeconds: 10 * 60
155
181
  },
156
182
  Arbitrum: {
157
- assets: ["ArbUsdc", "ArbEth"],
183
+ chainflipAssets: ["ArbUsdc", "ArbEth"],
184
+ assets: ["USDC", "ETH"],
158
185
  rpcAssets: ["USDC", "ETH"],
159
186
  gasAsset: "ArbEth",
160
187
  addressType: "Arb",
161
188
  blockTimeSeconds: 0.26
162
189
  },
163
190
  Solana: {
164
- assets: ["Sol", "SolUsdc"],
191
+ chainflipAssets: ["Sol", "SolUsdc"],
192
+ assets: ["SOL", "USDC"],
165
193
  rpcAssets: ["SOL", "USDC"],
166
194
  gasAsset: "Sol",
167
195
  addressType: "Sol",
168
196
  blockTimeSeconds: 0.8
169
197
  },
170
198
  Assethub: {
171
- assets: ["HubDot", "HubUsdt", "HubUsdc"],
199
+ chainflipAssets: ["HubDot", "HubUsdt", "HubUsdc"],
200
+ assets: ["DOT", "USDT", "USDC"],
172
201
  rpcAssets: ["DOT", "USDT", "USDC"],
173
202
  gasAsset: "HubDot",
174
203
  addressType: "Hub",
@@ -181,20 +210,20 @@ var MIN_TICK = -887272;
181
210
  var MAX_TICK = -MIN_TICK;
182
211
  var FULL_TICK_RANGE = { start: MIN_TICK, end: MAX_TICK };
183
212
  var tickToRate = (tick, baseAsset) => {
184
- const baseRate = new import_bignumber.BigNumber(1.0001 ** tick);
213
+ const baseRate = new import_bignumber.default(1.0001 ** tick);
185
214
  const rateDecimals = assetConstants.Usdc.decimals - assetConstants[baseAsset].decimals;
186
215
  return baseRate.shiftedBy(-rateDecimals).toNumber();
187
216
  };
188
217
  var rateToTick = (rate, baseAsset) => {
189
218
  const rateDecimals = assetConstants.Usdc.decimals - assetConstants[baseAsset].decimals;
190
- const rawRate = new import_bignumber.BigNumber(rate).shiftedBy(rateDecimals);
219
+ const rawRate = new import_bignumber.default(rate).shiftedBy(rateDecimals);
191
220
  let tick = Math.log(rawRate.toNumber()) / Math.log(1.0001);
192
221
  tick = Math.round(tick * 1e6) / 1e6;
193
222
  tick = Math.floor(tick);
194
223
  return Math.max(MIN_TICK, Math.min(tick, MAX_TICK));
195
224
  };
196
- var sqrtPriceX96ToPrice = (amount) => new import_bignumber.BigNumber(amount).div(new import_bignumber.BigNumber(2).pow(96)).pow(2);
197
- var priceX128ToPrice = (amount) => new import_bignumber.BigNumber(amount).div(new import_bignumber.BigNumber(2).pow(128));
225
+ var sqrtPriceX96ToPrice = (amount) => new import_bignumber.default(amount).div(new import_bignumber.default(2).pow(96)).pow(2);
226
+ var priceX128ToPrice = (amount) => new import_bignumber.default(amount).div(new import_bignumber.default(2).pow(128));
198
227
  // Annotate the CommonJS export names for ESM import in node:
199
228
  0 && (module.exports = {
200
229
  FULL_TICK_RANGE,
@@ -1,4 +1,4 @@
1
- import { BigNumber } from 'bignumber.js';
1
+ import BigNumber from 'bignumber.js';
2
2
  import { ChainflipAsset } from './chainflip.cjs';
3
3
 
4
4
  declare const MIN_TICK = -887272;
@@ -1,4 +1,4 @@
1
- import { BigNumber } from 'bignumber.js';
1
+ import BigNumber from 'bignumber.js';
2
2
  import { ChainflipAsset } from './chainflip.js';
3
3
 
4
4
  declare const MIN_TICK = -887272;
package/dist/tickMath.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  assetConstants
3
- } from "./chunk-3IZHLINB.js";
3
+ } from "./chunk-6LZGVCU6.js";
4
4
 
5
5
  // src/tickMath.ts
6
- import { BigNumber } from "bignumber.js";
6
+ import BigNumber from "bignumber.js";
7
7
  var MIN_TICK = -887272;
8
8
  var MAX_TICK = -MIN_TICK;
9
9
  var FULL_TICK_RANGE = { start: MIN_TICK, end: MAX_TICK };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -20,11 +20,11 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@noble/hashes": "^1.7.1",
23
- "@vitest/ui": "3.0.9"
23
+ "@vitest/ui": "3.1.1"
24
24
  },
25
25
  "dependencies": {
26
26
  "@date-fns/utc": "^2.1.0",
27
- "bignumber.js": "^9.1.2",
27
+ "bignumber.js": "^9.2.0",
28
28
  "date-fns": "4.1.0"
29
29
  },
30
30
  "repository": "https://github.com/chainflip-io/chainflip-product-toolkit.git",