@swapkit/core 1.0.0-rc.6 → 1.0.0-rc.61

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/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "author": "swapkit-oss-team",
3
3
  "dependencies": {
4
- "@swapkit/types": "1.0.0-rc.1",
5
- "@swapkit/helpers": "1.0.0-rc.2"
4
+ "@swapkit/helpers": "1.0.0-rc.48",
5
+ "@swapkit/types": "1.0.0-rc.25"
6
6
  },
7
7
  "description": "SwapKit Lib core",
8
8
  "devDependencies": {
9
- "@vitest/coverage-istanbul": "0.34.4",
10
- "ethers": "6.7.1",
11
- "vite": "4.4.9",
9
+ "@vitest/coverage-istanbul": "1.0.1",
10
+ "ethers": "6.9.0",
11
+ "vite": "5.0.6",
12
12
  "vite-plugin-top-level-await": "1.3.1",
13
13
  "vite-plugin-wasm": "3.2.2",
14
- "vitest": "0.34.4",
15
- "@internal/config": "0.0.0-internal.0",
16
- "@swapkit/api": "1.0.0-rc.1",
17
- "@swapkit/tokens": "1.0.0-rc.1",
18
- "@swapkit/toolbox-cosmos": "1.0.0-rc.4",
19
- "@swapkit/toolbox-evm": "1.0.0-rc.3",
20
- "@swapkit/toolbox-utxo": "1.0.0-rc.3"
14
+ "vitest": "1.0.1",
15
+ "@internal/config": "0.0.0-rc.11",
16
+ "@swapkit/api": "1.0.0-rc.25",
17
+ "@swapkit/tokens": "1.0.0-rc.27",
18
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.51",
19
+ "@swapkit/toolbox-evm": "1.0.0-rc.51",
20
+ "@swapkit/toolbox-utxo": "1.0.0-rc.51"
21
21
  },
22
22
  "peerDependencies": {
23
- "@swapkit/api": "1.0.0-rc.1",
24
- "@swapkit/tokens": "1.0.0-rc.1",
25
- "@swapkit/toolbox-cosmos": "1.0.0-rc.4",
26
- "@swapkit/toolbox-evm": "1.0.0-rc.3",
27
- "@swapkit/toolbox-utxo": "1.0.0-rc.3"
23
+ "@swapkit/api": "1.0.0-rc.25",
24
+ "@swapkit/tokens": "1.0.0-rc.27",
25
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.51",
26
+ "@swapkit/toolbox-evm": "1.0.0-rc.51",
27
+ "@swapkit/toolbox-utxo": "1.0.0-rc.51"
28
28
  },
29
29
  "eslintConfig": {
30
30
  "extends": "../../../internal/eslint-config"
@@ -52,7 +52,7 @@
52
52
  "repository": "https://github.com/thorswap/SwapKit.git",
53
53
  "type": "module",
54
54
  "types": "./dist/index.d.ts",
55
- "version": "1.0.0-rc.6",
55
+ "version": "1.0.0-rc.61",
56
56
  "scripts": {
57
57
  "build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
58
58
  "clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
@@ -4,19 +4,43 @@ import { describe, expect, test } from 'vitest';
4
4
  import { getExplorerAddressUrl, getExplorerTxUrl } from '../explorerUrls.ts';
5
5
 
6
6
  describe('Explorer URLs', () => {
7
- Object.values(Chain)
8
- .filter((c) => ![Chain.Litecoin, Chain.Dogecoin, Chain.Cosmos].includes(c))
9
- .forEach((chain) => {
10
- test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
11
- expect(getExplorerTxUrl({ chain, txHash: '0x12345' })).toBe(
12
- `${ChainToExplorerUrl[chain]}/tx/0x12345`,
13
- );
7
+ [
8
+ Chain.Binance,
9
+ Chain.Bitcoin,
10
+ Chain.BitcoinCash,
11
+ Chain.Maya,
12
+ Chain.Kujira,
13
+ Chain.THORChain,
14
+ ].forEach((chain) => {
15
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
16
+ expect(getExplorerTxUrl({ chain, txHash: '0x123456789' })).toBe(
17
+ `${ChainToExplorerUrl[chain]}/tx/123456789`,
18
+ );
14
19
 
15
- expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
16
- `${ChainToExplorerUrl[chain]}/address/asdfg`,
17
- );
18
- });
20
+ expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
21
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
22
+ );
19
23
  });
24
+ });
25
+
26
+ [
27
+ Chain.Arbitrum,
28
+ Chain.Avalanche,
29
+ Chain.BinanceSmartChain,
30
+ Chain.Ethereum,
31
+ Chain.Optimism,
32
+ Chain.Polygon,
33
+ ].forEach((chain) => {
34
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
35
+ expect(getExplorerTxUrl({ chain, txHash: '0x123456789' })).toBe(
36
+ `${ChainToExplorerUrl[chain]}/tx/0x123456789`,
37
+ );
38
+
39
+ expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
40
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
41
+ );
42
+ });
43
+ });
20
44
 
21
45
  test('getExplorerTxUrl throws Error for unsupported Chain', () => {
22
46
  expect(() =>
@@ -10,7 +10,7 @@ export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Cha
10
10
  case Chain.Maya:
11
11
  case Chain.Kujira:
12
12
  case Chain.THORChain:
13
- return `${baseUrl}/tx/${txHash}`;
13
+ return `${baseUrl}/tx/${txHash.startsWith('0x') ? txHash.slice(2) : txHash}`;
14
14
 
15
15
  case Chain.Arbitrum:
16
16
  case Chain.Avalanche:
@@ -54,6 +54,25 @@ const getEmptyWalletStructure = () =>
54
54
  {} as Record<Chain, null>,
55
55
  );
56
56
 
57
+ const validateAddress = async ({
58
+ chain,
59
+ address,
60
+ }: {
61
+ chain: Chain;
62
+ address: string | undefined;
63
+ }) => {
64
+ if (!address) return false;
65
+ switch (chain) {
66
+ case Chain.Bitcoin:
67
+ if (address.startsWith('bc1p')) {
68
+ return false;
69
+ }
70
+ return true;
71
+ default:
72
+ return true;
73
+ }
74
+ };
75
+
57
76
  export class SwapKitCore<T = ''> {
58
77
  public connectedChains: Wallet = getEmptyWalletStructure();
59
78
  public connectedWallets: WalletMethods = getEmptyWalletStructure();
@@ -68,9 +87,8 @@ export class SwapKitCore<T = ''> {
68
87
  getWallet = <T extends Chain>(chain: Chain) => this.connectedWallets[chain] as WalletMethods[T];
69
88
  getExplorerAddressUrl = (chain: Chain, address: string) =>
70
89
  getExplorerAddressUrl({ chain, address });
71
- getBalance = async (chain: Chain, refresh?: boolean) => {
72
- if (!refresh) return this.connectedChains[chain]?.balance || [];
73
- const wallet = await this.getWalletByChain(chain);
90
+ getBalance = async (chain: Chain, potentialScamFilter?: boolean) => {
91
+ const wallet = await this.getWalletByChain(chain, potentialScamFilter);
74
92
 
75
93
  return wallet?.balance || [];
76
94
  };
@@ -80,8 +98,8 @@ export class SwapKitCore<T = ''> {
80
98
  const evmChain = quoteMode.startsWith('ERC20-')
81
99
  ? Chain.Ethereum
82
100
  : quoteMode.startsWith('ARC20-')
83
- ? Chain.Avalanche
84
- : Chain.BinanceSmartChain;
101
+ ? Chain.Avalanche
102
+ : Chain.BinanceSmartChain;
85
103
 
86
104
  if (!route.complete) throw new SwapKitError('core_swap_route_not_complete');
87
105
 
@@ -95,7 +113,6 @@ export class SwapKitCore<T = ''> {
95
113
  const transaction = streamSwap ? route?.streamingSwap?.transaction : route?.transaction;
96
114
  if (!transaction) throw new SwapKitError('core_swap_route_transaction_not_found');
97
115
 
98
- const { isHexString, parseUnits } = await import('ethers');
99
116
  const { data, from, to, value } = route.transaction;
100
117
 
101
118
  const params = {
@@ -103,11 +120,7 @@ export class SwapKitCore<T = ''> {
103
120
  from,
104
121
  to: to.toLowerCase(),
105
122
  chainId: BigInt(ChainToChainId[evmChain]),
106
- value: value
107
- ? new SwapKitNumber({
108
- value: !isHexString(value) ? parseUnits(value, 'wei').toString(16) : value,
109
- }).baseValueBigInt
110
- : 0n,
123
+ value: value ? BigInt(value) : 0n,
111
124
  };
112
125
 
113
126
  return walletMethods.sendTransaction(params, feeOptionKey) as Promise<string>;
@@ -121,13 +134,20 @@ export class SwapKitCore<T = ''> {
121
134
  const { address: recipient } = await this.#getInboundDataByChain(asset.chain);
122
135
  const {
123
136
  contract: router,
124
- calldata: { amountIn, memo, memoStreamingSwap },
137
+ calldata: { expiration, amountIn, memo, memoStreamingSwap },
125
138
  } = route;
126
139
 
127
140
  const assetValue = asset.add(SwapKitNumber.fromBigInt(BigInt(amountIn), asset.decimal));
128
141
  const swapMemo = (streamSwap ? memoStreamingSwap || memo : memo) as string;
129
142
 
130
- return this.deposit({ assetValue, memo: swapMemo, feeOptionKey, router, recipient });
143
+ return this.deposit({
144
+ expiration,
145
+ assetValue,
146
+ memo: swapMemo,
147
+ feeOptionKey,
148
+ router,
149
+ recipient,
150
+ });
131
151
  }
132
152
 
133
153
  if (SWAP_IN.includes(quoteMode)) {
@@ -148,9 +168,7 @@ export class SwapKitCore<T = ''> {
148
168
 
149
169
  const contract = await walletMethods.createContract?.(contractAddress, abi, provider);
150
170
 
151
- // TODO: (@Towan) Contract evm methods should be generic
152
- // @ts-expect-error
153
- const tx = await contract.populateTransaction.swapIn?.(
171
+ const tx = await contract.getFunction('swapIn').populateTransaction(
154
172
  ...getSwapInParams({
155
173
  streamSwap,
156
174
  toChecksumAddress,
@@ -170,21 +188,27 @@ export class SwapKitCore<T = ''> {
170
188
  }
171
189
  };
172
190
 
173
- getWalletByChain = async (chain: Chain) => {
191
+ getWalletByChain = async (chain: Chain, potentialScamFilter?: boolean) => {
174
192
  const address = this.getAddress(chain);
175
193
  if (!address) return null;
194
+ const defaultBalance = [AssetValue.fromChainOrSignature(chain)];
195
+ const walletType = this.connectedChains[chain]?.walletType as WalletOption;
176
196
 
177
- const balance = (await this.getWallet(chain)?.getBalance(address)) ?? [
178
- AssetValue.fromChainOrSignature(chain),
179
- ];
197
+ try {
198
+ const balance = await this.getWallet(chain)?.getBalance(address, potentialScamFilter);
180
199
 
181
- this.connectedChains[chain] = {
182
- address,
183
- balance,
184
- walletType: this.connectedChains[chain]?.walletType as WalletOption,
185
- };
200
+ this.connectedChains[chain] = {
201
+ address,
202
+ balance: balance?.length ? balance : defaultBalance,
203
+ walletType,
204
+ };
186
205
 
187
- return { ...this.connectedChains[chain] };
206
+ return { ...this.connectedChains[chain] };
207
+ } catch (error) {
208
+ console.error(error);
209
+
210
+ return { address, balance: defaultBalance, walletType };
211
+ }
188
212
  };
189
213
 
190
214
  approveAssetValue = (assetValue: AssetValue, contractAddress?: string) =>
@@ -215,6 +239,8 @@ export class SwapKitCore<T = ''> {
215
239
  }: CoreTxParams & { router?: string }) => {
216
240
  const { chain, symbol, ticker } = assetValue;
217
241
  const walletInstance = this.connectedWallets[chain];
242
+ if (!(await validateAddress({ address: await walletInstance?.getAddress(), chain })))
243
+ throw new SwapKitError('core_transaction_invalid_sender_address');
218
244
  if (!walletInstance) throw new SwapKitError('core_wallet_connection_not_found');
219
245
 
220
246
  const params = this.#prepareTxParams({ assetValue, recipient, router, ...rest });
@@ -235,10 +261,10 @@ export class SwapKitCore<T = ''> {
235
261
  chain === Chain.Avalanche
236
262
  ? TCAvalancheDepositABI
237
263
  : chain === Chain.BinanceSmartChain
238
- ? TCBscDepositABI
239
- : TCEthereumVaultAbi;
264
+ ? TCBscDepositABI
265
+ : TCEthereumVaultAbi;
240
266
 
241
- return (await (
267
+ const response = await (
242
268
  walletInstance as EVMWallet<typeof AVAXToolbox | typeof ETHToolbox | typeof BSCToolbox>
243
269
  ).call({
244
270
  abi,
@@ -248,13 +274,17 @@ export class SwapKitCore<T = ''> {
248
274
  funcParams: [
249
275
  recipient,
250
276
  getChecksumAddressFromAsset({ chain, symbol, ticker }, chain),
251
- // TODO: (@Towan) Re-Check on that conversion 🙏
252
- assetValue.baseValueBigInt.toString(),
277
+ assetValue.getBaseValue('string'),
253
278
  params.memo,
254
- rest.expiration,
279
+ rest.expiration || parseInt(`${(new Date().getTime() + 15 * 60 * 1000) / 1000}`),
255
280
  ],
256
- txOverrides: { from: params.from, value: assetValue.baseValueBigInt },
257
- })) as Promise<string>;
281
+ txOverrides: {
282
+ from: params.from,
283
+ value: assetValue.isGasAsset ? assetValue.getBaseValue('bigint') : undefined,
284
+ },
285
+ });
286
+
287
+ return response as string;
258
288
  }
259
289
 
260
290
  default: {
@@ -269,10 +299,10 @@ export class SwapKitCore<T = ''> {
269
299
  const errorKey: Keys = isInsufficientFunds
270
300
  ? 'core_transaction_deposit_insufficient_funds_error'
271
301
  : isGas
272
- ? 'core_transaction_deposit_gas_error'
273
- : isServer
274
- ? 'core_transaction_deposit_server_error'
275
- : 'core_transaction_deposit_error';
302
+ ? 'core_transaction_deposit_gas_error'
303
+ : isServer
304
+ ? 'core_transaction_deposit_server_error'
305
+ : 'core_transaction_deposit_error';
276
306
 
277
307
  throw new SwapKitError(errorKey, error);
278
308
  }
@@ -323,7 +353,6 @@ export class SwapKitCore<T = ''> {
323
353
  };
324
354
 
325
355
  addLiquidity = async ({
326
- poolIdentifier,
327
356
  runeAssetValue,
328
357
  assetValue,
329
358
  runeAddr,
@@ -331,7 +360,6 @@ export class SwapKitCore<T = ''> {
331
360
  isPendingSymmAsset,
332
361
  mode = 'sym',
333
362
  }: {
334
- poolIdentifier: string;
335
363
  runeAssetValue: AssetValue;
336
364
  assetValue: AssetValue;
337
365
  isPendingSymmAsset?: boolean;
@@ -339,7 +367,7 @@ export class SwapKitCore<T = ''> {
339
367
  assetAddr?: string;
340
368
  mode?: 'sym' | 'rune' | 'asset';
341
369
  }) => {
342
- const [chain, ...symbolPath] = poolIdentifier.split('.') as [Chain, string];
370
+ const { chain, symbol } = assetValue;
343
371
  const isSym = mode === 'sym';
344
372
  const runeTransfer = runeAssetValue?.gt(0) && (isSym || mode === 'rune');
345
373
  const assetTransfer = assetValue?.gt(0) && (isSym || mode === 'asset');
@@ -355,13 +383,12 @@ export class SwapKitCore<T = ''> {
355
383
  }
356
384
 
357
385
  let runeTx, assetTx;
358
- const sharedParams = { chain, symbol: symbolPath.join('.') };
359
386
 
360
387
  if (runeTransfer && runeAssetValue) {
361
388
  try {
362
389
  runeTx = await this.#depositToPool({
363
390
  assetValue: runeAssetValue,
364
- memo: getMemoFor(MemoType.DEPOSIT, { ...sharedParams, address: assetAddress }),
391
+ memo: getMemoFor(MemoType.DEPOSIT, { chain, symbol, address: assetAddress }),
365
392
  });
366
393
  } catch (error) {
367
394
  throw new SwapKitError('core_transaction_add_liquidity_rune_error', error);
@@ -372,7 +399,7 @@ export class SwapKitCore<T = ''> {
372
399
  try {
373
400
  assetTx = await this.#depositToPool({
374
401
  assetValue,
375
- memo: getMemoFor(MemoType.DEPOSIT, { ...sharedParams, address: runeAddress }),
402
+ memo: getMemoFor(MemoType.DEPOSIT, { chain, symbol, address: runeAddress }),
376
403
  });
377
404
  } catch (error) {
378
405
  throw new SwapKitError('core_transaction_add_liquidity_asset_error', error);
@@ -382,6 +409,29 @@ export class SwapKitCore<T = ''> {
382
409
  return { runeTx, assetTx };
383
410
  };
384
411
 
412
+ addLiquidityPart = ({
413
+ assetValue,
414
+ poolAddress,
415
+ address,
416
+ symmetric,
417
+ }: {
418
+ assetValue: AssetValue;
419
+ address?: string;
420
+ poolAddress: string;
421
+ symmetric: boolean;
422
+ }) => {
423
+ if (symmetric && !address) {
424
+ throw new SwapKitError('core_transaction_add_liquidity_invalid_params');
425
+ }
426
+ const memo = getMemoFor(MemoType.DEPOSIT, {
427
+ chain: poolAddress.split('.')[0] as Chain,
428
+ symbol: poolAddress.split('.')[1],
429
+ address: symmetric ? address : '',
430
+ });
431
+
432
+ return this.#depositToPool({ assetValue, memo });
433
+ };
434
+
385
435
  withdraw = async ({
386
436
  memo,
387
437
  assetValue,
@@ -399,28 +449,22 @@ export class SwapKitCore<T = ''> {
399
449
  to === 'rune'
400
450
  ? AssetValue.fromChainOrSignature(Chain.THORChain)
401
451
  : (from === 'sym' && to === 'sym') || from === 'rune' || from === 'asset'
402
- ? undefined
403
- : assetValue;
452
+ ? undefined
453
+ : assetValue;
404
454
 
405
- try {
406
- const txHash = await this.#depositToPool({
407
- assetValue: getMinAmountByChain(from === 'asset' ? assetValue.chain : Chain.THORChain),
408
- memo:
409
- memo ||
410
- getMemoFor(MemoType.WITHDRAW, {
411
- symbol: assetValue.symbol,
412
- chain: assetValue.chain,
413
- ticker: assetValue.ticker,
414
- basisPoints: Math.max(10000, Math.round(percent * 100)),
415
- targetAssetString: targetAsset?.toString(),
416
- singleSide: false,
417
- }),
455
+ const value = getMinAmountByChain(from === 'asset' ? assetValue.chain : Chain.THORChain);
456
+ const memoString =
457
+ memo ||
458
+ getMemoFor(MemoType.WITHDRAW, {
459
+ symbol: assetValue.symbol,
460
+ chain: assetValue.chain,
461
+ ticker: assetValue.ticker,
462
+ basisPoints: Math.max(10000, Math.round(percent * 100)),
463
+ targetAssetString: targetAsset?.toString(),
464
+ singleSide: false,
418
465
  });
419
466
 
420
- return txHash;
421
- } catch (error) {
422
- throw new SwapKitError('core_transaction_withdraw_error', error);
423
- }
467
+ return this.#depositToPool({ assetValue: value, memo: memoString });
424
468
  };
425
469
 
426
470
  savings = async ({
@@ -440,10 +484,13 @@ export class SwapKitCore<T = ''> {
440
484
  symbol: assetValue.symbol,
441
485
  chain: assetValue.chain,
442
486
  singleSide: true,
443
- basisPoints: percent ? Math.max(10000, Math.round(percent * 100)) : undefined,
487
+ basisPoints: percent ? Math.min(10000, Math.round(percent * 100)) : undefined,
444
488
  });
445
489
 
446
- return this.#depositToPool({ assetValue, memo: memoString });
490
+ const value =
491
+ memoType === MemoType.DEPOSIT ? assetValue : getMinAmountByChain(assetValue.chain);
492
+
493
+ return this.#depositToPool({ memo: memoString, assetValue: value });
447
494
  };
448
495
 
449
496
  loan = ({
@@ -480,7 +527,7 @@ export class SwapKitCore<T = ''> {
480
527
  type === 'bond' ? MemoType.BOND : type === 'unbond' ? MemoType.UNBOND : MemoType.LEAVE;
481
528
  const memo = getMemoFor(memoType, {
482
529
  address,
483
- unbondAmount: type === 'unbond' ? assetValue.baseValueNumber : undefined,
530
+ unbondAmount: type === 'unbond' ? assetValue.getBaseValue('number') : undefined,
484
531
  });
485
532
 
486
533
  return this.#thorchainTransfer({
@@ -498,7 +545,7 @@ export class SwapKitCore<T = ''> {
498
545
  extend = ({ wallets, config, apis = {}, rpcUrls = {} }: ExtendParams<T>) => {
499
546
  try {
500
547
  wallets.forEach((wallet) => {
501
- // @ts-expect-error ANCHOR - Not Worth
548
+ // @ts-expect-error - this is fine as we are extending the class
502
549
  this[wallet.connectMethodName] = wallet.connect({
503
550
  addChain: this.#addConnectedChain,
504
551
  config: config || {},
@@ -612,7 +659,7 @@ export class SwapKitCore<T = ''> {
612
659
  };
613
660
 
614
661
  #approve = async <T = string>({
615
- assetValue: { baseValueBigInt, address, chain, isGasAsset, isSynthetic },
662
+ assetValue,
616
663
  type = 'checkOnly',
617
664
  contractAddress,
618
665
  }: {
@@ -620,6 +667,7 @@ export class SwapKitCore<T = ''> {
620
667
  type?: 'checkOnly' | 'approve';
621
668
  contractAddress?: string;
622
669
  }) => {
670
+ const { address, chain, isGasAsset, isSynthetic } = assetValue;
623
671
  const isEVMChain = [Chain.Ethereum, Chain.Avalanche, Chain.BinanceSmartChain].includes(chain);
624
672
  const isNativeEVM = isEVMChain && isGasAsset;
625
673
 
@@ -638,7 +686,7 @@ export class SwapKitCore<T = ''> {
638
686
  contractAddress || ((await this.#getInboundDataByChain(chain)).router as string);
639
687
 
640
688
  return walletAction({
641
- amount: baseValueBigInt,
689
+ amount: assetValue.getBaseValue('bigint'),
642
690
  assetAddress: address,
643
691
  from,
644
692
  spenderAddress,
@@ -1,4 +1,4 @@
1
- import { getRequest } from '@swapkit/helpers';
1
+ import { RequestClient } from '@swapkit/helpers';
2
2
  import type { Chain } from '@swapkit/types';
3
3
  import { ApiUrl } from '@swapkit/types';
4
4
 
@@ -21,11 +21,11 @@ type InboundAddressData = {
21
21
  export const getInboundData = (stagenet: boolean) => {
22
22
  const baseUrl = stagenet ? ApiUrl.ThornodeStagenet : ApiUrl.ThornodeMainnet;
23
23
 
24
- return getRequest<InboundAddressData>(`${baseUrl}/thorchain/inbound_addresses`);
24
+ return RequestClient.get<InboundAddressData>(`${baseUrl}/thorchain/inbound_addresses`);
25
25
  };
26
26
 
27
27
  export const getMimirData = (stagenet: boolean) => {
28
28
  const baseUrl = stagenet ? ApiUrl.ThornodeStagenet : ApiUrl.ThornodeMainnet;
29
29
 
30
- return getRequest<Record<string, number>>(`${baseUrl}/thorchain/mimir`);
30
+ return RequestClient.get<Record<string, number>>(`${baseUrl}/thorchain/mimir`);
31
31
  };
@@ -1 +0,0 @@
1
- "use strict";var nt=Object.defineProperty;var st=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var j=(e,t,r)=>(st(e,typeof t!="symbol"?t+"":t,r),r),D=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var s=(e,t,r)=>(D(e,t,"read from private field"),r?r.call(e):t.get(e)),b=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},M=(e,t,r,i)=>(D(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var u=(e,t,r)=>(D(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q="6.7.1";function ot(e,t,r){const i=t.split("|").map(o=>o.trim());for(let o=0;o<i.length;o++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof e===t)return}const n=new Error(`invalid value for type ${t}`);throw n.code="INVALID_ARGUMENT",n.argument=`value.${r}`,n.value=e,n}function K(e,t,r){for(let i in t){let n=t[i];const o=r?r[i]:null;o&&ot(n,o,i),Object.defineProperty(e,i,{enumerable:!0,value:n,writable:!1})}}function x(e){if(e==null)return"null";if(Array.isArray(e))return"[ "+e.map(x).join(", ")+" ]";if(e instanceof Uint8Array){const t="0123456789abcdef";let r="0x";for(let i=0;i<e.length;i++)r+=t[e[i]>>4],r+=t[e[i]&15];return r}if(typeof e=="object"&&typeof e.toJSON=="function")return x(e.toJSON());switch(typeof e){case"boolean":case"symbol":return e.toString();case"bigint":return BigInt(e).toString();case"number":return e.toString();case"string":return JSON.stringify(e);case"object":{const t=Object.keys(e);return t.sort(),"{ "+t.map(r=>`${x(r)}: ${x(e[r])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function W(e,t,r){{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${x(r)}`);for(const o in r){const l=r[o];n.push(o+"="+x(l))}}n.push(`code=${t}`),n.push(`version=${Q}`),n.length&&(e+=" ("+n.join(", ")+")")}let i;switch(t){case"INVALID_ARGUMENT":i=new TypeError(e);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(e);break;default:i=new Error(e)}return K(i,{code:t}),r&&Object.assign(i,r),i}function g(e,t,r,i){if(!e)throw W(t,r,i)}function c(e,t,r,i){g(e,t,"INVALID_ARGUMENT",{argument:r,value:i})}["NFD","NFC","NFKD","NFKC"].reduce((e,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"){const r=String.fromCharCode(233).normalize("NFD"),i=String.fromCharCode(101,769);if(r!==i)throw new Error("broken")}e.push(t)}catch{}return e},[]);function Y(e,t,r){if(r==null&&(r=""),e!==t){let i=r,n="new";r&&(i+=".",n+=" "+r),g(!1,`private constructor; use ${i}from* methods`,"UNSUPPORTED_OPERATION",{operation:n})}}function ft(e,t,r){if(e instanceof Uint8Array)return r?new Uint8Array(e):e;if(typeof e=="string"&&e.match(/^0x([0-9a-f][0-9a-f])*$/i)){const i=new Uint8Array((e.length-2)/2);let n=2;for(let o=0;o<i.length;o++)i[o]=parseInt(e.substring(n,n+2),16),n+=2;return i}c(!1,"invalid BytesLike value",t||"value",e)}function tt(e,t){return ft(e,t,!1)}function ut(e,t){return!(typeof e!="string"||!e.match(/^0x[0-9A-Fa-f]*$/)||typeof t=="number"&&e.length!==2+2*t||t===!0&&e.length%2!==0)}const et=BigInt(0),E=BigInt(1),S=9007199254740991;function k(e,t){const r=q(e,"value"),i=BigInt(T(t,"width"));if(g(r>>i===et,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),r>>i-E){const n=(E<<i)-E;return-((~r&n)+E)}return r}function z(e,t){const r=q(e,"value"),i=BigInt(T(t,"bits"));return r&(E<<i)-E}function V(e,t){switch(typeof e){case"bigint":return e;case"number":return c(Number.isInteger(e),"underflow",t||"value",e),c(e>=-S&&e<=S,"overflow",t||"value",e),BigInt(e);case"string":try{if(e==="")throw new Error("empty string");return e[0]==="-"&&e[1]!=="-"?-BigInt(e.substring(1)):BigInt(e)}catch(r){c(!1,`invalid BigNumberish string: ${r.message}`,t||"value",e)}}c(!1,"invalid BigNumberish value",t||"value",e)}function q(e,t){const r=V(e,t);return g(r>=et,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),r}const X="0123456789abcdef";function rt(e){if(e instanceof Uint8Array){let t="0x0";for(const r of e)t+=X[r>>4],t+=X[r&15];return BigInt(t)}return V(e)}function T(e,t){switch(typeof e){case"bigint":return c(e>=-S&&e<=S,"overflow",t||"value",e),Number(e);case"number":return c(Number.isInteger(e),"underflow",t||"value",e),c(e>=-S&&e<=S,"overflow",t||"value",e),e;case"string":try{if(e==="")throw new Error("empty string");return T(BigInt(e),t)}catch(r){c(!1,`invalid numeric string: ${r.message}`,t||"value",e)}}c(!1,"invalid numeric value",t||"value",e)}const ct=BigInt(-1),d=BigInt(0),F=BigInt(1),lt=BigInt(5),B={};let A="0000";for(;A.length<80;)A+=A;function y(e){let t=A;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function C(e,t,r){const i=BigInt(t.width);if(t.signed){const n=F<<i-F;g(r==null||e>=-n&&e<n,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:e}),e>d?e=k(z(e,i),i):e=-k(z(-e,i),i)}else{const n=F<<i;g(r==null||e>=0&&e<n,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:e}),e=(e%n+n)%n&n-F}return e}function P(e){typeof e=="number"&&(e=`fixed128x${e}`);let t=!0,r=128,i=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")t=!1;else{const o=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);c(o,"invalid fixed format","format",e),t=o[1]!=="u",r=parseInt(o[2]),i=parseInt(o[3])}}else if(e){const o=e,l=(h,R,it)=>o[h]==null?it:(c(typeof o[h]===R,"invalid fixed format ("+h+" not "+R+")","format."+h,o[h]),o[h]);t=l("signed","boolean",t),r=l("width","number",r),i=l("decimals","number",i)}c(r%8===0,"invalid FixedNumber width (not byte aligned)","format.width",r),c(i<=80,"invalid FixedNumber decimals (too large)","format.decimals",i);const n=(t?"":"u")+"fixed"+String(r)+"x"+String(i);return{signed:t,width:r,decimals:i,name:n}}function at(e,t){let r="";e<d&&(r="-",e*=ct);let i=e.toString();if(t===0)return r+i;for(;i.length<=t;)i=A+i;const n=i.length-t;for(i=i.substring(0,n)+"."+i.substring(n);i[0]==="0"&&i[1]!==".";)i=i.substring(1);for(;i[i.length-1]==="0"&&i[i.length-2]!==".";)i=i.substring(0,i.length-1);return r+i}var m,f,a,N,U,w,p,$,G,L,H,v,J,_,Z;const I=class I{constructor(t,r,i){b(this,N);b(this,w);b(this,$);b(this,L);b(this,v);b(this,_);j(this,"format");b(this,m,void 0);b(this,f,void 0);b(this,a,void 0);j(this,"_value");Y(t,B,"FixedNumber"),M(this,f,r),M(this,m,i);const n=at(r,i.decimals);K(this,{format:i.name,_value:n}),M(this,a,y(i.decimals))}get signed(){return s(this,m).signed}get width(){return s(this,m).width}get decimals(){return s(this,m).decimals}get value(){return s(this,f)}addUnsafe(t){return u(this,$,G).call(this,t)}add(t){return u(this,$,G).call(this,t,"add")}subUnsafe(t){return u(this,L,H).call(this,t)}sub(t){return u(this,L,H).call(this,t,"sub")}mulUnsafe(t){return u(this,v,J).call(this,t)}mul(t){return u(this,v,J).call(this,t,"mul")}mulSignal(t){u(this,N,U).call(this,t);const r=s(this,f)*s(t,f);return g(r%s(this,a)===d,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),u(this,w,p).call(this,r/s(this,a),"mulSignal")}divUnsafe(t){return u(this,_,Z).call(this,t)}div(t){return u(this,_,Z).call(this,t,"div")}divSignal(t){g(s(t,f)!==d,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),u(this,N,U).call(this,t);const r=s(this,f)*s(this,a);return g(r%s(t,f)===d,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),u(this,w,p).call(this,r/s(t,f),"divSignal")}cmp(t){let r=this.value,i=t.value;const n=this.decimals-t.decimals;return n>0?i*=y(n):n<0&&(r*=y(-n)),r<i?-1:r>i?1:0}eq(t){return this.cmp(t)===0}lt(t){return this.cmp(t)<0}lte(t){return this.cmp(t)<=0}gt(t){return this.cmp(t)>0}gte(t){return this.cmp(t)>=0}floor(){let t=s(this,f);return s(this,f)<d&&(t-=s(this,a)-F),t=s(this,f)/s(this,a)*s(this,a),u(this,w,p).call(this,t,"floor")}ceiling(){let t=s(this,f);return s(this,f)>d&&(t+=s(this,a)-F),t=s(this,f)/s(this,a)*s(this,a),u(this,w,p).call(this,t,"ceiling")}round(t){if(t==null&&(t=0),t>=this.decimals)return this;const r=this.decimals-t,i=lt*y(r-1);let n=this.value+i;const o=y(r);return n=n/o*o,C(n,s(this,m),"round"),new I(B,n,s(this,m))}isZero(){return s(this,f)===d}isNegative(){return s(this,f)<d}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return I.fromString(this.toString(),t)}static fromValue(t,r,i){const n=r==null?0:T(r),o=P(i);let l=V(t,"value");const h=n-o.decimals;if(h>0){const R=y(h);g(l%R===d,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:t}),l/=R}else h<0&&(l*=y(-h));return C(l,o,"fromValue"),new I(B,l,o)}static fromString(t,r){const i=t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);c(i&&i[2].length+i[3].length>0,"invalid FixedNumber string value","value",t);const n=P(r);let o=i[2]||"0",l=i[3]||"";for(;l.length<n.decimals;)l+=A;g(l.substring(n.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:t}),l=l.substring(0,n.decimals);const h=BigInt(i[1]+o+l);return C(h,n,"fromString"),new I(B,h,n)}static fromBytes(t,r){let i=rt(tt(t,"value"));const n=P(r);return n.signed&&(i=k(i,n.width)),C(i,n,"fromBytes"),new I(B,i,n)}};m=new WeakMap,f=new WeakMap,a=new WeakMap,N=new WeakSet,U=function(t){c(this.format===t.format,"incompatible format; use fixedNumber.toFormat","other",t)},w=new WeakSet,p=function(t,r){return t=C(t,s(this,m),r),new I(B,t,s(this,m))},$=new WeakSet,G=function(t,r){return u(this,N,U).call(this,t),u(this,w,p).call(this,s(this,f)+s(t,f),r)},L=new WeakSet,H=function(t,r){return u(this,N,U).call(this,t),u(this,w,p).call(this,s(this,f)-s(t,f),r)},v=new WeakSet,J=function(t,r){return u(this,N,U).call(this,t),u(this,w,p).call(this,s(this,f)*s(t,f)/s(this,a),r)},_=new WeakSet,Z=function(t,r){return g(s(t,f)!==d,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),u(this,N,U).call(this,t),u(this,w,p).call(this,s(this,f)*s(this,a)/s(t,f),r)};let O=I;const ht=["wei","kwei","mwei","gwei","szabo","finney","ether"];function gt(e,t){c(typeof e=="string","value must be a string","value",e);let r=18;if(typeof t=="string"){const i=ht.indexOf(t);c(i>=0,"invalid unit","unit",t),r=3*i}else t!=null&&(r=T(t,"unit"));return O.fromString(e,{decimals:r,width:512}).value}exports.FixedNumber=O;exports.assert=g;exports.assertArgument=c;exports.assertPrivate=Y;exports.defineProperties=K;exports.fromTwos=k;exports.getBigInt=V;exports.getBytes=tt;exports.getNumber=T;exports.getUint=q;exports.isHexString=ut;exports.makeError=W;exports.mask=z;exports.parseUnits=gt;exports.toBigInt=rt;exports.version=Q;