@gearbox-protocol/sdk 3.0.0-vfour.147 → 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 +1138 -156
- package/dist/esm/sdk/index.mjs +1134 -152
- package/package.json +1 -1
package/dist/cjs/sdk/index.cjs
CHANGED
|
@@ -14,7 +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
17
|
|
|
19
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
19
|
|
|
@@ -9420,7 +9419,7 @@ var require_form_data = __commonJS({
|
|
|
9420
9419
|
});
|
|
9421
9420
|
};
|
|
9422
9421
|
FormData3.prototype.submit = function(params, cb) {
|
|
9423
|
-
var request, options,
|
|
9422
|
+
var request, options, defaults3 = { method: "post" };
|
|
9424
9423
|
if (typeof params == "string") {
|
|
9425
9424
|
params = parseUrl(params);
|
|
9426
9425
|
options = populate({
|
|
@@ -9428,9 +9427,9 @@ var require_form_data = __commonJS({
|
|
|
9428
9427
|
path: params.pathname,
|
|
9429
9428
|
host: params.hostname,
|
|
9430
9429
|
protocol: params.protocol
|
|
9431
|
-
},
|
|
9430
|
+
}, defaults3);
|
|
9432
9431
|
} else {
|
|
9433
|
-
options = populate(params,
|
|
9432
|
+
options = populate(params, defaults3);
|
|
9434
9433
|
if (!options.port) {
|
|
9435
9434
|
options.port = options.protocol == "https:" ? 443 : 80;
|
|
9436
9435
|
}
|
|
@@ -79088,7 +79087,7 @@ var utils_default = {
|
|
|
79088
79087
|
};
|
|
79089
79088
|
|
|
79090
79089
|
// node_modules/axios/lib/core/AxiosError.js
|
|
79091
|
-
function AxiosError(message, code,
|
|
79090
|
+
function AxiosError(message, code, config2, request, response) {
|
|
79092
79091
|
Error.call(this);
|
|
79093
79092
|
if (Error.captureStackTrace) {
|
|
79094
79093
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -79098,7 +79097,7 @@ function AxiosError(message, code, config, request, response) {
|
|
|
79098
79097
|
this.message = message;
|
|
79099
79098
|
this.name = "AxiosError";
|
|
79100
79099
|
code && (this.code = code);
|
|
79101
|
-
|
|
79100
|
+
config2 && (this.config = config2);
|
|
79102
79101
|
request && (this.request = request);
|
|
79103
79102
|
if (response) {
|
|
79104
79103
|
this.response = response;
|
|
@@ -79147,14 +79146,14 @@ var descriptors = {};
|
|
|
79147
79146
|
});
|
|
79148
79147
|
Object.defineProperties(AxiosError, descriptors);
|
|
79149
79148
|
Object.defineProperty(prototype, "isAxiosError", { value: true });
|
|
79150
|
-
AxiosError.from = (error, code,
|
|
79149
|
+
AxiosError.from = (error, code, config2, request, response, customProps) => {
|
|
79151
79150
|
const axiosError = Object.create(prototype);
|
|
79152
79151
|
utils_default.toFlatObject(error, axiosError, function filter2(obj) {
|
|
79153
79152
|
return obj !== Error.prototype;
|
|
79154
79153
|
}, (prop) => {
|
|
79155
79154
|
return prop !== "isAxiosError";
|
|
79156
79155
|
});
|
|
79157
|
-
AxiosError.call(axiosError, error.message, code,
|
|
79156
|
+
AxiosError.call(axiosError, error.message, code, config2, request, response);
|
|
79158
79157
|
axiosError.cause = error;
|
|
79159
79158
|
axiosError.name = error.name;
|
|
79160
79159
|
customProps && Object.assign(axiosError, customProps);
|
|
@@ -79892,12 +79891,12 @@ var AxiosHeaders_default = AxiosHeaders;
|
|
|
79892
79891
|
|
|
79893
79892
|
// node_modules/axios/lib/core/transformData.js
|
|
79894
79893
|
function transformData(fns, response) {
|
|
79895
|
-
const
|
|
79896
|
-
const context = response ||
|
|
79894
|
+
const config2 = this || defaults_default;
|
|
79895
|
+
const context = response || config2;
|
|
79897
79896
|
const headers = AxiosHeaders_default.from(context.headers);
|
|
79898
79897
|
let data = context.data;
|
|
79899
79898
|
utils_default.forEach(fns, function transform(fn) {
|
|
79900
|
-
data = fn.call(
|
|
79899
|
+
data = fn.call(config2, data, headers.normalize(), response ? response.status : void 0);
|
|
79901
79900
|
});
|
|
79902
79901
|
headers.normalize();
|
|
79903
79902
|
return data;
|
|
@@ -79909,8 +79908,8 @@ function isCancel(value) {
|
|
|
79909
79908
|
}
|
|
79910
79909
|
|
|
79911
79910
|
// node_modules/axios/lib/cancel/CanceledError.js
|
|
79912
|
-
function CanceledError(message,
|
|
79913
|
-
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);
|
|
79914
79913
|
this.name = "CanceledError";
|
|
79915
79914
|
}
|
|
79916
79915
|
utils_default.inherits(CanceledError, AxiosError_default, {
|
|
@@ -80431,11 +80430,11 @@ var resolveFamily = ({ address, family }) => {
|
|
|
80431
80430
|
};
|
|
80432
80431
|
};
|
|
80433
80432
|
var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
|
|
80434
|
-
var http_default = isHttpAdapterSupported && function httpAdapter(
|
|
80433
|
+
var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
|
|
80435
80434
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
|
80436
|
-
let { data, lookup, family } =
|
|
80437
|
-
const { responseType, responseEncoding } =
|
|
80438
|
-
const method =
|
|
80435
|
+
let { data, lookup, family } = config2;
|
|
80436
|
+
const { responseType, responseEncoding } = config2;
|
|
80437
|
+
const method = config2.method.toUpperCase();
|
|
80439
80438
|
let isDone;
|
|
80440
80439
|
let rejected = false;
|
|
80441
80440
|
let req;
|
|
@@ -80453,11 +80452,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80453
80452
|
}
|
|
80454
80453
|
const emitter = new events.EventEmitter();
|
|
80455
80454
|
const onFinished = () => {
|
|
80456
|
-
if (
|
|
80457
|
-
|
|
80455
|
+
if (config2.cancelToken) {
|
|
80456
|
+
config2.cancelToken.unsubscribe(abort);
|
|
80458
80457
|
}
|
|
80459
|
-
if (
|
|
80460
|
-
|
|
80458
|
+
if (config2.signal) {
|
|
80459
|
+
config2.signal.removeEventListener("abort", abort);
|
|
80461
80460
|
}
|
|
80462
80461
|
emitter.removeAllListeners();
|
|
80463
80462
|
};
|
|
@@ -80469,16 +80468,16 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80469
80468
|
}
|
|
80470
80469
|
});
|
|
80471
80470
|
function abort(reason) {
|
|
80472
|
-
emitter.emit("abort", !reason || reason.type ? new CanceledError_default(null,
|
|
80471
|
+
emitter.emit("abort", !reason || reason.type ? new CanceledError_default(null, config2, req) : reason);
|
|
80473
80472
|
}
|
|
80474
80473
|
emitter.once("abort", reject);
|
|
80475
|
-
if (
|
|
80476
|
-
|
|
80477
|
-
if (
|
|
80478
|
-
|
|
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);
|
|
80479
80478
|
}
|
|
80480
80479
|
}
|
|
80481
|
-
const fullPath = buildFullPath(
|
|
80480
|
+
const fullPath = buildFullPath(config2.baseURL, config2.url);
|
|
80482
80481
|
const parsed = new URL(fullPath, platform_default.hasBrowserEnv ? platform_default.origin : void 0);
|
|
80483
80482
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
80484
80483
|
if (protocol === "data:") {
|
|
@@ -80488,15 +80487,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80488
80487
|
status: 405,
|
|
80489
80488
|
statusText: "method not allowed",
|
|
80490
80489
|
headers: {},
|
|
80491
|
-
config
|
|
80490
|
+
config: config2
|
|
80492
80491
|
});
|
|
80493
80492
|
}
|
|
80494
80493
|
try {
|
|
80495
|
-
convertedData = fromDataURI(
|
|
80496
|
-
Blob:
|
|
80494
|
+
convertedData = fromDataURI(config2.url, responseType === "blob", {
|
|
80495
|
+
Blob: config2.env && config2.env.Blob
|
|
80497
80496
|
});
|
|
80498
80497
|
} catch (err) {
|
|
80499
|
-
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST,
|
|
80498
|
+
throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST, config2);
|
|
80500
80499
|
}
|
|
80501
80500
|
if (responseType === "text") {
|
|
80502
80501
|
convertedData = convertedData.toString(responseEncoding);
|
|
@@ -80511,20 +80510,20 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80511
80510
|
status: 200,
|
|
80512
80511
|
statusText: "OK",
|
|
80513
80512
|
headers: new AxiosHeaders_default(),
|
|
80514
|
-
config
|
|
80513
|
+
config: config2
|
|
80515
80514
|
});
|
|
80516
80515
|
}
|
|
80517
80516
|
if (supportedProtocols.indexOf(protocol) === -1) {
|
|
80518
80517
|
return reject(new AxiosError_default(
|
|
80519
80518
|
"Unsupported protocol " + protocol,
|
|
80520
80519
|
AxiosError_default.ERR_BAD_REQUEST,
|
|
80521
|
-
|
|
80520
|
+
config2
|
|
80522
80521
|
));
|
|
80523
80522
|
}
|
|
80524
|
-
const headers = AxiosHeaders_default.from(
|
|
80523
|
+
const headers = AxiosHeaders_default.from(config2.headers).normalize();
|
|
80525
80524
|
headers.set("User-Agent", "axios/" + VERSION, false);
|
|
80526
|
-
const { onUploadProgress, onDownloadProgress } =
|
|
80527
|
-
const maxRate =
|
|
80525
|
+
const { onUploadProgress, onDownloadProgress } = config2;
|
|
80526
|
+
const maxRate = config2.maxRate;
|
|
80528
80527
|
let maxUploadRate = void 0;
|
|
80529
80528
|
let maxDownloadRate = void 0;
|
|
80530
80529
|
if (utils_default.isSpecCompliantForm(data)) {
|
|
@@ -80557,15 +80556,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80557
80556
|
return reject(new AxiosError_default(
|
|
80558
80557
|
"Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",
|
|
80559
80558
|
AxiosError_default.ERR_BAD_REQUEST,
|
|
80560
|
-
|
|
80559
|
+
config2
|
|
80561
80560
|
));
|
|
80562
80561
|
}
|
|
80563
80562
|
headers.setContentLength(data.length, false);
|
|
80564
|
-
if (
|
|
80563
|
+
if (config2.maxBodyLength > -1 && data.length > config2.maxBodyLength) {
|
|
80565
80564
|
return reject(new AxiosError_default(
|
|
80566
80565
|
"Request body larger than maxBodyLength limit",
|
|
80567
80566
|
AxiosError_default.ERR_BAD_REQUEST,
|
|
80568
|
-
|
|
80567
|
+
config2
|
|
80569
80568
|
));
|
|
80570
80569
|
}
|
|
80571
80570
|
}
|
|
@@ -80592,9 +80591,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80592
80591
|
));
|
|
80593
80592
|
}
|
|
80594
80593
|
let auth = void 0;
|
|
80595
|
-
if (
|
|
80596
|
-
const username =
|
|
80597
|
-
const password =
|
|
80594
|
+
if (config2.auth) {
|
|
80595
|
+
const username = config2.auth.username || "";
|
|
80596
|
+
const password = config2.auth.password || "";
|
|
80598
80597
|
auth = username + ":" + password;
|
|
80599
80598
|
}
|
|
80600
80599
|
if (!auth && parsed.username) {
|
|
@@ -80607,13 +80606,13 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80607
80606
|
try {
|
|
80608
80607
|
path = buildURL(
|
|
80609
80608
|
parsed.pathname + parsed.search,
|
|
80610
|
-
|
|
80611
|
-
|
|
80609
|
+
config2.params,
|
|
80610
|
+
config2.paramsSerializer
|
|
80612
80611
|
).replace(/^\?/, "");
|
|
80613
80612
|
} catch (err) {
|
|
80614
80613
|
const customErr = new Error(err.message);
|
|
80615
|
-
customErr.config =
|
|
80616
|
-
customErr.url =
|
|
80614
|
+
customErr.config = config2;
|
|
80615
|
+
customErr.url = config2.url;
|
|
80617
80616
|
customErr.exists = true;
|
|
80618
80617
|
return reject(customErr);
|
|
80619
80618
|
}
|
|
@@ -80626,7 +80625,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80626
80625
|
path,
|
|
80627
80626
|
method,
|
|
80628
80627
|
headers: headers.toJSON(),
|
|
80629
|
-
agents: { http:
|
|
80628
|
+
agents: { http: config2.httpAgent, https: config2.httpsAgent },
|
|
80630
80629
|
auth,
|
|
80631
80630
|
protocol,
|
|
80632
80631
|
family,
|
|
@@ -80634,36 +80633,36 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80634
80633
|
beforeRedirects: {}
|
|
80635
80634
|
};
|
|
80636
80635
|
!utils_default.isUndefined(lookup) && (options.lookup = lookup);
|
|
80637
|
-
if (
|
|
80638
|
-
options.socketPath =
|
|
80636
|
+
if (config2.socketPath) {
|
|
80637
|
+
options.socketPath = config2.socketPath;
|
|
80639
80638
|
} else {
|
|
80640
80639
|
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
80641
80640
|
options.port = parsed.port;
|
|
80642
|
-
setProxy(options,
|
|
80641
|
+
setProxy(options, config2.proxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path);
|
|
80643
80642
|
}
|
|
80644
80643
|
let transport;
|
|
80645
80644
|
const isHttpsRequest = isHttps.test(options.protocol);
|
|
80646
|
-
options.agent = isHttpsRequest ?
|
|
80647
|
-
if (
|
|
80648
|
-
transport =
|
|
80649
|
-
} else if (
|
|
80645
|
+
options.agent = isHttpsRequest ? config2.httpsAgent : config2.httpAgent;
|
|
80646
|
+
if (config2.transport) {
|
|
80647
|
+
transport = config2.transport;
|
|
80648
|
+
} else if (config2.maxRedirects === 0) {
|
|
80650
80649
|
transport = isHttpsRequest ? https__default.default : http3__default.default;
|
|
80651
80650
|
} else {
|
|
80652
|
-
if (
|
|
80653
|
-
options.maxRedirects =
|
|
80651
|
+
if (config2.maxRedirects) {
|
|
80652
|
+
options.maxRedirects = config2.maxRedirects;
|
|
80654
80653
|
}
|
|
80655
|
-
if (
|
|
80656
|
-
options.beforeRedirects.config =
|
|
80654
|
+
if (config2.beforeRedirect) {
|
|
80655
|
+
options.beforeRedirects.config = config2.beforeRedirect;
|
|
80657
80656
|
}
|
|
80658
80657
|
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
|
80659
80658
|
}
|
|
80660
|
-
if (
|
|
80661
|
-
options.maxBodyLength =
|
|
80659
|
+
if (config2.maxBodyLength > -1) {
|
|
80660
|
+
options.maxBodyLength = config2.maxBodyLength;
|
|
80662
80661
|
} else {
|
|
80663
80662
|
options.maxBodyLength = Infinity;
|
|
80664
80663
|
}
|
|
80665
|
-
if (
|
|
80666
|
-
options.insecureHTTPParser =
|
|
80664
|
+
if (config2.insecureHTTPParser) {
|
|
80665
|
+
options.insecureHTTPParser = config2.insecureHTTPParser;
|
|
80667
80666
|
}
|
|
80668
80667
|
req = transport.request(options, function handleResponse(res) {
|
|
80669
80668
|
if (req.destroyed) return;
|
|
@@ -80684,7 +80683,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80684
80683
|
}
|
|
80685
80684
|
let responseStream = res;
|
|
80686
80685
|
const lastRequest = res.req || req;
|
|
80687
|
-
if (
|
|
80686
|
+
if (config2.decompress !== false && res.headers["content-encoding"]) {
|
|
80688
80687
|
if (method === "HEAD" || res.statusCode === 204) {
|
|
80689
80688
|
delete res.headers["content-encoding"];
|
|
80690
80689
|
}
|
|
@@ -80718,7 +80717,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80718
80717
|
status: res.statusCode,
|
|
80719
80718
|
statusText: res.statusMessage,
|
|
80720
80719
|
headers: new AxiosHeaders_default(res.headers),
|
|
80721
|
-
config,
|
|
80720
|
+
config: config2,
|
|
80722
80721
|
request: lastRequest
|
|
80723
80722
|
};
|
|
80724
80723
|
if (responseType === "stream") {
|
|
@@ -80730,13 +80729,13 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80730
80729
|
responseStream.on("data", function handleStreamData(chunk) {
|
|
80731
80730
|
responseBuffer.push(chunk);
|
|
80732
80731
|
totalResponseBytes += chunk.length;
|
|
80733
|
-
if (
|
|
80732
|
+
if (config2.maxContentLength > -1 && totalResponseBytes > config2.maxContentLength) {
|
|
80734
80733
|
rejected = true;
|
|
80735
80734
|
responseStream.destroy();
|
|
80736
80735
|
reject(new AxiosError_default(
|
|
80737
|
-
"maxContentLength size of " +
|
|
80736
|
+
"maxContentLength size of " + config2.maxContentLength + " exceeded",
|
|
80738
80737
|
AxiosError_default.ERR_BAD_RESPONSE,
|
|
80739
|
-
|
|
80738
|
+
config2,
|
|
80740
80739
|
lastRequest
|
|
80741
80740
|
));
|
|
80742
80741
|
}
|
|
@@ -80748,7 +80747,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80748
80747
|
const err = new AxiosError_default(
|
|
80749
80748
|
"stream has been aborted",
|
|
80750
80749
|
AxiosError_default.ERR_BAD_RESPONSE,
|
|
80751
|
-
|
|
80750
|
+
config2,
|
|
80752
80751
|
lastRequest
|
|
80753
80752
|
);
|
|
80754
80753
|
responseStream.destroy(err);
|
|
@@ -80756,7 +80755,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80756
80755
|
});
|
|
80757
80756
|
responseStream.on("error", function handleStreamError(err) {
|
|
80758
80757
|
if (req.destroyed) return;
|
|
80759
|
-
reject(AxiosError_default.from(err, null,
|
|
80758
|
+
reject(AxiosError_default.from(err, null, config2, lastRequest));
|
|
80760
80759
|
});
|
|
80761
80760
|
responseStream.on("end", function handleStreamEnd() {
|
|
80762
80761
|
try {
|
|
@@ -80769,7 +80768,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80769
80768
|
}
|
|
80770
80769
|
response.data = responseData;
|
|
80771
80770
|
} catch (err) {
|
|
80772
|
-
return reject(AxiosError_default.from(err, null,
|
|
80771
|
+
return reject(AxiosError_default.from(err, null, config2, response.request, response));
|
|
80773
80772
|
}
|
|
80774
80773
|
settle(resolve, reject, response);
|
|
80775
80774
|
});
|
|
@@ -80786,33 +80785,33 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80786
80785
|
req.destroy(err);
|
|
80787
80786
|
});
|
|
80788
80787
|
req.on("error", function handleRequestError(err) {
|
|
80789
|
-
reject(AxiosError_default.from(err, null,
|
|
80788
|
+
reject(AxiosError_default.from(err, null, config2, req));
|
|
80790
80789
|
});
|
|
80791
80790
|
req.on("socket", function handleRequestSocket(socket) {
|
|
80792
80791
|
socket.setKeepAlive(true, 1e3 * 60);
|
|
80793
80792
|
});
|
|
80794
|
-
if (
|
|
80795
|
-
const timeout = parseInt(
|
|
80793
|
+
if (config2.timeout) {
|
|
80794
|
+
const timeout = parseInt(config2.timeout, 10);
|
|
80796
80795
|
if (Number.isNaN(timeout)) {
|
|
80797
80796
|
reject(new AxiosError_default(
|
|
80798
80797
|
"error trying to parse `config.timeout` to int",
|
|
80799
80798
|
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
80800
|
-
|
|
80799
|
+
config2,
|
|
80801
80800
|
req
|
|
80802
80801
|
));
|
|
80803
80802
|
return;
|
|
80804
80803
|
}
|
|
80805
80804
|
req.setTimeout(timeout, function handleRequestTimeout() {
|
|
80806
80805
|
if (isDone) return;
|
|
80807
|
-
let timeoutErrorMessage =
|
|
80808
|
-
const transitional2 =
|
|
80809
|
-
if (
|
|
80810
|
-
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;
|
|
80811
80810
|
}
|
|
80812
80811
|
reject(new AxiosError_default(
|
|
80813
80812
|
timeoutErrorMessage,
|
|
80814
80813
|
transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
80815
|
-
|
|
80814
|
+
config2,
|
|
80816
80815
|
req
|
|
80817
80816
|
));
|
|
80818
80817
|
abort();
|
|
@@ -80830,7 +80829,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
80830
80829
|
});
|
|
80831
80830
|
data.on("close", () => {
|
|
80832
80831
|
if (!ended && !errored) {
|
|
80833
|
-
abort(new CanceledError_default("Request stream has been aborted",
|
|
80832
|
+
abort(new CanceledError_default("Request stream has been aborted", config2, req));
|
|
80834
80833
|
}
|
|
80835
80834
|
});
|
|
80836
80835
|
data.pipe(req);
|
|
@@ -80886,7 +80885,7 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
|
|
|
80886
80885
|
var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
|
|
80887
80886
|
function mergeConfig(config1, config2) {
|
|
80888
80887
|
config2 = config2 || {};
|
|
80889
|
-
const
|
|
80888
|
+
const config3 = {};
|
|
80890
80889
|
function getMergedValue(target, source, prop, caseless) {
|
|
80891
80890
|
if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
|
|
80892
80891
|
return utils_default.merge.call({ caseless }, target, source);
|
|
@@ -80957,17 +80956,17 @@ function mergeConfig(config1, config2) {
|
|
|
80957
80956
|
utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
80958
80957
|
const merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
80959
80958
|
const configValue = merge2(config1[prop], config2[prop], prop);
|
|
80960
|
-
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (
|
|
80959
|
+
utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config3[prop] = configValue);
|
|
80961
80960
|
});
|
|
80962
|
-
return
|
|
80961
|
+
return config3;
|
|
80963
80962
|
}
|
|
80964
80963
|
|
|
80965
80964
|
// node_modules/axios/lib/helpers/resolveConfig.js
|
|
80966
|
-
var resolveConfig_default = (
|
|
80967
|
-
const newConfig = mergeConfig({},
|
|
80965
|
+
var resolveConfig_default = (config2) => {
|
|
80966
|
+
const newConfig = mergeConfig({}, config2);
|
|
80968
80967
|
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
80969
80968
|
newConfig.headers = headers = AxiosHeaders_default.from(headers);
|
|
80970
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url),
|
|
80969
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config2.params, config2.paramsSerializer);
|
|
80971
80970
|
if (auth) {
|
|
80972
80971
|
headers.set(
|
|
80973
80972
|
"Authorization",
|
|
@@ -80997,9 +80996,9 @@ var resolveConfig_default = (config) => {
|
|
|
80997
80996
|
|
|
80998
80997
|
// node_modules/axios/lib/adapters/xhr.js
|
|
80999
80998
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
81000
|
-
var xhr_default = isXHRAdapterSupported && function(
|
|
80999
|
+
var xhr_default = isXHRAdapterSupported && function(config2) {
|
|
81001
81000
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
81002
|
-
const _config = resolveConfig_default(
|
|
81001
|
+
const _config = resolveConfig_default(config2);
|
|
81003
81002
|
let requestData = _config.data;
|
|
81004
81003
|
const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
|
|
81005
81004
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
@@ -81028,7 +81027,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81028
81027
|
status: request.status,
|
|
81029
81028
|
statusText: request.statusText,
|
|
81030
81029
|
headers: responseHeaders,
|
|
81031
|
-
config,
|
|
81030
|
+
config: config2,
|
|
81032
81031
|
request
|
|
81033
81032
|
};
|
|
81034
81033
|
settle(function _resolve(value) {
|
|
@@ -81057,11 +81056,11 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81057
81056
|
if (!request) {
|
|
81058
81057
|
return;
|
|
81059
81058
|
}
|
|
81060
|
-
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED,
|
|
81059
|
+
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config2, request));
|
|
81061
81060
|
request = null;
|
|
81062
81061
|
};
|
|
81063
81062
|
request.onerror = function handleError() {
|
|
81064
|
-
reject(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK,
|
|
81063
|
+
reject(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config2, request));
|
|
81065
81064
|
request = null;
|
|
81066
81065
|
};
|
|
81067
81066
|
request.ontimeout = function handleTimeout() {
|
|
@@ -81073,7 +81072,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81073
81072
|
reject(new AxiosError_default(
|
|
81074
81073
|
timeoutErrorMessage,
|
|
81075
81074
|
transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
|
|
81076
|
-
|
|
81075
|
+
config2,
|
|
81077
81076
|
request
|
|
81078
81077
|
));
|
|
81079
81078
|
request = null;
|
|
@@ -81104,7 +81103,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81104
81103
|
if (!request) {
|
|
81105
81104
|
return;
|
|
81106
81105
|
}
|
|
81107
|
-
reject(!cancel || cancel.type ? new CanceledError_default(null,
|
|
81106
|
+
reject(!cancel || cancel.type ? new CanceledError_default(null, config2, request) : cancel);
|
|
81108
81107
|
request.abort();
|
|
81109
81108
|
request = null;
|
|
81110
81109
|
};
|
|
@@ -81115,7 +81114,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
81115
81114
|
}
|
|
81116
81115
|
const protocol = parseProtocol(_config.url);
|
|
81117
81116
|
if (protocol && platform_default.protocols.indexOf(protocol) === -1) {
|
|
81118
|
-
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));
|
|
81119
81118
|
return;
|
|
81120
81119
|
}
|
|
81121
81120
|
request.send(requestData || null);
|
|
@@ -81265,8 +81264,8 @@ var resolvers = {
|
|
|
81265
81264
|
};
|
|
81266
81265
|
isFetchSupported && ((res) => {
|
|
81267
81266
|
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
|
|
81268
|
-
!resolvers[type] && (resolvers[type] = utils_default.isFunction(res[type]) ? (res2) => res2[type]() : (_,
|
|
81269
|
-
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);
|
|
81270
81269
|
});
|
|
81271
81270
|
});
|
|
81272
81271
|
})(new Response());
|
|
@@ -81298,7 +81297,7 @@ var resolveBodyLength = async (headers, body) => {
|
|
|
81298
81297
|
const length = utils_default.toFiniteNumber(headers.getContentLength());
|
|
81299
81298
|
return length == null ? getBodyLength(body) : length;
|
|
81300
81299
|
};
|
|
81301
|
-
var fetch_default = isFetchSupported && (async (
|
|
81300
|
+
var fetch_default = isFetchSupported && (async (config2) => {
|
|
81302
81301
|
let {
|
|
81303
81302
|
url: url2,
|
|
81304
81303
|
method,
|
|
@@ -81312,7 +81311,7 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81312
81311
|
headers,
|
|
81313
81312
|
withCredentials = "same-origin",
|
|
81314
81313
|
fetchOptions
|
|
81315
|
-
} = resolveConfig_default(
|
|
81314
|
+
} = resolveConfig_default(config2);
|
|
81316
81315
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
81317
81316
|
let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
81318
81317
|
let request;
|
|
@@ -81373,7 +81372,7 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81373
81372
|
);
|
|
81374
81373
|
}
|
|
81375
81374
|
responseType = responseType || "text";
|
|
81376
|
-
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response,
|
|
81375
|
+
let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config2);
|
|
81377
81376
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
81378
81377
|
return await new Promise((resolve, reject) => {
|
|
81379
81378
|
settle(resolve, reject, {
|
|
@@ -81381,7 +81380,7 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81381
81380
|
headers: AxiosHeaders_default.from(response.headers),
|
|
81382
81381
|
status: response.status,
|
|
81383
81382
|
statusText: response.statusText,
|
|
81384
|
-
config,
|
|
81383
|
+
config: config2,
|
|
81385
81384
|
request
|
|
81386
81385
|
});
|
|
81387
81386
|
});
|
|
@@ -81389,13 +81388,13 @@ var fetch_default = isFetchSupported && (async (config) => {
|
|
|
81389
81388
|
unsubscribe && unsubscribe();
|
|
81390
81389
|
if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
|
|
81391
81390
|
throw Object.assign(
|
|
81392
|
-
new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK,
|
|
81391
|
+
new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config2, request),
|
|
81393
81392
|
{
|
|
81394
81393
|
cause: err.cause || err
|
|
81395
81394
|
}
|
|
81396
81395
|
);
|
|
81397
81396
|
}
|
|
81398
|
-
throw AxiosError_default.from(err, err && err.code,
|
|
81397
|
+
throw AxiosError_default.from(err, err && err.code, config2, request);
|
|
81399
81398
|
}
|
|
81400
81399
|
});
|
|
81401
81400
|
|
|
@@ -81454,41 +81453,41 @@ var adapters_default = {
|
|
|
81454
81453
|
};
|
|
81455
81454
|
|
|
81456
81455
|
// node_modules/axios/lib/core/dispatchRequest.js
|
|
81457
|
-
function throwIfCancellationRequested(
|
|
81458
|
-
if (
|
|
81459
|
-
|
|
81456
|
+
function throwIfCancellationRequested(config2) {
|
|
81457
|
+
if (config2.cancelToken) {
|
|
81458
|
+
config2.cancelToken.throwIfRequested();
|
|
81460
81459
|
}
|
|
81461
|
-
if (
|
|
81462
|
-
throw new CanceledError_default(null,
|
|
81460
|
+
if (config2.signal && config2.signal.aborted) {
|
|
81461
|
+
throw new CanceledError_default(null, config2);
|
|
81463
81462
|
}
|
|
81464
81463
|
}
|
|
81465
|
-
function dispatchRequest(
|
|
81466
|
-
throwIfCancellationRequested(
|
|
81467
|
-
|
|
81468
|
-
|
|
81469
|
-
|
|
81470
|
-
|
|
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
|
|
81471
81470
|
);
|
|
81472
|
-
if (["post", "put", "patch"].indexOf(
|
|
81473
|
-
|
|
81471
|
+
if (["post", "put", "patch"].indexOf(config2.method) !== -1) {
|
|
81472
|
+
config2.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
81474
81473
|
}
|
|
81475
|
-
const adapter = adapters_default.getAdapter(
|
|
81476
|
-
return adapter(
|
|
81477
|
-
throwIfCancellationRequested(
|
|
81474
|
+
const adapter = adapters_default.getAdapter(config2.adapter || defaults_default.adapter);
|
|
81475
|
+
return adapter(config2).then(function onAdapterResolution(response) {
|
|
81476
|
+
throwIfCancellationRequested(config2);
|
|
81478
81477
|
response.data = transformData.call(
|
|
81479
|
-
|
|
81480
|
-
|
|
81478
|
+
config2,
|
|
81479
|
+
config2.transformResponse,
|
|
81481
81480
|
response
|
|
81482
81481
|
);
|
|
81483
81482
|
response.headers = AxiosHeaders_default.from(response.headers);
|
|
81484
81483
|
return response;
|
|
81485
81484
|
}, function onAdapterRejection(reason) {
|
|
81486
81485
|
if (!isCancel(reason)) {
|
|
81487
|
-
throwIfCancellationRequested(
|
|
81486
|
+
throwIfCancellationRequested(config2);
|
|
81488
81487
|
if (reason && reason.response) {
|
|
81489
81488
|
reason.response.data = transformData.call(
|
|
81490
|
-
|
|
81491
|
-
|
|
81489
|
+
config2,
|
|
81490
|
+
config2.transformResponse,
|
|
81492
81491
|
reason.response
|
|
81493
81492
|
);
|
|
81494
81493
|
reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
|
|
@@ -81580,9 +81579,9 @@ var Axios = class {
|
|
|
81580
81579
|
*
|
|
81581
81580
|
* @returns {Promise} The Promise to be fulfilled
|
|
81582
81581
|
*/
|
|
81583
|
-
async request(configOrUrl,
|
|
81582
|
+
async request(configOrUrl, config2) {
|
|
81584
81583
|
try {
|
|
81585
|
-
return await this._request(configOrUrl,
|
|
81584
|
+
return await this._request(configOrUrl, config2);
|
|
81586
81585
|
} catch (err) {
|
|
81587
81586
|
if (err instanceof Error) {
|
|
81588
81587
|
let dummy = {};
|
|
@@ -81600,15 +81599,15 @@ var Axios = class {
|
|
|
81600
81599
|
throw err;
|
|
81601
81600
|
}
|
|
81602
81601
|
}
|
|
81603
|
-
_request(configOrUrl,
|
|
81602
|
+
_request(configOrUrl, config2) {
|
|
81604
81603
|
if (typeof configOrUrl === "string") {
|
|
81605
|
-
|
|
81606
|
-
|
|
81604
|
+
config2 = config2 || {};
|
|
81605
|
+
config2.url = configOrUrl;
|
|
81607
81606
|
} else {
|
|
81608
|
-
|
|
81607
|
+
config2 = configOrUrl || {};
|
|
81609
81608
|
}
|
|
81610
|
-
|
|
81611
|
-
const { transitional: transitional2, paramsSerializer, headers } =
|
|
81609
|
+
config2 = mergeConfig(this.defaults, config2);
|
|
81610
|
+
const { transitional: transitional2, paramsSerializer, headers } = config2;
|
|
81612
81611
|
if (transitional2 !== void 0) {
|
|
81613
81612
|
validator_default.assertOptions(transitional2, {
|
|
81614
81613
|
silentJSONParsing: validators2.transitional(validators2.boolean),
|
|
@@ -81618,7 +81617,7 @@ var Axios = class {
|
|
|
81618
81617
|
}
|
|
81619
81618
|
if (paramsSerializer != null) {
|
|
81620
81619
|
if (utils_default.isFunction(paramsSerializer)) {
|
|
81621
|
-
|
|
81620
|
+
config2.paramsSerializer = {
|
|
81622
81621
|
serialize: paramsSerializer
|
|
81623
81622
|
};
|
|
81624
81623
|
} else {
|
|
@@ -81628,14 +81627,14 @@ var Axios = class {
|
|
|
81628
81627
|
}, true);
|
|
81629
81628
|
}
|
|
81630
81629
|
}
|
|
81631
|
-
validator_default.assertOptions(
|
|
81630
|
+
validator_default.assertOptions(config2, {
|
|
81632
81631
|
baseUrl: validators2.spelling("baseURL"),
|
|
81633
81632
|
withXsrfToken: validators2.spelling("withXSRFToken")
|
|
81634
81633
|
}, true);
|
|
81635
|
-
|
|
81634
|
+
config2.method = (config2.method || this.defaults.method || "get").toLowerCase();
|
|
81636
81635
|
let contextHeaders = headers && utils_default.merge(
|
|
81637
81636
|
headers.common,
|
|
81638
|
-
headers[
|
|
81637
|
+
headers[config2.method]
|
|
81639
81638
|
);
|
|
81640
81639
|
headers && utils_default.forEach(
|
|
81641
81640
|
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
@@ -81643,11 +81642,11 @@ var Axios = class {
|
|
|
81643
81642
|
delete headers[method];
|
|
81644
81643
|
}
|
|
81645
81644
|
);
|
|
81646
|
-
|
|
81645
|
+
config2.headers = AxiosHeaders_default.concat(contextHeaders, headers);
|
|
81647
81646
|
const requestInterceptorChain = [];
|
|
81648
81647
|
let synchronousRequestInterceptors = true;
|
|
81649
81648
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
81650
|
-
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(
|
|
81649
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config2) === false) {
|
|
81651
81650
|
return;
|
|
81652
81651
|
}
|
|
81653
81652
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
@@ -81665,14 +81664,14 @@ var Axios = class {
|
|
|
81665
81664
|
chain.unshift.apply(chain, requestInterceptorChain);
|
|
81666
81665
|
chain.push.apply(chain, responseInterceptorChain);
|
|
81667
81666
|
len = chain.length;
|
|
81668
|
-
promise = Promise.resolve(
|
|
81667
|
+
promise = Promise.resolve(config2);
|
|
81669
81668
|
while (i < len) {
|
|
81670
81669
|
promise = promise.then(chain[i++], chain[i++]);
|
|
81671
81670
|
}
|
|
81672
81671
|
return promise;
|
|
81673
81672
|
}
|
|
81674
81673
|
len = requestInterceptorChain.length;
|
|
81675
|
-
let newConfig =
|
|
81674
|
+
let newConfig = config2;
|
|
81676
81675
|
i = 0;
|
|
81677
81676
|
while (i < len) {
|
|
81678
81677
|
const onFulfilled = requestInterceptorChain[i++];
|
|
@@ -81696,25 +81695,25 @@ var Axios = class {
|
|
|
81696
81695
|
}
|
|
81697
81696
|
return promise;
|
|
81698
81697
|
}
|
|
81699
|
-
getUri(
|
|
81700
|
-
|
|
81701
|
-
const fullPath = buildFullPath(
|
|
81702
|
-
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);
|
|
81703
81702
|
}
|
|
81704
81703
|
};
|
|
81705
81704
|
utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
81706
|
-
Axios.prototype[method] = function(url2,
|
|
81707
|
-
return this.request(mergeConfig(
|
|
81705
|
+
Axios.prototype[method] = function(url2, config2) {
|
|
81706
|
+
return this.request(mergeConfig(config2 || {}, {
|
|
81708
81707
|
method,
|
|
81709
81708
|
url: url2,
|
|
81710
|
-
data: (
|
|
81709
|
+
data: (config2 || {}).data
|
|
81711
81710
|
}));
|
|
81712
81711
|
};
|
|
81713
81712
|
});
|
|
81714
81713
|
utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
81715
81714
|
function generateHTTPMethod(isForm) {
|
|
81716
|
-
return function httpMethod(url2, data,
|
|
81717
|
-
return this.request(mergeConfig(
|
|
81715
|
+
return function httpMethod(url2, data, config2) {
|
|
81716
|
+
return this.request(mergeConfig(config2 || {}, {
|
|
81718
81717
|
method,
|
|
81719
81718
|
headers: isForm ? {
|
|
81720
81719
|
"Content-Type": "multipart/form-data"
|
|
@@ -81759,11 +81758,11 @@ var CancelToken = class _CancelToken {
|
|
|
81759
81758
|
};
|
|
81760
81759
|
return promise;
|
|
81761
81760
|
};
|
|
81762
|
-
executor(function cancel(message,
|
|
81761
|
+
executor(function cancel(message, config2, request) {
|
|
81763
81762
|
if (token.reason) {
|
|
81764
81763
|
return;
|
|
81765
81764
|
}
|
|
81766
|
-
token.reason = new CanceledError_default(message,
|
|
81765
|
+
token.reason = new CanceledError_default(message, config2, request);
|
|
81767
81766
|
resolvePromise(token.reason);
|
|
81768
81767
|
});
|
|
81769
81768
|
}
|
|
@@ -82431,19 +82430,1002 @@ var PriceUtils = class {
|
|
|
82431
82430
|
return totalMoney * 10n ** BigInt(targetDecimals) * PRICE_DECIMALS / targetPrice / WAD;
|
|
82432
82431
|
}
|
|
82433
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
|
|
82434
83416
|
function rayToNumber(num) {
|
|
82435
83417
|
return Number(toBigInt(num) / 10n ** 21n) / 1e6;
|
|
82436
83418
|
}
|
|
82437
83419
|
function toSignificant(num, decimals2, precision = 6) {
|
|
82438
83420
|
if (num === 1n) return "0";
|
|
82439
|
-
const divider = new
|
|
82440
|
-
const number = new
|
|
83421
|
+
const divider = new Decimal(10).toPower(decimals2);
|
|
83422
|
+
const number = new Decimal(num.toString()).div(divider);
|
|
82441
83423
|
return number.toSignificantDigits(precision, 4).toString();
|
|
82442
83424
|
}
|
|
82443
83425
|
function toBN(num, decimals2) {
|
|
82444
83426
|
if (num === "") return 0n;
|
|
82445
|
-
const multiplier = new
|
|
82446
|
-
const number = new
|
|
83427
|
+
const multiplier = new Decimal(10).toPower(decimals2);
|
|
83428
|
+
const number = new Decimal(num).mul(multiplier);
|
|
82447
83429
|
return BigInt(number.toFixed(0));
|
|
82448
83430
|
}
|
|
82449
83431
|
function shortAddress(address) {
|
|
@@ -87742,7 +88724,7 @@ var POOL_REWARDS_ABI = [
|
|
|
87742
88724
|
|
|
87743
88725
|
// src/sdk/sdk-legacy/gearboxRewards/apy.ts
|
|
87744
88726
|
var PERCENTAGE_FACTOR_1KK = PERCENTAGE_DECIMALS * PERCENTAGE_FACTOR;
|
|
87745
|
-
var
|
|
88727
|
+
var ONE2 = PERCENTAGE_FACTOR_1KK * 10n;
|
|
87746
88728
|
var GearboxRewardsApy = class {
|
|
87747
88729
|
static getPoolExtraAPY_V3({
|
|
87748
88730
|
rewardPoolsInfo,
|
|
@@ -87823,7 +88805,7 @@ var GearboxRewardsApy = class {
|
|
|
87823
88805
|
reward.decimals
|
|
87824
88806
|
);
|
|
87825
88807
|
const durationRatio = toBigInt(SECONDS_PER_YEAR) * WAD / info.duration;
|
|
87826
|
-
const apyBn = rewardMoney *
|
|
88808
|
+
const apyBn = rewardMoney * ONE2 / supplyMoney * durationRatio / WAD;
|
|
87827
88809
|
return Math.round(Number(apyBn) / 10);
|
|
87828
88810
|
}
|
|
87829
88811
|
static getCAExtraAPY_V3({
|