@xchainjs/xchain-thorchain-amm 3.0.31 → 3.0.32
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/lib/index.esm.js +146 -163
- package/lib/index.js +142 -159
- package/package.json +19 -19
package/lib/index.esm.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AVAXChain, Client as Client$7, defaultAvaxParams, AssetAVAX } from '@xchainjs/xchain-avax';
|
|
2
|
+
import { BASEChain, Client as Client$5, defaultBaseParams, AssetBETH } from '@xchainjs/xchain-base';
|
|
3
3
|
import { XRPChain, Client as Client$2, defaultXRPParams } from '@xchainjs/xchain-ripple';
|
|
4
4
|
import { BTCChain, Client as Client$c, defaultBTCParams } from '@xchainjs/xchain-bitcoin';
|
|
5
5
|
import { BCHChain, Client as Client$b, defaultBchParams } from '@xchainjs/xchain-bitcoincash';
|
|
6
|
-
import {
|
|
6
|
+
import { BSCChain, Client as Client$6, defaultBscParams, AssetBSC } from '@xchainjs/xchain-bsc';
|
|
7
7
|
import { SOLChain, Client as Client$1, defaultSolanaParams } from '@xchainjs/xchain-solana';
|
|
8
8
|
import { Protocol, Network } from '@xchainjs/xchain-client';
|
|
9
9
|
import { GAIAChain, Client as Client$4, AssetATOM } from '@xchainjs/xchain-cosmos';
|
|
10
10
|
import { DOGEChain, Client as Client$9, defaultDogeParams } from '@xchainjs/xchain-doge';
|
|
11
|
-
import {
|
|
11
|
+
import { ETHChain, Client as Client$8, defaultEthParams, AssetETH } from '@xchainjs/xchain-ethereum';
|
|
12
12
|
import { abi, MAX_APPROVAL } from '@xchainjs/xchain-evm';
|
|
13
13
|
import { LTCChain, Client as Client$a, defaultLtcParams } from '@xchainjs/xchain-litecoin';
|
|
14
14
|
import { TRONChain, Client, defaultTRONParams } from '@xchainjs/xchain-tron';
|
|
@@ -51,10 +51,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
/*
|
|
54
|
-
* bignumber.js
|
|
54
|
+
* bignumber.js v10.0.1
|
|
55
55
|
* A JavaScript library for arbitrary-precision arithmetic.
|
|
56
56
|
* https://github.com/MikeMcl/bignumber.js
|
|
57
|
-
* Copyright (c)
|
|
57
|
+
* Copyright (c) 2026 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
58
58
|
* MIT Licensed.
|
|
59
59
|
*
|
|
60
60
|
* BigNumber.prototype methods | BigNumber methods
|
|
@@ -91,6 +91,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
91
91
|
* toFraction |
|
|
92
92
|
* toJSON |
|
|
93
93
|
* toNumber |
|
|
94
|
+
* toObject |
|
|
94
95
|
* toPrecision |
|
|
95
96
|
* toString |
|
|
96
97
|
* valueOf |
|
|
@@ -99,12 +100,12 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
99
100
|
|
|
100
101
|
|
|
101
102
|
var
|
|
103
|
+
BigNumber = clone(),
|
|
102
104
|
isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
|
|
103
105
|
mathceil = Math.ceil,
|
|
104
106
|
mathfloor = Math.floor,
|
|
105
107
|
|
|
106
108
|
bignumberError = '[BigNumber Error] ',
|
|
107
|
-
tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
|
|
108
109
|
|
|
109
110
|
BASE = 1e14,
|
|
110
111
|
LOG_BASE = 14,
|
|
@@ -123,7 +124,7 @@ var
|
|
|
123
124
|
* Create and return a BigNumber constructor.
|
|
124
125
|
*/
|
|
125
126
|
function clone(configObject) {
|
|
126
|
-
var div, convertBase,
|
|
127
|
+
var div, convertBase, parseUnusualNumeric,
|
|
127
128
|
P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
|
|
128
129
|
ONE = new BigNumber(1),
|
|
129
130
|
|
|
@@ -208,11 +209,11 @@ function clone(configObject) {
|
|
|
208
209
|
suffix: ''
|
|
209
210
|
},
|
|
210
211
|
|
|
211
|
-
// The alphabet used for base conversion.
|
|
212
|
-
// '-', '.', whitespace, or repeated
|
|
212
|
+
// The alphabet used for base conversion.
|
|
213
|
+
// It must be at least two characters long and have no '+', '-', '.', whitespace, or repeated
|
|
214
|
+
// character.
|
|
213
215
|
// '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
|
|
214
|
-
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'
|
|
215
|
-
alphabetHasNormalDecimalDigits = true;
|
|
216
|
+
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
216
217
|
|
|
217
218
|
|
|
218
219
|
//------------------------------------------------------------------------------------------
|
|
@@ -229,17 +230,19 @@ function clone(configObject) {
|
|
|
229
230
|
* [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
|
|
230
231
|
*/
|
|
231
232
|
function BigNumber(v, b) {
|
|
232
|
-
var alphabet, c, caseChanged, e, i,
|
|
233
|
+
var alphabet, c, caseChanged, e, i, len, str, t,
|
|
233
234
|
x = this;
|
|
234
235
|
|
|
235
236
|
// Enable constructor call without `new`.
|
|
236
237
|
if (!(x instanceof BigNumber)) return new BigNumber(v, b);
|
|
237
238
|
|
|
239
|
+
t = typeof v;
|
|
240
|
+
|
|
238
241
|
if (b == null) {
|
|
239
242
|
|
|
240
|
-
if (v
|
|
243
|
+
if (isBigNumber(v)) {
|
|
241
244
|
x.s = v.s;
|
|
242
|
-
|
|
245
|
+
|
|
243
246
|
if (!v.c || v.e > MAX_EXP) {
|
|
244
247
|
x.c = x.e = null;
|
|
245
248
|
} else if (v.e < MIN_EXP) {
|
|
@@ -248,16 +251,23 @@ function clone(configObject) {
|
|
|
248
251
|
x.e = v.e;
|
|
249
252
|
x.c = v.c.slice();
|
|
250
253
|
}
|
|
251
|
-
|
|
254
|
+
|
|
252
255
|
return;
|
|
253
256
|
}
|
|
257
|
+
|
|
258
|
+
if (t == 'number') {
|
|
254
259
|
|
|
255
|
-
|
|
260
|
+
// Handle ±Infinity and NaN.
|
|
261
|
+
if (v * 0 != 0) {
|
|
262
|
+
x.s = isNaN(v) ? null : v < 0 ? -1 : 1;
|
|
263
|
+
x.c = x.e = null;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
256
266
|
|
|
257
|
-
// Use `1 /
|
|
267
|
+
// Use `1 / v` to handle minus zero also.
|
|
258
268
|
x.s = 1 / v < 0 ? (v = -v, -1) : 1;
|
|
259
269
|
|
|
260
|
-
// Fast path for integers, where
|
|
270
|
+
// Fast path for integers, where v < 2147483648 (2**31).
|
|
261
271
|
if (v === ~~v) {
|
|
262
272
|
for (e = 0, i = v; i >= 10; i /= 10, e++);
|
|
263
273
|
|
|
@@ -273,11 +283,20 @@ function clone(configObject) {
|
|
|
273
283
|
|
|
274
284
|
str = String(v);
|
|
275
285
|
} else {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
286
|
+
if (t == 'string') {
|
|
287
|
+
str = v;
|
|
288
|
+
if (!isNumeric.test(str)) {
|
|
289
|
+
return parseUnusualNumeric(x, str);
|
|
290
|
+
}
|
|
291
|
+
} else if (t == 'bigint') {
|
|
292
|
+
str = String(v);
|
|
293
|
+
} else {
|
|
294
|
+
throw Error
|
|
295
|
+
(bignumberError + 'Invalid argument: ' + v);
|
|
296
|
+
}
|
|
297
|
+
|
|
279
298
|
x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
|
|
280
|
-
}
|
|
299
|
+
}
|
|
281
300
|
|
|
282
301
|
// Decimal point?
|
|
283
302
|
if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
|
|
@@ -295,36 +314,20 @@ function clone(configObject) {
|
|
|
295
314
|
e = str.length;
|
|
296
315
|
}
|
|
297
316
|
|
|
298
|
-
|
|
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;
|
|
317
|
+
// Base specified.
|
|
318
|
+
} else {
|
|
318
319
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
} else {
|
|
325
|
-
x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
|
|
320
|
+
// '[BigNumber Error] String expected: {v}'
|
|
321
|
+
if (t != 'string') {
|
|
322
|
+
throw Error
|
|
323
|
+
(bignumberError + 'String expected: ' + v);
|
|
326
324
|
}
|
|
327
325
|
|
|
326
|
+
// '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
|
|
327
|
+
intCheck(b, 2, ALPHABET.length, 'Base');
|
|
328
|
+
|
|
329
|
+
str = v;
|
|
330
|
+
x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
|
|
328
331
|
alphabet = ALPHABET.slice(0, b);
|
|
329
332
|
e = i = 0;
|
|
330
333
|
|
|
@@ -351,12 +354,10 @@ function clone(configObject) {
|
|
|
351
354
|
}
|
|
352
355
|
}
|
|
353
356
|
|
|
354
|
-
return
|
|
357
|
+
return parseUnusualNumeric(x, v, b);
|
|
355
358
|
}
|
|
356
|
-
}
|
|
359
|
+
}
|
|
357
360
|
|
|
358
|
-
// Prevent later check for length on converted number.
|
|
359
|
-
isNum = false;
|
|
360
361
|
str = convertBase(str, b, 10, x.s);
|
|
361
362
|
|
|
362
363
|
// Decimal point?
|
|
@@ -372,16 +373,10 @@ function clone(configObject) {
|
|
|
372
373
|
|
|
373
374
|
if (str = str.slice(i, ++len)) {
|
|
374
375
|
len -= i;
|
|
376
|
+
e = e - i - 1;
|
|
375
377
|
|
|
376
|
-
//
|
|
377
|
-
if (
|
|
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) {
|
|
378
|
+
// Overflow?
|
|
379
|
+
if (e > MAX_EXP) {
|
|
385
380
|
|
|
386
381
|
// Infinity.
|
|
387
382
|
x.c = x.e = null;
|
|
@@ -455,8 +450,8 @@ function clone(configObject) {
|
|
|
455
450
|
* CRYPTO {boolean} true or false
|
|
456
451
|
* MODULO_MODE {number} 0 to 9
|
|
457
452
|
* POW_PRECISION {number} 0 to MAX
|
|
458
|
-
* ALPHABET {string} A string of
|
|
459
|
-
*
|
|
453
|
+
* ALPHABET {string} A string of unique characters which does not contain
|
|
454
|
+
* '+', '-', '.', or whitespace, and starts with '0123456789'.
|
|
460
455
|
* FORMAT {object} An object with some of the following properties:
|
|
461
456
|
* prefix {string}
|
|
462
457
|
* groupSize {number}
|
|
@@ -591,10 +586,9 @@ function clone(configObject) {
|
|
|
591
586
|
if (obj.hasOwnProperty(p = 'ALPHABET')) {
|
|
592
587
|
v = obj[p];
|
|
593
588
|
|
|
594
|
-
// Disallow if
|
|
595
|
-
// or
|
|
589
|
+
// Disallow if the alphabet is not at least two characters long,
|
|
590
|
+
// or contains '+', '-', '.', whitespace, or a repeated character.
|
|
596
591
|
if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
|
|
597
|
-
alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789';
|
|
598
592
|
ALPHABET = v;
|
|
599
593
|
} else {
|
|
600
594
|
throw Error
|
|
@@ -625,58 +619,51 @@ function clone(configObject) {
|
|
|
625
619
|
|
|
626
620
|
|
|
627
621
|
/*
|
|
628
|
-
* Return true if v
|
|
629
|
-
*
|
|
630
|
-
* If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
|
|
622
|
+
* Return true if v appears to be a BigNumber instance that has a valid coefficient (c),
|
|
623
|
+
* exponent (e), and sign (s), otherwise return false.
|
|
631
624
|
*
|
|
632
625
|
* v {any}
|
|
633
|
-
*
|
|
634
|
-
* '[BigNumber Error] Invalid BigNumber: {v}'
|
|
635
626
|
*/
|
|
636
627
|
BigNumber.isBigNumber = function (v) {
|
|
637
|
-
if (!v
|
|
638
|
-
if (!BigNumber.DEBUG) return true;
|
|
639
|
-
|
|
628
|
+
if (!isBigNumber(v)) return false;
|
|
640
629
|
var i, n,
|
|
641
630
|
c = v.c,
|
|
642
631
|
e = v.e,
|
|
643
632
|
s = v.s;
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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;
|
|
633
|
+
|
|
634
|
+
if ({}.toString.call(c) != '[object Array]') {
|
|
635
|
+
|
|
636
|
+
// ±Infinity and NaN
|
|
637
|
+
return c === null && e === null && (s === null || s === 1 || s === -1)
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Check sign and check that exponent is an integer within the allowed range.
|
|
641
|
+
if ((s !== 1 && s !== -1) || e < -MAX || e > MAX || e !== mathfloor(e)) {
|
|
642
|
+
return false;
|
|
676
643
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
644
|
+
|
|
645
|
+
// If the first element is zero, the BigNumber value must be zero.
|
|
646
|
+
if (c[0] === 0) {
|
|
647
|
+
return e === 0 && c.length === 1;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// Calculate number of digits that c[0] should have, based on the exponent.
|
|
651
|
+
i = (e + 1) % LOG_BASE;
|
|
652
|
+
if (i < 1) i += LOG_BASE;
|
|
653
|
+
|
|
654
|
+
// Calculate number of digits of c[0].
|
|
655
|
+
//if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) !== i) {
|
|
656
|
+
if (String(c[0]).length !== i) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
for (i = 0; i < c.length; i++) {
|
|
661
|
+
n = c[i];
|
|
662
|
+
if (n < 0 || n >= BASE || n !== mathfloor(n)) return false;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// Last element cannot be zero, unless it is the only element.
|
|
666
|
+
return n !== 0;
|
|
680
667
|
};
|
|
681
668
|
|
|
682
669
|
|
|
@@ -844,7 +831,7 @@ function clone(configObject) {
|
|
|
844
831
|
})();
|
|
845
832
|
|
|
846
833
|
|
|
847
|
-
|
|
834
|
+
/*
|
|
848
835
|
* Return a BigNumber whose value is the sum of the arguments.
|
|
849
836
|
*
|
|
850
837
|
* arguments {number|string|BigNumber}
|
|
@@ -955,7 +942,7 @@ function clone(configObject) {
|
|
|
955
942
|
|
|
956
943
|
// xc now represents str converted to baseOut.
|
|
957
944
|
|
|
958
|
-
//
|
|
945
|
+
// The index of the rounding digit.
|
|
959
946
|
d = e + dp + 1;
|
|
960
947
|
|
|
961
948
|
// The rounding digit: the digit to the right of the digit that may be rounded up.
|
|
@@ -1319,7 +1306,7 @@ function clone(configObject) {
|
|
|
1319
1306
|
|
|
1320
1307
|
// Fixed-point notation.
|
|
1321
1308
|
} else {
|
|
1322
|
-
i -= ne;
|
|
1309
|
+
i -= ne + (id === 2 && e > ne);
|
|
1323
1310
|
str = toFixedPoint(str, e, '0');
|
|
1324
1311
|
|
|
1325
1312
|
// Append zeros?
|
|
@@ -1339,6 +1326,11 @@ function clone(configObject) {
|
|
|
1339
1326
|
}
|
|
1340
1327
|
|
|
1341
1328
|
|
|
1329
|
+
function isBigNumber(v) {
|
|
1330
|
+
return v instanceof BigNumber || !!v && v._isBigNumber === true;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
|
|
1342
1334
|
// Handle BigNumber.max and BigNumber.min.
|
|
1343
1335
|
// If any number is NaN, return NaN.
|
|
1344
1336
|
function maxOrMin(args, n) {
|
|
@@ -1392,51 +1384,43 @@ function clone(configObject) {
|
|
|
1392
1384
|
|
|
1393
1385
|
|
|
1394
1386
|
// Handle values that fail the validity test in BigNumber.
|
|
1395
|
-
|
|
1387
|
+
parseUnusualNumeric = (function () {
|
|
1396
1388
|
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
|
|
1397
1389
|
dotAfter = /^([^.]+)\.$/,
|
|
1398
1390
|
dotBefore = /^\.([^.]+)$/,
|
|
1399
1391
|
isInfinityOrNaN = /^-?(Infinity|NaN)$/,
|
|
1400
1392
|
whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
1401
1393
|
|
|
1402
|
-
return function (x, str,
|
|
1394
|
+
return function (x, str, b) {
|
|
1403
1395
|
var base,
|
|
1404
|
-
s =
|
|
1396
|
+
s = str.replace(whitespaceOrPlus, '');
|
|
1405
1397
|
|
|
1406
1398
|
// No exception on ±Infinity or NaN.
|
|
1407
1399
|
if (isInfinityOrNaN.test(s)) {
|
|
1408
1400
|
x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
|
|
1409
|
-
|
|
1410
|
-
|
|
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;
|
|
1401
|
+
x.c = x.e = null;
|
|
1402
|
+
return;
|
|
1437
1403
|
}
|
|
1438
1404
|
|
|
1439
|
-
|
|
1405
|
+
// basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
|
|
1406
|
+
s = s.replace(basePrefix, function (m, p1, p2) {
|
|
1407
|
+
base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
|
|
1408
|
+
return !b || b == base ? p1 : m;
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
if (b) {
|
|
1412
|
+
base = b;
|
|
1413
|
+
|
|
1414
|
+
// E.g. '1.' to '1', '.1' to '0.1'
|
|
1415
|
+
s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
if (str != s) return new BigNumber(s, base);
|
|
1419
|
+
|
|
1420
|
+
// '[BigNumber Error] Not a number: {n}'
|
|
1421
|
+
// '[BigNumber Error] Not a base {b} number: {n}'
|
|
1422
|
+
throw Error
|
|
1423
|
+
(bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
|
|
1440
1424
|
}
|
|
1441
1425
|
})();
|
|
1442
1426
|
|
|
@@ -2740,6 +2724,19 @@ function clone(configObject) {
|
|
|
2740
2724
|
};
|
|
2741
2725
|
|
|
2742
2726
|
|
|
2727
|
+
/*
|
|
2728
|
+
* Return the value of this BigNumber converted to a plain object.
|
|
2729
|
+
*/
|
|
2730
|
+
P.toObject = function() {
|
|
2731
|
+
var x = this;
|
|
2732
|
+
return {
|
|
2733
|
+
c: x.c ? x.c.slice() : null,
|
|
2734
|
+
e: x.e,
|
|
2735
|
+
s: x.s
|
|
2736
|
+
};
|
|
2737
|
+
};
|
|
2738
|
+
|
|
2739
|
+
|
|
2743
2740
|
/*
|
|
2744
2741
|
* Return a string representing the value of this BigNumber rounded to sd significant digits
|
|
2745
2742
|
* using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
|
|
@@ -2759,8 +2756,8 @@ function clone(configObject) {
|
|
|
2759
2756
|
|
|
2760
2757
|
/*
|
|
2761
2758
|
* 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,
|
|
2763
|
-
*
|
|
2759
|
+
* omitted. If a base is specified, round according to DECIMAL_PLACES and ROUNDING_MODE.
|
|
2760
|
+
* If a base is not specified, and this BigNumber has a positive exponent
|
|
2764
2761
|
* that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
|
|
2765
2762
|
* TO_EXP_NEG, return exponential notation.
|
|
2766
2763
|
*
|
|
@@ -2787,9 +2784,6 @@ function clone(configObject) {
|
|
|
2787
2784
|
str = e <= TO_EXP_NEG || e >= TO_EXP_POS
|
|
2788
2785
|
? toExponential(coeffToString(n.c), e)
|
|
2789
2786
|
: 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
2787
|
} else {
|
|
2794
2788
|
intCheck(b, 2, ALPHABET.length, 'Base');
|
|
2795
2789
|
str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
|
|
@@ -2813,11 +2807,6 @@ function clone(configObject) {
|
|
|
2813
2807
|
|
|
2814
2808
|
P._isBigNumber = true;
|
|
2815
2809
|
|
|
2816
|
-
P[Symbol.toStringTag] = 'BigNumber';
|
|
2817
|
-
|
|
2818
|
-
// Node.js v10.12.0+
|
|
2819
|
-
P[Symbol.for('nodejs.util.inspect.custom')] = P.valueOf;
|
|
2820
|
-
|
|
2821
2810
|
if (configObject != null) BigNumber.set(configObject);
|
|
2822
2811
|
|
|
2823
2812
|
return BigNumber;
|
|
@@ -2948,13 +2937,7 @@ function toFixedPoint(str, e, z) {
|
|
|
2948
2937
|
}
|
|
2949
2938
|
|
|
2950
2939
|
return str;
|
|
2951
|
-
}
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
// EXPORT
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
var BigNumber = clone();
|
|
2940
|
+
}
|
|
2958
2941
|
|
|
2959
2942
|
/**
|
|
2960
2943
|
* Check if a chain is EVM and supported by the protocol
|
package/lib/index.js
CHANGED
|
@@ -53,10 +53,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
/*
|
|
56
|
-
* bignumber.js
|
|
56
|
+
* bignumber.js v10.0.1
|
|
57
57
|
* A JavaScript library for arbitrary-precision arithmetic.
|
|
58
58
|
* https://github.com/MikeMcl/bignumber.js
|
|
59
|
-
* Copyright (c)
|
|
59
|
+
* Copyright (c) 2026 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
60
60
|
* MIT Licensed.
|
|
61
61
|
*
|
|
62
62
|
* BigNumber.prototype methods | BigNumber methods
|
|
@@ -93,6 +93,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
93
93
|
* toFraction |
|
|
94
94
|
* toJSON |
|
|
95
95
|
* toNumber |
|
|
96
|
+
* toObject |
|
|
96
97
|
* toPrecision |
|
|
97
98
|
* toString |
|
|
98
99
|
* valueOf |
|
|
@@ -101,12 +102,12 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
var
|
|
105
|
+
BigNumber = clone(),
|
|
104
106
|
isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
|
|
105
107
|
mathceil = Math.ceil,
|
|
106
108
|
mathfloor = Math.floor,
|
|
107
109
|
|
|
108
110
|
bignumberError = '[BigNumber Error] ',
|
|
109
|
-
tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
|
|
110
111
|
|
|
111
112
|
BASE = 1e14,
|
|
112
113
|
LOG_BASE = 14,
|
|
@@ -125,7 +126,7 @@ var
|
|
|
125
126
|
* Create and return a BigNumber constructor.
|
|
126
127
|
*/
|
|
127
128
|
function clone(configObject) {
|
|
128
|
-
var div, convertBase,
|
|
129
|
+
var div, convertBase, parseUnusualNumeric,
|
|
129
130
|
P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
|
|
130
131
|
ONE = new BigNumber(1),
|
|
131
132
|
|
|
@@ -210,11 +211,11 @@ function clone(configObject) {
|
|
|
210
211
|
suffix: ''
|
|
211
212
|
},
|
|
212
213
|
|
|
213
|
-
// The alphabet used for base conversion.
|
|
214
|
-
// '-', '.', whitespace, or repeated
|
|
214
|
+
// The alphabet used for base conversion.
|
|
215
|
+
// It must be at least two characters long and have no '+', '-', '.', whitespace, or repeated
|
|
216
|
+
// character.
|
|
215
217
|
// '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
|
|
216
|
-
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'
|
|
217
|
-
alphabetHasNormalDecimalDigits = true;
|
|
218
|
+
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
218
219
|
|
|
219
220
|
|
|
220
221
|
//------------------------------------------------------------------------------------------
|
|
@@ -231,17 +232,19 @@ function clone(configObject) {
|
|
|
231
232
|
* [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
|
|
232
233
|
*/
|
|
233
234
|
function BigNumber(v, b) {
|
|
234
|
-
var alphabet, c, caseChanged, e, i,
|
|
235
|
+
var alphabet, c, caseChanged, e, i, len, str, t,
|
|
235
236
|
x = this;
|
|
236
237
|
|
|
237
238
|
// Enable constructor call without `new`.
|
|
238
239
|
if (!(x instanceof BigNumber)) return new BigNumber(v, b);
|
|
239
240
|
|
|
241
|
+
t = typeof v;
|
|
242
|
+
|
|
240
243
|
if (b == null) {
|
|
241
244
|
|
|
242
|
-
if (v
|
|
245
|
+
if (isBigNumber(v)) {
|
|
243
246
|
x.s = v.s;
|
|
244
|
-
|
|
247
|
+
|
|
245
248
|
if (!v.c || v.e > MAX_EXP) {
|
|
246
249
|
x.c = x.e = null;
|
|
247
250
|
} else if (v.e < MIN_EXP) {
|
|
@@ -250,16 +253,23 @@ function clone(configObject) {
|
|
|
250
253
|
x.e = v.e;
|
|
251
254
|
x.c = v.c.slice();
|
|
252
255
|
}
|
|
253
|
-
|
|
256
|
+
|
|
254
257
|
return;
|
|
255
258
|
}
|
|
259
|
+
|
|
260
|
+
if (t == 'number') {
|
|
256
261
|
|
|
257
|
-
|
|
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
|
+
}
|
|
258
268
|
|
|
259
|
-
// Use `1 /
|
|
269
|
+
// Use `1 / v` to handle minus zero also.
|
|
260
270
|
x.s = 1 / v < 0 ? (v = -v, -1) : 1;
|
|
261
271
|
|
|
262
|
-
// Fast path for integers, where
|
|
272
|
+
// Fast path for integers, where v < 2147483648 (2**31).
|
|
263
273
|
if (v === ~~v) {
|
|
264
274
|
for (e = 0, i = v; i >= 10; i /= 10, e++);
|
|
265
275
|
|
|
@@ -275,11 +285,20 @@ function clone(configObject) {
|
|
|
275
285
|
|
|
276
286
|
str = String(v);
|
|
277
287
|
} else {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
+
|
|
281
300
|
x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
|
|
282
|
-
}
|
|
301
|
+
}
|
|
283
302
|
|
|
284
303
|
// Decimal point?
|
|
285
304
|
if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
|
|
@@ -297,36 +316,20 @@ function clone(configObject) {
|
|
|
297
316
|
e = str.length;
|
|
298
317
|
}
|
|
299
318
|
|
|
300
|
-
|
|
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;
|
|
319
|
+
// Base specified.
|
|
320
|
+
} else {
|
|
320
321
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
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);
|
|
328
326
|
}
|
|
329
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;
|
|
330
333
|
alphabet = ALPHABET.slice(0, b);
|
|
331
334
|
e = i = 0;
|
|
332
335
|
|
|
@@ -353,12 +356,10 @@ function clone(configObject) {
|
|
|
353
356
|
}
|
|
354
357
|
}
|
|
355
358
|
|
|
356
|
-
return
|
|
359
|
+
return parseUnusualNumeric(x, v, b);
|
|
357
360
|
}
|
|
358
|
-
}
|
|
361
|
+
}
|
|
359
362
|
|
|
360
|
-
// Prevent later check for length on converted number.
|
|
361
|
-
isNum = false;
|
|
362
363
|
str = convertBase(str, b, 10, x.s);
|
|
363
364
|
|
|
364
365
|
// Decimal point?
|
|
@@ -374,16 +375,10 @@ function clone(configObject) {
|
|
|
374
375
|
|
|
375
376
|
if (str = str.slice(i, ++len)) {
|
|
376
377
|
len -= i;
|
|
378
|
+
e = e - i - 1;
|
|
377
379
|
|
|
378
|
-
//
|
|
379
|
-
if (
|
|
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) {
|
|
380
|
+
// Overflow?
|
|
381
|
+
if (e > MAX_EXP) {
|
|
387
382
|
|
|
388
383
|
// Infinity.
|
|
389
384
|
x.c = x.e = null;
|
|
@@ -457,8 +452,8 @@ function clone(configObject) {
|
|
|
457
452
|
* CRYPTO {boolean} true or false
|
|
458
453
|
* MODULO_MODE {number} 0 to 9
|
|
459
454
|
* POW_PRECISION {number} 0 to MAX
|
|
460
|
-
* ALPHABET {string} A string of
|
|
461
|
-
*
|
|
455
|
+
* ALPHABET {string} A string of unique characters which does not contain
|
|
456
|
+
* '+', '-', '.', or whitespace, and starts with '0123456789'.
|
|
462
457
|
* FORMAT {object} An object with some of the following properties:
|
|
463
458
|
* prefix {string}
|
|
464
459
|
* groupSize {number}
|
|
@@ -593,10 +588,9 @@ function clone(configObject) {
|
|
|
593
588
|
if (obj.hasOwnProperty(p = 'ALPHABET')) {
|
|
594
589
|
v = obj[p];
|
|
595
590
|
|
|
596
|
-
// Disallow if
|
|
597
|
-
// or
|
|
591
|
+
// Disallow if the alphabet is not at least two characters long,
|
|
592
|
+
// or contains '+', '-', '.', whitespace, or a repeated character.
|
|
598
593
|
if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
|
|
599
|
-
alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789';
|
|
600
594
|
ALPHABET = v;
|
|
601
595
|
} else {
|
|
602
596
|
throw Error
|
|
@@ -627,58 +621,51 @@ function clone(configObject) {
|
|
|
627
621
|
|
|
628
622
|
|
|
629
623
|
/*
|
|
630
|
-
* Return true if v
|
|
631
|
-
*
|
|
632
|
-
* 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.
|
|
633
626
|
*
|
|
634
627
|
* v {any}
|
|
635
|
-
*
|
|
636
|
-
* '[BigNumber Error] Invalid BigNumber: {v}'
|
|
637
628
|
*/
|
|
638
629
|
BigNumber.isBigNumber = function (v) {
|
|
639
|
-
if (!v
|
|
640
|
-
if (!BigNumber.DEBUG) return true;
|
|
641
|
-
|
|
630
|
+
if (!isBigNumber(v)) return false;
|
|
642
631
|
var i, n,
|
|
643
632
|
c = v.c,
|
|
644
633
|
e = v.e,
|
|
645
634
|
s = v.s;
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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;
|
|
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;
|
|
678
645
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
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;
|
|
682
669
|
};
|
|
683
670
|
|
|
684
671
|
|
|
@@ -846,7 +833,7 @@ function clone(configObject) {
|
|
|
846
833
|
})();
|
|
847
834
|
|
|
848
835
|
|
|
849
|
-
|
|
836
|
+
/*
|
|
850
837
|
* Return a BigNumber whose value is the sum of the arguments.
|
|
851
838
|
*
|
|
852
839
|
* arguments {number|string|BigNumber}
|
|
@@ -957,7 +944,7 @@ function clone(configObject) {
|
|
|
957
944
|
|
|
958
945
|
// xc now represents str converted to baseOut.
|
|
959
946
|
|
|
960
|
-
//
|
|
947
|
+
// The index of the rounding digit.
|
|
961
948
|
d = e + dp + 1;
|
|
962
949
|
|
|
963
950
|
// The rounding digit: the digit to the right of the digit that may be rounded up.
|
|
@@ -1321,7 +1308,7 @@ function clone(configObject) {
|
|
|
1321
1308
|
|
|
1322
1309
|
// Fixed-point notation.
|
|
1323
1310
|
} else {
|
|
1324
|
-
i -= ne;
|
|
1311
|
+
i -= ne + (id === 2 && e > ne);
|
|
1325
1312
|
str = toFixedPoint(str, e, '0');
|
|
1326
1313
|
|
|
1327
1314
|
// Append zeros?
|
|
@@ -1341,6 +1328,11 @@ function clone(configObject) {
|
|
|
1341
1328
|
}
|
|
1342
1329
|
|
|
1343
1330
|
|
|
1331
|
+
function isBigNumber(v) {
|
|
1332
|
+
return v instanceof BigNumber || !!v && v._isBigNumber === true;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
|
|
1344
1336
|
// Handle BigNumber.max and BigNumber.min.
|
|
1345
1337
|
// If any number is NaN, return NaN.
|
|
1346
1338
|
function maxOrMin(args, n) {
|
|
@@ -1394,51 +1386,43 @@ function clone(configObject) {
|
|
|
1394
1386
|
|
|
1395
1387
|
|
|
1396
1388
|
// Handle values that fail the validity test in BigNumber.
|
|
1397
|
-
|
|
1389
|
+
parseUnusualNumeric = (function () {
|
|
1398
1390
|
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
|
|
1399
1391
|
dotAfter = /^([^.]+)\.$/,
|
|
1400
1392
|
dotBefore = /^\.([^.]+)$/,
|
|
1401
1393
|
isInfinityOrNaN = /^-?(Infinity|NaN)$/,
|
|
1402
1394
|
whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
1403
1395
|
|
|
1404
|
-
return function (x, str,
|
|
1396
|
+
return function (x, str, b) {
|
|
1405
1397
|
var base,
|
|
1406
|
-
s =
|
|
1398
|
+
s = str.replace(whitespaceOrPlus, '');
|
|
1407
1399
|
|
|
1408
1400
|
// No exception on ±Infinity or NaN.
|
|
1409
1401
|
if (isInfinityOrNaN.test(s)) {
|
|
1410
1402
|
x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
|
|
1411
|
-
|
|
1412
|
-
|
|
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;
|
|
1403
|
+
x.c = x.e = null;
|
|
1404
|
+
return;
|
|
1439
1405
|
}
|
|
1440
1406
|
|
|
1441
|
-
|
|
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);
|
|
1442
1426
|
}
|
|
1443
1427
|
})();
|
|
1444
1428
|
|
|
@@ -2742,6 +2726,19 @@ function clone(configObject) {
|
|
|
2742
2726
|
};
|
|
2743
2727
|
|
|
2744
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
|
+
|
|
2745
2742
|
/*
|
|
2746
2743
|
* Return a string representing the value of this BigNumber rounded to sd significant digits
|
|
2747
2744
|
* using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
|
|
@@ -2761,8 +2758,8 @@ function clone(configObject) {
|
|
|
2761
2758
|
|
|
2762
2759
|
/*
|
|
2763
2760
|
* 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,
|
|
2765
|
-
*
|
|
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
|
|
2766
2763
|
* that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
|
|
2767
2764
|
* TO_EXP_NEG, return exponential notation.
|
|
2768
2765
|
*
|
|
@@ -2789,9 +2786,6 @@ function clone(configObject) {
|
|
|
2789
2786
|
str = e <= TO_EXP_NEG || e >= TO_EXP_POS
|
|
2790
2787
|
? toExponential(coeffToString(n.c), e)
|
|
2791
2788
|
: 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
2789
|
} else {
|
|
2796
2790
|
intCheck(b, 2, ALPHABET.length, 'Base');
|
|
2797
2791
|
str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
|
|
@@ -2815,11 +2809,6 @@ function clone(configObject) {
|
|
|
2815
2809
|
|
|
2816
2810
|
P._isBigNumber = true;
|
|
2817
2811
|
|
|
2818
|
-
P[Symbol.toStringTag] = 'BigNumber';
|
|
2819
|
-
|
|
2820
|
-
// Node.js v10.12.0+
|
|
2821
|
-
P[Symbol.for('nodejs.util.inspect.custom')] = P.valueOf;
|
|
2822
|
-
|
|
2823
2812
|
if (configObject != null) BigNumber.set(configObject);
|
|
2824
2813
|
|
|
2825
2814
|
return BigNumber;
|
|
@@ -2950,13 +2939,7 @@ function toFixedPoint(str, e, z) {
|
|
|
2950
2939
|
}
|
|
2951
2940
|
|
|
2952
2941
|
return str;
|
|
2953
|
-
}
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
// EXPORT
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
var BigNumber = clone();
|
|
2942
|
+
}
|
|
2960
2943
|
|
|
2961
2944
|
/**
|
|
2962
2945
|
* Check if a chain is EVM and supported by the protocol
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-amm",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.32",
|
|
4
4
|
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
"url": "https://github.com/xchainjs/xchainjs-lib/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xchainjs/xchain-avax": "2.0.
|
|
40
|
-
"@xchainjs/xchain-base": "1.0.
|
|
41
|
-
"@xchainjs/xchain-bitcoin": "2.2.
|
|
42
|
-
"@xchainjs/xchain-bitcoincash": "2.2.
|
|
43
|
-
"@xchainjs/xchain-bsc": "2.0.
|
|
44
|
-
"@xchainjs/xchain-client": "2.0.
|
|
45
|
-
"@xchainjs/xchain-cosmos": "3.0.
|
|
46
|
-
"@xchainjs/xchain-doge": "2.2.
|
|
47
|
-
"@xchainjs/xchain-ethereum": "2.0.
|
|
48
|
-
"@xchainjs/xchain-evm": "2.0.
|
|
49
|
-
"@xchainjs/xchain-litecoin": "2.2.
|
|
50
|
-
"@xchainjs/xchain-ripple": "1.0.
|
|
51
|
-
"@xchainjs/xchain-solana": "1.1.
|
|
52
|
-
"@xchainjs/xchain-thorchain": "3.0.
|
|
53
|
-
"@xchainjs/xchain-thorchain-query": "3.0.
|
|
54
|
-
"@xchainjs/xchain-tron": "3.0.
|
|
55
|
-
"@xchainjs/xchain-util": "2.0.
|
|
56
|
-
"@xchainjs/xchain-wallet": "2.0.
|
|
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.2",
|
|
52
|
+
"@xchainjs/xchain-thorchain": "3.0.15",
|
|
53
|
+
"@xchainjs/xchain-thorchain-query": "3.0.2",
|
|
54
|
+
"@xchainjs/xchain-tron": "3.0.4",
|
|
55
|
+
"@xchainjs/xchain-util": "2.0.6",
|
|
56
|
+
"@xchainjs/xchain-wallet": "2.0.24",
|
|
57
57
|
"ethers": "^6.14.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|