@swapkit/helpers 1.0.0-rc.70 → 1.0.0-rc.72

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.
@@ -1,96 +1,96 @@
1
- import { BaseDecimal, Chain } from '@swapkit/types';
2
- import { describe, expect, test } from 'vitest';
1
+ import { BaseDecimal, Chain } from "@swapkit/types";
2
+ import { describe, expect, test } from "vitest";
3
3
 
4
- import { AssetValue, getMinAmountByChain } from '../assetValue.ts';
4
+ import { AssetValue, getMinAmountByChain } from "../assetValue.ts";
5
5
 
6
- describe('AssetValue', () => {
7
- describe('assetValue', () => {
8
- test('returns asset ticker with value', () => {
6
+ describe("AssetValue", () => {
7
+ describe("assetValue", () => {
8
+ test("returns asset ticker with value", () => {
9
9
  const fakeAvaxUSDCAsset = new AssetValue({
10
10
  decimal: 6,
11
11
  value: 1234567890,
12
12
  chain: Chain.Avalanche,
13
- symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
13
+ symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
14
14
  });
15
15
  expect(fakeAvaxUSDCAsset.toString()).toBe(
16
- 'AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
16
+ "AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
17
17
  );
18
18
 
19
19
  const ethSynth = new AssetValue({
20
20
  chain: Chain.THORChain,
21
- symbol: 'ETH/ETH',
21
+ symbol: "ETH/ETH",
22
22
  decimal: 8,
23
23
  value: 1234567890,
24
24
  });
25
25
 
26
- expect(ethSynth.toString()).toBe('ETH/ETH');
27
- expect(ethSynth.mul(21.37).getValue('string')).toBe('26382715809.3');
26
+ expect(ethSynth.toString()).toBe("ETH/ETH");
27
+ expect(ethSynth.mul(21.37).getValue("string")).toBe("26382715809.3");
28
28
 
29
29
  const ethThorSynth = new AssetValue({
30
30
  chain: Chain.THORChain,
31
- symbol: 'ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
31
+ symbol: "ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
32
32
  decimal: 8,
33
33
  value: 1234567890,
34
34
  });
35
- expect(ethThorSynth.toString()).toBe('ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
35
+ expect(ethThorSynth.toString()).toBe("ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
36
36
 
37
37
  const atomDerived = new AssetValue({
38
- identifier: 'THOR.ATOM',
38
+ identifier: "THOR.ATOM",
39
39
  decimal: 6,
40
40
  value: 123456789,
41
41
  });
42
42
 
43
- expect(atomDerived.toString()).toBe('THOR.ATOM');
43
+ expect(atomDerived.toString()).toBe("THOR.ATOM");
44
44
  });
45
45
  });
46
46
 
47
- describe('toUrl', () => {
48
- test('returns asset compliance with url', () => {
47
+ describe("toUrl", () => {
48
+ test("returns asset compliance with url", () => {
49
49
  const fakeAvaxUSDCAsset = new AssetValue({
50
50
  decimal: 6,
51
51
  value: 1234567890,
52
52
  chain: Chain.Avalanche,
53
- symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
53
+ symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
54
54
  });
55
55
  expect(fakeAvaxUSDCAsset.toUrl()).toBe(
56
- 'AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
56
+ "AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
57
57
  );
58
58
 
59
- const thor = AssetValue.fromChainOrSignature('ETH.THOR');
60
- expect(thor.toUrl()).toBe('ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
59
+ const thor = AssetValue.fromChainOrSignature("ETH.THOR");
60
+ expect(thor.toUrl()).toBe("ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
61
61
 
62
62
  const ethSynth = new AssetValue({
63
63
  chain: Chain.THORChain,
64
- symbol: 'ETH/ETH',
64
+ symbol: "ETH/ETH",
65
65
  decimal: 8,
66
66
  value: 1234567890,
67
67
  });
68
- expect(ethSynth.toUrl()).toBe('THOR.ETH.ETH');
68
+ expect(ethSynth.toUrl()).toBe("THOR.ETH.ETH");
69
69
 
70
70
  const ethThorSynth = new AssetValue({
71
71
  chain: Chain.THORChain,
72
- symbol: 'ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
72
+ symbol: "ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
73
73
  decimal: 8,
74
74
  value: 1234567890,
75
75
  });
76
- expect(ethThorSynth.toUrl()).toBe('THOR.ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
76
+ expect(ethThorSynth.toUrl()).toBe("THOR.ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
77
77
  });
78
78
  });
79
79
 
80
- describe('eq', () => {
81
- test('checks if assets are same chain and symbol', () => {
82
- const firstThor = AssetValue.fromChainOrSignature('ETH.THOR');
83
- const secondThor = AssetValue.fromChainOrSignature('ETH.THOR');
84
- const vThor = AssetValue.fromChainOrSignature('ETH.vTHOR');
80
+ describe("eq", () => {
81
+ test("checks if assets are same chain and symbol", () => {
82
+ const firstThor = AssetValue.fromChainOrSignature("ETH.THOR");
83
+ const secondThor = AssetValue.fromChainOrSignature("ETH.THOR");
84
+ const vThor = AssetValue.fromChainOrSignature("ETH.vTHOR");
85
85
  const firstUsdc = new AssetValue({
86
86
  chain: Chain.Avalanche,
87
- symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
87
+ symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
88
88
  decimal: 6,
89
89
  value: 1234567890,
90
90
  });
91
91
  const secondUsdc = new AssetValue({
92
92
  chain: Chain.Avalanche,
93
- symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
93
+ symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
94
94
  decimal: 6,
95
95
  value: 1234,
96
96
  });
@@ -109,192 +109,293 @@ describe('AssetValue', () => {
109
109
  });
110
110
  });
111
111
 
112
- describe('from bigint', () => {
113
- test('returns asset value with correct decimal', async () => {
112
+ describe("from bigint", () => {
113
+ test.todo("returns asset value with correct decimal", async () => {
114
114
  const avaxUSDCAsset = await AssetValue.fromIdentifier(
115
115
  `${Chain.Avalanche}.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e`,
116
116
  1234567800n,
117
117
  );
118
- expect(avaxUSDCAsset.getValue('string')).toBe('1234.5678');
118
+ expect(avaxUSDCAsset.getValue("string")).toBe("1234.5678");
119
119
  });
120
120
  });
121
121
 
122
- describe('toString', () => {
123
- test('returns asset value string/identifier', async () => {
122
+ describe("toString", () => {
123
+ test("returns asset value string/identifier", async () => {
124
124
  const avaxUSDCAsset = new AssetValue({
125
125
  decimal: 6,
126
126
  value: 1234567890,
127
127
  chain: Chain.Avalanche,
128
- symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
128
+ symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
129
129
  });
130
- expect(avaxUSDCAsset.toString()).toBe('AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e');
130
+ expect(avaxUSDCAsset.toString()).toBe("AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e");
131
131
 
132
- const thor = AssetValue.fromChainOrSignature('ETH.THOR');
133
- expect(thor.toString()).toBe('ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
132
+ const thor = AssetValue.fromChainOrSignature("ETH.THOR");
133
+ expect(thor.toString()).toBe("ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
134
134
 
135
- const ethSynth = await AssetValue.fromIdentifier('ETH/ETH');
136
- expect(ethSynth.toString()).toBe('ETH/ETH');
135
+ const ethSynth = await AssetValue.fromIdentifier("ETH/ETH");
136
+ expect(ethSynth.toString()).toBe("ETH/ETH");
137
137
  });
138
138
  });
139
139
 
140
- describe('fromIdentifier', () => {
141
- test('creates AssetValue from string', async () => {
140
+ describe("fromIdentifier", () => {
141
+ test.skip("creates AssetValue from string", async () => {
142
142
  const avaxUSDCAsset = await AssetValue.fromIdentifier(
143
- 'AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
143
+ "AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
144
144
  );
145
145
 
146
146
  expect(avaxUSDCAsset).toEqual(
147
147
  expect.objectContaining({
148
- address: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
148
+ address: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
149
149
  chain: Chain.Avalanche,
150
150
  decimal: 6,
151
151
  isGasAsset: false,
152
152
  isSynthetic: false,
153
- symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
154
- ticker: 'USDC',
153
+ symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
154
+ ticker: "USDC",
155
155
  }),
156
156
  );
157
157
  });
158
158
  });
159
159
 
160
- describe('fromString', () => {
161
- test('creates AssetValue from string', async () => {
162
- const fakeAvaxAssetString = 'AVAX.ASDF-1234';
160
+ describe("fromString", () => {
161
+ test("creates AssetValue from string", async () => {
162
+ const fakeAvaxAssetString = "AVAX.ASDF-1234";
163
163
  const fakeAvaxAsset = await AssetValue.fromString(fakeAvaxAssetString);
164
164
 
165
165
  expect(fakeAvaxAsset).toEqual(
166
166
  expect.objectContaining({
167
- address: '1234',
167
+ address: "1234",
168
168
  chain: Chain.Avalanche,
169
169
  decimal: 18,
170
170
  isGasAsset: false,
171
171
  isSynthetic: false,
172
- symbol: 'ASDF-1234',
173
- ticker: 'ASDF',
172
+ symbol: "ASDF-1234",
173
+ ticker: "ASDF",
174
174
  }),
175
175
  );
176
176
  });
177
177
  });
178
178
 
179
- describe('fromUrl', () => {
180
- test('creates AssetValue from url like format', async () => {
181
- const synthETHString = 'THOR.ETH.ETH';
182
- const ethString = 'ETH.ETH';
183
- const thorString = 'ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044';
184
- const synthThorString = 'THOR.ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044';
179
+ describe("fromStringWithBase", () => {
180
+ test("creates AssetValue from string with base", async () => {
181
+ const fakeAvaxAssetString = "AVAX.ASDF-1234";
182
+ const fakeAvaxAsset = await AssetValue.fromStringWithBase(fakeAvaxAssetString, 1, 8);
183
+
184
+ expect(fakeAvaxAsset).toEqual(
185
+ expect.objectContaining({
186
+ address: "1234",
187
+ chain: Chain.Avalanche,
188
+ decimal: 18,
189
+ isGasAsset: false,
190
+ isSynthetic: false,
191
+ symbol: "ASDF-1234",
192
+ ticker: "ASDF",
193
+ }),
194
+ );
195
+ expect(fakeAvaxAsset.getValue("string")).toBe("100000000");
196
+ expect(fakeAvaxAsset.getBaseValue("string")).toBe("100000000000000000000000000");
197
+ });
198
+ });
199
+
200
+ describe("fromUrl", () => {
201
+ test("creates AssetValue from url like format", async () => {
202
+ const synthETHString = "THOR.ETH.ETH";
203
+ const ethString = "ETH.ETH";
204
+ const thorString = "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044";
205
+ const synthThorString = "THOR.ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044";
185
206
 
186
207
  const synthETH = await AssetValue.fromUrl(synthETHString);
187
208
  const eth = await AssetValue.fromUrl(ethString);
188
209
  const thor = await AssetValue.fromUrl(thorString);
189
210
  const synthThor = await AssetValue.fromUrl(synthThorString);
190
211
 
191
- expect(synthETH.toString()).toBe('ETH/ETH');
192
- expect(eth.toString()).toBe('ETH.ETH');
193
- expect(thor.toString()).toBe('ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
194
- expect(synthThor.toString()).toBe('ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
212
+ expect(synthETH.toString()).toBe("ETH/ETH");
213
+ expect(eth.toString()).toBe("ETH.ETH");
214
+ expect(thor.toString()).toBe("ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
215
+ expect(synthThor.toString()).toBe("ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
195
216
  });
196
217
  });
197
218
 
198
- describe('fromIdentifierSync', () => {
199
- test('(same as fromIdentifier) - creates AssetValue from string via `@swapkit/tokens` lists', async () => {
219
+ describe("fromIdentifierSync", () => {
220
+ test("(same as fromIdentifier) - creates AssetValue from string via `@swapkit/tokens` lists", async () => {
200
221
  await AssetValue.loadStaticAssets();
201
222
  const thor = AssetValue.fromIdentifierSync(
202
- 'ARB.USDT-0XFD086BC7CD5C481DCC9C85EBE478A1C0B69FCBB9',
223
+ "ARB.USDT-0XFD086BC7CD5C481DCC9C85EBE478A1C0B69FCBB9",
203
224
  );
204
225
 
205
226
  expect(thor).toBeDefined();
206
227
  expect(thor).toEqual(
207
228
  expect.objectContaining({
208
- address: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
229
+ address: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
209
230
  chain: Chain.Arbitrum,
210
231
  decimal: 6,
211
232
  isGasAsset: false,
212
233
  isSynthetic: false,
213
- symbol: 'USDT-0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
214
- ticker: 'USDT',
234
+ symbol: "USDT-0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
235
+ ticker: "USDT",
215
236
  }),
216
237
  );
217
238
  });
218
239
  });
219
240
 
220
- describe('fromStringSync', () => {
221
- test('creates AssetValue from string via `@swapkit/tokens` lists', async () => {
241
+ describe("fromStringSync", () => {
242
+ test("creates AssetValue from string via `@swapkit/tokens` lists", async () => {
222
243
  await AssetValue.loadStaticAssets();
223
- const thor = AssetValue.fromStringSync('ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
244
+ const thor = AssetValue.fromStringSync("ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
224
245
 
225
246
  expect(thor).toBeDefined();
226
247
  expect(thor).toEqual(
227
248
  expect.objectContaining({
228
- address: '0xa5f2211b9b8170f694421f2046281775e8468044',
249
+ address: "0xa5f2211b9b8170f694421f2046281775e8468044",
229
250
  chain: Chain.Ethereum,
230
251
  decimal: 18,
231
252
  isGasAsset: false,
232
253
  isSynthetic: false,
233
- symbol: 'THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
234
- ticker: 'THOR',
254
+ symbol: "THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
255
+ ticker: "THOR",
256
+ }),
257
+ );
258
+
259
+ const usdc = AssetValue.fromStringSync("ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48");
260
+ expect(usdc).toBeDefined();
261
+ expect(usdc).toEqual(
262
+ expect.objectContaining({
263
+ address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
264
+ chain: Chain.Ethereum,
265
+ decimal: 6,
266
+ isGasAsset: false,
267
+ isSynthetic: false,
268
+ symbol: "USDC-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
269
+ ticker: "USDC",
235
270
  }),
236
271
  );
237
272
  });
238
273
 
239
- test('returns safe decimals if string is not in `@swapkit/tokens` lists', async () => {
274
+ test("returns safe decimals if string is not in `@swapkit/tokens` lists", async () => {
240
275
  await AssetValue.loadStaticAssets();
241
- const fakeAvaxUSDCAssetString = 'AVAX.USDC-1234';
276
+ const fakeAvaxUSDCAssetString = "AVAX.USDC-1234";
242
277
  const fakeAvaxUSDCAsset = AssetValue.fromStringSync(fakeAvaxUSDCAssetString);
243
278
 
244
279
  expect(fakeAvaxUSDCAsset).toBeDefined();
245
280
  expect(fakeAvaxUSDCAsset).toEqual(
246
281
  expect.objectContaining({
247
- address: '1234',
282
+ address: "1234",
248
283
  chain: Chain.Avalanche,
249
284
  decimal: 18,
250
285
  isGasAsset: false,
251
286
  isSynthetic: false,
252
- symbol: 'USDC-1234',
253
- ticker: 'USDC',
287
+ symbol: "USDC-1234",
288
+ ticker: "USDC",
254
289
  }),
255
290
  );
256
291
  });
257
292
 
258
- test('returns proper avax string with address from `@swapkit/tokens` lists', async () => {
293
+ test("returns proper avax string with address from `@swapkit/tokens` lists", async () => {
259
294
  await AssetValue.loadStaticAssets();
260
- const avaxBTCb = 'AVAX.BTC.b-0x152b9d0fdc40c096757f570a51e494bd4b943e50';
295
+ const avaxBTCb = "AVAX.BTC.b-0x152b9d0fdc40c096757f570a51e494bd4b943e50";
261
296
  const AvaxBTCb = AssetValue.fromStringSync(avaxBTCb);
262
297
 
263
298
  expect(AvaxBTCb).toBeDefined();
264
299
  expect(AvaxBTCb).toEqual(
265
300
  expect.objectContaining({
266
- address: '0x152b9d0fdc40c096757f570a51e494bd4b943e50',
301
+ address: "0x152b9d0fdc40c096757f570a51e494bd4b943e50",
267
302
  chain: Chain.Avalanche,
268
303
  decimal: 8,
269
304
  isGasAsset: false,
270
305
  isSynthetic: false,
271
- symbol: 'BTC.b-0x152b9d0fdc40c096757f570a51e494bd4b943e50',
272
- ticker: 'BTC.b',
306
+ symbol: "BTC.b-0x152b9d0fdc40c096757f570a51e494bd4b943e50",
307
+ ticker: "BTC.b",
308
+ }),
309
+ );
310
+ });
311
+ });
312
+
313
+ describe("fromStringWithBaseSync", () => {
314
+ test("creates AssetValue from string with base decimals via `@swapkit/tokens` lists", async () => {
315
+ await AssetValue.loadStaticAssets();
316
+ const btc = AssetValue.fromStringWithBaseSync("BTC.BTC", 5200000000000, 8);
317
+
318
+ expect(btc).toBeDefined();
319
+ expect(btc).toEqual(
320
+ expect.objectContaining({
321
+ chain: Chain.Bitcoin,
322
+ decimal: 8,
323
+ isGasAsset: true,
324
+ isSynthetic: false,
325
+ symbol: "BTC",
326
+ ticker: "BTC",
327
+ }),
328
+ );
329
+
330
+ expect(btc.getValue("string")).toBe("52000");
331
+ expect(btc.getBaseValue("string")).toBe("5200000000000");
332
+ });
333
+
334
+ test("returns safe decimals if string is not in `@swapkit/tokens` lists", async () => {
335
+ await AssetValue.loadStaticAssets();
336
+ const fakeAvaxUSDCAssetString = "AVAX.USDC-1234";
337
+ const fakeAvaxUSDCAsset = AssetValue.fromStringWithBaseSync(fakeAvaxUSDCAssetString, 1, 8);
338
+
339
+ expect(fakeAvaxUSDCAsset).toBeDefined();
340
+ expect(fakeAvaxUSDCAsset).toEqual(
341
+ expect.objectContaining({
342
+ address: "1234",
343
+ chain: Chain.Avalanche,
344
+ decimal: 18,
345
+ isGasAsset: false,
346
+ isSynthetic: false,
347
+ symbol: "USDC-1234",
348
+ ticker: "USDC",
349
+ }),
350
+ );
351
+
352
+ expect(fakeAvaxUSDCAsset.getValue("string")).toBe("0.00000001");
353
+ expect(fakeAvaxUSDCAsset.getBaseValue("string")).toBe("10000000000");
354
+ });
355
+
356
+ test("returns proper avax string with address from `@swapkit/tokens` lists", async () => {
357
+ await AssetValue.loadStaticAssets();
358
+ const avaxUSDC = "AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e";
359
+ const AvaxUSDC = AssetValue.fromStringWithBaseSync(avaxUSDC, 100000000, 8);
360
+
361
+ expect(AvaxUSDC).toBeDefined();
362
+ expect(AvaxUSDC).toEqual(
363
+ expect.objectContaining({
364
+ address: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
365
+ chain: Chain.Avalanche,
366
+ decimal: 6,
367
+ isGasAsset: false,
368
+ isSynthetic: false,
369
+ symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
370
+ ticker: "USDC",
273
371
  }),
274
372
  );
373
+
374
+ expect(AvaxUSDC.getValue("string")).toBe("1");
375
+ expect(AvaxUSDC.getBaseValue("string")).toBe("1000000");
275
376
  });
276
377
  });
277
378
 
278
- describe('fromChainOrSignature', () => {
279
- test('creates AssetValue from common asset string or chain', () => {
379
+ describe("fromChainOrSignature", () => {
380
+ test("creates AssetValue from common asset string or chain", () => {
280
381
  const customBaseAsset = [Chain.Cosmos, Chain.BinanceSmartChain, Chain.THORChain, Chain.Maya];
281
- Object.values(Chain)
282
- .filter((c) => !customBaseAsset.includes(c))
283
- .forEach((chain) => {
284
- const asset = AssetValue.fromChainOrSignature(chain);
285
- expect(asset).toEqual(
286
- expect.objectContaining({
287
- address: undefined,
288
- chain,
289
- decimal: BaseDecimal[chain],
290
- isGasAsset: ![Chain.Arbitrum, Chain.Optimism].includes(chain),
291
- isSynthetic: false,
292
- symbol: chain,
293
- ticker: chain,
294
- type: 'Native',
295
- }),
296
- );
297
- });
382
+ const filteredChains = Object.values(Chain).filter((c) => !customBaseAsset.includes(c));
383
+
384
+ for (const chain of filteredChains) {
385
+ const asset = AssetValue.fromChainOrSignature(chain);
386
+ expect(asset).toEqual(
387
+ expect.objectContaining({
388
+ address: undefined,
389
+ chain,
390
+ decimal: BaseDecimal[chain],
391
+ isGasAsset: ![Chain.Arbitrum, Chain.Optimism].includes(chain),
392
+ isSynthetic: false,
393
+ symbol: chain,
394
+ ticker: chain,
395
+ type: "Native",
396
+ }),
397
+ );
398
+ }
298
399
 
299
400
  const cosmosAsset = AssetValue.fromChainOrSignature(Chain.Cosmos);
300
401
  expect(cosmosAsset).toEqual(
@@ -304,9 +405,9 @@ describe('AssetValue', () => {
304
405
  decimal: BaseDecimal.GAIA,
305
406
  isGasAsset: true,
306
407
  isSynthetic: false,
307
- symbol: 'ATOM',
308
- ticker: 'ATOM',
309
- type: 'Native',
408
+ symbol: "ATOM",
409
+ ticker: "ATOM",
410
+ type: "Native",
310
411
  }),
311
412
  );
312
413
 
@@ -318,9 +419,9 @@ describe('AssetValue', () => {
318
419
  decimal: BaseDecimal.BSC,
319
420
  isGasAsset: true,
320
421
  isSynthetic: false,
321
- symbol: 'BNB',
322
- ticker: 'BNB',
323
- type: 'Native',
422
+ symbol: "BNB",
423
+ ticker: "BNB",
424
+ type: "Native",
324
425
  }),
325
426
  );
326
427
 
@@ -332,9 +433,9 @@ describe('AssetValue', () => {
332
433
  decimal: BaseDecimal.THOR,
333
434
  isGasAsset: true,
334
435
  isSynthetic: false,
335
- symbol: 'RUNE',
336
- ticker: 'RUNE',
337
- type: 'Native',
436
+ symbol: "RUNE",
437
+ ticker: "RUNE",
438
+ type: "Native",
338
439
  }),
339
440
  );
340
441
 
@@ -346,42 +447,42 @@ describe('AssetValue', () => {
346
447
  decimal: BaseDecimal.MAYA,
347
448
  isGasAsset: true,
348
449
  isSynthetic: false,
349
- symbol: 'CACAO',
350
- ticker: 'CACAO',
351
- type: 'Native',
450
+ symbol: "CACAO",
451
+ ticker: "CACAO",
452
+ type: "Native",
352
453
  }),
353
454
  );
354
455
 
355
- const thor = AssetValue.fromChainOrSignature('ETH.THOR');
456
+ const thor = AssetValue.fromChainOrSignature("ETH.THOR");
356
457
  expect(thor).toEqual(
357
458
  expect.objectContaining({
358
- address: '0xa5f2211b9b8170f694421f2046281775e8468044',
459
+ address: "0xa5f2211b9b8170f694421f2046281775e8468044",
359
460
  chain: Chain.Ethereum,
360
461
  decimal: 18,
361
462
  isGasAsset: false,
362
463
  isSynthetic: false,
363
- symbol: 'THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
364
- ticker: 'THOR',
464
+ symbol: "THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
465
+ ticker: "THOR",
365
466
  }),
366
467
  );
367
468
 
368
- const vthor = AssetValue.fromChainOrSignature('ETH.vTHOR');
469
+ const vthor = AssetValue.fromChainOrSignature("ETH.vTHOR");
369
470
  expect(vthor).toEqual(
370
471
  expect.objectContaining({
371
- address: '0x815c23eca83261b6ec689b60cc4a58b54bc24d8d',
472
+ address: "0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",
372
473
  chain: Chain.Ethereum,
373
474
  decimal: 18,
374
475
  isGasAsset: false,
375
476
  isSynthetic: false,
376
- symbol: 'vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d',
377
- ticker: 'vTHOR',
477
+ symbol: "vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",
478
+ ticker: "vTHOR",
378
479
  }),
379
480
  );
380
481
  });
381
482
  });
382
483
 
383
- describe('loadStaticAssets', () => {
384
- test('loads static assets from `@swapkit/tokens` lists', async () => {
484
+ describe("loadStaticAssets", () => {
485
+ test("loads static assets from `@swapkit/tokens` lists", async () => {
385
486
  // Dummy test - think of sth more meaningful
386
487
  const { ok } = await AssetValue.loadStaticAssets();
387
488
  expect(ok).toBe(true);
@@ -389,21 +490,21 @@ describe('AssetValue', () => {
389
490
  });
390
491
  });
391
492
 
392
- describe('getMinAmountByChain', () => {
393
- test('returns min amount for chain', () => {
394
- expect(getMinAmountByChain(Chain.THORChain).getValue('string')).toBe('0');
395
- expect(getMinAmountByChain(Chain.Maya).getValue('string')).toBe('0');
396
- expect(getMinAmountByChain(Chain.Cosmos).getValue('string')).toBe('0.000001');
397
-
398
- expect(getMinAmountByChain(Chain.Bitcoin).getValue('string')).toBe('0.00010001');
399
- expect(getMinAmountByChain(Chain.Litecoin).getValue('string')).toBe('0.00010001');
400
- expect(getMinAmountByChain(Chain.BitcoinCash).getValue('string')).toBe('0.00010001');
401
- expect(getMinAmountByChain(Chain.Dogecoin).getValue('string')).toBe('1.00000001');
402
-
403
- expect(getMinAmountByChain(Chain.BinanceSmartChain).getValue('string')).toBe('0.00000001');
404
- expect(getMinAmountByChain(Chain.Ethereum).getValue('string')).toBe('0.00000001');
405
- expect(getMinAmountByChain(Chain.Avalanche).getValue('string')).toBe('0.00000001');
406
- expect(getMinAmountByChain(Chain.Arbitrum).getValue('string')).toBe('0.00000001');
407
- expect(getMinAmountByChain(Chain.Optimism).getValue('string')).toBe('0.00000001');
493
+ describe("getMinAmountByChain", () => {
494
+ test("returns min amount for chain", () => {
495
+ expect(getMinAmountByChain(Chain.THORChain).getValue("string")).toBe("0");
496
+ expect(getMinAmountByChain(Chain.Maya).getValue("string")).toBe("0");
497
+ expect(getMinAmountByChain(Chain.Cosmos).getValue("string")).toBe("0.000001");
498
+
499
+ expect(getMinAmountByChain(Chain.Bitcoin).getValue("string")).toBe("0.00010001");
500
+ expect(getMinAmountByChain(Chain.Litecoin).getValue("string")).toBe("0.00010001");
501
+ expect(getMinAmountByChain(Chain.BitcoinCash).getValue("string")).toBe("0.00010001");
502
+ expect(getMinAmountByChain(Chain.Dogecoin).getValue("string")).toBe("1.00000001");
503
+
504
+ expect(getMinAmountByChain(Chain.BinanceSmartChain).getValue("string")).toBe("0.00000001");
505
+ expect(getMinAmountByChain(Chain.Ethereum).getValue("string")).toBe("0.00000001");
506
+ expect(getMinAmountByChain(Chain.Avalanche).getValue("string")).toBe("0.00000001");
507
+ expect(getMinAmountByChain(Chain.Arbitrum).getValue("string")).toBe("0.00000001");
508
+ expect(getMinAmountByChain(Chain.Optimism).getValue("string")).toBe("0.00000001");
408
509
  });
409
510
  });