@chainflip/utils 0.7.5 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chainflip.cjs +110 -7
- package/dist/chainflip.d.cts +61 -4
- package/dist/chainflip.d.ts +61 -4
- package/dist/chainflip.js +7 -1
- package/dist/{chunk-YOAHWTE7.js → chunk-LY7K57IN.js} +108 -8
- package/dist/tickMath.cjs +39 -3
- package/dist/tickMath.js +1 -1
- package/package.json +1 -1
package/dist/chainflip.cjs
CHANGED
|
@@ -30,31 +30,49 @@ __export(chainflip_exports, {
|
|
|
30
30
|
chainflipChains: () => chainflipChains,
|
|
31
31
|
chainflipEvmChains: () => chainflipEvmChains,
|
|
32
32
|
chainflipNetworks: () => chainflipNetworks,
|
|
33
|
+
getInternalAsset: () => getInternalAsset,
|
|
34
|
+
getInternalAssets: () => getInternalAssets,
|
|
33
35
|
internalAssetToRpcAsset: () => internalAssetToRpcAsset,
|
|
36
|
+
isValidAssetAndChain: () => isValidAssetAndChain,
|
|
34
37
|
readAssetValue: () => readAssetValue,
|
|
35
38
|
rpcAssets: () => rpcAssets
|
|
36
39
|
});
|
|
37
40
|
module.exports = __toCommonJS(chainflip_exports);
|
|
38
41
|
var chainflipAssets = [
|
|
42
|
+
// Ethereum
|
|
39
43
|
"Usdc",
|
|
40
44
|
"Usdt",
|
|
41
45
|
"Flip",
|
|
42
|
-
"Dot",
|
|
43
46
|
"Eth",
|
|
47
|
+
// Polkadot
|
|
48
|
+
"Dot",
|
|
49
|
+
// Bitcoin
|
|
44
50
|
"Btc",
|
|
51
|
+
// Arbitrum
|
|
45
52
|
"ArbUsdc",
|
|
46
53
|
"ArbEth",
|
|
54
|
+
// Solana
|
|
47
55
|
"Sol",
|
|
48
|
-
"SolUsdc"
|
|
56
|
+
"SolUsdc",
|
|
57
|
+
// Assethub
|
|
58
|
+
"HubDot",
|
|
59
|
+
"HubUsdt",
|
|
60
|
+
"HubUsdc"
|
|
49
61
|
];
|
|
50
62
|
var rpcAssets = ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
|
|
51
63
|
var baseChainflipAssets = chainflipAssets.filter(
|
|
52
64
|
(asset) => asset !== "Usdc"
|
|
53
65
|
);
|
|
54
66
|
var chainflipEvmChains = ["Ethereum", "Arbitrum"];
|
|
55
|
-
var chainflipChains = [
|
|
67
|
+
var chainflipChains = [
|
|
68
|
+
...chainflipEvmChains,
|
|
69
|
+
"Bitcoin",
|
|
70
|
+
"Polkadot",
|
|
71
|
+
"Solana",
|
|
72
|
+
"Assethub"
|
|
73
|
+
];
|
|
56
74
|
var chainflipNetworks = ["backspin", "sisyphos", "perseverance", "mainnet"];
|
|
57
|
-
var addressTypes = ["Eth", "Btc", "Dot", "Arb", "Sol"];
|
|
75
|
+
var addressTypes = ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
|
|
58
76
|
function readAssetValue(map, asset) {
|
|
59
77
|
const chainValues = map[assetConstants[asset].chain];
|
|
60
78
|
return chainValues[assetConstants[asset].rpcAsset];
|
|
@@ -109,6 +127,21 @@ var assetConstants = {
|
|
|
109
127
|
chain: "Solana",
|
|
110
128
|
rpcAsset: "USDC",
|
|
111
129
|
decimals: 6
|
|
130
|
+
},
|
|
131
|
+
HubDot: {
|
|
132
|
+
chain: "Assethub",
|
|
133
|
+
rpcAsset: "DOT",
|
|
134
|
+
decimals: 10
|
|
135
|
+
},
|
|
136
|
+
HubUsdc: {
|
|
137
|
+
chain: "Assethub",
|
|
138
|
+
rpcAsset: "USDC",
|
|
139
|
+
decimals: 6
|
|
140
|
+
},
|
|
141
|
+
HubUsdt: {
|
|
142
|
+
chain: "Assethub",
|
|
143
|
+
rpcAsset: "USDT",
|
|
144
|
+
decimals: 6
|
|
112
145
|
}
|
|
113
146
|
};
|
|
114
147
|
var chainConstants = {
|
|
@@ -141,6 +174,12 @@ var chainConstants = {
|
|
|
141
174
|
gasAsset: "Sol",
|
|
142
175
|
addressType: "Sol",
|
|
143
176
|
blockTimeSeconds: 0.8
|
|
177
|
+
},
|
|
178
|
+
Assethub: {
|
|
179
|
+
assets: ["HubDot", "HubUsdt", "HubUsdc"],
|
|
180
|
+
gasAsset: "HubDot",
|
|
181
|
+
addressType: "Hub",
|
|
182
|
+
blockTimeSeconds: 12
|
|
144
183
|
}
|
|
145
184
|
};
|
|
146
185
|
var internalAssetToRpcAsset = {
|
|
@@ -153,14 +192,18 @@ var internalAssetToRpcAsset = {
|
|
|
153
192
|
ArbUsdc: { chain: "Arbitrum", asset: "USDC" },
|
|
154
193
|
ArbEth: { chain: "Arbitrum", asset: "ETH" },
|
|
155
194
|
Sol: { chain: "Solana", asset: "SOL" },
|
|
156
|
-
SolUsdc: { chain: "Solana", asset: "USDC" }
|
|
195
|
+
SolUsdc: { chain: "Solana", asset: "USDC" },
|
|
196
|
+
HubDot: { chain: "Assethub", asset: "DOT" },
|
|
197
|
+
HubUsdt: { chain: "Assethub", asset: "USDT" },
|
|
198
|
+
HubUsdc: { chain: "Assethub", asset: "USDC" }
|
|
157
199
|
};
|
|
158
200
|
var chainContractId = {
|
|
159
201
|
Ethereum: 1,
|
|
160
202
|
Polkadot: 2,
|
|
161
203
|
Bitcoin: 3,
|
|
162
204
|
Arbitrum: 4,
|
|
163
|
-
Solana: 5
|
|
205
|
+
Solana: 5,
|
|
206
|
+
Assethub: 6
|
|
164
207
|
};
|
|
165
208
|
var assetContractId = {
|
|
166
209
|
Eth: 1,
|
|
@@ -172,8 +215,65 @@ var assetContractId = {
|
|
|
172
215
|
ArbEth: 6,
|
|
173
216
|
ArbUsdc: 7,
|
|
174
217
|
Sol: 9,
|
|
175
|
-
SolUsdc: 10
|
|
218
|
+
SolUsdc: 10,
|
|
219
|
+
HubDot: 11,
|
|
220
|
+
HubUsdt: 12,
|
|
221
|
+
HubUsdc: 13
|
|
176
222
|
};
|
|
223
|
+
function isValidAssetAndChain(assetAndChain) {
|
|
224
|
+
const { asset, chain } = assetAndChain;
|
|
225
|
+
if (!(chain in chainConstants)) return false;
|
|
226
|
+
const validAssets = chainConstants[chain].assets;
|
|
227
|
+
return validAssets.includes(asset);
|
|
228
|
+
}
|
|
229
|
+
function getInternalAsset(asset, assert = true) {
|
|
230
|
+
if (!isValidAssetAndChain(asset)) {
|
|
231
|
+
if (assert) {
|
|
232
|
+
throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
|
|
233
|
+
}
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const map = {
|
|
237
|
+
Ethereum: {
|
|
238
|
+
USDC: "Usdc",
|
|
239
|
+
FLIP: "Flip",
|
|
240
|
+
ETH: "Eth",
|
|
241
|
+
USDT: "Usdt"
|
|
242
|
+
},
|
|
243
|
+
Bitcoin: {
|
|
244
|
+
BTC: "Btc"
|
|
245
|
+
},
|
|
246
|
+
Polkadot: {
|
|
247
|
+
DOT: "Dot"
|
|
248
|
+
},
|
|
249
|
+
Arbitrum: {
|
|
250
|
+
USDC: "ArbUsdc",
|
|
251
|
+
ETH: "ArbEth"
|
|
252
|
+
},
|
|
253
|
+
Solana: {
|
|
254
|
+
SOL: "Sol",
|
|
255
|
+
USDC: "SolUsdc"
|
|
256
|
+
},
|
|
257
|
+
Assethub: {
|
|
258
|
+
USDC: "HubUsdc",
|
|
259
|
+
USDT: "HubUsdt",
|
|
260
|
+
DOT: "HubDot"
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const chain = map[asset.chain];
|
|
264
|
+
return chain[asset.asset];
|
|
265
|
+
}
|
|
266
|
+
function getInternalAssets({
|
|
267
|
+
srcAsset,
|
|
268
|
+
srcChain,
|
|
269
|
+
destAsset,
|
|
270
|
+
destChain
|
|
271
|
+
}, assert = true) {
|
|
272
|
+
return {
|
|
273
|
+
srcAsset: getInternalAsset({ asset: srcAsset, chain: srcChain }, assert),
|
|
274
|
+
destAsset: getInternalAsset({ asset: destAsset, chain: destChain }, assert)
|
|
275
|
+
};
|
|
276
|
+
}
|
|
177
277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
178
278
|
0 && (module.exports = {
|
|
179
279
|
addressTypes,
|
|
@@ -186,7 +286,10 @@ var assetContractId = {
|
|
|
186
286
|
chainflipChains,
|
|
187
287
|
chainflipEvmChains,
|
|
188
288
|
chainflipNetworks,
|
|
289
|
+
getInternalAsset,
|
|
290
|
+
getInternalAssets,
|
|
189
291
|
internalAssetToRpcAsset,
|
|
292
|
+
isValidAssetAndChain,
|
|
190
293
|
readAssetValue,
|
|
191
294
|
rpcAssets
|
|
192
295
|
});
|
package/dist/chainflip.d.cts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
declare const chainflipAssets: readonly ["Usdc", "Usdt", "Flip", "
|
|
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
3
|
declare const rpcAssets: readonly ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
|
|
4
|
+
type RpcAsset = (typeof rpcAssets)[number];
|
|
4
5
|
type BaseChainflipAsset = Exclude<ChainflipAsset, 'Usdc'>;
|
|
5
6
|
declare const baseChainflipAssets: BaseChainflipAsset[];
|
|
6
7
|
declare const chainflipEvmChains: readonly ["Ethereum", "Arbitrum"];
|
|
7
8
|
type ChainflipEvmChain = (typeof chainflipEvmChains)[number];
|
|
8
|
-
declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Polkadot", "Solana"];
|
|
9
|
+
declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Polkadot", "Solana", "Assethub"];
|
|
9
10
|
type ChainflipChain = (typeof chainflipChains)[number];
|
|
10
11
|
declare const chainflipNetworks: readonly ["backspin", "sisyphos", "perseverance", "mainnet"];
|
|
11
12
|
type ChainflipNetwork = (typeof chainflipNetworks)[number];
|
|
12
|
-
declare const addressTypes: readonly ["Eth", "Btc", "Dot", "Arb", "Sol"];
|
|
13
|
+
declare const addressTypes: readonly ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
|
|
13
14
|
type AddressType = (typeof addressTypes)[number];
|
|
14
15
|
type AssetOfChain<C extends ChainflipChain> = (typeof chainConstants)[C]['assets'][number];
|
|
15
16
|
type ChainAssetMap<T> = {
|
|
@@ -28,6 +29,10 @@ type AssetAndChain = {
|
|
|
28
29
|
asset: keyof ChainAssetMap<unknown>[C];
|
|
29
30
|
};
|
|
30
31
|
}[ChainflipChain];
|
|
32
|
+
type UncheckedAssetAndChain = {
|
|
33
|
+
chain: ChainflipChain;
|
|
34
|
+
asset: RpcAsset;
|
|
35
|
+
};
|
|
31
36
|
declare function readAssetValue<T>(map: ChainAssetMap<T>, asset: ChainflipAsset | BaseChainflipAsset): T;
|
|
32
37
|
declare function readAssetValue<T>(map: BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
|
|
33
38
|
declare function readAssetValue<T>(map: ChainAssetMap<T> | BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
|
|
@@ -82,6 +87,21 @@ declare const assetConstants: {
|
|
|
82
87
|
readonly rpcAsset: "USDC";
|
|
83
88
|
readonly decimals: 6;
|
|
84
89
|
};
|
|
90
|
+
readonly HubDot: {
|
|
91
|
+
readonly chain: "Assethub";
|
|
92
|
+
readonly rpcAsset: "DOT";
|
|
93
|
+
readonly decimals: 10;
|
|
94
|
+
};
|
|
95
|
+
readonly HubUsdc: {
|
|
96
|
+
readonly chain: "Assethub";
|
|
97
|
+
readonly rpcAsset: "USDC";
|
|
98
|
+
readonly decimals: 6;
|
|
99
|
+
};
|
|
100
|
+
readonly HubUsdt: {
|
|
101
|
+
readonly chain: "Assethub";
|
|
102
|
+
readonly rpcAsset: "USDT";
|
|
103
|
+
readonly decimals: 6;
|
|
104
|
+
};
|
|
85
105
|
};
|
|
86
106
|
declare const chainConstants: {
|
|
87
107
|
readonly Ethereum: {
|
|
@@ -114,9 +134,46 @@ declare const chainConstants: {
|
|
|
114
134
|
readonly addressType: "Sol";
|
|
115
135
|
readonly blockTimeSeconds: 0.8;
|
|
116
136
|
};
|
|
137
|
+
readonly Assethub: {
|
|
138
|
+
readonly assets: ["HubDot", "HubUsdt", "HubUsdc"];
|
|
139
|
+
readonly gasAsset: "HubDot";
|
|
140
|
+
readonly addressType: "Hub";
|
|
141
|
+
readonly blockTimeSeconds: 12;
|
|
142
|
+
};
|
|
117
143
|
};
|
|
118
144
|
declare const internalAssetToRpcAsset: Record<ChainflipAsset, AssetAndChain>;
|
|
119
145
|
declare const chainContractId: Record<ChainflipChain, number>;
|
|
120
146
|
declare const assetContractId: Record<ChainflipAsset, number>;
|
|
147
|
+
declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
|
|
148
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
|
|
149
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
|
|
150
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
|
|
151
|
+
declare function getInternalAssets(data: {
|
|
152
|
+
srcAsset: RpcAsset;
|
|
153
|
+
srcChain: ChainflipChain;
|
|
154
|
+
destAsset: RpcAsset;
|
|
155
|
+
destChain: ChainflipChain;
|
|
156
|
+
}): {
|
|
157
|
+
srcAsset: ChainflipAsset;
|
|
158
|
+
destAsset: ChainflipAsset;
|
|
159
|
+
};
|
|
160
|
+
declare function getInternalAssets(data: {
|
|
161
|
+
srcAsset: RpcAsset;
|
|
162
|
+
srcChain: ChainflipChain;
|
|
163
|
+
destAsset: RpcAsset;
|
|
164
|
+
destChain: ChainflipChain;
|
|
165
|
+
}, assert: true): {
|
|
166
|
+
srcAsset: ChainflipAsset;
|
|
167
|
+
destAsset: ChainflipAsset;
|
|
168
|
+
};
|
|
169
|
+
declare function getInternalAssets(data: {
|
|
170
|
+
srcAsset: RpcAsset;
|
|
171
|
+
srcChain: ChainflipChain;
|
|
172
|
+
destAsset: RpcAsset;
|
|
173
|
+
destChain: ChainflipChain;
|
|
174
|
+
}, assert: boolean): {
|
|
175
|
+
srcAsset: ChainflipAsset | null;
|
|
176
|
+
destAsset: ChainflipAsset | null;
|
|
177
|
+
};
|
|
121
178
|
|
|
122
|
-
export { type AddressType, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, addressTypes, assetConstants, assetContractId, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, internalAssetToRpcAsset, readAssetValue, rpcAssets };
|
|
179
|
+
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 };
|
package/dist/chainflip.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
declare const chainflipAssets: readonly ["Usdc", "Usdt", "Flip", "
|
|
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
3
|
declare const rpcAssets: readonly ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
|
|
4
|
+
type RpcAsset = (typeof rpcAssets)[number];
|
|
4
5
|
type BaseChainflipAsset = Exclude<ChainflipAsset, 'Usdc'>;
|
|
5
6
|
declare const baseChainflipAssets: BaseChainflipAsset[];
|
|
6
7
|
declare const chainflipEvmChains: readonly ["Ethereum", "Arbitrum"];
|
|
7
8
|
type ChainflipEvmChain = (typeof chainflipEvmChains)[number];
|
|
8
|
-
declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Polkadot", "Solana"];
|
|
9
|
+
declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Polkadot", "Solana", "Assethub"];
|
|
9
10
|
type ChainflipChain = (typeof chainflipChains)[number];
|
|
10
11
|
declare const chainflipNetworks: readonly ["backspin", "sisyphos", "perseverance", "mainnet"];
|
|
11
12
|
type ChainflipNetwork = (typeof chainflipNetworks)[number];
|
|
12
|
-
declare const addressTypes: readonly ["Eth", "Btc", "Dot", "Arb", "Sol"];
|
|
13
|
+
declare const addressTypes: readonly ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
|
|
13
14
|
type AddressType = (typeof addressTypes)[number];
|
|
14
15
|
type AssetOfChain<C extends ChainflipChain> = (typeof chainConstants)[C]['assets'][number];
|
|
15
16
|
type ChainAssetMap<T> = {
|
|
@@ -28,6 +29,10 @@ type AssetAndChain = {
|
|
|
28
29
|
asset: keyof ChainAssetMap<unknown>[C];
|
|
29
30
|
};
|
|
30
31
|
}[ChainflipChain];
|
|
32
|
+
type UncheckedAssetAndChain = {
|
|
33
|
+
chain: ChainflipChain;
|
|
34
|
+
asset: RpcAsset;
|
|
35
|
+
};
|
|
31
36
|
declare function readAssetValue<T>(map: ChainAssetMap<T>, asset: ChainflipAsset | BaseChainflipAsset): T;
|
|
32
37
|
declare function readAssetValue<T>(map: BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
|
|
33
38
|
declare function readAssetValue<T>(map: ChainAssetMap<T> | BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
|
|
@@ -82,6 +87,21 @@ declare const assetConstants: {
|
|
|
82
87
|
readonly rpcAsset: "USDC";
|
|
83
88
|
readonly decimals: 6;
|
|
84
89
|
};
|
|
90
|
+
readonly HubDot: {
|
|
91
|
+
readonly chain: "Assethub";
|
|
92
|
+
readonly rpcAsset: "DOT";
|
|
93
|
+
readonly decimals: 10;
|
|
94
|
+
};
|
|
95
|
+
readonly HubUsdc: {
|
|
96
|
+
readonly chain: "Assethub";
|
|
97
|
+
readonly rpcAsset: "USDC";
|
|
98
|
+
readonly decimals: 6;
|
|
99
|
+
};
|
|
100
|
+
readonly HubUsdt: {
|
|
101
|
+
readonly chain: "Assethub";
|
|
102
|
+
readonly rpcAsset: "USDT";
|
|
103
|
+
readonly decimals: 6;
|
|
104
|
+
};
|
|
85
105
|
};
|
|
86
106
|
declare const chainConstants: {
|
|
87
107
|
readonly Ethereum: {
|
|
@@ -114,9 +134,46 @@ declare const chainConstants: {
|
|
|
114
134
|
readonly addressType: "Sol";
|
|
115
135
|
readonly blockTimeSeconds: 0.8;
|
|
116
136
|
};
|
|
137
|
+
readonly Assethub: {
|
|
138
|
+
readonly assets: ["HubDot", "HubUsdt", "HubUsdc"];
|
|
139
|
+
readonly gasAsset: "HubDot";
|
|
140
|
+
readonly addressType: "Hub";
|
|
141
|
+
readonly blockTimeSeconds: 12;
|
|
142
|
+
};
|
|
117
143
|
};
|
|
118
144
|
declare const internalAssetToRpcAsset: Record<ChainflipAsset, AssetAndChain>;
|
|
119
145
|
declare const chainContractId: Record<ChainflipChain, number>;
|
|
120
146
|
declare const assetContractId: Record<ChainflipAsset, number>;
|
|
147
|
+
declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
|
|
148
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
|
|
149
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
|
|
150
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
|
|
151
|
+
declare function getInternalAssets(data: {
|
|
152
|
+
srcAsset: RpcAsset;
|
|
153
|
+
srcChain: ChainflipChain;
|
|
154
|
+
destAsset: RpcAsset;
|
|
155
|
+
destChain: ChainflipChain;
|
|
156
|
+
}): {
|
|
157
|
+
srcAsset: ChainflipAsset;
|
|
158
|
+
destAsset: ChainflipAsset;
|
|
159
|
+
};
|
|
160
|
+
declare function getInternalAssets(data: {
|
|
161
|
+
srcAsset: RpcAsset;
|
|
162
|
+
srcChain: ChainflipChain;
|
|
163
|
+
destAsset: RpcAsset;
|
|
164
|
+
destChain: ChainflipChain;
|
|
165
|
+
}, assert: true): {
|
|
166
|
+
srcAsset: ChainflipAsset;
|
|
167
|
+
destAsset: ChainflipAsset;
|
|
168
|
+
};
|
|
169
|
+
declare function getInternalAssets(data: {
|
|
170
|
+
srcAsset: RpcAsset;
|
|
171
|
+
srcChain: ChainflipChain;
|
|
172
|
+
destAsset: RpcAsset;
|
|
173
|
+
destChain: ChainflipChain;
|
|
174
|
+
}, assert: boolean): {
|
|
175
|
+
srcAsset: ChainflipAsset | null;
|
|
176
|
+
destAsset: ChainflipAsset | null;
|
|
177
|
+
};
|
|
121
178
|
|
|
122
|
-
export { type AddressType, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, addressTypes, assetConstants, assetContractId, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, internalAssetToRpcAsset, readAssetValue, rpcAssets };
|
|
179
|
+
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 };
|
package/dist/chainflip.js
CHANGED
|
@@ -9,10 +9,13 @@ import {
|
|
|
9
9
|
chainflipChains,
|
|
10
10
|
chainflipEvmChains,
|
|
11
11
|
chainflipNetworks,
|
|
12
|
+
getInternalAsset,
|
|
13
|
+
getInternalAssets,
|
|
12
14
|
internalAssetToRpcAsset,
|
|
15
|
+
isValidAssetAndChain,
|
|
13
16
|
readAssetValue,
|
|
14
17
|
rpcAssets
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LY7K57IN.js";
|
|
16
19
|
export {
|
|
17
20
|
addressTypes,
|
|
18
21
|
assetConstants,
|
|
@@ -24,7 +27,10 @@ export {
|
|
|
24
27
|
chainflipChains,
|
|
25
28
|
chainflipEvmChains,
|
|
26
29
|
chainflipNetworks,
|
|
30
|
+
getInternalAsset,
|
|
31
|
+
getInternalAssets,
|
|
27
32
|
internalAssetToRpcAsset,
|
|
33
|
+
isValidAssetAndChain,
|
|
28
34
|
readAssetValue,
|
|
29
35
|
rpcAssets
|
|
30
36
|
};
|
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
// src/chainflip.ts
|
|
2
2
|
var chainflipAssets = [
|
|
3
|
+
// Ethereum
|
|
3
4
|
"Usdc",
|
|
4
5
|
"Usdt",
|
|
5
6
|
"Flip",
|
|
6
|
-
"Dot",
|
|
7
7
|
"Eth",
|
|
8
|
+
// Polkadot
|
|
9
|
+
"Dot",
|
|
10
|
+
// Bitcoin
|
|
8
11
|
"Btc",
|
|
12
|
+
// Arbitrum
|
|
9
13
|
"ArbUsdc",
|
|
10
14
|
"ArbEth",
|
|
15
|
+
// Solana
|
|
11
16
|
"Sol",
|
|
12
|
-
"SolUsdc"
|
|
17
|
+
"SolUsdc",
|
|
18
|
+
// Assethub
|
|
19
|
+
"HubDot",
|
|
20
|
+
"HubUsdt",
|
|
21
|
+
"HubUsdc"
|
|
13
22
|
];
|
|
14
23
|
var rpcAssets = ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
|
|
15
24
|
var baseChainflipAssets = chainflipAssets.filter(
|
|
16
25
|
(asset) => asset !== "Usdc"
|
|
17
26
|
);
|
|
18
27
|
var chainflipEvmChains = ["Ethereum", "Arbitrum"];
|
|
19
|
-
var chainflipChains = [
|
|
28
|
+
var chainflipChains = [
|
|
29
|
+
...chainflipEvmChains,
|
|
30
|
+
"Bitcoin",
|
|
31
|
+
"Polkadot",
|
|
32
|
+
"Solana",
|
|
33
|
+
"Assethub"
|
|
34
|
+
];
|
|
20
35
|
var chainflipNetworks = ["backspin", "sisyphos", "perseverance", "mainnet"];
|
|
21
|
-
var addressTypes = ["Eth", "Btc", "Dot", "Arb", "Sol"];
|
|
36
|
+
var addressTypes = ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
|
|
22
37
|
function readAssetValue(map, asset) {
|
|
23
38
|
const chainValues = map[assetConstants[asset].chain];
|
|
24
39
|
return chainValues[assetConstants[asset].rpcAsset];
|
|
@@ -73,6 +88,21 @@ var assetConstants = {
|
|
|
73
88
|
chain: "Solana",
|
|
74
89
|
rpcAsset: "USDC",
|
|
75
90
|
decimals: 6
|
|
91
|
+
},
|
|
92
|
+
HubDot: {
|
|
93
|
+
chain: "Assethub",
|
|
94
|
+
rpcAsset: "DOT",
|
|
95
|
+
decimals: 10
|
|
96
|
+
},
|
|
97
|
+
HubUsdc: {
|
|
98
|
+
chain: "Assethub",
|
|
99
|
+
rpcAsset: "USDC",
|
|
100
|
+
decimals: 6
|
|
101
|
+
},
|
|
102
|
+
HubUsdt: {
|
|
103
|
+
chain: "Assethub",
|
|
104
|
+
rpcAsset: "USDT",
|
|
105
|
+
decimals: 6
|
|
76
106
|
}
|
|
77
107
|
};
|
|
78
108
|
var chainConstants = {
|
|
@@ -105,6 +135,12 @@ var chainConstants = {
|
|
|
105
135
|
gasAsset: "Sol",
|
|
106
136
|
addressType: "Sol",
|
|
107
137
|
blockTimeSeconds: 0.8
|
|
138
|
+
},
|
|
139
|
+
Assethub: {
|
|
140
|
+
assets: ["HubDot", "HubUsdt", "HubUsdc"],
|
|
141
|
+
gasAsset: "HubDot",
|
|
142
|
+
addressType: "Hub",
|
|
143
|
+
blockTimeSeconds: 12
|
|
108
144
|
}
|
|
109
145
|
};
|
|
110
146
|
var internalAssetToRpcAsset = {
|
|
@@ -117,14 +153,18 @@ var internalAssetToRpcAsset = {
|
|
|
117
153
|
ArbUsdc: { chain: "Arbitrum", asset: "USDC" },
|
|
118
154
|
ArbEth: { chain: "Arbitrum", asset: "ETH" },
|
|
119
155
|
Sol: { chain: "Solana", asset: "SOL" },
|
|
120
|
-
SolUsdc: { chain: "Solana", asset: "USDC" }
|
|
156
|
+
SolUsdc: { chain: "Solana", asset: "USDC" },
|
|
157
|
+
HubDot: { chain: "Assethub", asset: "DOT" },
|
|
158
|
+
HubUsdt: { chain: "Assethub", asset: "USDT" },
|
|
159
|
+
HubUsdc: { chain: "Assethub", asset: "USDC" }
|
|
121
160
|
};
|
|
122
161
|
var chainContractId = {
|
|
123
162
|
Ethereum: 1,
|
|
124
163
|
Polkadot: 2,
|
|
125
164
|
Bitcoin: 3,
|
|
126
165
|
Arbitrum: 4,
|
|
127
|
-
Solana: 5
|
|
166
|
+
Solana: 5,
|
|
167
|
+
Assethub: 6
|
|
128
168
|
};
|
|
129
169
|
var assetContractId = {
|
|
130
170
|
Eth: 1,
|
|
@@ -136,8 +176,65 @@ var assetContractId = {
|
|
|
136
176
|
ArbEth: 6,
|
|
137
177
|
ArbUsdc: 7,
|
|
138
178
|
Sol: 9,
|
|
139
|
-
SolUsdc: 10
|
|
179
|
+
SolUsdc: 10,
|
|
180
|
+
HubDot: 11,
|
|
181
|
+
HubUsdt: 12,
|
|
182
|
+
HubUsdc: 13
|
|
140
183
|
};
|
|
184
|
+
function isValidAssetAndChain(assetAndChain) {
|
|
185
|
+
const { asset, chain } = assetAndChain;
|
|
186
|
+
if (!(chain in chainConstants)) return false;
|
|
187
|
+
const validAssets = chainConstants[chain].assets;
|
|
188
|
+
return validAssets.includes(asset);
|
|
189
|
+
}
|
|
190
|
+
function getInternalAsset(asset, assert = true) {
|
|
191
|
+
if (!isValidAssetAndChain(asset)) {
|
|
192
|
+
if (assert) {
|
|
193
|
+
throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const map = {
|
|
198
|
+
Ethereum: {
|
|
199
|
+
USDC: "Usdc",
|
|
200
|
+
FLIP: "Flip",
|
|
201
|
+
ETH: "Eth",
|
|
202
|
+
USDT: "Usdt"
|
|
203
|
+
},
|
|
204
|
+
Bitcoin: {
|
|
205
|
+
BTC: "Btc"
|
|
206
|
+
},
|
|
207
|
+
Polkadot: {
|
|
208
|
+
DOT: "Dot"
|
|
209
|
+
},
|
|
210
|
+
Arbitrum: {
|
|
211
|
+
USDC: "ArbUsdc",
|
|
212
|
+
ETH: "ArbEth"
|
|
213
|
+
},
|
|
214
|
+
Solana: {
|
|
215
|
+
SOL: "Sol",
|
|
216
|
+
USDC: "SolUsdc"
|
|
217
|
+
},
|
|
218
|
+
Assethub: {
|
|
219
|
+
USDC: "HubUsdc",
|
|
220
|
+
USDT: "HubUsdt",
|
|
221
|
+
DOT: "HubDot"
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const chain = map[asset.chain];
|
|
225
|
+
return chain[asset.asset];
|
|
226
|
+
}
|
|
227
|
+
function getInternalAssets({
|
|
228
|
+
srcAsset,
|
|
229
|
+
srcChain,
|
|
230
|
+
destAsset,
|
|
231
|
+
destChain
|
|
232
|
+
}, assert = true) {
|
|
233
|
+
return {
|
|
234
|
+
srcAsset: getInternalAsset({ asset: srcAsset, chain: srcChain }, assert),
|
|
235
|
+
destAsset: getInternalAsset({ asset: destAsset, chain: destChain }, assert)
|
|
236
|
+
};
|
|
237
|
+
}
|
|
141
238
|
|
|
142
239
|
export {
|
|
143
240
|
chainflipAssets,
|
|
@@ -152,5 +249,8 @@ export {
|
|
|
152
249
|
chainConstants,
|
|
153
250
|
internalAssetToRpcAsset,
|
|
154
251
|
chainContractId,
|
|
155
|
-
assetContractId
|
|
252
|
+
assetContractId,
|
|
253
|
+
isValidAssetAndChain,
|
|
254
|
+
getInternalAsset,
|
|
255
|
+
getInternalAssets
|
|
156
256
|
};
|
package/dist/tickMath.cjs
CHANGED
|
@@ -33,22 +33,37 @@ var import_bignumber = require("bignumber.js");
|
|
|
33
33
|
|
|
34
34
|
// src/chainflip.ts
|
|
35
35
|
var chainflipAssets = [
|
|
36
|
+
// Ethereum
|
|
36
37
|
"Usdc",
|
|
37
38
|
"Usdt",
|
|
38
39
|
"Flip",
|
|
39
|
-
"Dot",
|
|
40
40
|
"Eth",
|
|
41
|
+
// Polkadot
|
|
42
|
+
"Dot",
|
|
43
|
+
// Bitcoin
|
|
41
44
|
"Btc",
|
|
45
|
+
// Arbitrum
|
|
42
46
|
"ArbUsdc",
|
|
43
47
|
"ArbEth",
|
|
48
|
+
// Solana
|
|
44
49
|
"Sol",
|
|
45
|
-
"SolUsdc"
|
|
50
|
+
"SolUsdc",
|
|
51
|
+
// Assethub
|
|
52
|
+
"HubDot",
|
|
53
|
+
"HubUsdt",
|
|
54
|
+
"HubUsdc"
|
|
46
55
|
];
|
|
47
56
|
var baseChainflipAssets = chainflipAssets.filter(
|
|
48
57
|
(asset) => asset !== "Usdc"
|
|
49
58
|
);
|
|
50
59
|
var chainflipEvmChains = ["Ethereum", "Arbitrum"];
|
|
51
|
-
var chainflipChains = [
|
|
60
|
+
var chainflipChains = [
|
|
61
|
+
...chainflipEvmChains,
|
|
62
|
+
"Bitcoin",
|
|
63
|
+
"Polkadot",
|
|
64
|
+
"Solana",
|
|
65
|
+
"Assethub"
|
|
66
|
+
];
|
|
52
67
|
var assetConstants = {
|
|
53
68
|
Eth: {
|
|
54
69
|
chain: "Ethereum",
|
|
@@ -99,6 +114,21 @@ var assetConstants = {
|
|
|
99
114
|
chain: "Solana",
|
|
100
115
|
rpcAsset: "USDC",
|
|
101
116
|
decimals: 6
|
|
117
|
+
},
|
|
118
|
+
HubDot: {
|
|
119
|
+
chain: "Assethub",
|
|
120
|
+
rpcAsset: "DOT",
|
|
121
|
+
decimals: 10
|
|
122
|
+
},
|
|
123
|
+
HubUsdc: {
|
|
124
|
+
chain: "Assethub",
|
|
125
|
+
rpcAsset: "USDC",
|
|
126
|
+
decimals: 6
|
|
127
|
+
},
|
|
128
|
+
HubUsdt: {
|
|
129
|
+
chain: "Assethub",
|
|
130
|
+
rpcAsset: "USDT",
|
|
131
|
+
decimals: 6
|
|
102
132
|
}
|
|
103
133
|
};
|
|
104
134
|
var chainConstants = {
|
|
@@ -131,6 +161,12 @@ var chainConstants = {
|
|
|
131
161
|
gasAsset: "Sol",
|
|
132
162
|
addressType: "Sol",
|
|
133
163
|
blockTimeSeconds: 0.8
|
|
164
|
+
},
|
|
165
|
+
Assethub: {
|
|
166
|
+
assets: ["HubDot", "HubUsdt", "HubUsdc"],
|
|
167
|
+
gasAsset: "HubDot",
|
|
168
|
+
addressType: "Hub",
|
|
169
|
+
blockTimeSeconds: 12
|
|
134
170
|
}
|
|
135
171
|
};
|
|
136
172
|
|
package/dist/tickMath.js
CHANGED