@gearbox-protocol/sdk 3.0.0-vfour.146 → 3.0.0-vfour.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/sdk/index.cjs +1140 -176
- package/dist/cjs/sdk/index.d.ts +1 -6
- package/dist/esm/sdk/index.d.mts +1 -6
- package/dist/esm/sdk/index.mjs +1137 -171
- package/package.json +1 -2
package/dist/cjs/sdk/index.cjs
CHANGED
|
@@ -14,8 +14,6 @@ var util = require('util');
|
|
|
14
14
|
var zlib = require('zlib');
|
|
15
15
|
var stream3 = require('stream');
|
|
16
16
|
var events = require('events');
|
|
17
|
-
var decimal_jsLight = require('decimal.js-light');
|
|
18
|
-
var moment = require('moment');
|
|
19
17
|
|
|
20
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
19
|
|
|
@@ -25,7 +23,6 @@ var https__default = /*#__PURE__*/_interopDefault(https);
|
|
|
25
23
|
var util__default = /*#__PURE__*/_interopDefault(util);
|
|
26
24
|
var zlib__default = /*#__PURE__*/_interopDefault(zlib);
|
|
27
25
|
var stream3__default = /*#__PURE__*/_interopDefault(stream3);
|
|
28
|
-
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
29
26
|
|
|
30
27
|
var __create = Object.create;
|
|
31
28
|
var __defProp = Object.defineProperty;
|
|
@@ -9422,7 +9419,7 @@ var require_form_data = __commonJS({
|
|
|
9422
9419
|
});
|
|
9423
9420
|
};
|
|
9424
9421
|
FormData3.prototype.submit = function(params, cb) {
|
|
9425
|
-
var request, options,
|
|
9422
|
+
var request, options, defaults3 = { method: "post" };
|
|
9426
9423
|
if (typeof params == "string") {
|
|
9427
9424
|
params = parseUrl(params);
|
|
9428
9425
|
options = populate({
|
|
@@ -9430,9 +9427,9 @@ var require_form_data = __commonJS({
|
|
|
9430
9427
|
path: params.pathname,
|
|
9431
9428
|
host: params.hostname,
|
|
9432
9429
|
protocol: params.protocol
|
|
9433
|
-
},
|
|
9430
|
+
}, defaults3);
|
|
9434
9431
|
} else {
|
|
9435
|
-
options = populate(params,
|
|
9432
|
+
options = populate(params, defaults3);
|
|
9436
9433
|
if (!options.port) {
|
|
9437
9434
|
options.port = options.protocol == "https:" ? 443 : 80;
|
|
9438
9435
|
}
|
|
@@ -79090,7 +79087,7 @@ var utils_default = {
|
|
|
79090
79087
|
};
|
|
79091
79088
|
|
|
79092
79089
|
// node_modules/axios/lib/core/AxiosError.js
|
|
79093
|
-
function AxiosError(message, code,
|
|
79090
|
+
function AxiosError(message, code, config2, request, response) {
|
|
79094
79091
|
Error.call(this);
|
|
79095
79092
|
if (Error.captureStackTrace) {
|
|
79096
79093
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -79100,7 +79097,7 @@ function AxiosError(message, code, config, request, response) {
|
|
|
79100
79097
|
this.message = message;
|
|
79101
79098
|
this.name = "AxiosError";
|
|
79102
79099
|
code && (this.code = code);
|
|
79103
|
-
|
|
79100
|
+
config2 && (this.config = config2);
|
|
79104
79101
|
request && (this.request = request);
|
|
79105
79102
|
if (response) {
|
|
79106
79103
|
this.response = response;
|
|
@@ -79149,14 +79146,14 @@ var descriptors = {};
|
|
|
79149
79146
|
});
|
|
79150
79147
|
Object.defineProperties(AxiosError, descriptors);
|
|
79151
79148
|
Object.defineProperty(prototype, "isAxiosError", { value: true });
|
|
79152
|
-
AxiosError.from = (error, code,
|
|
79149
|
+
AxiosError.from = (error, code, config2, request, response, customProps) => {
|
|
79153
79150
|
const axiosError = Object.create(prototype);
|
|
79154
79151
|
utils_default.toFlatObject(error, axiosError, function filter2(obj) {
|
|
79155
79152
|
return obj !== Error.prototype;
|
|
79156
79153
|
}, (prop) => {
|
|
79157
79154
|
return prop !== "isAxiosError";
|
|
79158
79155
|
});
|
|
79159
|
-
AxiosError.call(axiosError, error.message, code,
|
|
79156
|
+
AxiosError.call(axiosError, error.message, code, config2, request, response);
|
|
79160
79157
|
axiosError.cause = error;
|
|
79161
79158
|
axiosError.name = error.name;
|
|
79162
79159
|
customProps && Object.assign(axiosError, customProps);
|
|
@@ -79894,12 +79891,12 @@ var AxiosHeaders_default = AxiosHeaders;
|
|
|
79894
79891
|
|
|
79895
79892
|
// node_modules/axios/lib/core/transformData.js
|
|
79896
79893
|
function transformData(fns, response) {
|
|
79897
|
-
const
|
|
79898
|
-
const context = response ||
|
|
79894
|
+
const config2 = this || defaults_default;
|
|
79895
|
+
const context = response || config2;
|
|
79899
79896
|
const headers = AxiosHeaders_default.from(context.headers);
|
|
79900
79897
|
let data = context.data;
|
|
79901
79898
|
utils_default.forEach(fns, function transform(fn) {
|
|
79902
|
-
data = fn.call(
|
|
79899
|
+
data = fn.call(config2, data, headers.normalize(), response ? response.status : void 0);
|
|
79903
79900
|
});
|
|
79904
79901
|
headers.normalize();
|
|
79905
79902
|
return data;
|
|
@@ -79911,8 +79908,8 @@ function isCancel(value) {
|
|
|
79911
79908
|
}
|
|
79912
79909
|
|
|
79913
79910
|
// node_modules/axios/lib/cancel/CanceledError.js
|
|
79914
|
-
function CanceledError(message,
|
|
79915
|
-
AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED,
|
|
79911
|
+
function CanceledError(message, config2, request) {
|
|
79912
|
+
AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED, config2, request);
|
|
79916
79913
|
this.name = "CanceledError";
|
|
79917
79914
|
}
|
|
79918
79915
|
utils_default.inherits(CanceledError, AxiosError_default, {
|
|
@@ -80433,11 +80430,11 @@ var resolveFamily = ({ address, family }) => {
|
|
|
80433
80430
|
};
|
|
80434
80431
|
};
|
|
80435
80432
|
var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
|
|
80436
|
-
var http_default = isHttpAdapterSupported && function httpAdapter(
|
|
80433
|
+
var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
80437
80434
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
|
80438
|
-
let { data, lookup, family } =
|
|
80439
|
-
const { responseType, responseEncoding } =
|
|
80440
|
-
const method =
|
|
80435
|
+
let { data, lookup, family } = config2;
|
|
80436
|
+
const { responseType, responseEncoding } = config2;
|
|
80437
|
+
const method = config2.method.toUpperCase();
|
|
80441
80438
|
let isDone;
|
|
80442
80439
|
let rejected = false;
|
|
80443
80440
|
let req;
|
|
@@ -80455,11 +80452,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80455
80452
|
}
|
|
80456
80453
|
const emitter = new events.EventEmitter();
|
|
80457
80454
|
const onFinished = () => {
|
|
80458
|
-
if (
|
|
80459
|
-
|
|
80455
|
+
if (config2.cancelToken) {
|
|
80456
|
+
config2.cancelToken.unsubscribe(abort);
|
|
80460
80457
|
}
|
|
80461
|
-
if (
|
|
80462
|
-
|
|
80458
|
+
if (config2.signal) {
|
|
80459
|
+
config2.signal.removeEventListener("abort", abort);
|
|
80463
80460
|
}
|
|
80464
80461
|
emitter.removeAllListeners();
|
|
80465
80462
|
};
|
|
@@ -80471,16 +80468,16 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80471
80468
|
}
|
|
80472
80469
|
});
|
|
80473
80470
|
function abort(reason) {
|
|
80474
|
-
emitter.emit("abort", !reason || reason.type ? new CanceledError_default(null,
|
|
80471
|
+
emitter.emit("abort", !reason || reason.type ? new CanceledError_default(null, config2, req) : reason);
|
|
80475
80472
|
}
|
|
80476
80473
|
emitter.once("abort", reject);
|
|
80477
|
-
if (
|
|
80478
|
-
|
|
80479
|
-
if (
|
|
80480
|
-
|
|
80474
|
+
if (config2.cancelToken || config2.signal) {
|
|
80475
|
+
config2.cancelToken && config2.cancelToken.subscribe(abort);
|
|
80476
|
+
if (config2.signal) {
|
|
80477
|
+
config2.signal.aborted ? abort() : config2.signal.addEventListener("abort", abort);
|
|
80481
80478
|
}
|
|
80482
80479
|
}
|
|
80483
|
-
const fullPath = buildFullPath(
|
|
80480
|
+
const fullPath = buildFullPath(config2.baseURL, config2.url);
|
|
80484
80481
|
const parsed = new URL(fullPath, platform_default.hasBrowserEnv ? platform_default.origin : void 0);
|
|
80485
80482
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
80486
80483
|
if (protocol === "data:") {
|
|
@@ -80490,15 +80487,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80490
80487
|
status: 405,
|
|
80491
80488
|
statusText: "method not allowed",
|
|
80492
80489
|
headers: {},
|
|
80493
|
-
config
|
|
80490
|
+
config: config2
|
|
80494
80491
|
});
|
|
80495
80492
|
}
|
|
80496
80493
|
try {
|
|
80497
|
-
convertedData = fromDataURI(
|
|
80498
|
-
Blob:
|
|
80494
|
+
convertedData = fromDataURI(config2.url, responseType === "blob", {
|
|
80495
|
+
Blob: config2.env && config2.env.Blob
|
|
80499
80496
|
});
|
|
80500
80497
|
} catch (err) {
|
|
80501
|
-
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST,
|
|
80498
|
+
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST, config2);
|
|
80502
80499
|
}
|
|
80503
80500
|
if (responseType === "text") {
|
|
80504
80501
|
convertedData = convertedData.toString(responseEncoding);
|
|
@@ -80513,20 +80510,20 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80513
80510
|
status: 200,
|
|
80514
80511
|
statusText: "OK",
|
|
80515
80512
|
headers: new AxiosHeaders_default(),
|
|
80516
|
-
config
|
|
80513
|
+
config: config2
|
|
80517
80514
|
});
|
|
80518
80515
|
}
|
|
80519
80516
|
if (supportedProtocols.indexOf(protocol) === -1) {
|
|
80520
80517
|
return reject(new AxiosError_default(
|
|
80521
80518
|
"Unsupported protocol " + protocol,
|
|
80522
80519
|
AxiosError_default.ERR_BAD_REQUEST,
|
|
80523
|
-
|
|
80520
|
+
config2
|
|
80524
80521
|
));
|
|
80525
80522
|
}
|
|
80526
|
-
const headers = AxiosHeaders_default.from(
|
|
80523
|
+
const headers = AxiosHeaders_default.from(config2.headers).normalize();
|
|
80527
80524
|
headers.set("User-Agent", "axios/" + VERSION, false);
|
|
80528
|
-
const { onUploadProgress, onDownloadProgress } =
|
|
80529
|
-
const maxRate =
|
|
80525
|
+
const { onUploadProgress, onDownloadProgress } = config2;
|
|
80526
|
+
const maxRate = config2.maxRate;
|
|
80530
80527
|
let maxUploadRate = void 0;
|
|
80531
80528
|
let maxDownloadRate = void 0;
|
|
80532
80529
|
if (utils_default.isSpecCompliantForm(data)) {
|
|
@@ -80559,15 +80556,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80559
80556
|
return reject(new AxiosError_default(
|
|
80560
80557
|
"Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",
|
|
80561
80558
|
AxiosError_default.ERR_BAD_REQUEST,
|
|
80562
|
-
|
|
80559
|
+
config2
|
|
80563
80560
|
));
|
|
80564
80561
|
}
|
|
80565
80562
|
headers.setContentLength(data.length, false);
|
|
80566
|
-
if (
|
|
80563
|
+
if (config2.maxBodyLength > -1 && data.length > config2.maxBodyLength) {
|
|
80567
80564
|
return reject(new AxiosError_default(
|
|
80568
80565
|
"Request body larger than maxBodyLength limit",
|
|
80569
80566
|
AxiosError_default.ERR_BAD_REQUEST,
|
|
80570
|
-
|
|
80567
|
+
config2
|
|
80571
80568
|
));
|
|
80572
80569
|
}
|
|
80573
80570
|
}
|
|
@@ -80594,9 +80591,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80594
80591
|
));
|
|
80595
80592
|
}
|
|
80596
80593
|
let auth = void 0;
|
|
80597
|
-
if (
|
|
80598
|
-
const username =
|
|
80599
|
-
const password =
|
|
80594
|
+
if (config2.auth) {
|
|
80595
|
+
const username = config2.auth.username || "";
|
|
80596
|
+
const password = config2.auth.password || "";
|
|
80600
80597
|
auth = username + ":" + password;
|
|
80601
80598
|
}
|
|
80602
80599
|
if (!auth && parsed.username) {
|
|
@@ -80609,13 +80606,13 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80609
80606
|
try {
|
|
80610
80607
|
path = buildURL(
|
|
80611
80608
|
parsed.pathname + parsed.search,
|
|
80612
|
-
|
|
80613
|
-
|
|
80609
|
+
config2.params,
|
|
80610
|
+
config2.paramsSerializer
|
|
80614
80611
|
).replace(/^\?/, "");
|
|
80615
80612
|
} catch (err) {
|
|
80616
80613
|
const customErr = new Error(err.message);
|
|
80617
|
-
customErr.config =
|
|
80618
|
-
customErr.url =
|
|
80614
|
+
customErr.config = config2;
|
|
80615
|
+
customErr.url = config2.url;
|
|
80619
80616
|
customErr.exists = true;
|
|
80620
80617
|
return reject(customErr);
|
|
80621
80618
|
}
|
|
@@ -80628,7 +80625,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80628
80625
|
path,
|
|
80629
80626
|
method,
|
|
80630
80627
|
headers: headers.toJSON(),
|
|
80631
|
-
agents: { http:
|
|
80628
|
+
agents: { http: config2.httpAgent, https: config2.httpsAgent },
|
|
80632
80629
|
auth,
|
|
80633
80630
|
protocol,
|
|
80634
80631
|
family,
|
|
@@ -80636,36 +80633,36 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80636
80633
|
beforeRedirects: {}
|
|
80637
80634
|
};
|
|
80638
80635
|
!utils_default.isUndefined(lookup) && (options.lookup = lookup);
|
|
80639
|
-
if (
|
|
80640
|
-
options.socketPath =
|
|
80636
|
+
if (config2.socketPath) {
|
|
80637
|
+
options.socketPath = config2.socketPath;
|
|
80641
80638
|
} else {
|
|
80642
80639
|
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
80643
80640
|
options.port = parsed.port;
|
|
80644
|
-
setProxy(options,
|
|
80641
|
+
setProxy(options, config2.proxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path);
|
|
80645
80642
|
}
|
|
80646
80643
|
let transport;
|
|
80647
80644
|
const isHttpsRequest = isHttps.test(options.protocol);
|
|
80648
|
-
options.agent = isHttpsRequest ?
|
|
80649
|
-
if (
|
|
80650
|
-
transport =
|
|
80651
|
-
} else if (
|
|
80645
|
+
options.agent = isHttpsRequest ? config2.httpsAgent : config2.httpAgent;
|
|
80646
|
+
if (config2.transport) {
|
|
80647
|
+
transport = config2.transport;
|
|
80648
|
+
} else if (config2.maxRedirects === 0) {
|
|
80652
80649
|
transport = isHttpsRequest ? https__default.default : http3__default.default;
|
|
80653
80650
|
} else {
|
|
80654
|
-
if (
|
|
80655
|
-
options.maxRedirects =
|
|
80651
|
+
if (config2.maxRedirects) {
|
|
80652
|
+
options.maxRedirects = config2.maxRedirects;
|
|
80656
80653
|
}
|
|
80657
|
-
if (
|
|
80658
|
-
options.beforeRedirects.config =
|
|
80654
|
+
if (config2.beforeRedirect) {
|
|
80655
|
+
options.beforeRedirects.config = config2.beforeRedirect;
|
|
80659
80656
|
}
|
|
80660
80657
|
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
|
80661
80658
|
}
|
|
80662
|
-
if (
|
|
80663
|
-
options.maxBodyLength =
|
|
80659
|
+
if (config2.maxBodyLength > -1) {
|
|
80660
|
+
options.maxBodyLength = config2.maxBodyLength;
|
|
80664
80661
|
} else {
|
|
80665
80662
|
options.maxBodyLength = Infinity;
|
|
80666
80663
|
}
|
|
80667
|
-
if (
|
|
80668
|
-
options.insecureHTTPParser =
|
|
80664
|
+
if (config2.insecureHTTPParser) {
|
|
80665
|
+
options.insecureHTTPParser = config2.insecureHTTPParser;
|
|
80669
80666
|
}
|
|
80670
80667
|
req = transport.request(options, function handleResponse(res) {
|
|
80671
80668
|
if (req.destroyed) return;
|
|
@@ -80686,7 +80683,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80686
80683
|
}
|
|
80687
80684
|
let responseStream = res;
|
|
80688
80685
|
const lastRequest = res.req || req;
|
|
80689
|
-
if (
|
|
80686
|
+
if (config2.decompress !== false && res.headers["content-encoding"]) {
|
|
80690
80687
|
if (method === "HEAD" || res.statusCode === 204) {
|
|
80691
80688
|
delete res.headers["content-encoding"];
|
|
80692
80689
|
}
|
|
@@ -80720,7 +80717,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80720
80717
|
status: res.statusCode,
|
|
80721
80718
|
statusText: res.statusMessage,
|
|
80722
80719
|
headers: new AxiosHeaders_default(res.headers),
|
|
80723
|
-
config,
|
|
80720
|
+
config: config2,
|
|
80724
80721
|
request: lastRequest
|
|
80725
80722
|
};
|
|
80726
80723
|
if (responseType === "stream") {
|
|
@@ -80732,13 +80729,13 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80732
80729
|
responseStream.on("data", function handleStreamData(chunk) {
|
|
80733
80730
|
responseBuffer.push(chunk);
|
|
80734
80731
|
totalResponseBytes += chunk.length;
|
|
80735
|
-
if (
|
|
80732
|
+
if (config2.maxContentLength > -1 && totalResponseBytes > config2.maxContentLength) {
|
|
80736
80733
|
rejected = true;
|
|
80737
80734
|
responseStream.destroy();
|
|
80738
80735
|
reject(new AxiosError_default(
|
|
80739
|
-
"maxContentLength size of " +
|
|
80736
|
+
"maxContentLength size of " + config2.maxContentLength + " exceeded",
|
|
80740
80737
|
AxiosError_default.ERR_BAD_RESPONSE,
|
|
80741
|
-
|
|
80738
|
+
config2,
|
|
80742
80739
|
lastRequest
|
|
80743
80740
|
));
|
|
80744
80741
|
}
|
|
@@ -80750,7 +80747,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80750
80747
|
const err = new AxiosError_default(
|
|
80751
80748
|
"stream has been aborted",
|
|
80752
80749
|
AxiosError_default.ERR_BAD_RESPONSE,
|
|
80753
|
-
|
|
80750
|
+
config2,
|
|
80754
80751
|
lastRequest
|
|
80755
80752
|
);
|
|
80756
80753
|
responseStream.destroy(err);
|
|
@@ -80758,7 +80755,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80758
80755
|
});
|
|
80759
80756
|
responseStream.on("error", function handleStreamError(err) {
|
|
80760
80757
|
if (req.destroyed) return;
|
|
80761
|
-
reject(AxiosError_default.from(err, null,
|
|
80758
|
+
reject(AxiosError_default.from(err, null, config2, lastRequest));
|
|
80762
80759
|
});
|
|
80763
80760
|
responseStream.on("end", function handleStreamEnd() {
|
|
80764
80761
|
try {
|
|
@@ -80771,7 +80768,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80771
80768
|
}
|
|
80772
80769
|
response.data = responseData;
|
|
80773
80770
|
} catch (err) {
|
|
80774
|
-
return reject(AxiosError_default.from(err, null,
|
|
80771
|
+
return reject(AxiosError_default.from(err, null, config2, response.request, response));
|
|
80775
80772
|
}
|
|
80776
80773
|
settle(resolve, reject, response);
|
|
80777
80774
|
});
|
|
@@ -80788,33 +80785,33 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80788
80785
|
req.destroy(err);
|
|
80789
80786
|
});
|
|
80790
80787
|
req.on("error", function handleRequestError(err) {
|
|
80791
|
-
reject(AxiosError_default.from(err, null,
|
|
80788
|
+
reject(AxiosError_default.from(err, null, config2, req));
|
|
80792
80789
|
});
|
|
80793
80790
|
req.on("socket", function handleRequestSocket(socket) {
|
|
80794
80791
|
socket.setKeepAlive(true, 1e3 * 60);
|
|
80795
80792
|
});
|
|
80796
|
-
if (
|
|
80797
|
-
const timeout = parseInt(
|
|
80793
|
+
if (config2.timeout) {
|
|
80794
|
+
const timeout = parseInt(config2.timeout, 10);
|
|
80798
80795
|
if (Number.isNaN(timeout)) {
|
|
80799
80796
|
reject(new AxiosError_default(
|
|
80800
80797
|
"error trying to parse `config.timeout` to int",
|
|
80801
80798
|
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
80802
|
-
|
|
80799
|
+
config2,
|
|
80803
80800
|
req
|
|
80804
80801
|
));
|
|
80805
80802
|
return;
|
|
80806
80803
|
}
|
|
80807
80804
|
req.setTimeout(timeout, function handleRequestTimeout() {
|
|
80808
80805
|
if (isDone) return;
|
|
80809
|
-
let timeoutErrorMessage =
|
|
80810
|
-
const transitional2 =
|
|
80811
|
-
if (
|
|
80812
|
-
timeoutErrorMessage =
|
|
80806
|
+
let timeoutErrorMessage = config2.timeout ? "timeout of " + config2.timeout + "ms exceeded" : "timeout exceeded";
|
|
80807
|
+
const transitional2 = config2.transitional || transitional_default;
|
|
80808
|
+
if (config2.timeoutErrorMessage) {
|
|
80809
|
+
timeoutErrorMessage = config2.timeoutErrorMessage;
|
|
80813
80810
|
}
|
|
80814
80811
|
reject(new AxiosError_default(
|
|
80815
80812
|
timeoutErrorMessage,
|
|
80816
80813
|
transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
80817
|
-
|
|
80814
|
+
config2,
|
|
80818
80815
|
req
|
|
80819
80816
|
));
|
|
80820
80817
|
abort();
|
|
@@ -80832,7 +80829,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80832
80829
|
});
|
|
80833
80830
|
data.on("close", () => {
|
|
80834
80831
|
if (!ended && !errored) {
|
|
80835
|
-
abort(new CanceledError_default("Request stream has been aborted",
|
|
80832
|
+
abort(new CanceledError_default("Request stream has been aborted", config2, req));
|
|
80836
80833
|
}
|
|
80837
80834
|
});
|
|
80838
80835
|
data.pipe(req);
|
|
@@ -80888,7 +80885,7 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
|
|
|
80888
80885
|
var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
|
|
80889
80886
|
function mergeConfig(config1, config2) {
|
|
80890
80887
|
config2 = config2 || {};
|
|
80891
|
-
const
|
|
80888
|
+
const config3 = {};
|
|
80892
80889
|
function getMergedValue(target, source, prop, caseless) {
|
|
80893
80890
|
if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
|
|
80894
80891
|
return utils_default.merge.call({ caseless }, target, source);
|
|
@@ -80959,17 +80956,17 @@ function mergeConfig(config1, config2) {
|
|
|
80959
80956
|
utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
80960
80957
|
const merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
80961
80958
|
const configValue = merge2(config1[prop], config2[prop], prop);
|
|
80962
|
-
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (
|
|
80959
|
+
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config3[prop] = configValue);
|
|
80963
80960
|
});
|
|
80964
|
-
return
|
|
80961
|
+
return config3;
|
|
80965
80962
|
}
|
|
80966
80963
|
|
|
80967
80964
|
// node_modules/axios/lib/helpers/resolveConfig.js
|
|
80968
|
-
var resolveConfig_default = (
|
|
80969
|
-
const newConfig = mergeConfig({},
|
|
80965
|
+
var resolveConfig_default = (config2) => {
|
|
80966
|
+
const newConfig = mergeConfig({}, config2);
|
|
80970
80967
|
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
80971
80968
|
newConfig.headers = headers = AxiosHeaders_default.from(headers);
|
|
80972
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url),
|
|
80969
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config2.params, config2.paramsSerializer);
|
|
80973
80970
|
if (auth) {
|
|
80974
80971
|
headers.set(
|
|
80975
80972
|
"Authorization",
|
|
@@ -80999,9 +80996,9 @@ var resolveConfig_default = (config) => {
|
|
|
80999
80996
|
|
|
81000
80997
|
// node_modules/axios/lib/adapters/xhr.js
|
|
81001
80998
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
81002
|
-
var xhr_default = isXHRAdapterSupported && function(
|
|
80999
|
+
var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
81003
81000
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
81004
|
-
const _config = resolveConfig_default(
|
|
81001
|
+
const _config = resolveConfig_default(config2);
|
|
81005
81002
|
let requestData = _config.data;
|
|
81006
81003
|
const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
|
|
81007
81004
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
@@ -81030,7 +81027,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81030
81027
|
status: request.status,
|
|
81031
81028
|
statusText: request.statusText,
|
|
81032
81029
|
headers: responseHeaders,
|
|
81033
|
-
config,
|
|
81030
|
+
config: config2,
|
|
81034
81031
|
request
|
|
81035
81032
|
};
|
|
81036
81033
|
settle(function _resolve(value) {
|
|
@@ -81059,11 +81056,11 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81059
81056
|
if (!request) {
|
|
81060
81057
|
return;
|
|
81061
81058
|
}
|
|
81062
|
-
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED,
|
|
81059
|
+
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config2, request));
|
|
81063
81060
|
request = null;
|
|
81064
81061
|
};
|
|
81065
81062
|
request.onerror = function handleError() {
|
|
81066
|
-
reject(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK,
|
|
81063
|
+
reject(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config2, request));
|
|
81067
81064
|
request = null;
|
|
81068
81065
|
};
|
|
81069
81066
|
request.ontimeout = function handleTimeout() {
|
|
@@ -81075,7 +81072,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81075
81072
|
reject(new AxiosError_default(
|
|
81076
81073
|
timeoutErrorMessage,
|
|
81077
81074
|
transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
81078
|
-
|
|
81075
|
+
config2,
|
|
81079
81076
|
request
|
|
81080
81077
|
));
|
|
81081
81078
|
request = null;
|
|
@@ -81106,7 +81103,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81106
81103
|
if (!request) {
|
|
81107
81104
|
return;
|
|
81108
81105
|
}
|
|
81109
|
-
reject(!cancel || cancel.type ? new CanceledError_default(null,
|
|
81106
|
+
reject(!cancel || cancel.type ? new CanceledError_default(null, config2, request) : cancel);
|
|
81110
81107
|
request.abort();
|
|
81111
81108
|
request = null;
|
|
81112
81109
|
};
|
|
@@ -81117,7 +81114,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81117
81114
|
}
|
|
81118
81115
|
const protocol = parseProtocol(_config.url);
|
|
81119
81116
|
if (protocol && platform_default.protocols.indexOf(protocol) === -1) {
|
|
81120
|
-
reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST,
|
|
81117
|
+
reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST, config2));
|
|
81121
81118
|
return;
|
|
81122
81119
|
}
|
|
81123
81120
|
request.send(requestData || null);
|
|
@@ -81267,8 +81264,8 @@ var resolvers = {
|
|
|
81267
81264
|
};
|
|
81268
81265
|
isFetchSupported && ((res) => {
|
|
81269
81266
|
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
|
|
81270
|
-
!resolvers[type] && (resolvers[type] = utils_default.isFunction(res[type]) ? (res2) => res2[type]() : (_,
|
|
81271
|
-
throw new AxiosError_default(`Response type '${type}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT,
|
|
81267
|
+
!resolvers[type] && (resolvers[type] = utils_default.isFunction(res[type]) ? (res2) => res2[type]() : (_, config2) => {
|
|
81268
|
+
throw new AxiosError_default(`Response type '${type}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT, config2);
|
|
81272
81269
|
});
|
|
81273
81270
|
});
|
|
81274
81271
|
})(new Response());
|
|
@@ -81300,7 +81297,7 @@ var resolveBodyLength = async (headers, body) => {
|
|
|
81300
81297
|
const length = utils_default.toFiniteNumber(headers.getContentLength());
|
|
81301
81298
|
return length == null ? getBodyLength(body) : length;
|
|
81302
81299
|
};
|
|
81303
|
-
var fetch_default = isFetchSupported && (async (
|
|
81300
|
+
var fetch_default = isFetchSupported && (async (config2) => {
|
|
81304
81301
|
let {
|
|
81305
81302
|
url: url2,
|
|
81306
81303
|
method,
|
|
@@ -81314,7 +81311,7 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81314
81311
|
headers,
|
|
81315
81312
|
withCredentials = "same-origin",
|
|
81316
81313
|
fetchOptions
|
|
81317
|
-
} = resolveConfig_default(
|
|
81314
|
+
} = resolveConfig_default(config2);
|
|
81318
81315
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
81319
81316
|
let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
81320
81317
|
let request;
|
|
@@ -81375,7 +81372,7 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81375
81372
|
);
|
|
81376
81373
|
}
|
|
81377
81374
|
responseType = responseType || "text";
|
|
81378
|
-
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response,
|
|
81375
|
+
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config2);
|
|
81379
81376
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
81380
81377
|
return await new Promise((resolve, reject) => {
|
|
81381
81378
|
settle(resolve, reject, {
|
|
@@ -81383,7 +81380,7 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81383
81380
|
headers: AxiosHeaders_default.from(response.headers),
|
|
81384
81381
|
status: response.status,
|
|
81385
81382
|
statusText: response.statusText,
|
|
81386
|
-
config,
|
|
81383
|
+
config: config2,
|
|
81387
81384
|
request
|
|
81388
81385
|
});
|
|
81389
81386
|
});
|
|
@@ -81391,13 +81388,13 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81391
81388
|
unsubscribe && unsubscribe();
|
|
81392
81389
|
if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
|
|
81393
81390
|
throw Object.assign(
|
|
81394
|
-
new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK,
|
|
81391
|
+
new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config2, request),
|
|
81395
81392
|
{
|
|
81396
81393
|
cause: err.cause || err
|
|
81397
81394
|
}
|
|
81398
81395
|
);
|
|
81399
81396
|
}
|
|
81400
|
-
throw AxiosError_default.from(err, err && err.code,
|
|
81397
|
+
throw AxiosError_default.from(err, err && err.code, config2, request);
|
|
81401
81398
|
}
|
|
81402
81399
|
});
|
|
81403
81400
|
|
|
@@ -81456,41 +81453,41 @@ var adapters_default = {
|
|
|
81456
81453
|
};
|
|
81457
81454
|
|
|
81458
81455
|
// node_modules/axios/lib/core/dispatchRequest.js
|
|
81459
|
-
function throwIfCancellationRequested(
|
|
81460
|
-
if (
|
|
81461
|
-
|
|
81456
|
+
function throwIfCancellationRequested(config2) {
|
|
81457
|
+
if (config2.cancelToken) {
|
|
81458
|
+
config2.cancelToken.throwIfRequested();
|
|
81462
81459
|
}
|
|
81463
|
-
if (
|
|
81464
|
-
throw new CanceledError_default(null,
|
|
81460
|
+
if (config2.signal && config2.signal.aborted) {
|
|
81461
|
+
throw new CanceledError_default(null, config2);
|
|
81465
81462
|
}
|
|
81466
81463
|
}
|
|
81467
|
-
function dispatchRequest(
|
|
81468
|
-
throwIfCancellationRequested(
|
|
81469
|
-
|
|
81470
|
-
|
|
81471
|
-
|
|
81472
|
-
|
|
81464
|
+
function dispatchRequest(config2) {
|
|
81465
|
+
throwIfCancellationRequested(config2);
|
|
81466
|
+
config2.headers = AxiosHeaders_default.from(config2.headers);
|
|
81467
|
+
config2.data = transformData.call(
|
|
81468
|
+
config2,
|
|
81469
|
+
config2.transformRequest
|
|
81473
81470
|
);
|
|
81474
|
-
if (["post", "put", "patch"].indexOf(
|
|
81475
|
-
|
|
81471
|
+
if (["post", "put", "patch"].indexOf(config2.method) !== -1) {
|
|
81472
|
+
config2.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
81476
81473
|
}
|
|
81477
|
-
const adapter = adapters_default.getAdapter(
|
|
81478
|
-
return adapter(
|
|
81479
|
-
throwIfCancellationRequested(
|
|
81474
|
+
const adapter = adapters_default.getAdapter(config2.adapter || defaults_default.adapter);
|
|
81475
|
+
return adapter(config2).then(function onAdapterResolution(response) {
|
|
81476
|
+
throwIfCancellationRequested(config2);
|
|
81480
81477
|
response.data = transformData.call(
|
|
81481
|
-
|
|
81482
|
-
|
|
81478
|
+
config2,
|
|
81479
|
+
config2.transformResponse,
|
|
81483
81480
|
response
|
|
81484
81481
|
);
|
|
81485
81482
|
response.headers = AxiosHeaders_default.from(response.headers);
|
|
81486
81483
|
return response;
|
|
81487
81484
|
}, function onAdapterRejection(reason) {
|
|
81488
81485
|
if (!isCancel(reason)) {
|
|
81489
|
-
throwIfCancellationRequested(
|
|
81486
|
+
throwIfCancellationRequested(config2);
|
|
81490
81487
|
if (reason && reason.response) {
|
|
81491
81488
|
reason.response.data = transformData.call(
|
|
81492
|
-
|
|
81493
|
-
|
|
81489
|
+
config2,
|
|
81490
|
+
config2.transformResponse,
|
|
81494
81491
|
reason.response
|
|
81495
81492
|
);
|
|
81496
81493
|
reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
|
|
@@ -81582,9 +81579,9 @@ var Axios = class {
|
|
|
81582
81579
|
*
|
|
81583
81580
|
* @returns {Promise} The Promise to be fulfilled
|
|
81584
81581
|
*/
|
|
81585
|
-
async request(configOrUrl,
|
|
81582
|
+
async request(configOrUrl, config2) {
|
|
81586
81583
|
try {
|
|
81587
|
-
return await this._request(configOrUrl,
|
|
81584
|
+
return await this._request(configOrUrl, config2);
|
|
81588
81585
|
} catch (err) {
|
|
81589
81586
|
if (err instanceof Error) {
|
|
81590
81587
|
let dummy = {};
|
|
@@ -81602,15 +81599,15 @@ var Axios = class {
|
|
|
81602
81599
|
throw err;
|
|
81603
81600
|
}
|
|
81604
81601
|
}
|
|
81605
|
-
_request(configOrUrl,
|
|
81602
|
+
_request(configOrUrl, config2) {
|
|
81606
81603
|
if (typeof configOrUrl === "string") {
|
|
81607
|
-
|
|
81608
|
-
|
|
81604
|
+
config2 = config2 || {};
|
|
81605
|
+
config2.url = configOrUrl;
|
|
81609
81606
|
} else {
|
|
81610
|
-
|
|
81607
|
+
config2 = configOrUrl || {};
|
|
81611
81608
|
}
|
|
81612
|
-
|
|
81613
|
-
const { transitional: transitional2, paramsSerializer, headers } =
|
|
81609
|
+
config2 = mergeConfig(this.defaults, config2);
|
|
81610
|
+
const { transitional: transitional2, paramsSerializer, headers } = config2;
|
|
81614
81611
|
if (transitional2 !== void 0) {
|
|
81615
81612
|
validator_default.assertOptions(transitional2, {
|
|
81616
81613
|
silentJSONParsing: validators2.transitional(validators2.boolean),
|
|
@@ -81620,7 +81617,7 @@ var Axios = class {
|
|
|
81620
81617
|
}
|
|
81621
81618
|
if (paramsSerializer != null) {
|
|
81622
81619
|
if (utils_default.isFunction(paramsSerializer)) {
|
|
81623
|
-
|
|
81620
|
+
config2.paramsSerializer = {
|
|
81624
81621
|
serialize: paramsSerializer
|
|
81625
81622
|
};
|
|
81626
81623
|
} else {
|
|
@@ -81630,14 +81627,14 @@ var Axios = class {
|
|
|
81630
81627
|
}, true);
|
|
81631
81628
|
}
|
|
81632
81629
|
}
|
|
81633
|
-
validator_default.assertOptions(
|
|
81630
|
+
validator_default.assertOptions(config2, {
|
|
81634
81631
|
baseUrl: validators2.spelling("baseURL"),
|
|
81635
81632
|
withXsrfToken: validators2.spelling("withXSRFToken")
|
|
81636
81633
|
}, true);
|
|
81637
|
-
|
|
81634
|
+
config2.method = (config2.method || this.defaults.method || "get").toLowerCase();
|
|
81638
81635
|
let contextHeaders = headers && utils_default.merge(
|
|
81639
81636
|
headers.common,
|
|
81640
|
-
headers[
|
|
81637
|
+
headers[config2.method]
|
|
81641
81638
|
);
|
|
81642
81639
|
headers && utils_default.forEach(
|
|
81643
81640
|
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
@@ -81645,11 +81642,11 @@ var Axios = class {
|
|
|
81645
81642
|
delete headers[method];
|
|
81646
81643
|
}
|
|
81647
81644
|
);
|
|
81648
|
-
|
|
81645
|
+
config2.headers = AxiosHeaders_default.concat(contextHeaders, headers);
|
|
81649
81646
|
const requestInterceptorChain = [];
|
|
81650
81647
|
let synchronousRequestInterceptors = true;
|
|
81651
81648
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
81652
|
-
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(
|
|
81649
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config2) === false) {
|
|
81653
81650
|
return;
|
|
81654
81651
|
}
|
|
81655
81652
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
@@ -81667,14 +81664,14 @@ var Axios = class {
|
|
|
81667
81664
|
chain.unshift.apply(chain, requestInterceptorChain);
|
|
81668
81665
|
chain.push.apply(chain, responseInterceptorChain);
|
|
81669
81666
|
len = chain.length;
|
|
81670
|
-
promise = Promise.resolve(
|
|
81667
|
+
promise = Promise.resolve(config2);
|
|
81671
81668
|
while (i < len) {
|
|
81672
81669
|
promise = promise.then(chain[i++], chain[i++]);
|
|
81673
81670
|
}
|
|
81674
81671
|
return promise;
|
|
81675
81672
|
}
|
|
81676
81673
|
len = requestInterceptorChain.length;
|
|
81677
|
-
let newConfig =
|
|
81674
|
+
let newConfig = config2;
|
|
81678
81675
|
i = 0;
|
|
81679
81676
|
while (i < len) {
|
|
81680
81677
|
const onFulfilled = requestInterceptorChain[i++];
|
|
@@ -81698,25 +81695,25 @@ var Axios = class {
|
|
|
81698
81695
|
}
|
|
81699
81696
|
return promise;
|
|
81700
81697
|
}
|
|
81701
|
-
getUri(
|
|
81702
|
-
|
|
81703
|
-
const fullPath = buildFullPath(
|
|
81704
|
-
return buildURL(fullPath,
|
|
81698
|
+
getUri(config2) {
|
|
81699
|
+
config2 = mergeConfig(this.defaults, config2);
|
|
81700
|
+
const fullPath = buildFullPath(config2.baseURL, config2.url);
|
|
81701
|
+
return buildURL(fullPath, config2.params, config2.paramsSerializer);
|
|
81705
81702
|
}
|
|
81706
81703
|
};
|
|
81707
81704
|
utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
81708
|
-
Axios.prototype[method] = function(url2,
|
|
81709
|
-
return this.request(mergeConfig(
|
|
81705
|
+
Axios.prototype[method] = function(url2, config2) {
|
|
81706
|
+
return this.request(mergeConfig(config2 || {}, {
|
|
81710
81707
|
method,
|
|
81711
81708
|
url: url2,
|
|
81712
|
-
data: (
|
|
81709
|
+
data: (config2 || {}).data
|
|
81713
81710
|
}));
|
|
81714
81711
|
};
|
|
81715
81712
|
});
|
|
81716
81713
|
utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
81717
81714
|
function generateHTTPMethod(isForm) {
|
|
81718
|
-
return function httpMethod(url2, data,
|
|
81719
|
-
return this.request(mergeConfig(
|
|
81715
|
+
return function httpMethod(url2, data, config2) {
|
|
81716
|
+
return this.request(mergeConfig(config2 || {}, {
|
|
81720
81717
|
method,
|
|
81721
81718
|
headers: isForm ? {
|
|
81722
81719
|
"Content-Type": "multipart/form-data"
|
|
@@ -81761,11 +81758,11 @@ var CancelToken = class _CancelToken {
|
|
|
81761
81758
|
};
|
|
81762
81759
|
return promise;
|
|
81763
81760
|
};
|
|
81764
|
-
executor(function cancel(message,
|
|
81761
|
+
executor(function cancel(message, config2, request) {
|
|
81765
81762
|
if (token.reason) {
|
|
81766
81763
|
return;
|
|
81767
81764
|
}
|
|
81768
|
-
token.reason = new CanceledError_default(message,
|
|
81765
|
+
token.reason = new CanceledError_default(message, config2, request);
|
|
81769
81766
|
resolvePromise(token.reason);
|
|
81770
81767
|
});
|
|
81771
81768
|
}
|
|
@@ -82433,19 +82430,1002 @@ var PriceUtils = class {
|
|
|
82433
82430
|
return totalMoney * 10n ** BigInt(targetDecimals) * PRICE_DECIMALS / targetPrice / WAD;
|
|
82434
82431
|
}
|
|
82435
82432
|
};
|
|
82433
|
+
|
|
82434
|
+
// node_modules/decimal.js-light/decimal.mjs
|
|
82435
|
+
var MAX_DIGITS = 1e9;
|
|
82436
|
+
var defaults2 = {
|
|
82437
|
+
// These values must be integers within the stated ranges (inclusive).
|
|
82438
|
+
// Most of these values can be changed during run-time using `Decimal.config`.
|
|
82439
|
+
// The maximum number of significant digits of the result of a calculation or base conversion.
|
|
82440
|
+
// E.g. `Decimal.config({ precision: 20 });`
|
|
82441
|
+
precision: 20,
|
|
82442
|
+
// 1 to MAX_DIGITS
|
|
82443
|
+
// The rounding mode used by default by `toInteger`, `toDecimalPlaces`, `toExponential`,
|
|
82444
|
+
// `toFixed`, `toPrecision` and `toSignificantDigits`.
|
|
82445
|
+
//
|
|
82446
|
+
// ROUND_UP 0 Away from zero.
|
|
82447
|
+
// ROUND_DOWN 1 Towards zero.
|
|
82448
|
+
// ROUND_CEIL 2 Towards +Infinity.
|
|
82449
|
+
// ROUND_FLOOR 3 Towards -Infinity.
|
|
82450
|
+
// ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
|
|
82451
|
+
// ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
|
|
82452
|
+
// ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
|
|
82453
|
+
// ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
|
|
82454
|
+
// ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
|
|
82455
|
+
//
|
|
82456
|
+
// E.g.
|
|
82457
|
+
// `Decimal.rounding = 4;`
|
|
82458
|
+
// `Decimal.rounding = Decimal.ROUND_HALF_UP;`
|
|
82459
|
+
rounding: 4,
|
|
82460
|
+
// 0 to 8
|
|
82461
|
+
// The exponent value at and beneath which `toString` returns exponential notation.
|
|
82462
|
+
// JavaScript numbers: -7
|
|
82463
|
+
toExpNeg: -7,
|
|
82464
|
+
// 0 to -MAX_E
|
|
82465
|
+
// The exponent value at and above which `toString` returns exponential notation.
|
|
82466
|
+
// JavaScript numbers: 21
|
|
82467
|
+
toExpPos: 21,
|
|
82468
|
+
// 0 to MAX_E
|
|
82469
|
+
// The natural logarithm of 10.
|
|
82470
|
+
// 115 digits
|
|
82471
|
+
LN10: "2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"
|
|
82472
|
+
};
|
|
82473
|
+
var Decimal;
|
|
82474
|
+
var external = true;
|
|
82475
|
+
var decimalError = "[DecimalError] ";
|
|
82476
|
+
var invalidArgument = decimalError + "Invalid argument: ";
|
|
82477
|
+
var exponentOutOfRange = decimalError + "Exponent out of range: ";
|
|
82478
|
+
var mathfloor = Math.floor;
|
|
82479
|
+
var mathpow = Math.pow;
|
|
82480
|
+
var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
82481
|
+
var ONE;
|
|
82482
|
+
var BASE = 1e7;
|
|
82483
|
+
var LOG_BASE = 7;
|
|
82484
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
82485
|
+
var MAX_E = mathfloor(MAX_SAFE_INTEGER / LOG_BASE);
|
|
82486
|
+
var P = {};
|
|
82487
|
+
P.absoluteValue = P.abs = function() {
|
|
82488
|
+
var x = new this.constructor(this);
|
|
82489
|
+
if (x.s) x.s = 1;
|
|
82490
|
+
return x;
|
|
82491
|
+
};
|
|
82492
|
+
P.comparedTo = P.cmp = function(y) {
|
|
82493
|
+
var i, j, xdL, ydL, x = this;
|
|
82494
|
+
y = new x.constructor(y);
|
|
82495
|
+
if (x.s !== y.s) return x.s || -y.s;
|
|
82496
|
+
if (x.e !== y.e) return x.e > y.e ^ x.s < 0 ? 1 : -1;
|
|
82497
|
+
xdL = x.d.length;
|
|
82498
|
+
ydL = y.d.length;
|
|
82499
|
+
for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
|
|
82500
|
+
if (x.d[i] !== y.d[i]) return x.d[i] > y.d[i] ^ x.s < 0 ? 1 : -1;
|
|
82501
|
+
}
|
|
82502
|
+
return xdL === ydL ? 0 : xdL > ydL ^ x.s < 0 ? 1 : -1;
|
|
82503
|
+
};
|
|
82504
|
+
P.decimalPlaces = P.dp = function() {
|
|
82505
|
+
var x = this, w = x.d.length - 1, dp = (w - x.e) * LOG_BASE;
|
|
82506
|
+
w = x.d[w];
|
|
82507
|
+
if (w) for (; w % 10 == 0; w /= 10) dp--;
|
|
82508
|
+
return dp < 0 ? 0 : dp;
|
|
82509
|
+
};
|
|
82510
|
+
P.dividedBy = P.div = function(y) {
|
|
82511
|
+
return divide(this, new this.constructor(y));
|
|
82512
|
+
};
|
|
82513
|
+
P.dividedToIntegerBy = P.idiv = function(y) {
|
|
82514
|
+
var x = this, Ctor = x.constructor;
|
|
82515
|
+
return round(divide(x, new Ctor(y), 0, 1), Ctor.precision);
|
|
82516
|
+
};
|
|
82517
|
+
P.equals = P.eq = function(y) {
|
|
82518
|
+
return !this.cmp(y);
|
|
82519
|
+
};
|
|
82520
|
+
P.exponent = function() {
|
|
82521
|
+
return getBase10Exponent(this);
|
|
82522
|
+
};
|
|
82523
|
+
P.greaterThan = P.gt = function(y) {
|
|
82524
|
+
return this.cmp(y) > 0;
|
|
82525
|
+
};
|
|
82526
|
+
P.greaterThanOrEqualTo = P.gte = function(y) {
|
|
82527
|
+
return this.cmp(y) >= 0;
|
|
82528
|
+
};
|
|
82529
|
+
P.isInteger = P.isint = function() {
|
|
82530
|
+
return this.e > this.d.length - 2;
|
|
82531
|
+
};
|
|
82532
|
+
P.isNegative = P.isneg = function() {
|
|
82533
|
+
return this.s < 0;
|
|
82534
|
+
};
|
|
82535
|
+
P.isPositive = P.ispos = function() {
|
|
82536
|
+
return this.s > 0;
|
|
82537
|
+
};
|
|
82538
|
+
P.isZero = function() {
|
|
82539
|
+
return this.s === 0;
|
|
82540
|
+
};
|
|
82541
|
+
P.lessThan = P.lt = function(y) {
|
|
82542
|
+
return this.cmp(y) < 0;
|
|
82543
|
+
};
|
|
82544
|
+
P.lessThanOrEqualTo = P.lte = function(y) {
|
|
82545
|
+
return this.cmp(y) < 1;
|
|
82546
|
+
};
|
|
82547
|
+
P.logarithm = P.log = function(base2) {
|
|
82548
|
+
var r, x = this, Ctor = x.constructor, pr = Ctor.precision, wpr = pr + 5;
|
|
82549
|
+
if (base2 === void 0) {
|
|
82550
|
+
base2 = new Ctor(10);
|
|
82551
|
+
} else {
|
|
82552
|
+
base2 = new Ctor(base2);
|
|
82553
|
+
if (base2.s < 1 || base2.eq(ONE)) throw Error(decimalError + "NaN");
|
|
82554
|
+
}
|
|
82555
|
+
if (x.s < 1) throw Error(decimalError + (x.s ? "NaN" : "-Infinity"));
|
|
82556
|
+
if (x.eq(ONE)) return new Ctor(0);
|
|
82557
|
+
external = false;
|
|
82558
|
+
r = divide(ln(x, wpr), ln(base2, wpr), wpr);
|
|
82559
|
+
external = true;
|
|
82560
|
+
return round(r, pr);
|
|
82561
|
+
};
|
|
82562
|
+
P.minus = P.sub = function(y) {
|
|
82563
|
+
var x = this;
|
|
82564
|
+
y = new x.constructor(y);
|
|
82565
|
+
return x.s == y.s ? subtract(x, y) : add(x, (y.s = -y.s, y));
|
|
82566
|
+
};
|
|
82567
|
+
P.modulo = P.mod = function(y) {
|
|
82568
|
+
var q, x = this, Ctor = x.constructor, pr = Ctor.precision;
|
|
82569
|
+
y = new Ctor(y);
|
|
82570
|
+
if (!y.s) throw Error(decimalError + "NaN");
|
|
82571
|
+
if (!x.s) return round(new Ctor(x), pr);
|
|
82572
|
+
external = false;
|
|
82573
|
+
q = divide(x, y, 0, 1).times(y);
|
|
82574
|
+
external = true;
|
|
82575
|
+
return x.minus(q);
|
|
82576
|
+
};
|
|
82577
|
+
P.naturalExponential = P.exp = function() {
|
|
82578
|
+
return exp(this);
|
|
82579
|
+
};
|
|
82580
|
+
P.naturalLogarithm = P.ln = function() {
|
|
82581
|
+
return ln(this);
|
|
82582
|
+
};
|
|
82583
|
+
P.negated = P.neg = function() {
|
|
82584
|
+
var x = new this.constructor(this);
|
|
82585
|
+
x.s = -x.s || 0;
|
|
82586
|
+
return x;
|
|
82587
|
+
};
|
|
82588
|
+
P.plus = P.add = function(y) {
|
|
82589
|
+
var x = this;
|
|
82590
|
+
y = new x.constructor(y);
|
|
82591
|
+
return x.s == y.s ? add(x, y) : subtract(x, (y.s = -y.s, y));
|
|
82592
|
+
};
|
|
82593
|
+
P.precision = P.sd = function(z) {
|
|
82594
|
+
var e, sd, w, x = this;
|
|
82595
|
+
if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z);
|
|
82596
|
+
e = getBase10Exponent(x) + 1;
|
|
82597
|
+
w = x.d.length - 1;
|
|
82598
|
+
sd = w * LOG_BASE + 1;
|
|
82599
|
+
w = x.d[w];
|
|
82600
|
+
if (w) {
|
|
82601
|
+
for (; w % 10 == 0; w /= 10) sd--;
|
|
82602
|
+
for (w = x.d[0]; w >= 10; w /= 10) sd++;
|
|
82603
|
+
}
|
|
82604
|
+
return z && e > sd ? e : sd;
|
|
82605
|
+
};
|
|
82606
|
+
P.squareRoot = P.sqrt = function() {
|
|
82607
|
+
var e, n, pr, r, s, t, wpr, x = this, Ctor = x.constructor;
|
|
82608
|
+
if (x.s < 1) {
|
|
82609
|
+
if (!x.s) return new Ctor(0);
|
|
82610
|
+
throw Error(decimalError + "NaN");
|
|
82611
|
+
}
|
|
82612
|
+
e = getBase10Exponent(x);
|
|
82613
|
+
external = false;
|
|
82614
|
+
s = Math.sqrt(+x);
|
|
82615
|
+
if (s == 0 || s == 1 / 0) {
|
|
82616
|
+
n = digitsToString(x.d);
|
|
82617
|
+
if ((n.length + e) % 2 == 0) n += "0";
|
|
82618
|
+
s = Math.sqrt(n);
|
|
82619
|
+
e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
|
|
82620
|
+
if (s == 1 / 0) {
|
|
82621
|
+
n = "5e" + e;
|
|
82622
|
+
} else {
|
|
82623
|
+
n = s.toExponential();
|
|
82624
|
+
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
82625
|
+
}
|
|
82626
|
+
r = new Ctor(n);
|
|
82627
|
+
} else {
|
|
82628
|
+
r = new Ctor(s.toString());
|
|
82629
|
+
}
|
|
82630
|
+
pr = Ctor.precision;
|
|
82631
|
+
s = wpr = pr + 3;
|
|
82632
|
+
for (; ; ) {
|
|
82633
|
+
t = r;
|
|
82634
|
+
r = t.plus(divide(x, t, wpr + 2)).times(0.5);
|
|
82635
|
+
if (digitsToString(t.d).slice(0, wpr) === (n = digitsToString(r.d)).slice(0, wpr)) {
|
|
82636
|
+
n = n.slice(wpr - 3, wpr + 1);
|
|
82637
|
+
if (s == wpr && n == "4999") {
|
|
82638
|
+
round(t, pr + 1, 0);
|
|
82639
|
+
if (t.times(t).eq(x)) {
|
|
82640
|
+
r = t;
|
|
82641
|
+
break;
|
|
82642
|
+
}
|
|
82643
|
+
} else if (n != "9999") {
|
|
82644
|
+
break;
|
|
82645
|
+
}
|
|
82646
|
+
wpr += 4;
|
|
82647
|
+
}
|
|
82648
|
+
}
|
|
82649
|
+
external = true;
|
|
82650
|
+
return round(r, pr);
|
|
82651
|
+
};
|
|
82652
|
+
P.times = P.mul = function(y) {
|
|
82653
|
+
var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
|
|
82654
|
+
if (!x.s || !y.s) return new Ctor(0);
|
|
82655
|
+
y.s *= x.s;
|
|
82656
|
+
e = x.e + y.e;
|
|
82657
|
+
xdL = xd.length;
|
|
82658
|
+
ydL = yd.length;
|
|
82659
|
+
if (xdL < ydL) {
|
|
82660
|
+
r = xd;
|
|
82661
|
+
xd = yd;
|
|
82662
|
+
yd = r;
|
|
82663
|
+
rL = xdL;
|
|
82664
|
+
xdL = ydL;
|
|
82665
|
+
ydL = rL;
|
|
82666
|
+
}
|
|
82667
|
+
r = [];
|
|
82668
|
+
rL = xdL + ydL;
|
|
82669
|
+
for (i = rL; i--; ) r.push(0);
|
|
82670
|
+
for (i = ydL; --i >= 0; ) {
|
|
82671
|
+
carry = 0;
|
|
82672
|
+
for (k = xdL + i; k > i; ) {
|
|
82673
|
+
t = r[k] + yd[i] * xd[k - i - 1] + carry;
|
|
82674
|
+
r[k--] = t % BASE | 0;
|
|
82675
|
+
carry = t / BASE | 0;
|
|
82676
|
+
}
|
|
82677
|
+
r[k] = (r[k] + carry) % BASE | 0;
|
|
82678
|
+
}
|
|
82679
|
+
for (; !r[--rL]; ) r.pop();
|
|
82680
|
+
if (carry) ++e;
|
|
82681
|
+
else r.shift();
|
|
82682
|
+
y.d = r;
|
|
82683
|
+
y.e = e;
|
|
82684
|
+
return external ? round(y, Ctor.precision) : y;
|
|
82685
|
+
};
|
|
82686
|
+
P.toDecimalPlaces = P.todp = function(dp, rm) {
|
|
82687
|
+
var x = this, Ctor = x.constructor;
|
|
82688
|
+
x = new Ctor(x);
|
|
82689
|
+
if (dp === void 0) return x;
|
|
82690
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
82691
|
+
if (rm === void 0) rm = Ctor.rounding;
|
|
82692
|
+
else checkInt32(rm, 0, 8);
|
|
82693
|
+
return round(x, dp + getBase10Exponent(x) + 1, rm);
|
|
82694
|
+
};
|
|
82695
|
+
P.toExponential = function(dp, rm) {
|
|
82696
|
+
var str, x = this, Ctor = x.constructor;
|
|
82697
|
+
if (dp === void 0) {
|
|
82698
|
+
str = toString3(x, true);
|
|
82699
|
+
} else {
|
|
82700
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
82701
|
+
if (rm === void 0) rm = Ctor.rounding;
|
|
82702
|
+
else checkInt32(rm, 0, 8);
|
|
82703
|
+
x = round(new Ctor(x), dp + 1, rm);
|
|
82704
|
+
str = toString3(x, true, dp + 1);
|
|
82705
|
+
}
|
|
82706
|
+
return str;
|
|
82707
|
+
};
|
|
82708
|
+
P.toFixed = function(dp, rm) {
|
|
82709
|
+
var str, y, x = this, Ctor = x.constructor;
|
|
82710
|
+
if (dp === void 0) return toString3(x);
|
|
82711
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
82712
|
+
if (rm === void 0) rm = Ctor.rounding;
|
|
82713
|
+
else checkInt32(rm, 0, 8);
|
|
82714
|
+
y = round(new Ctor(x), dp + getBase10Exponent(x) + 1, rm);
|
|
82715
|
+
str = toString3(y.abs(), false, dp + getBase10Exponent(y) + 1);
|
|
82716
|
+
return x.isneg() && !x.isZero() ? "-" + str : str;
|
|
82717
|
+
};
|
|
82718
|
+
P.toInteger = P.toint = function() {
|
|
82719
|
+
var x = this, Ctor = x.constructor;
|
|
82720
|
+
return round(new Ctor(x), getBase10Exponent(x) + 1, Ctor.rounding);
|
|
82721
|
+
};
|
|
82722
|
+
P.toNumber = function() {
|
|
82723
|
+
return +this;
|
|
82724
|
+
};
|
|
82725
|
+
P.toPower = P.pow = function(y) {
|
|
82726
|
+
var e, k, pr, r, sign, yIsInt, x = this, Ctor = x.constructor, guard = 12, yn = +(y = new Ctor(y));
|
|
82727
|
+
if (!y.s) return new Ctor(ONE);
|
|
82728
|
+
x = new Ctor(x);
|
|
82729
|
+
if (!x.s) {
|
|
82730
|
+
if (y.s < 1) throw Error(decimalError + "Infinity");
|
|
82731
|
+
return x;
|
|
82732
|
+
}
|
|
82733
|
+
if (x.eq(ONE)) return x;
|
|
82734
|
+
pr = Ctor.precision;
|
|
82735
|
+
if (y.eq(ONE)) return round(x, pr);
|
|
82736
|
+
e = y.e;
|
|
82737
|
+
k = y.d.length - 1;
|
|
82738
|
+
yIsInt = e >= k;
|
|
82739
|
+
sign = x.s;
|
|
82740
|
+
if (!yIsInt) {
|
|
82741
|
+
if (sign < 0) throw Error(decimalError + "NaN");
|
|
82742
|
+
} else if ((k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
|
|
82743
|
+
r = new Ctor(ONE);
|
|
82744
|
+
e = Math.ceil(pr / LOG_BASE + 4);
|
|
82745
|
+
external = false;
|
|
82746
|
+
for (; ; ) {
|
|
82747
|
+
if (k % 2) {
|
|
82748
|
+
r = r.times(x);
|
|
82749
|
+
truncate(r.d, e);
|
|
82750
|
+
}
|
|
82751
|
+
k = mathfloor(k / 2);
|
|
82752
|
+
if (k === 0) break;
|
|
82753
|
+
x = x.times(x);
|
|
82754
|
+
truncate(x.d, e);
|
|
82755
|
+
}
|
|
82756
|
+
external = true;
|
|
82757
|
+
return y.s < 0 ? new Ctor(ONE).div(r) : round(r, pr);
|
|
82758
|
+
}
|
|
82759
|
+
sign = sign < 0 && y.d[Math.max(e, k)] & 1 ? -1 : 1;
|
|
82760
|
+
x.s = 1;
|
|
82761
|
+
external = false;
|
|
82762
|
+
r = y.times(ln(x, pr + guard));
|
|
82763
|
+
external = true;
|
|
82764
|
+
r = exp(r);
|
|
82765
|
+
r.s = sign;
|
|
82766
|
+
return r;
|
|
82767
|
+
};
|
|
82768
|
+
P.toPrecision = function(sd, rm) {
|
|
82769
|
+
var e, str, x = this, Ctor = x.constructor;
|
|
82770
|
+
if (sd === void 0) {
|
|
82771
|
+
e = getBase10Exponent(x);
|
|
82772
|
+
str = toString3(x, e <= Ctor.toExpNeg || e >= Ctor.toExpPos);
|
|
82773
|
+
} else {
|
|
82774
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
82775
|
+
if (rm === void 0) rm = Ctor.rounding;
|
|
82776
|
+
else checkInt32(rm, 0, 8);
|
|
82777
|
+
x = round(new Ctor(x), sd, rm);
|
|
82778
|
+
e = getBase10Exponent(x);
|
|
82779
|
+
str = toString3(x, sd <= e || e <= Ctor.toExpNeg, sd);
|
|
82780
|
+
}
|
|
82781
|
+
return str;
|
|
82782
|
+
};
|
|
82783
|
+
P.toSignificantDigits = P.tosd = function(sd, rm) {
|
|
82784
|
+
var x = this, Ctor = x.constructor;
|
|
82785
|
+
if (sd === void 0) {
|
|
82786
|
+
sd = Ctor.precision;
|
|
82787
|
+
rm = Ctor.rounding;
|
|
82788
|
+
} else {
|
|
82789
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
82790
|
+
if (rm === void 0) rm = Ctor.rounding;
|
|
82791
|
+
else checkInt32(rm, 0, 8);
|
|
82792
|
+
}
|
|
82793
|
+
return round(new Ctor(x), sd, rm);
|
|
82794
|
+
};
|
|
82795
|
+
P.toString = P.valueOf = P.val = P.toJSON = P[Symbol.for("nodejs.util.inspect.custom")] = function() {
|
|
82796
|
+
var x = this, e = getBase10Exponent(x), Ctor = x.constructor;
|
|
82797
|
+
return toString3(x, e <= Ctor.toExpNeg || e >= Ctor.toExpPos);
|
|
82798
|
+
};
|
|
82799
|
+
function add(x, y) {
|
|
82800
|
+
var carry, d, e, i, k, len, xd, yd, Ctor = x.constructor, pr = Ctor.precision;
|
|
82801
|
+
if (!x.s || !y.s) {
|
|
82802
|
+
if (!y.s) y = new Ctor(x);
|
|
82803
|
+
return external ? round(y, pr) : y;
|
|
82804
|
+
}
|
|
82805
|
+
xd = x.d;
|
|
82806
|
+
yd = y.d;
|
|
82807
|
+
k = x.e;
|
|
82808
|
+
e = y.e;
|
|
82809
|
+
xd = xd.slice();
|
|
82810
|
+
i = k - e;
|
|
82811
|
+
if (i) {
|
|
82812
|
+
if (i < 0) {
|
|
82813
|
+
d = xd;
|
|
82814
|
+
i = -i;
|
|
82815
|
+
len = yd.length;
|
|
82816
|
+
} else {
|
|
82817
|
+
d = yd;
|
|
82818
|
+
e = k;
|
|
82819
|
+
len = xd.length;
|
|
82820
|
+
}
|
|
82821
|
+
k = Math.ceil(pr / LOG_BASE);
|
|
82822
|
+
len = k > len ? k + 1 : len + 1;
|
|
82823
|
+
if (i > len) {
|
|
82824
|
+
i = len;
|
|
82825
|
+
d.length = 1;
|
|
82826
|
+
}
|
|
82827
|
+
d.reverse();
|
|
82828
|
+
for (; i--; ) d.push(0);
|
|
82829
|
+
d.reverse();
|
|
82830
|
+
}
|
|
82831
|
+
len = xd.length;
|
|
82832
|
+
i = yd.length;
|
|
82833
|
+
if (len - i < 0) {
|
|
82834
|
+
i = len;
|
|
82835
|
+
d = yd;
|
|
82836
|
+
yd = xd;
|
|
82837
|
+
xd = d;
|
|
82838
|
+
}
|
|
82839
|
+
for (carry = 0; i; ) {
|
|
82840
|
+
carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
|
|
82841
|
+
xd[i] %= BASE;
|
|
82842
|
+
}
|
|
82843
|
+
if (carry) {
|
|
82844
|
+
xd.unshift(carry);
|
|
82845
|
+
++e;
|
|
82846
|
+
}
|
|
82847
|
+
for (len = xd.length; xd[--len] == 0; ) xd.pop();
|
|
82848
|
+
y.d = xd;
|
|
82849
|
+
y.e = e;
|
|
82850
|
+
return external ? round(y, pr) : y;
|
|
82851
|
+
}
|
|
82852
|
+
function checkInt32(i, min, max) {
|
|
82853
|
+
if (i !== ~~i || i < min || i > max) {
|
|
82854
|
+
throw Error(invalidArgument + i);
|
|
82855
|
+
}
|
|
82856
|
+
}
|
|
82857
|
+
function digitsToString(d) {
|
|
82858
|
+
var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
|
|
82859
|
+
if (indexOfLastWord > 0) {
|
|
82860
|
+
str += w;
|
|
82861
|
+
for (i = 1; i < indexOfLastWord; i++) {
|
|
82862
|
+
ws = d[i] + "";
|
|
82863
|
+
k = LOG_BASE - ws.length;
|
|
82864
|
+
if (k) str += getZeroString(k);
|
|
82865
|
+
str += ws;
|
|
82866
|
+
}
|
|
82867
|
+
w = d[i];
|
|
82868
|
+
ws = w + "";
|
|
82869
|
+
k = LOG_BASE - ws.length;
|
|
82870
|
+
if (k) str += getZeroString(k);
|
|
82871
|
+
} else if (w === 0) {
|
|
82872
|
+
return "0";
|
|
82873
|
+
}
|
|
82874
|
+
for (; w % 10 === 0; ) w /= 10;
|
|
82875
|
+
return str + w;
|
|
82876
|
+
}
|
|
82877
|
+
var divide = /* @__PURE__ */ function() {
|
|
82878
|
+
function multiplyInteger(x, k) {
|
|
82879
|
+
var temp, carry = 0, i = x.length;
|
|
82880
|
+
for (x = x.slice(); i--; ) {
|
|
82881
|
+
temp = x[i] * k + carry;
|
|
82882
|
+
x[i] = temp % BASE | 0;
|
|
82883
|
+
carry = temp / BASE | 0;
|
|
82884
|
+
}
|
|
82885
|
+
if (carry) x.unshift(carry);
|
|
82886
|
+
return x;
|
|
82887
|
+
}
|
|
82888
|
+
function compare(a, b, aL, bL) {
|
|
82889
|
+
var i, r;
|
|
82890
|
+
if (aL != bL) {
|
|
82891
|
+
r = aL > bL ? 1 : -1;
|
|
82892
|
+
} else {
|
|
82893
|
+
for (i = r = 0; i < aL; i++) {
|
|
82894
|
+
if (a[i] != b[i]) {
|
|
82895
|
+
r = a[i] > b[i] ? 1 : -1;
|
|
82896
|
+
break;
|
|
82897
|
+
}
|
|
82898
|
+
}
|
|
82899
|
+
}
|
|
82900
|
+
return r;
|
|
82901
|
+
}
|
|
82902
|
+
function subtract2(a, b, aL) {
|
|
82903
|
+
var i = 0;
|
|
82904
|
+
for (; aL--; ) {
|
|
82905
|
+
a[aL] -= i;
|
|
82906
|
+
i = a[aL] < b[aL] ? 1 : 0;
|
|
82907
|
+
a[aL] = i * BASE + a[aL] - b[aL];
|
|
82908
|
+
}
|
|
82909
|
+
for (; !a[0] && a.length > 1; ) a.shift();
|
|
82910
|
+
}
|
|
82911
|
+
return function(x, y, pr, dp) {
|
|
82912
|
+
var cmp, e, i, k, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
|
|
82913
|
+
if (!x.s) return new Ctor(x);
|
|
82914
|
+
if (!y.s) throw Error(decimalError + "Division by zero");
|
|
82915
|
+
e = x.e - y.e;
|
|
82916
|
+
yL = yd.length;
|
|
82917
|
+
xL = xd.length;
|
|
82918
|
+
q = new Ctor(sign);
|
|
82919
|
+
qd = q.d = [];
|
|
82920
|
+
for (i = 0; yd[i] == (xd[i] || 0); ) ++i;
|
|
82921
|
+
if (yd[i] > (xd[i] || 0)) --e;
|
|
82922
|
+
if (pr == null) {
|
|
82923
|
+
sd = pr = Ctor.precision;
|
|
82924
|
+
} else if (dp) {
|
|
82925
|
+
sd = pr + (getBase10Exponent(x) - getBase10Exponent(y)) + 1;
|
|
82926
|
+
} else {
|
|
82927
|
+
sd = pr;
|
|
82928
|
+
}
|
|
82929
|
+
if (sd < 0) return new Ctor(0);
|
|
82930
|
+
sd = sd / LOG_BASE + 2 | 0;
|
|
82931
|
+
i = 0;
|
|
82932
|
+
if (yL == 1) {
|
|
82933
|
+
k = 0;
|
|
82934
|
+
yd = yd[0];
|
|
82935
|
+
sd++;
|
|
82936
|
+
for (; (i < xL || k) && sd--; i++) {
|
|
82937
|
+
t = k * BASE + (xd[i] || 0);
|
|
82938
|
+
qd[i] = t / yd | 0;
|
|
82939
|
+
k = t % yd | 0;
|
|
82940
|
+
}
|
|
82941
|
+
} else {
|
|
82942
|
+
k = BASE / (yd[0] + 1) | 0;
|
|
82943
|
+
if (k > 1) {
|
|
82944
|
+
yd = multiplyInteger(yd, k);
|
|
82945
|
+
xd = multiplyInteger(xd, k);
|
|
82946
|
+
yL = yd.length;
|
|
82947
|
+
xL = xd.length;
|
|
82948
|
+
}
|
|
82949
|
+
xi = yL;
|
|
82950
|
+
rem = xd.slice(0, yL);
|
|
82951
|
+
remL = rem.length;
|
|
82952
|
+
for (; remL < yL; ) rem[remL++] = 0;
|
|
82953
|
+
yz = yd.slice();
|
|
82954
|
+
yz.unshift(0);
|
|
82955
|
+
yd0 = yd[0];
|
|
82956
|
+
if (yd[1] >= BASE / 2) ++yd0;
|
|
82957
|
+
do {
|
|
82958
|
+
k = 0;
|
|
82959
|
+
cmp = compare(yd, rem, yL, remL);
|
|
82960
|
+
if (cmp < 0) {
|
|
82961
|
+
rem0 = rem[0];
|
|
82962
|
+
if (yL != remL) rem0 = rem0 * BASE + (rem[1] || 0);
|
|
82963
|
+
k = rem0 / yd0 | 0;
|
|
82964
|
+
if (k > 1) {
|
|
82965
|
+
if (k >= BASE) k = BASE - 1;
|
|
82966
|
+
prod = multiplyInteger(yd, k);
|
|
82967
|
+
prodL = prod.length;
|
|
82968
|
+
remL = rem.length;
|
|
82969
|
+
cmp = compare(prod, rem, prodL, remL);
|
|
82970
|
+
if (cmp == 1) {
|
|
82971
|
+
k--;
|
|
82972
|
+
subtract2(prod, yL < prodL ? yz : yd, prodL);
|
|
82973
|
+
}
|
|
82974
|
+
} else {
|
|
82975
|
+
if (k == 0) cmp = k = 1;
|
|
82976
|
+
prod = yd.slice();
|
|
82977
|
+
}
|
|
82978
|
+
prodL = prod.length;
|
|
82979
|
+
if (prodL < remL) prod.unshift(0);
|
|
82980
|
+
subtract2(rem, prod, remL);
|
|
82981
|
+
if (cmp == -1) {
|
|
82982
|
+
remL = rem.length;
|
|
82983
|
+
cmp = compare(yd, rem, yL, remL);
|
|
82984
|
+
if (cmp < 1) {
|
|
82985
|
+
k++;
|
|
82986
|
+
subtract2(rem, yL < remL ? yz : yd, remL);
|
|
82987
|
+
}
|
|
82988
|
+
}
|
|
82989
|
+
remL = rem.length;
|
|
82990
|
+
} else if (cmp === 0) {
|
|
82991
|
+
k++;
|
|
82992
|
+
rem = [0];
|
|
82993
|
+
}
|
|
82994
|
+
qd[i++] = k;
|
|
82995
|
+
if (cmp && rem[0]) {
|
|
82996
|
+
rem[remL++] = xd[xi] || 0;
|
|
82997
|
+
} else {
|
|
82998
|
+
rem = [xd[xi]];
|
|
82999
|
+
remL = 1;
|
|
83000
|
+
}
|
|
83001
|
+
} while ((xi++ < xL || rem[0] !== void 0) && sd--);
|
|
83002
|
+
}
|
|
83003
|
+
if (!qd[0]) qd.shift();
|
|
83004
|
+
q.e = e;
|
|
83005
|
+
return round(q, dp ? pr + getBase10Exponent(q) + 1 : pr);
|
|
83006
|
+
};
|
|
83007
|
+
}();
|
|
83008
|
+
function exp(x, sd) {
|
|
83009
|
+
var denominator, guard, pow, sum, t, wpr, i = 0, k = 0, Ctor = x.constructor, pr = Ctor.precision;
|
|
83010
|
+
if (getBase10Exponent(x) > 16) throw Error(exponentOutOfRange + getBase10Exponent(x));
|
|
83011
|
+
if (!x.s) return new Ctor(ONE);
|
|
83012
|
+
if (sd == null) {
|
|
83013
|
+
external = false;
|
|
83014
|
+
wpr = pr;
|
|
83015
|
+
} else {
|
|
83016
|
+
wpr = sd;
|
|
83017
|
+
}
|
|
83018
|
+
t = new Ctor(0.03125);
|
|
83019
|
+
while (x.abs().gte(0.1)) {
|
|
83020
|
+
x = x.times(t);
|
|
83021
|
+
k += 5;
|
|
83022
|
+
}
|
|
83023
|
+
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
|
|
83024
|
+
wpr += guard;
|
|
83025
|
+
denominator = pow = sum = new Ctor(ONE);
|
|
83026
|
+
Ctor.precision = wpr;
|
|
83027
|
+
for (; ; ) {
|
|
83028
|
+
pow = round(pow.times(x), wpr);
|
|
83029
|
+
denominator = denominator.times(++i);
|
|
83030
|
+
t = sum.plus(divide(pow, denominator, wpr));
|
|
83031
|
+
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
83032
|
+
while (k--) sum = round(sum.times(sum), wpr);
|
|
83033
|
+
Ctor.precision = pr;
|
|
83034
|
+
return sd == null ? (external = true, round(sum, pr)) : sum;
|
|
83035
|
+
}
|
|
83036
|
+
sum = t;
|
|
83037
|
+
}
|
|
83038
|
+
}
|
|
83039
|
+
function getBase10Exponent(x) {
|
|
83040
|
+
var e = x.e * LOG_BASE, w = x.d[0];
|
|
83041
|
+
for (; w >= 10; w /= 10) e++;
|
|
83042
|
+
return e;
|
|
83043
|
+
}
|
|
83044
|
+
function getLn10(Ctor, sd, pr) {
|
|
83045
|
+
if (sd > Ctor.LN10.sd()) {
|
|
83046
|
+
external = true;
|
|
83047
|
+
if (pr) Ctor.precision = pr;
|
|
83048
|
+
throw Error(decimalError + "LN10 precision limit exceeded");
|
|
83049
|
+
}
|
|
83050
|
+
return round(new Ctor(Ctor.LN10), sd);
|
|
83051
|
+
}
|
|
83052
|
+
function getZeroString(k) {
|
|
83053
|
+
var zs = "";
|
|
83054
|
+
for (; k--; ) zs += "0";
|
|
83055
|
+
return zs;
|
|
83056
|
+
}
|
|
83057
|
+
function ln(y, sd) {
|
|
83058
|
+
var c, c0, denominator, e, numerator, sum, t, wpr, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, pr = Ctor.precision;
|
|
83059
|
+
if (x.s < 1) throw Error(decimalError + (x.s ? "NaN" : "-Infinity"));
|
|
83060
|
+
if (x.eq(ONE)) return new Ctor(0);
|
|
83061
|
+
if (sd == null) {
|
|
83062
|
+
external = false;
|
|
83063
|
+
wpr = pr;
|
|
83064
|
+
} else {
|
|
83065
|
+
wpr = sd;
|
|
83066
|
+
}
|
|
83067
|
+
if (x.eq(10)) {
|
|
83068
|
+
if (sd == null) external = true;
|
|
83069
|
+
return getLn10(Ctor, wpr);
|
|
83070
|
+
}
|
|
83071
|
+
wpr += guard;
|
|
83072
|
+
Ctor.precision = wpr;
|
|
83073
|
+
c = digitsToString(xd);
|
|
83074
|
+
c0 = c.charAt(0);
|
|
83075
|
+
e = getBase10Exponent(x);
|
|
83076
|
+
if (Math.abs(e) < 15e14) {
|
|
83077
|
+
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
|
|
83078
|
+
x = x.times(y);
|
|
83079
|
+
c = digitsToString(x.d);
|
|
83080
|
+
c0 = c.charAt(0);
|
|
83081
|
+
n++;
|
|
83082
|
+
}
|
|
83083
|
+
e = getBase10Exponent(x);
|
|
83084
|
+
if (c0 > 1) {
|
|
83085
|
+
x = new Ctor("0." + c);
|
|
83086
|
+
e++;
|
|
83087
|
+
} else {
|
|
83088
|
+
x = new Ctor(c0 + "." + c.slice(1));
|
|
83089
|
+
}
|
|
83090
|
+
} else {
|
|
83091
|
+
t = getLn10(Ctor, wpr + 2, pr).times(e + "");
|
|
83092
|
+
x = ln(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
|
|
83093
|
+
Ctor.precision = pr;
|
|
83094
|
+
return sd == null ? (external = true, round(x, pr)) : x;
|
|
83095
|
+
}
|
|
83096
|
+
sum = numerator = x = divide(x.minus(ONE), x.plus(ONE), wpr);
|
|
83097
|
+
x2 = round(x.times(x), wpr);
|
|
83098
|
+
denominator = 3;
|
|
83099
|
+
for (; ; ) {
|
|
83100
|
+
numerator = round(numerator.times(x2), wpr);
|
|
83101
|
+
t = sum.plus(divide(numerator, new Ctor(denominator), wpr));
|
|
83102
|
+
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
83103
|
+
sum = sum.times(2);
|
|
83104
|
+
if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
|
|
83105
|
+
sum = divide(sum, new Ctor(n), wpr);
|
|
83106
|
+
Ctor.precision = pr;
|
|
83107
|
+
return sd == null ? (external = true, round(sum, pr)) : sum;
|
|
83108
|
+
}
|
|
83109
|
+
sum = t;
|
|
83110
|
+
denominator += 2;
|
|
83111
|
+
}
|
|
83112
|
+
}
|
|
83113
|
+
function parseDecimal(x, str) {
|
|
83114
|
+
var e, i, len;
|
|
83115
|
+
if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
|
|
83116
|
+
if ((i = str.search(/e/i)) > 0) {
|
|
83117
|
+
if (e < 0) e = i;
|
|
83118
|
+
e += +str.slice(i + 1);
|
|
83119
|
+
str = str.substring(0, i);
|
|
83120
|
+
} else if (e < 0) {
|
|
83121
|
+
e = str.length;
|
|
83122
|
+
}
|
|
83123
|
+
for (i = 0; str.charCodeAt(i) === 48; ) ++i;
|
|
83124
|
+
for (len = str.length; str.charCodeAt(len - 1) === 48; ) --len;
|
|
83125
|
+
str = str.slice(i, len);
|
|
83126
|
+
if (str) {
|
|
83127
|
+
len -= i;
|
|
83128
|
+
e = e - i - 1;
|
|
83129
|
+
x.e = mathfloor(e / LOG_BASE);
|
|
83130
|
+
x.d = [];
|
|
83131
|
+
i = (e + 1) % LOG_BASE;
|
|
83132
|
+
if (e < 0) i += LOG_BASE;
|
|
83133
|
+
if (i < len) {
|
|
83134
|
+
if (i) x.d.push(+str.slice(0, i));
|
|
83135
|
+
for (len -= LOG_BASE; i < len; ) x.d.push(+str.slice(i, i += LOG_BASE));
|
|
83136
|
+
str = str.slice(i);
|
|
83137
|
+
i = LOG_BASE - str.length;
|
|
83138
|
+
} else {
|
|
83139
|
+
i -= len;
|
|
83140
|
+
}
|
|
83141
|
+
for (; i--; ) str += "0";
|
|
83142
|
+
x.d.push(+str);
|
|
83143
|
+
if (external && (x.e > MAX_E || x.e < -MAX_E)) throw Error(exponentOutOfRange + e);
|
|
83144
|
+
} else {
|
|
83145
|
+
x.s = 0;
|
|
83146
|
+
x.e = 0;
|
|
83147
|
+
x.d = [0];
|
|
83148
|
+
}
|
|
83149
|
+
return x;
|
|
83150
|
+
}
|
|
83151
|
+
function round(x, sd, rm) {
|
|
83152
|
+
var i, j, k, n, rd, doRound, w, xdi, xd = x.d;
|
|
83153
|
+
for (n = 1, k = xd[0]; k >= 10; k /= 10) n++;
|
|
83154
|
+
i = sd - n;
|
|
83155
|
+
if (i < 0) {
|
|
83156
|
+
i += LOG_BASE;
|
|
83157
|
+
j = sd;
|
|
83158
|
+
w = xd[xdi = 0];
|
|
83159
|
+
} else {
|
|
83160
|
+
xdi = Math.ceil((i + 1) / LOG_BASE);
|
|
83161
|
+
k = xd.length;
|
|
83162
|
+
if (xdi >= k) return x;
|
|
83163
|
+
w = k = xd[xdi];
|
|
83164
|
+
for (n = 1; k >= 10; k /= 10) n++;
|
|
83165
|
+
i %= LOG_BASE;
|
|
83166
|
+
j = i - LOG_BASE + n;
|
|
83167
|
+
}
|
|
83168
|
+
if (rm !== void 0) {
|
|
83169
|
+
k = mathpow(10, n - j - 1);
|
|
83170
|
+
rd = w / k % 10 | 0;
|
|
83171
|
+
doRound = sd < 0 || xd[xdi + 1] !== void 0 || w % k;
|
|
83172
|
+
doRound = rm < 4 ? (rd || doRound) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || doRound || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
|
|
83173
|
+
(i > 0 ? j > 0 ? w / mathpow(10, n - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
83174
|
+
}
|
|
83175
|
+
if (sd < 1 || !xd[0]) {
|
|
83176
|
+
if (doRound) {
|
|
83177
|
+
k = getBase10Exponent(x);
|
|
83178
|
+
xd.length = 1;
|
|
83179
|
+
sd = sd - k - 1;
|
|
83180
|
+
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
|
|
83181
|
+
x.e = mathfloor(-sd / LOG_BASE) || 0;
|
|
83182
|
+
} else {
|
|
83183
|
+
xd.length = 1;
|
|
83184
|
+
xd[0] = x.e = x.s = 0;
|
|
83185
|
+
}
|
|
83186
|
+
return x;
|
|
83187
|
+
}
|
|
83188
|
+
if (i == 0) {
|
|
83189
|
+
xd.length = xdi;
|
|
83190
|
+
k = 1;
|
|
83191
|
+
xdi--;
|
|
83192
|
+
} else {
|
|
83193
|
+
xd.length = xdi + 1;
|
|
83194
|
+
k = mathpow(10, LOG_BASE - i);
|
|
83195
|
+
xd[xdi] = j > 0 ? (w / mathpow(10, n - j) % mathpow(10, j) | 0) * k : 0;
|
|
83196
|
+
}
|
|
83197
|
+
if (doRound) {
|
|
83198
|
+
for (; ; ) {
|
|
83199
|
+
if (xdi == 0) {
|
|
83200
|
+
if ((xd[0] += k) == BASE) {
|
|
83201
|
+
xd[0] = 1;
|
|
83202
|
+
++x.e;
|
|
83203
|
+
}
|
|
83204
|
+
break;
|
|
83205
|
+
} else {
|
|
83206
|
+
xd[xdi] += k;
|
|
83207
|
+
if (xd[xdi] != BASE) break;
|
|
83208
|
+
xd[xdi--] = 0;
|
|
83209
|
+
k = 1;
|
|
83210
|
+
}
|
|
83211
|
+
}
|
|
83212
|
+
}
|
|
83213
|
+
for (i = xd.length; xd[--i] === 0; ) xd.pop();
|
|
83214
|
+
if (external && (x.e > MAX_E || x.e < -MAX_E)) {
|
|
83215
|
+
throw Error(exponentOutOfRange + getBase10Exponent(x));
|
|
83216
|
+
}
|
|
83217
|
+
return x;
|
|
83218
|
+
}
|
|
83219
|
+
function subtract(x, y) {
|
|
83220
|
+
var d, e, i, j, k, len, xd, xe, xLTy, yd, Ctor = x.constructor, pr = Ctor.precision;
|
|
83221
|
+
if (!x.s || !y.s) {
|
|
83222
|
+
if (y.s) y.s = -y.s;
|
|
83223
|
+
else y = new Ctor(x);
|
|
83224
|
+
return external ? round(y, pr) : y;
|
|
83225
|
+
}
|
|
83226
|
+
xd = x.d;
|
|
83227
|
+
yd = y.d;
|
|
83228
|
+
e = y.e;
|
|
83229
|
+
xe = x.e;
|
|
83230
|
+
xd = xd.slice();
|
|
83231
|
+
k = xe - e;
|
|
83232
|
+
if (k) {
|
|
83233
|
+
xLTy = k < 0;
|
|
83234
|
+
if (xLTy) {
|
|
83235
|
+
d = xd;
|
|
83236
|
+
k = -k;
|
|
83237
|
+
len = yd.length;
|
|
83238
|
+
} else {
|
|
83239
|
+
d = yd;
|
|
83240
|
+
e = xe;
|
|
83241
|
+
len = xd.length;
|
|
83242
|
+
}
|
|
83243
|
+
i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
|
|
83244
|
+
if (k > i) {
|
|
83245
|
+
k = i;
|
|
83246
|
+
d.length = 1;
|
|
83247
|
+
}
|
|
83248
|
+
d.reverse();
|
|
83249
|
+
for (i = k; i--; ) d.push(0);
|
|
83250
|
+
d.reverse();
|
|
83251
|
+
} else {
|
|
83252
|
+
i = xd.length;
|
|
83253
|
+
len = yd.length;
|
|
83254
|
+
xLTy = i < len;
|
|
83255
|
+
if (xLTy) len = i;
|
|
83256
|
+
for (i = 0; i < len; i++) {
|
|
83257
|
+
if (xd[i] != yd[i]) {
|
|
83258
|
+
xLTy = xd[i] < yd[i];
|
|
83259
|
+
break;
|
|
83260
|
+
}
|
|
83261
|
+
}
|
|
83262
|
+
k = 0;
|
|
83263
|
+
}
|
|
83264
|
+
if (xLTy) {
|
|
83265
|
+
d = xd;
|
|
83266
|
+
xd = yd;
|
|
83267
|
+
yd = d;
|
|
83268
|
+
y.s = -y.s;
|
|
83269
|
+
}
|
|
83270
|
+
len = xd.length;
|
|
83271
|
+
for (i = yd.length - len; i > 0; --i) xd[len++] = 0;
|
|
83272
|
+
for (i = yd.length; i > k; ) {
|
|
83273
|
+
if (xd[--i] < yd[i]) {
|
|
83274
|
+
for (j = i; j && xd[--j] === 0; ) xd[j] = BASE - 1;
|
|
83275
|
+
--xd[j];
|
|
83276
|
+
xd[i] += BASE;
|
|
83277
|
+
}
|
|
83278
|
+
xd[i] -= yd[i];
|
|
83279
|
+
}
|
|
83280
|
+
for (; xd[--len] === 0; ) xd.pop();
|
|
83281
|
+
for (; xd[0] === 0; xd.shift()) --e;
|
|
83282
|
+
if (!xd[0]) return new Ctor(0);
|
|
83283
|
+
y.d = xd;
|
|
83284
|
+
y.e = e;
|
|
83285
|
+
return external ? round(y, pr) : y;
|
|
83286
|
+
}
|
|
83287
|
+
function toString3(x, isExp, sd) {
|
|
83288
|
+
var k, e = getBase10Exponent(x), str = digitsToString(x.d), len = str.length;
|
|
83289
|
+
if (isExp) {
|
|
83290
|
+
if (sd && (k = sd - len) > 0) {
|
|
83291
|
+
str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
|
|
83292
|
+
} else if (len > 1) {
|
|
83293
|
+
str = str.charAt(0) + "." + str.slice(1);
|
|
83294
|
+
}
|
|
83295
|
+
str = str + (e < 0 ? "e" : "e+") + e;
|
|
83296
|
+
} else if (e < 0) {
|
|
83297
|
+
str = "0." + getZeroString(-e - 1) + str;
|
|
83298
|
+
if (sd && (k = sd - len) > 0) str += getZeroString(k);
|
|
83299
|
+
} else if (e >= len) {
|
|
83300
|
+
str += getZeroString(e + 1 - len);
|
|
83301
|
+
if (sd && (k = sd - e - 1) > 0) str = str + "." + getZeroString(k);
|
|
83302
|
+
} else {
|
|
83303
|
+
if ((k = e + 1) < len) str = str.slice(0, k) + "." + str.slice(k);
|
|
83304
|
+
if (sd && (k = sd - len) > 0) {
|
|
83305
|
+
if (e + 1 === len) str += ".";
|
|
83306
|
+
str += getZeroString(k);
|
|
83307
|
+
}
|
|
83308
|
+
}
|
|
83309
|
+
return x.s < 0 ? "-" + str : str;
|
|
83310
|
+
}
|
|
83311
|
+
function truncate(arr, len) {
|
|
83312
|
+
if (arr.length > len) {
|
|
83313
|
+
arr.length = len;
|
|
83314
|
+
return true;
|
|
83315
|
+
}
|
|
83316
|
+
}
|
|
83317
|
+
function clone(obj) {
|
|
83318
|
+
var i, p, ps;
|
|
83319
|
+
function Decimal2(value) {
|
|
83320
|
+
var x = this;
|
|
83321
|
+
if (!(x instanceof Decimal2)) return new Decimal2(value);
|
|
83322
|
+
x.constructor = Decimal2;
|
|
83323
|
+
if (value instanceof Decimal2) {
|
|
83324
|
+
x.s = value.s;
|
|
83325
|
+
x.e = value.e;
|
|
83326
|
+
x.d = (value = value.d) ? value.slice() : value;
|
|
83327
|
+
return;
|
|
83328
|
+
}
|
|
83329
|
+
if (typeof value === "number") {
|
|
83330
|
+
if (value * 0 !== 0) {
|
|
83331
|
+
throw Error(invalidArgument + value);
|
|
83332
|
+
}
|
|
83333
|
+
if (value > 0) {
|
|
83334
|
+
x.s = 1;
|
|
83335
|
+
} else if (value < 0) {
|
|
83336
|
+
value = -value;
|
|
83337
|
+
x.s = -1;
|
|
83338
|
+
} else {
|
|
83339
|
+
x.s = 0;
|
|
83340
|
+
x.e = 0;
|
|
83341
|
+
x.d = [0];
|
|
83342
|
+
return;
|
|
83343
|
+
}
|
|
83344
|
+
if (value === ~~value && value < 1e7) {
|
|
83345
|
+
x.e = 0;
|
|
83346
|
+
x.d = [value];
|
|
83347
|
+
return;
|
|
83348
|
+
}
|
|
83349
|
+
return parseDecimal(x, value.toString());
|
|
83350
|
+
} else if (typeof value !== "string") {
|
|
83351
|
+
throw Error(invalidArgument + value);
|
|
83352
|
+
}
|
|
83353
|
+
if (value.charCodeAt(0) === 45) {
|
|
83354
|
+
value = value.slice(1);
|
|
83355
|
+
x.s = -1;
|
|
83356
|
+
} else {
|
|
83357
|
+
x.s = 1;
|
|
83358
|
+
}
|
|
83359
|
+
if (isDecimal.test(value)) parseDecimal(x, value);
|
|
83360
|
+
else throw Error(invalidArgument + value);
|
|
83361
|
+
}
|
|
83362
|
+
Decimal2.prototype = P;
|
|
83363
|
+
Decimal2.ROUND_UP = 0;
|
|
83364
|
+
Decimal2.ROUND_DOWN = 1;
|
|
83365
|
+
Decimal2.ROUND_CEIL = 2;
|
|
83366
|
+
Decimal2.ROUND_FLOOR = 3;
|
|
83367
|
+
Decimal2.ROUND_HALF_UP = 4;
|
|
83368
|
+
Decimal2.ROUND_HALF_DOWN = 5;
|
|
83369
|
+
Decimal2.ROUND_HALF_EVEN = 6;
|
|
83370
|
+
Decimal2.ROUND_HALF_CEIL = 7;
|
|
83371
|
+
Decimal2.ROUND_HALF_FLOOR = 8;
|
|
83372
|
+
Decimal2.clone = clone;
|
|
83373
|
+
Decimal2.config = Decimal2.set = config;
|
|
83374
|
+
if (obj === void 0) obj = {};
|
|
83375
|
+
if (obj) {
|
|
83376
|
+
ps = ["precision", "rounding", "toExpNeg", "toExpPos", "LN10"];
|
|
83377
|
+
for (i = 0; i < ps.length; ) if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p];
|
|
83378
|
+
}
|
|
83379
|
+
Decimal2.config(obj);
|
|
83380
|
+
return Decimal2;
|
|
83381
|
+
}
|
|
83382
|
+
function config(obj) {
|
|
83383
|
+
if (!obj || typeof obj !== "object") {
|
|
83384
|
+
throw Error(decimalError + "Object expected");
|
|
83385
|
+
}
|
|
83386
|
+
var i, p, v, ps = [
|
|
83387
|
+
"precision",
|
|
83388
|
+
1,
|
|
83389
|
+
MAX_DIGITS,
|
|
83390
|
+
"rounding",
|
|
83391
|
+
0,
|
|
83392
|
+
8,
|
|
83393
|
+
"toExpNeg",
|
|
83394
|
+
-1 / 0,
|
|
83395
|
+
0,
|
|
83396
|
+
"toExpPos",
|
|
83397
|
+
0,
|
|
83398
|
+
1 / 0
|
|
83399
|
+
];
|
|
83400
|
+
for (i = 0; i < ps.length; i += 3) {
|
|
83401
|
+
if ((v = obj[p = ps[i]]) !== void 0) {
|
|
83402
|
+
if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;
|
|
83403
|
+
else throw Error(invalidArgument + p + ": " + v);
|
|
83404
|
+
}
|
|
83405
|
+
}
|
|
83406
|
+
if ((v = obj[p = "LN10"]) !== void 0) {
|
|
83407
|
+
if (v == Math.LN10) this[p] = new this(v);
|
|
83408
|
+
else throw Error(invalidArgument + p + ": " + v);
|
|
83409
|
+
}
|
|
83410
|
+
return this;
|
|
83411
|
+
}
|
|
83412
|
+
var Decimal = clone(defaults2);
|
|
83413
|
+
ONE = new Decimal(1);
|
|
83414
|
+
|
|
83415
|
+
// src/sdk/sdk-legacy/utils/formatter.ts
|
|
82436
83416
|
function rayToNumber(num) {
|
|
82437
83417
|
return Number(toBigInt(num) / 10n ** 21n) / 1e6;
|
|
82438
83418
|
}
|
|
82439
83419
|
function toSignificant(num, decimals2, precision = 6) {
|
|
82440
83420
|
if (num === 1n) return "0";
|
|
82441
|
-
const divider = new
|
|
82442
|
-
const number = new
|
|
83421
|
+
const divider = new Decimal(10).toPower(decimals2);
|
|
83422
|
+
const number = new Decimal(num.toString()).div(divider);
|
|
82443
83423
|
return number.toSignificantDigits(precision, 4).toString();
|
|
82444
83424
|
}
|
|
82445
83425
|
function toBN(num, decimals2) {
|
|
82446
83426
|
if (num === "") return 0n;
|
|
82447
|
-
const multiplier = new
|
|
82448
|
-
const number = new
|
|
83427
|
+
const multiplier = new Decimal(10).toPower(decimals2);
|
|
83428
|
+
const number = new Decimal(num).mul(multiplier);
|
|
82449
83429
|
return BigInt(number.toFixed(0));
|
|
82450
83430
|
}
|
|
82451
83431
|
function shortAddress(address) {
|
|
@@ -82460,9 +83440,6 @@ function formatPercentage(healthFactor, decimals2 = 2) {
|
|
|
82460
83440
|
function formatLeverage(leverage, decimals2 = 2) {
|
|
82461
83441
|
return (leverage / Number(LEVERAGE_DECIMALS)).toFixed(decimals2);
|
|
82462
83442
|
}
|
|
82463
|
-
function formatDateTime(timestamp) {
|
|
82464
|
-
return `${moment.unix(timestamp).format("Do MMM YYYY HH:mm")} UTC`;
|
|
82465
|
-
}
|
|
82466
83443
|
|
|
82467
83444
|
// src/sdk/sdk-legacy/core/creditAccount.ts
|
|
82468
83445
|
var MAX_UINT162 = 65535;
|
|
@@ -83287,6 +84264,8 @@ var ChartsCreditManagerData = class {
|
|
|
83287
84264
|
this.totalLiquidatedAccountsChange = payload.totalLiquidatedAccountsChange || 0;
|
|
83288
84265
|
}
|
|
83289
84266
|
};
|
|
84267
|
+
|
|
84268
|
+
// src/sdk/sdk-legacy/core/creditSession.ts
|
|
83290
84269
|
var CREDIT_SESSION_STATUS_BY_ID = {
|
|
83291
84270
|
0: "active",
|
|
83292
84271
|
1: "closed",
|
|
@@ -83307,9 +84286,7 @@ var CreditSession = class {
|
|
|
83307
84286
|
underlyingToken;
|
|
83308
84287
|
version;
|
|
83309
84288
|
since;
|
|
83310
|
-
sinceDate;
|
|
83311
84289
|
closedAt;
|
|
83312
|
-
closedAtDate;
|
|
83313
84290
|
initialAmount;
|
|
83314
84291
|
borrowedAmount;
|
|
83315
84292
|
totalValue;
|
|
@@ -83362,12 +84339,6 @@ var CreditSession = class {
|
|
|
83362
84339
|
this.healthFactor = Number(toBigInt(payload.healthFactor || 0));
|
|
83363
84340
|
this.since = payload.since || 0;
|
|
83364
84341
|
this.closedAt = payload.closedAt || 0;
|
|
83365
|
-
this.sinceDate = moment__default.default((payload.sinceTimestamp || 0) * 1e3).format(
|
|
83366
|
-
"Do MMM YYYY"
|
|
83367
|
-
);
|
|
83368
|
-
this.closedAtDate = moment__default.default((payload.closedAtTimestamp || 0) * 1e3).format(
|
|
83369
|
-
"Do MMM YYYY"
|
|
83370
|
-
);
|
|
83371
84342
|
this.sinceTimestamp = payload.sinceTimestamp || 0;
|
|
83372
84343
|
this.closedAtTimestamp = payload.closedAtTimestamp || 0;
|
|
83373
84344
|
this.profitInUSD = payload.profitInUSD || 0;
|
|
@@ -83436,9 +84407,7 @@ var CreditSessionFiltered = class {
|
|
|
83436
84407
|
underlyingToken;
|
|
83437
84408
|
status;
|
|
83438
84409
|
since;
|
|
83439
|
-
sinceDate;
|
|
83440
84410
|
closedAt;
|
|
83441
|
-
closedAtDate;
|
|
83442
84411
|
sinceTimestamp;
|
|
83443
84412
|
closedAtTimestamp;
|
|
83444
84413
|
healthFactor;
|
|
@@ -83462,10 +84431,6 @@ var CreditSessionFiltered = class {
|
|
|
83462
84431
|
this.status = CREDIT_SESSION_STATUS_BY_ID[payload.status || 0];
|
|
83463
84432
|
this.since = payload.since || 0;
|
|
83464
84433
|
this.closedAt = payload.closedAt || 0;
|
|
83465
|
-
this.sinceDate = moment__default.default((payload.since || 0) * 1e3).format("Do MMM YYYY");
|
|
83466
|
-
this.closedAtDate = moment__default.default((payload.closedAt || 0) * 1e3).format(
|
|
83467
|
-
"Do MMM YYYY"
|
|
83468
|
-
);
|
|
83469
84434
|
this.sinceTimestamp = payload.sinceTimestamp || 0;
|
|
83470
84435
|
this.closedAtTimestamp = payload.closedAtTimestamp || 0;
|
|
83471
84436
|
this.healthFactor = Number(toBigInt(payload.healthFactor || 0));
|
|
@@ -87759,7 +88724,7 @@ var POOL_REWARDS_ABI = [
|
|
|
87759
88724
|
|
|
87760
88725
|
// src/sdk/sdk-legacy/gearboxRewards/apy.ts
|
|
87761
88726
|
var PERCENTAGE_FACTOR_1KK = PERCENTAGE_DECIMALS * PERCENTAGE_FACTOR;
|
|
87762
|
-
var
|
|
88727
|
+
var ONE2 = PERCENTAGE_FACTOR_1KK * 10n;
|
|
87763
88728
|
var GearboxRewardsApy = class {
|
|
87764
88729
|
static getPoolExtraAPY_V3({
|
|
87765
88730
|
rewardPoolsInfo,
|
|
@@ -87840,7 +88805,7 @@ var GearboxRewardsApy = class {
|
|
|
87840
88805
|
reward.decimals
|
|
87841
88806
|
);
|
|
87842
88807
|
const durationRatio = toBigInt(SECONDS_PER_YEAR) * WAD / info.duration;
|
|
87843
|
-
const apyBn = rewardMoney *
|
|
88808
|
+
const apyBn = rewardMoney * ONE2 / supplyMoney * durationRatio / WAD;
|
|
87844
88809
|
return Math.round(Number(apyBn) / 10);
|
|
87845
88810
|
}
|
|
87846
88811
|
static getCAExtraAPY_V3({
|
|
@@ -88388,7 +89353,6 @@ exports.fmtBinaryMask = fmtBinaryMask;
|
|
|
88388
89353
|
exports.formatBN = formatBN;
|
|
88389
89354
|
exports.formatBNvalue = formatBNvalue;
|
|
88390
89355
|
exports.formatBn4dig = formatBn4dig;
|
|
88391
|
-
exports.formatDateTime = formatDateTime;
|
|
88392
89356
|
exports.formatDuration = formatDuration;
|
|
88393
89357
|
exports.formatLeverage = formatLeverage;
|
|
88394
89358
|
exports.formatNumberToString_ = formatNumberToString_;
|