@xchainjs/xchain-thorchain-amm 3.0.31 → 3.0.33

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.
Files changed (3) hide show
  1. package/lib/index.esm.js +190 -199
  2. package/lib/index.js +151 -160
  3. package/package.json +21 -19
package/lib/index.esm.js CHANGED
@@ -1,18 +1,20 @@
1
- import { AssetAVAX, AVAXChain, Client as Client$7, defaultAvaxParams } from '@xchainjs/xchain-avax';
2
- import { AssetBETH, BASEChain, Client as Client$5, defaultBaseParams } from '@xchainjs/xchain-base';
3
- import { XRPChain, Client as Client$2, defaultXRPParams } from '@xchainjs/xchain-ripple';
4
- import { BTCChain, Client as Client$c, defaultBTCParams } from '@xchainjs/xchain-bitcoin';
5
- import { BCHChain, Client as Client$b, defaultBchParams } from '@xchainjs/xchain-bitcoincash';
6
- import { AssetBSC, BSCChain, Client as Client$6, defaultBscParams } from '@xchainjs/xchain-bsc';
7
- import { SOLChain, Client as Client$1, defaultSolanaParams } from '@xchainjs/xchain-solana';
1
+ import { AVAXChain, Client as Client$9, defaultAvaxParams, AssetAVAX } from '@xchainjs/xchain-avax';
2
+ import { BASEChain, Client as Client$7, defaultBaseParams, AssetBETH } from '@xchainjs/xchain-base';
3
+ import { XRPChain, Client as Client$4, defaultXRPParams } from '@xchainjs/xchain-ripple';
4
+ import { BTCChain, Client as Client$e, defaultBTCParams } from '@xchainjs/xchain-bitcoin';
5
+ import { BCHChain, Client as Client$d, defaultBchParams } from '@xchainjs/xchain-bitcoincash';
6
+ import { BSCChain, Client as Client$8, defaultBscParams, AssetBSC } from '@xchainjs/xchain-bsc';
7
+ import { SOLChain, Client as Client$3, defaultSolanaParams } from '@xchainjs/xchain-solana';
8
+ import { SUIChain, Client as Client$2, defaultSuiParams } from '@xchainjs/xchain-sui';
8
9
  import { Protocol, Network } from '@xchainjs/xchain-client';
9
- import { GAIAChain, Client as Client$4, AssetATOM } from '@xchainjs/xchain-cosmos';
10
- import { DOGEChain, Client as Client$9, defaultDogeParams } from '@xchainjs/xchain-doge';
11
- import { AssetETH, ETHChain, Client as Client$8, defaultEthParams } from '@xchainjs/xchain-ethereum';
10
+ import { GAIAChain, Client as Client$6, AssetATOM } from '@xchainjs/xchain-cosmos';
11
+ import { DOGEChain, Client as Client$b, defaultDogeParams } from '@xchainjs/xchain-doge';
12
+ import { ETHChain, Client as Client$a, defaultEthParams, AssetETH } from '@xchainjs/xchain-ethereum';
12
13
  import { abi, MAX_APPROVAL } from '@xchainjs/xchain-evm';
13
- import { LTCChain, Client as Client$a, defaultLtcParams } from '@xchainjs/xchain-litecoin';
14
- import { TRONChain, Client, defaultTRONParams } from '@xchainjs/xchain-tron';
15
- import { THORChain, Client as Client$3, defaultClientConfig, AssetRuneNative, RUNE_DECIMAL } from '@xchainjs/xchain-thorchain';
14
+ import { LTCChain, Client as Client$c, defaultLtcParams } from '@xchainjs/xchain-litecoin';
15
+ import { TRONChain, Client as Client$1, defaultTRONParams } from '@xchainjs/xchain-tron';
16
+ import { ZECChain, Client, defaultZECParams } from '@xchainjs/xchain-zcash';
17
+ import { THORChain, Client as Client$5, defaultClientConfig, AssetRuneNative, RUNE_DECIMAL } from '@xchainjs/xchain-thorchain';
16
18
  import { ThorchainQuery, ThorchainCache, Thornode } from '@xchainjs/xchain-thorchain-query';
17
19
  import { eqAsset, isSynthAsset, getContractAddressFromAsset, baseAmount, isTradeAsset, isSecuredAsset, assetToString, AssetCryptoAmount, CryptoAmount } from '@xchainjs/xchain-util';
18
20
  import { Wallet } from '@xchainjs/xchain-wallet';
@@ -51,10 +53,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
51
53
  };
52
54
 
53
55
  /*
54
- * bignumber.js v9.1.2
56
+ * bignumber.js v10.0.1
55
57
  * A JavaScript library for arbitrary-precision arithmetic.
56
58
  * https://github.com/MikeMcl/bignumber.js
57
- * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
59
+ * Copyright (c) 2026 Michael Mclaughlin <M8ch88l@gmail.com>
58
60
  * MIT Licensed.
59
61
  *
60
62
  * BigNumber.prototype methods | BigNumber methods
@@ -91,6 +93,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
91
93
  * toFraction |
92
94
  * toJSON |
93
95
  * toNumber |
96
+ * toObject |
94
97
  * toPrecision |
95
98
  * toString |
96
99
  * valueOf |
@@ -99,12 +102,12 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
99
102
 
100
103
 
101
104
  var
105
+ BigNumber = clone(),
102
106
  isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
103
107
  mathceil = Math.ceil,
104
108
  mathfloor = Math.floor,
105
109
 
106
110
  bignumberError = '[BigNumber Error] ',
107
- tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
108
111
 
109
112
  BASE = 1e14,
110
113
  LOG_BASE = 14,
@@ -123,7 +126,7 @@ var
123
126
  * Create and return a BigNumber constructor.
124
127
  */
125
128
  function clone(configObject) {
126
- var div, convertBase, parseNumeric,
129
+ var div, convertBase, parseUnusualNumeric,
127
130
  P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
128
131
  ONE = new BigNumber(1),
129
132
 
@@ -208,11 +211,11 @@ function clone(configObject) {
208
211
  suffix: ''
209
212
  },
210
213
 
211
- // The alphabet used for base conversion. It must be at least 2 characters long, with no '+',
212
- // '-', '.', whitespace, or repeated character.
214
+ // The alphabet used for base conversion.
215
+ // It must be at least two characters long and have no '+', '-', '.', whitespace, or repeated
216
+ // character.
213
217
  // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
214
- ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz',
215
- alphabetHasNormalDecimalDigits = true;
218
+ ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
216
219
 
217
220
 
218
221
  //------------------------------------------------------------------------------------------
@@ -229,17 +232,19 @@ function clone(configObject) {
229
232
  * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
230
233
  */
231
234
  function BigNumber(v, b) {
232
- var alphabet, c, caseChanged, e, i, isNum, len, str,
235
+ var alphabet, c, caseChanged, e, i, len, str, t,
233
236
  x = this;
234
237
 
235
238
  // Enable constructor call without `new`.
236
239
  if (!(x instanceof BigNumber)) return new BigNumber(v, b);
237
240
 
241
+ t = typeof v;
242
+
238
243
  if (b == null) {
239
244
 
240
- if (v && v._isBigNumber === true) {
245
+ if (isBigNumber(v)) {
241
246
  x.s = v.s;
242
-
247
+
243
248
  if (!v.c || v.e > MAX_EXP) {
244
249
  x.c = x.e = null;
245
250
  } else if (v.e < MIN_EXP) {
@@ -248,16 +253,23 @@ function clone(configObject) {
248
253
  x.e = v.e;
249
254
  x.c = v.c.slice();
250
255
  }
251
-
256
+
252
257
  return;
253
258
  }
259
+
260
+ if (t == 'number') {
254
261
 
255
- if ((isNum = typeof v == 'number') && v * 0 == 0) {
262
+ // Handle ±Infinity and NaN.
263
+ if (v * 0 != 0) {
264
+ x.s = isNaN(v) ? null : v < 0 ? -1 : 1;
265
+ x.c = x.e = null;
266
+ return;
267
+ }
256
268
 
257
- // Use `1 / n` to handle minus zero also.
269
+ // Use `1 / v` to handle minus zero also.
258
270
  x.s = 1 / v < 0 ? (v = -v, -1) : 1;
259
271
 
260
- // Fast path for integers, where n < 2147483648 (2**31).
272
+ // Fast path for integers, where v < 2147483648 (2**31).
261
273
  if (v === ~~v) {
262
274
  for (e = 0, i = v; i >= 10; i /= 10, e++);
263
275
 
@@ -273,11 +285,20 @@ function clone(configObject) {
273
285
 
274
286
  str = String(v);
275
287
  } else {
276
-
277
- if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
278
-
288
+ if (t == 'string') {
289
+ str = v;
290
+ if (!isNumeric.test(str)) {
291
+ return parseUnusualNumeric(x, str);
292
+ }
293
+ } else if (t == 'bigint') {
294
+ str = String(v);
295
+ } else {
296
+ throw Error
297
+ (bignumberError + 'Invalid argument: ' + v);
298
+ }
299
+
279
300
  x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
280
- }
301
+ }
281
302
 
282
303
  // Decimal point?
283
304
  if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
@@ -295,36 +316,20 @@ function clone(configObject) {
295
316
  e = str.length;
296
317
  }
297
318
 
298
- } else {
299
-
300
- // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
301
- intCheck(b, 2, ALPHABET.length, 'Base');
302
-
303
- // Allow exponential notation to be used with base 10 argument, while
304
- // also rounding to DECIMAL_PLACES as with other bases.
305
- if (b == 10 && alphabetHasNormalDecimalDigits) {
306
- x = new BigNumber(v);
307
- return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
308
- }
309
-
310
- str = String(v);
311
-
312
- if (isNum = typeof v == 'number') {
313
-
314
- // Avoid potential interpretation of Infinity and NaN as base 44+ values.
315
- if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
316
-
317
- x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
319
+ // Base specified.
320
+ } else {
318
321
 
319
- // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
320
- if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {
321
- throw Error
322
- (tooManyDigits + v);
323
- }
324
- } else {
325
- x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
322
+ // '[BigNumber Error] String expected: {v}'
323
+ if (t != 'string') {
324
+ throw Error
325
+ (bignumberError + 'String expected: ' + v);
326
326
  }
327
327
 
328
+ // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
329
+ intCheck(b, 2, ALPHABET.length, 'Base');
330
+
331
+ str = v;
332
+ x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
328
333
  alphabet = ALPHABET.slice(0, b);
329
334
  e = i = 0;
330
335
 
@@ -351,12 +356,10 @@ function clone(configObject) {
351
356
  }
352
357
  }
353
358
 
354
- return parseNumeric(x, String(v), isNum, b);
359
+ return parseUnusualNumeric(x, v, b);
355
360
  }
356
- }
361
+ }
357
362
 
358
- // Prevent later check for length on converted number.
359
- isNum = false;
360
363
  str = convertBase(str, b, 10, x.s);
361
364
 
362
365
  // Decimal point?
@@ -372,16 +375,10 @@ function clone(configObject) {
372
375
 
373
376
  if (str = str.slice(i, ++len)) {
374
377
  len -= i;
378
+ e = e - i - 1;
375
379
 
376
- // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
377
- if (isNum && BigNumber.DEBUG &&
378
- len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
379
- throw Error
380
- (tooManyDigits + (x.s * v));
381
- }
382
-
383
- // Overflow?
384
- if ((e = e - i - 1) > MAX_EXP) {
380
+ // Overflow?
381
+ if (e > MAX_EXP) {
385
382
 
386
383
  // Infinity.
387
384
  x.c = x.e = null;
@@ -455,8 +452,8 @@ function clone(configObject) {
455
452
  * CRYPTO {boolean} true or false
456
453
  * MODULO_MODE {number} 0 to 9
457
454
  * POW_PRECISION {number} 0 to MAX
458
- * ALPHABET {string} A string of two or more unique characters which does
459
- * not contain '.'.
455
+ * ALPHABET {string} A string of unique characters which does not contain
456
+ * '+', '-', '.', or whitespace, and starts with '0123456789'.
460
457
  * FORMAT {object} An object with some of the following properties:
461
458
  * prefix {string}
462
459
  * groupSize {number}
@@ -591,10 +588,9 @@ function clone(configObject) {
591
588
  if (obj.hasOwnProperty(p = 'ALPHABET')) {
592
589
  v = obj[p];
593
590
 
594
- // Disallow if less than two characters,
595
- // or if it contains '+', '-', '.', whitespace, or a repeated character.
591
+ // Disallow if the alphabet is not at least two characters long,
592
+ // or contains '+', '-', '.', whitespace, or a repeated character.
596
593
  if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
597
- alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789';
598
594
  ALPHABET = v;
599
595
  } else {
600
596
  throw Error
@@ -625,58 +621,51 @@ function clone(configObject) {
625
621
 
626
622
 
627
623
  /*
628
- * Return true if v is a BigNumber instance, otherwise return false.
629
- *
630
- * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
624
+ * Return true if v appears to be a BigNumber instance that has a valid coefficient (c),
625
+ * exponent (e), and sign (s), otherwise return false.
631
626
  *
632
627
  * v {any}
633
- *
634
- * '[BigNumber Error] Invalid BigNumber: {v}'
635
628
  */
636
629
  BigNumber.isBigNumber = function (v) {
637
- if (!v || v._isBigNumber !== true) return false;
638
- if (!BigNumber.DEBUG) return true;
639
-
630
+ if (!isBigNumber(v)) return false;
640
631
  var i, n,
641
632
  c = v.c,
642
633
  e = v.e,
643
634
  s = v.s;
644
-
645
- out: if ({}.toString.call(c) == '[object Array]') {
646
-
647
- if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
648
-
649
- // If the first element is zero, the BigNumber value must be zero.
650
- if (c[0] === 0) {
651
- if (e === 0 && c.length === 1) return true;
652
- break out;
653
- }
654
-
655
- // Calculate number of digits that c[0] should have, based on the exponent.
656
- i = (e + 1) % LOG_BASE;
657
- if (i < 1) i += LOG_BASE;
658
-
659
- // Calculate number of digits of c[0].
660
- //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {
661
- if (String(c[0]).length == i) {
662
-
663
- for (i = 0; i < c.length; i++) {
664
- n = c[i];
665
- if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
666
- }
667
-
668
- // Last element cannot be zero, unless it is the only element.
669
- if (n !== 0) return true;
670
- }
671
- }
672
-
673
- // Infinity/NaN
674
- } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
675
- return true;
635
+
636
+ if ({}.toString.call(c) != '[object Array]') {
637
+
638
+ // ±Infinity and NaN
639
+ return c === null && e === null && (s === null || s === 1 || s === -1)
640
+ }
641
+
642
+ // Check sign and check that exponent is an integer within the allowed range.
643
+ if ((s !== 1 && s !== -1) || e < -MAX || e > MAX || e !== mathfloor(e)) {
644
+ return false;
676
645
  }
677
-
678
- throw Error
679
- (bignumberError + 'Invalid BigNumber: ' + v);
646
+
647
+ // If the first element is zero, the BigNumber value must be zero.
648
+ if (c[0] === 0) {
649
+ return e === 0 && c.length === 1;
650
+ }
651
+
652
+ // Calculate number of digits that c[0] should have, based on the exponent.
653
+ i = (e + 1) % LOG_BASE;
654
+ if (i < 1) i += LOG_BASE;
655
+
656
+ // Calculate number of digits of c[0].
657
+ //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) !== i) {
658
+ if (String(c[0]).length !== i) {
659
+ return false;
660
+ }
661
+
662
+ for (i = 0; i < c.length; i++) {
663
+ n = c[i];
664
+ if (n < 0 || n >= BASE || n !== mathfloor(n)) return false;
665
+ }
666
+
667
+ // Last element cannot be zero, unless it is the only element.
668
+ return n !== 0;
680
669
  };
681
670
 
682
671
 
@@ -844,7 +833,7 @@ function clone(configObject) {
844
833
  })();
845
834
 
846
835
 
847
- /*
836
+ /*
848
837
  * Return a BigNumber whose value is the sum of the arguments.
849
838
  *
850
839
  * arguments {number|string|BigNumber}
@@ -955,7 +944,7 @@ function clone(configObject) {
955
944
 
956
945
  // xc now represents str converted to baseOut.
957
946
 
958
- // THe index of the rounding digit.
947
+ // The index of the rounding digit.
959
948
  d = e + dp + 1;
960
949
 
961
950
  // The rounding digit: the digit to the right of the digit that may be rounded up.
@@ -1319,7 +1308,7 @@ function clone(configObject) {
1319
1308
 
1320
1309
  // Fixed-point notation.
1321
1310
  } else {
1322
- i -= ne;
1311
+ i -= ne + (id === 2 && e > ne);
1323
1312
  str = toFixedPoint(str, e, '0');
1324
1313
 
1325
1314
  // Append zeros?
@@ -1339,6 +1328,11 @@ function clone(configObject) {
1339
1328
  }
1340
1329
 
1341
1330
 
1331
+ function isBigNumber(v) {
1332
+ return v instanceof BigNumber || !!v && v._isBigNumber === true;
1333
+ }
1334
+
1335
+
1342
1336
  // Handle BigNumber.max and BigNumber.min.
1343
1337
  // If any number is NaN, return NaN.
1344
1338
  function maxOrMin(args, n) {
@@ -1392,51 +1386,43 @@ function clone(configObject) {
1392
1386
 
1393
1387
 
1394
1388
  // Handle values that fail the validity test in BigNumber.
1395
- parseNumeric = (function () {
1389
+ parseUnusualNumeric = (function () {
1396
1390
  var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
1397
1391
  dotAfter = /^([^.]+)\.$/,
1398
1392
  dotBefore = /^\.([^.]+)$/,
1399
1393
  isInfinityOrNaN = /^-?(Infinity|NaN)$/,
1400
1394
  whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
1401
1395
 
1402
- return function (x, str, isNum, b) {
1396
+ return function (x, str, b) {
1403
1397
  var base,
1404
- s = isNum ? str : str.replace(whitespaceOrPlus, '');
1398
+ s = str.replace(whitespaceOrPlus, '');
1405
1399
 
1406
1400
  // No exception on ±Infinity or NaN.
1407
1401
  if (isInfinityOrNaN.test(s)) {
1408
1402
  x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
1409
- } else {
1410
- if (!isNum) {
1411
-
1412
- // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
1413
- s = s.replace(basePrefix, function (m, p1, p2) {
1414
- base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
1415
- return !b || b == base ? p1 : m;
1416
- });
1417
-
1418
- if (b) {
1419
- base = b;
1420
-
1421
- // E.g. '1.' to '1', '.1' to '0.1'
1422
- s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
1423
- }
1424
-
1425
- if (str != s) return new BigNumber(s, base);
1426
- }
1427
-
1428
- // '[BigNumber Error] Not a number: {n}'
1429
- // '[BigNumber Error] Not a base {b} number: {n}'
1430
- if (BigNumber.DEBUG) {
1431
- throw Error
1432
- (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
1433
- }
1434
-
1435
- // NaN
1436
- x.s = null;
1403
+ x.c = x.e = null;
1404
+ return;
1437
1405
  }
1438
1406
 
1439
- x.c = x.e = null;
1407
+ // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
1408
+ s = s.replace(basePrefix, function (m, p1, p2) {
1409
+ base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
1410
+ return !b || b == base ? p1 : m;
1411
+ });
1412
+
1413
+ if (b) {
1414
+ base = b;
1415
+
1416
+ // E.g. '1.' to '1', '.1' to '0.1'
1417
+ s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
1418
+ }
1419
+
1420
+ if (str != s) return new BigNumber(s, base);
1421
+
1422
+ // '[BigNumber Error] Not a number: {n}'
1423
+ // '[BigNumber Error] Not a base {b} number: {n}'
1424
+ throw Error
1425
+ (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
1440
1426
  }
1441
1427
  })();
1442
1428
 
@@ -2740,6 +2726,19 @@ function clone(configObject) {
2740
2726
  };
2741
2727
 
2742
2728
 
2729
+ /*
2730
+ * Return the value of this BigNumber converted to a plain object.
2731
+ */
2732
+ P.toObject = function() {
2733
+ var x = this;
2734
+ return {
2735
+ c: x.c ? x.c.slice() : null,
2736
+ e: x.e,
2737
+ s: x.s
2738
+ };
2739
+ };
2740
+
2741
+
2743
2742
  /*
2744
2743
  * Return a string representing the value of this BigNumber rounded to sd significant digits
2745
2744
  * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
@@ -2759,8 +2758,8 @@ function clone(configObject) {
2759
2758
 
2760
2759
  /*
2761
2760
  * Return a string representing the value of this BigNumber in base b, or base 10 if b is
2762
- * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
2763
- * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
2761
+ * omitted. If a base is specified, round according to DECIMAL_PLACES and ROUNDING_MODE.
2762
+ * If a base is not specified, and this BigNumber has a positive exponent
2764
2763
  * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
2765
2764
  * TO_EXP_NEG, return exponential notation.
2766
2765
  *
@@ -2787,9 +2786,6 @@ function clone(configObject) {
2787
2786
  str = e <= TO_EXP_NEG || e >= TO_EXP_POS
2788
2787
  ? toExponential(coeffToString(n.c), e)
2789
2788
  : toFixedPoint(coeffToString(n.c), e, '0');
2790
- } else if (b === 10 && alphabetHasNormalDecimalDigits) {
2791
- n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
2792
- str = toFixedPoint(coeffToString(n.c), n.e, '0');
2793
2789
  } else {
2794
2790
  intCheck(b, 2, ALPHABET.length, 'Base');
2795
2791
  str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
@@ -2813,11 +2809,6 @@ function clone(configObject) {
2813
2809
 
2814
2810
  P._isBigNumber = true;
2815
2811
 
2816
- P[Symbol.toStringTag] = 'BigNumber';
2817
-
2818
- // Node.js v10.12.0+
2819
- P[Symbol.for('nodejs.util.inspect.custom')] = P.valueOf;
2820
-
2821
2812
  if (configObject != null) BigNumber.set(configObject);
2822
2813
 
2823
2814
  return BigNumber;
@@ -2948,13 +2939,7 @@ function toFixedPoint(str, e, z) {
2948
2939
  }
2949
2940
 
2950
2941
  return str;
2951
- }
2952
-
2953
-
2954
- // EXPORT
2955
-
2956
-
2957
- var BigNumber = clone();
2942
+ }
2958
2943
 
2959
2944
  /**
2960
2945
  * Check if a chain is EVM and supported by the protocol
@@ -2991,36 +2976,40 @@ const isTokenCryptoAmount = (amount) => {
2991
2976
  * @returns true if chain is EVM, otherwise, false
2992
2977
  */
2993
2978
  const isProtocolBFTChain = (chain) => {
2994
- return [AssetATOM.chain, SOLChain].includes(chain);
2979
+ return [AssetATOM.chain, SOLChain, SUIChain].includes(chain);
2995
2980
  };
2996
2981
  const validateAddress = (network, chain, address) => {
2997
2982
  switch (chain) {
2998
2983
  case BTCChain:
2999
- return new Client$c(Object.assign(Object.assign({}, defaultBTCParams), { network })).validateAddress(address);
2984
+ return new Client$e(Object.assign(Object.assign({}, defaultBTCParams), { network })).validateAddress(address);
3000
2985
  case BCHChain:
3001
- return new Client$b(Object.assign(Object.assign({}, defaultBchParams), { network })).validateAddress(address);
2986
+ return new Client$d(Object.assign(Object.assign({}, defaultBchParams), { network })).validateAddress(address);
3002
2987
  case LTCChain:
3003
- return new Client$a(Object.assign(Object.assign({}, defaultLtcParams), { network })).validateAddress(address);
2988
+ return new Client$c(Object.assign(Object.assign({}, defaultLtcParams), { network })).validateAddress(address);
3004
2989
  case DOGEChain:
3005
- return new Client$9(Object.assign(Object.assign({}, defaultDogeParams), { network })).validateAddress(address);
2990
+ return new Client$b(Object.assign(Object.assign({}, defaultDogeParams), { network })).validateAddress(address);
3006
2991
  case ETHChain:
3007
- return new Client$8(Object.assign(Object.assign({}, defaultEthParams), { network })).validateAddress(address);
2992
+ return new Client$a(Object.assign(Object.assign({}, defaultEthParams), { network })).validateAddress(address);
3008
2993
  case AVAXChain:
3009
- return new Client$7(Object.assign(Object.assign({}, defaultAvaxParams), { network })).validateAddress(address);
2994
+ return new Client$9(Object.assign(Object.assign({}, defaultAvaxParams), { network })).validateAddress(address);
3010
2995
  case BSCChain:
3011
- return new Client$6(Object.assign(Object.assign({}, defaultBscParams), { network })).validateAddress(address);
2996
+ return new Client$8(Object.assign(Object.assign({}, defaultBscParams), { network })).validateAddress(address);
3012
2997
  case BASEChain:
3013
- return new Client$5(Object.assign(Object.assign({}, defaultBaseParams), { network })).validateAddress(address);
2998
+ return new Client$7(Object.assign(Object.assign({}, defaultBaseParams), { network })).validateAddress(address);
3014
2999
  case GAIAChain:
3015
- return new Client$4({ network }).validateAddress(address);
3000
+ return new Client$6({ network }).validateAddress(address);
3016
3001
  case THORChain:
3017
- return new Client$3(Object.assign(Object.assign({}, defaultClientConfig), { network })).validateAddress(address);
3002
+ return new Client$5(Object.assign(Object.assign({}, defaultClientConfig), { network })).validateAddress(address);
3018
3003
  case XRPChain:
3019
- return new Client$2(Object.assign(Object.assign({}, defaultXRPParams), { network })).validateAddress(address);
3004
+ return new Client$4(Object.assign(Object.assign({}, defaultXRPParams), { network })).validateAddress(address);
3020
3005
  case SOLChain:
3021
- return new Client$1(Object.assign(Object.assign({}, defaultSolanaParams), { network })).validateAddress(address);
3006
+ return new Client$3(Object.assign(Object.assign({}, defaultSolanaParams), { network })).validateAddress(address);
3007
+ case SUIChain:
3008
+ return new Client$2(Object.assign(Object.assign({}, defaultSuiParams), { network })).validateAddress(address);
3022
3009
  case TRONChain:
3023
- return new Client(Object.assign(Object.assign({}, defaultTRONParams), { network })).validateAddress(address);
3010
+ return new Client$1(Object.assign(Object.assign({}, defaultTRONParams), { network })).validateAddress(address);
3011
+ case ZECChain:
3012
+ return new Client(Object.assign(Object.assign({}, defaultZECParams), { network })).validateAddress(address);
3024
3013
  default:
3025
3014
  throw Error('Unsupported chain');
3026
3015
  }
@@ -3142,19 +3131,21 @@ class ThorchainAMM {
3142
3131
  * @returns ThorchainAMM
3143
3132
  */
3144
3133
  constructor(thorchainQuery = new ThorchainQuery(), wallet = new Wallet({
3145
- BTC: new Client$c(Object.assign(Object.assign({}, defaultBTCParams), { network: Network.Mainnet })),
3146
- BCH: new Client$b(Object.assign(Object.assign({}, defaultBchParams), { network: Network.Mainnet })),
3147
- LTC: new Client$a(Object.assign(Object.assign({}, defaultLtcParams), { network: Network.Mainnet })),
3148
- DOGE: new Client$9(Object.assign(Object.assign({}, defaultDogeParams), { network: Network.Mainnet })),
3149
- ETH: new Client$8(Object.assign(Object.assign({}, defaultEthParams), { network: Network.Mainnet })),
3150
- AVAX: new Client$7(Object.assign(Object.assign({}, defaultAvaxParams), { network: Network.Mainnet })),
3151
- BSC: new Client$6(Object.assign(Object.assign({}, defaultBscParams), { network: Network.Mainnet })),
3152
- GAIA: new Client$4({ network: Network.Mainnet }),
3153
- THOR: new Client$3(Object.assign(Object.assign({}, defaultClientConfig), { network: Network.Mainnet })),
3154
- BASE: new Client$5(Object.assign(Object.assign({}, defaultBaseParams), { network: Network.Mainnet })),
3155
- XRP: new Client$2(Object.assign(Object.assign({}, defaultXRPParams), { network: Network.Mainnet })),
3156
- SOL: new Client$1(Object.assign(Object.assign({}, defaultSolanaParams), { network: Network.Mainnet })),
3157
- TRON: new Client(Object.assign(Object.assign({}, defaultTRONParams), { network: Network.Mainnet })),
3134
+ BTC: new Client$e(Object.assign(Object.assign({}, defaultBTCParams), { network: Network.Mainnet })),
3135
+ BCH: new Client$d(Object.assign(Object.assign({}, defaultBchParams), { network: Network.Mainnet })),
3136
+ LTC: new Client$c(Object.assign(Object.assign({}, defaultLtcParams), { network: Network.Mainnet })),
3137
+ DOGE: new Client$b(Object.assign(Object.assign({}, defaultDogeParams), { network: Network.Mainnet })),
3138
+ ETH: new Client$a(Object.assign(Object.assign({}, defaultEthParams), { network: Network.Mainnet })),
3139
+ AVAX: new Client$9(Object.assign(Object.assign({}, defaultAvaxParams), { network: Network.Mainnet })),
3140
+ BSC: new Client$8(Object.assign(Object.assign({}, defaultBscParams), { network: Network.Mainnet })),
3141
+ GAIA: new Client$6({ network: Network.Mainnet }),
3142
+ THOR: new Client$5(Object.assign(Object.assign({}, defaultClientConfig), { network: Network.Mainnet })),
3143
+ BASE: new Client$7(Object.assign(Object.assign({}, defaultBaseParams), { network: Network.Mainnet })),
3144
+ XRP: new Client$4(Object.assign(Object.assign({}, defaultXRPParams), { network: Network.Mainnet })),
3145
+ SOL: new Client$3(Object.assign(Object.assign({}, defaultSolanaParams), { network: Network.Mainnet })),
3146
+ SUI: new Client$2(Object.assign(Object.assign({}, defaultSuiParams), { network: Network.Mainnet })),
3147
+ TRON: new Client$1(Object.assign(Object.assign({}, defaultTRONParams), { network: Network.Mainnet })),
3148
+ ZEC: new Client(Object.assign(Object.assign({}, defaultZECParams), { network: Network.Mainnet })),
3158
3149
  })) {
3159
3150
  this.thorchainQuery = thorchainQuery;
3160
3151
  this.wallet = wallet;
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ var xchainBitcoin = require('@xchainjs/xchain-bitcoin');
7
7
  var xchainBitcoincash = require('@xchainjs/xchain-bitcoincash');
8
8
  var xchainBsc = require('@xchainjs/xchain-bsc');
9
9
  var xchainSolana = require('@xchainjs/xchain-solana');
10
+ var xchainSui = require('@xchainjs/xchain-sui');
10
11
  var xchainClient = require('@xchainjs/xchain-client');
11
12
  var xchainCosmos = require('@xchainjs/xchain-cosmos');
12
13
  var xchainDoge = require('@xchainjs/xchain-doge');
@@ -14,6 +15,7 @@ var xchainEthereum = require('@xchainjs/xchain-ethereum');
14
15
  var xchainEvm = require('@xchainjs/xchain-evm');
15
16
  var xchainLitecoin = require('@xchainjs/xchain-litecoin');
16
17
  var xchainTron = require('@xchainjs/xchain-tron');
18
+ var xchainZcash = require('@xchainjs/xchain-zcash');
17
19
  var xchainThorchain = require('@xchainjs/xchain-thorchain');
18
20
  var xchainThorchainQuery = require('@xchainjs/xchain-thorchain-query');
19
21
  var xchainUtil = require('@xchainjs/xchain-util');
@@ -53,10 +55,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
53
55
  };
54
56
 
55
57
  /*
56
- * bignumber.js v9.1.2
58
+ * bignumber.js v10.0.1
57
59
  * A JavaScript library for arbitrary-precision arithmetic.
58
60
  * https://github.com/MikeMcl/bignumber.js
59
- * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
61
+ * Copyright (c) 2026 Michael Mclaughlin <M8ch88l@gmail.com>
60
62
  * MIT Licensed.
61
63
  *
62
64
  * BigNumber.prototype methods | BigNumber methods
@@ -93,6 +95,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
93
95
  * toFraction |
94
96
  * toJSON |
95
97
  * toNumber |
98
+ * toObject |
96
99
  * toPrecision |
97
100
  * toString |
98
101
  * valueOf |
@@ -101,12 +104,12 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
101
104
 
102
105
 
103
106
  var
107
+ BigNumber = clone(),
104
108
  isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
105
109
  mathceil = Math.ceil,
106
110
  mathfloor = Math.floor,
107
111
 
108
112
  bignumberError = '[BigNumber Error] ',
109
- tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
110
113
 
111
114
  BASE = 1e14,
112
115
  LOG_BASE = 14,
@@ -125,7 +128,7 @@ var
125
128
  * Create and return a BigNumber constructor.
126
129
  */
127
130
  function clone(configObject) {
128
- var div, convertBase, parseNumeric,
131
+ var div, convertBase, parseUnusualNumeric,
129
132
  P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
130
133
  ONE = new BigNumber(1),
131
134
 
@@ -210,11 +213,11 @@ function clone(configObject) {
210
213
  suffix: ''
211
214
  },
212
215
 
213
- // The alphabet used for base conversion. It must be at least 2 characters long, with no '+',
214
- // '-', '.', whitespace, or repeated character.
216
+ // The alphabet used for base conversion.
217
+ // It must be at least two characters long and have no '+', '-', '.', whitespace, or repeated
218
+ // character.
215
219
  // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
216
- ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz',
217
- alphabetHasNormalDecimalDigits = true;
220
+ ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
218
221
 
219
222
 
220
223
  //------------------------------------------------------------------------------------------
@@ -231,17 +234,19 @@ function clone(configObject) {
231
234
  * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
232
235
  */
233
236
  function BigNumber(v, b) {
234
- var alphabet, c, caseChanged, e, i, isNum, len, str,
237
+ var alphabet, c, caseChanged, e, i, len, str, t,
235
238
  x = this;
236
239
 
237
240
  // Enable constructor call without `new`.
238
241
  if (!(x instanceof BigNumber)) return new BigNumber(v, b);
239
242
 
243
+ t = typeof v;
244
+
240
245
  if (b == null) {
241
246
 
242
- if (v && v._isBigNumber === true) {
247
+ if (isBigNumber(v)) {
243
248
  x.s = v.s;
244
-
249
+
245
250
  if (!v.c || v.e > MAX_EXP) {
246
251
  x.c = x.e = null;
247
252
  } else if (v.e < MIN_EXP) {
@@ -250,16 +255,23 @@ function clone(configObject) {
250
255
  x.e = v.e;
251
256
  x.c = v.c.slice();
252
257
  }
253
-
258
+
254
259
  return;
255
260
  }
261
+
262
+ if (t == 'number') {
256
263
 
257
- if ((isNum = typeof v == 'number') && v * 0 == 0) {
264
+ // Handle ±Infinity and NaN.
265
+ if (v * 0 != 0) {
266
+ x.s = isNaN(v) ? null : v < 0 ? -1 : 1;
267
+ x.c = x.e = null;
268
+ return;
269
+ }
258
270
 
259
- // Use `1 / n` to handle minus zero also.
271
+ // Use `1 / v` to handle minus zero also.
260
272
  x.s = 1 / v < 0 ? (v = -v, -1) : 1;
261
273
 
262
- // Fast path for integers, where n < 2147483648 (2**31).
274
+ // Fast path for integers, where v < 2147483648 (2**31).
263
275
  if (v === ~~v) {
264
276
  for (e = 0, i = v; i >= 10; i /= 10, e++);
265
277
 
@@ -275,11 +287,20 @@ function clone(configObject) {
275
287
 
276
288
  str = String(v);
277
289
  } else {
278
-
279
- if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
280
-
290
+ if (t == 'string') {
291
+ str = v;
292
+ if (!isNumeric.test(str)) {
293
+ return parseUnusualNumeric(x, str);
294
+ }
295
+ } else if (t == 'bigint') {
296
+ str = String(v);
297
+ } else {
298
+ throw Error
299
+ (bignumberError + 'Invalid argument: ' + v);
300
+ }
301
+
281
302
  x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
282
- }
303
+ }
283
304
 
284
305
  // Decimal point?
285
306
  if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
@@ -297,36 +318,20 @@ function clone(configObject) {
297
318
  e = str.length;
298
319
  }
299
320
 
300
- } else {
301
-
302
- // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
303
- intCheck(b, 2, ALPHABET.length, 'Base');
304
-
305
- // Allow exponential notation to be used with base 10 argument, while
306
- // also rounding to DECIMAL_PLACES as with other bases.
307
- if (b == 10 && alphabetHasNormalDecimalDigits) {
308
- x = new BigNumber(v);
309
- return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
310
- }
311
-
312
- str = String(v);
313
-
314
- if (isNum = typeof v == 'number') {
315
-
316
- // Avoid potential interpretation of Infinity and NaN as base 44+ values.
317
- if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
318
-
319
- x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
321
+ // Base specified.
322
+ } else {
320
323
 
321
- // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
322
- if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {
323
- throw Error
324
- (tooManyDigits + v);
325
- }
326
- } else {
327
- x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
324
+ // '[BigNumber Error] String expected: {v}'
325
+ if (t != 'string') {
326
+ throw Error
327
+ (bignumberError + 'String expected: ' + v);
328
328
  }
329
329
 
330
+ // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
331
+ intCheck(b, 2, ALPHABET.length, 'Base');
332
+
333
+ str = v;
334
+ x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
330
335
  alphabet = ALPHABET.slice(0, b);
331
336
  e = i = 0;
332
337
 
@@ -353,12 +358,10 @@ function clone(configObject) {
353
358
  }
354
359
  }
355
360
 
356
- return parseNumeric(x, String(v), isNum, b);
361
+ return parseUnusualNumeric(x, v, b);
357
362
  }
358
- }
363
+ }
359
364
 
360
- // Prevent later check for length on converted number.
361
- isNum = false;
362
365
  str = convertBase(str, b, 10, x.s);
363
366
 
364
367
  // Decimal point?
@@ -374,16 +377,10 @@ function clone(configObject) {
374
377
 
375
378
  if (str = str.slice(i, ++len)) {
376
379
  len -= i;
380
+ e = e - i - 1;
377
381
 
378
- // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
379
- if (isNum && BigNumber.DEBUG &&
380
- len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
381
- throw Error
382
- (tooManyDigits + (x.s * v));
383
- }
384
-
385
- // Overflow?
386
- if ((e = e - i - 1) > MAX_EXP) {
382
+ // Overflow?
383
+ if (e > MAX_EXP) {
387
384
 
388
385
  // Infinity.
389
386
  x.c = x.e = null;
@@ -457,8 +454,8 @@ function clone(configObject) {
457
454
  * CRYPTO {boolean} true or false
458
455
  * MODULO_MODE {number} 0 to 9
459
456
  * POW_PRECISION {number} 0 to MAX
460
- * ALPHABET {string} A string of two or more unique characters which does
461
- * not contain '.'.
457
+ * ALPHABET {string} A string of unique characters which does not contain
458
+ * '+', '-', '.', or whitespace, and starts with '0123456789'.
462
459
  * FORMAT {object} An object with some of the following properties:
463
460
  * prefix {string}
464
461
  * groupSize {number}
@@ -593,10 +590,9 @@ function clone(configObject) {
593
590
  if (obj.hasOwnProperty(p = 'ALPHABET')) {
594
591
  v = obj[p];
595
592
 
596
- // Disallow if less than two characters,
597
- // or if it contains '+', '-', '.', whitespace, or a repeated character.
593
+ // Disallow if the alphabet is not at least two characters long,
594
+ // or contains '+', '-', '.', whitespace, or a repeated character.
598
595
  if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
599
- alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789';
600
596
  ALPHABET = v;
601
597
  } else {
602
598
  throw Error
@@ -627,58 +623,51 @@ function clone(configObject) {
627
623
 
628
624
 
629
625
  /*
630
- * Return true if v is a BigNumber instance, otherwise return false.
631
- *
632
- * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
626
+ * Return true if v appears to be a BigNumber instance that has a valid coefficient (c),
627
+ * exponent (e), and sign (s), otherwise return false.
633
628
  *
634
629
  * v {any}
635
- *
636
- * '[BigNumber Error] Invalid BigNumber: {v}'
637
630
  */
638
631
  BigNumber.isBigNumber = function (v) {
639
- if (!v || v._isBigNumber !== true) return false;
640
- if (!BigNumber.DEBUG) return true;
641
-
632
+ if (!isBigNumber(v)) return false;
642
633
  var i, n,
643
634
  c = v.c,
644
635
  e = v.e,
645
636
  s = v.s;
646
-
647
- out: if ({}.toString.call(c) == '[object Array]') {
648
-
649
- if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
650
-
651
- // If the first element is zero, the BigNumber value must be zero.
652
- if (c[0] === 0) {
653
- if (e === 0 && c.length === 1) return true;
654
- break out;
655
- }
656
-
657
- // Calculate number of digits that c[0] should have, based on the exponent.
658
- i = (e + 1) % LOG_BASE;
659
- if (i < 1) i += LOG_BASE;
660
-
661
- // Calculate number of digits of c[0].
662
- //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {
663
- if (String(c[0]).length == i) {
664
-
665
- for (i = 0; i < c.length; i++) {
666
- n = c[i];
667
- if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
668
- }
669
-
670
- // Last element cannot be zero, unless it is the only element.
671
- if (n !== 0) return true;
672
- }
673
- }
674
-
675
- // Infinity/NaN
676
- } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
677
- return true;
637
+
638
+ if ({}.toString.call(c) != '[object Array]') {
639
+
640
+ // ±Infinity and NaN
641
+ return c === null && e === null && (s === null || s === 1 || s === -1)
642
+ }
643
+
644
+ // Check sign and check that exponent is an integer within the allowed range.
645
+ if ((s !== 1 && s !== -1) || e < -MAX || e > MAX || e !== mathfloor(e)) {
646
+ return false;
678
647
  }
679
-
680
- throw Error
681
- (bignumberError + 'Invalid BigNumber: ' + v);
648
+
649
+ // If the first element is zero, the BigNumber value must be zero.
650
+ if (c[0] === 0) {
651
+ return e === 0 && c.length === 1;
652
+ }
653
+
654
+ // Calculate number of digits that c[0] should have, based on the exponent.
655
+ i = (e + 1) % LOG_BASE;
656
+ if (i < 1) i += LOG_BASE;
657
+
658
+ // Calculate number of digits of c[0].
659
+ //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) !== i) {
660
+ if (String(c[0]).length !== i) {
661
+ return false;
662
+ }
663
+
664
+ for (i = 0; i < c.length; i++) {
665
+ n = c[i];
666
+ if (n < 0 || n >= BASE || n !== mathfloor(n)) return false;
667
+ }
668
+
669
+ // Last element cannot be zero, unless it is the only element.
670
+ return n !== 0;
682
671
  };
683
672
 
684
673
 
@@ -846,7 +835,7 @@ function clone(configObject) {
846
835
  })();
847
836
 
848
837
 
849
- /*
838
+ /*
850
839
  * Return a BigNumber whose value is the sum of the arguments.
851
840
  *
852
841
  * arguments {number|string|BigNumber}
@@ -957,7 +946,7 @@ function clone(configObject) {
957
946
 
958
947
  // xc now represents str converted to baseOut.
959
948
 
960
- // THe index of the rounding digit.
949
+ // The index of the rounding digit.
961
950
  d = e + dp + 1;
962
951
 
963
952
  // The rounding digit: the digit to the right of the digit that may be rounded up.
@@ -1321,7 +1310,7 @@ function clone(configObject) {
1321
1310
 
1322
1311
  // Fixed-point notation.
1323
1312
  } else {
1324
- i -= ne;
1313
+ i -= ne + (id === 2 && e > ne);
1325
1314
  str = toFixedPoint(str, e, '0');
1326
1315
 
1327
1316
  // Append zeros?
@@ -1341,6 +1330,11 @@ function clone(configObject) {
1341
1330
  }
1342
1331
 
1343
1332
 
1333
+ function isBigNumber(v) {
1334
+ return v instanceof BigNumber || !!v && v._isBigNumber === true;
1335
+ }
1336
+
1337
+
1344
1338
  // Handle BigNumber.max and BigNumber.min.
1345
1339
  // If any number is NaN, return NaN.
1346
1340
  function maxOrMin(args, n) {
@@ -1394,51 +1388,43 @@ function clone(configObject) {
1394
1388
 
1395
1389
 
1396
1390
  // Handle values that fail the validity test in BigNumber.
1397
- parseNumeric = (function () {
1391
+ parseUnusualNumeric = (function () {
1398
1392
  var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
1399
1393
  dotAfter = /^([^.]+)\.$/,
1400
1394
  dotBefore = /^\.([^.]+)$/,
1401
1395
  isInfinityOrNaN = /^-?(Infinity|NaN)$/,
1402
1396
  whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
1403
1397
 
1404
- return function (x, str, isNum, b) {
1398
+ return function (x, str, b) {
1405
1399
  var base,
1406
- s = isNum ? str : str.replace(whitespaceOrPlus, '');
1400
+ s = str.replace(whitespaceOrPlus, '');
1407
1401
 
1408
1402
  // No exception on ±Infinity or NaN.
1409
1403
  if (isInfinityOrNaN.test(s)) {
1410
1404
  x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
1411
- } else {
1412
- if (!isNum) {
1413
-
1414
- // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
1415
- s = s.replace(basePrefix, function (m, p1, p2) {
1416
- base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
1417
- return !b || b == base ? p1 : m;
1418
- });
1419
-
1420
- if (b) {
1421
- base = b;
1422
-
1423
- // E.g. '1.' to '1', '.1' to '0.1'
1424
- s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
1425
- }
1426
-
1427
- if (str != s) return new BigNumber(s, base);
1428
- }
1429
-
1430
- // '[BigNumber Error] Not a number: {n}'
1431
- // '[BigNumber Error] Not a base {b} number: {n}'
1432
- if (BigNumber.DEBUG) {
1433
- throw Error
1434
- (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
1435
- }
1436
-
1437
- // NaN
1438
- x.s = null;
1405
+ x.c = x.e = null;
1406
+ return;
1439
1407
  }
1440
1408
 
1441
- x.c = x.e = null;
1409
+ // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
1410
+ s = s.replace(basePrefix, function (m, p1, p2) {
1411
+ base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
1412
+ return !b || b == base ? p1 : m;
1413
+ });
1414
+
1415
+ if (b) {
1416
+ base = b;
1417
+
1418
+ // E.g. '1.' to '1', '.1' to '0.1'
1419
+ s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
1420
+ }
1421
+
1422
+ if (str != s) return new BigNumber(s, base);
1423
+
1424
+ // '[BigNumber Error] Not a number: {n}'
1425
+ // '[BigNumber Error] Not a base {b} number: {n}'
1426
+ throw Error
1427
+ (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
1442
1428
  }
1443
1429
  })();
1444
1430
 
@@ -2742,6 +2728,19 @@ function clone(configObject) {
2742
2728
  };
2743
2729
 
2744
2730
 
2731
+ /*
2732
+ * Return the value of this BigNumber converted to a plain object.
2733
+ */
2734
+ P.toObject = function() {
2735
+ var x = this;
2736
+ return {
2737
+ c: x.c ? x.c.slice() : null,
2738
+ e: x.e,
2739
+ s: x.s
2740
+ };
2741
+ };
2742
+
2743
+
2745
2744
  /*
2746
2745
  * Return a string representing the value of this BigNumber rounded to sd significant digits
2747
2746
  * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
@@ -2761,8 +2760,8 @@ function clone(configObject) {
2761
2760
 
2762
2761
  /*
2763
2762
  * Return a string representing the value of this BigNumber in base b, or base 10 if b is
2764
- * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
2765
- * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
2763
+ * omitted. If a base is specified, round according to DECIMAL_PLACES and ROUNDING_MODE.
2764
+ * If a base is not specified, and this BigNumber has a positive exponent
2766
2765
  * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
2767
2766
  * TO_EXP_NEG, return exponential notation.
2768
2767
  *
@@ -2789,9 +2788,6 @@ function clone(configObject) {
2789
2788
  str = e <= TO_EXP_NEG || e >= TO_EXP_POS
2790
2789
  ? toExponential(coeffToString(n.c), e)
2791
2790
  : toFixedPoint(coeffToString(n.c), e, '0');
2792
- } else if (b === 10 && alphabetHasNormalDecimalDigits) {
2793
- n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
2794
- str = toFixedPoint(coeffToString(n.c), n.e, '0');
2795
2791
  } else {
2796
2792
  intCheck(b, 2, ALPHABET.length, 'Base');
2797
2793
  str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
@@ -2815,11 +2811,6 @@ function clone(configObject) {
2815
2811
 
2816
2812
  P._isBigNumber = true;
2817
2813
 
2818
- P[Symbol.toStringTag] = 'BigNumber';
2819
-
2820
- // Node.js v10.12.0+
2821
- P[Symbol.for('nodejs.util.inspect.custom')] = P.valueOf;
2822
-
2823
2814
  if (configObject != null) BigNumber.set(configObject);
2824
2815
 
2825
2816
  return BigNumber;
@@ -2950,13 +2941,7 @@ function toFixedPoint(str, e, z) {
2950
2941
  }
2951
2942
 
2952
2943
  return str;
2953
- }
2954
-
2955
-
2956
- // EXPORT
2957
-
2958
-
2959
- var BigNumber = clone();
2944
+ }
2960
2945
 
2961
2946
  /**
2962
2947
  * Check if a chain is EVM and supported by the protocol
@@ -2993,7 +2978,7 @@ const isTokenCryptoAmount = (amount) => {
2993
2978
  * @returns true if chain is EVM, otherwise, false
2994
2979
  */
2995
2980
  const isProtocolBFTChain = (chain) => {
2996
- return [xchainCosmos.AssetATOM.chain, xchainSolana.SOLChain].includes(chain);
2981
+ return [xchainCosmos.AssetATOM.chain, xchainSolana.SOLChain, xchainSui.SUIChain].includes(chain);
2997
2982
  };
2998
2983
  const validateAddress = (network, chain, address) => {
2999
2984
  switch (chain) {
@@ -3021,8 +3006,12 @@ const validateAddress = (network, chain, address) => {
3021
3006
  return new xchainRipple.Client(Object.assign(Object.assign({}, xchainRipple.defaultXRPParams), { network })).validateAddress(address);
3022
3007
  case xchainSolana.SOLChain:
3023
3008
  return new xchainSolana.Client(Object.assign(Object.assign({}, xchainSolana.defaultSolanaParams), { network })).validateAddress(address);
3009
+ case xchainSui.SUIChain:
3010
+ return new xchainSui.Client(Object.assign(Object.assign({}, xchainSui.defaultSuiParams), { network })).validateAddress(address);
3024
3011
  case xchainTron.TRONChain:
3025
3012
  return new xchainTron.Client(Object.assign(Object.assign({}, xchainTron.defaultTRONParams), { network })).validateAddress(address);
3013
+ case xchainZcash.ZECChain:
3014
+ return new xchainZcash.Client(Object.assign(Object.assign({}, xchainZcash.defaultZECParams), { network })).validateAddress(address);
3026
3015
  default:
3027
3016
  throw Error('Unsupported chain');
3028
3017
  }
@@ -3156,7 +3145,9 @@ class ThorchainAMM {
3156
3145
  BASE: new xchainBase.Client(Object.assign(Object.assign({}, xchainBase.defaultBaseParams), { network: xchainClient.Network.Mainnet })),
3157
3146
  XRP: new xchainRipple.Client(Object.assign(Object.assign({}, xchainRipple.defaultXRPParams), { network: xchainClient.Network.Mainnet })),
3158
3147
  SOL: new xchainSolana.Client(Object.assign(Object.assign({}, xchainSolana.defaultSolanaParams), { network: xchainClient.Network.Mainnet })),
3148
+ SUI: new xchainSui.Client(Object.assign(Object.assign({}, xchainSui.defaultSuiParams), { network: xchainClient.Network.Mainnet })),
3159
3149
  TRON: new xchainTron.Client(Object.assign(Object.assign({}, xchainTron.defaultTRONParams), { network: xchainClient.Network.Mainnet })),
3150
+ ZEC: new xchainZcash.Client(Object.assign(Object.assign({}, xchainZcash.defaultZECParams), { network: xchainClient.Network.Mainnet })),
3160
3151
  })) {
3161
3152
  this.thorchainQuery = thorchainQuery;
3162
3153
  this.wallet = wallet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-amm",
3
- "version": "3.0.31",
3
+ "version": "3.0.33",
4
4
  "description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -36,24 +36,26 @@
36
36
  "url": "https://github.com/xchainjs/xchainjs-lib/issues"
37
37
  },
38
38
  "dependencies": {
39
- "@xchainjs/xchain-avax": "2.0.14",
40
- "@xchainjs/xchain-base": "1.0.14",
41
- "@xchainjs/xchain-bitcoin": "2.2.1",
42
- "@xchainjs/xchain-bitcoincash": "2.2.1",
43
- "@xchainjs/xchain-bsc": "2.0.15",
44
- "@xchainjs/xchain-client": "2.0.10",
45
- "@xchainjs/xchain-cosmos": "3.0.10",
46
- "@xchainjs/xchain-doge": "2.2.1",
47
- "@xchainjs/xchain-ethereum": "2.0.15",
48
- "@xchainjs/xchain-evm": "2.0.14",
49
- "@xchainjs/xchain-litecoin": "2.2.1",
50
- "@xchainjs/xchain-ripple": "1.0.12",
51
- "@xchainjs/xchain-solana": "1.1.1",
52
- "@xchainjs/xchain-thorchain": "3.0.14",
53
- "@xchainjs/xchain-thorchain-query": "3.0.1",
54
- "@xchainjs/xchain-tron": "3.0.3",
55
- "@xchainjs/xchain-util": "2.0.5",
56
- "@xchainjs/xchain-wallet": "2.0.23",
39
+ "@xchainjs/xchain-avax": "2.0.15",
40
+ "@xchainjs/xchain-base": "1.0.15",
41
+ "@xchainjs/xchain-bitcoin": "2.2.2",
42
+ "@xchainjs/xchain-bitcoincash": "2.2.2",
43
+ "@xchainjs/xchain-bsc": "2.0.16",
44
+ "@xchainjs/xchain-client": "2.0.11",
45
+ "@xchainjs/xchain-cosmos": "3.0.11",
46
+ "@xchainjs/xchain-doge": "2.2.2",
47
+ "@xchainjs/xchain-ethereum": "2.0.16",
48
+ "@xchainjs/xchain-evm": "2.0.15",
49
+ "@xchainjs/xchain-litecoin": "2.2.2",
50
+ "@xchainjs/xchain-ripple": "1.0.13",
51
+ "@xchainjs/xchain-solana": "1.1.3",
52
+ "@xchainjs/xchain-sui": "0.1.0",
53
+ "@xchainjs/xchain-thorchain": "3.0.15",
54
+ "@xchainjs/xchain-thorchain-query": "3.0.2",
55
+ "@xchainjs/xchain-tron": "3.0.4",
56
+ "@xchainjs/xchain-util": "2.0.6",
57
+ "@xchainjs/xchain-wallet": "2.0.25",
58
+ "@xchainjs/xchain-zcash": "1.3.2",
57
59
  "ethers": "^6.14.3"
58
60
  },
59
61
  "devDependencies": {