@swapkit/helpers 1.0.0-rc.70 → 1.0.0-rc.71
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +167 -144
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/modules/__tests__/assetValue.test.ts +87 -0
- package/src/modules/assetValue.ts +39 -1
package/dist/index.es.js
CHANGED
|
@@ -10,11 +10,11 @@ var O = (e, t, n) => {
|
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
12
|
var T = (e, t, n) => (Ve(e, t, "access private method"), n);
|
|
13
|
-
import { FeeOption as Y, BaseDecimal as d, Chain as l, EVMChainList as Be, ChainToRPC as Ue, MemoType as
|
|
13
|
+
import { FeeOption as Y, BaseDecimal as d, Chain as l, EVMChainList as Be, ChainToRPC as Ue, MemoType as I, ChainToChainId as Le } from "@swapkit/types";
|
|
14
14
|
var u = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_MAX_500 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.SWAP_AMOUNT_TOO_LOW = "2012", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(u || {});
|
|
15
15
|
u.INVALID_INPUT_PARAMETERS + "", u.UNKNOWN_PROVIDERS + "", u.CANNOT_FIND_INBOUND_ADDRESS + "", u.NO_INBOUND_ADDRESSES + "", u.CHAIN_HALTED_OR_UNSUPPORTED + "", u.MISSING_INPUT_PARAMETER + "", u.INVALID_TYPE_GENERIC + "", u.INVALID_NUMBER_STRING + "", u.INVALID_NUMBER + "", u.INVALID_BOOLEAN + "", u.INVALID_OBJECT + "", u.INVALID_ARRAY + "", u.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", u.SELL_BUY_ASSETS_ARE_THE_SAME + "", u.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", u.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", u.AFF_ADDRESS_TOO_LONG + "", u.AFF_BPS_INTEGER_MAX_500 + "", u.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", u.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", u.PREFERRED_PROVIDER_NOT_SUPPORTED + "", u.SOURCE_ADDRESS_SMART_CONTRACT + "", u.SWAP_AMOUNT_TOO_LOW + "", u.DESTINATION_ADDRESS_SMART_CONTRACT + "", u.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", u.INVALID_PROVIDER + "", u.MISSING_CROSS_CHAIN_PROVIDER + "", u.MISSING_AVAX_PROVIDER + "", u.MISSING_BSC_PROVIDER + "", u.MISSING_ETH_PROVIDER + "", u.MISSING_ARB_PROVIDER + "", u.INVALID_PROVIDER_FOR_SWAP_OUT + "", u.INVALID_CHAIN + "", u.INVALID_ASSET + "", u.UNSUPPORTED_CHAIN + "", u.UNSUPPORTED_ASSET + "", u.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", u.THORNODE_QUOTE_GENERIC_ERROR + "", u.INVALID_SOURCE_ADDRESS + "", u.INVALID_DESTINATION_ADDRESS + "", u.NOT_ENOUGH_SYNTH_BALANCE + "", u.SYNTH_MINTING_CAP_REACHED + "", u.INVALID_QUOTE_MODE + "", u.NO_QUOTES + "", u.SERVICE_UNAVAILABLE_GENERIC + "", u.MISSING_GAS_DATA_GENERIC + "", u.MISSING_TOKEN_INFO_GENERIC + "", u.CANT_FIND_TOKEN_LIST + "", u.NO_PRICE + "", u.PRICE_IS_STALE + "", u.ADDRESS_NOT_WHITELISTED + "", u.ADDRESS_ALREADY_CLAIMED + "";
|
|
16
|
-
var j = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(j || {}),
|
|
17
|
-
const q = Object.values(j), $e = Object.keys(j),
|
|
16
|
+
var j = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(j || {}), ne = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(ne || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), f = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(f || {});
|
|
17
|
+
const q = Object.values(j), $e = Object.keys(j), re = q.reduce(
|
|
18
18
|
(e, t) => {
|
|
19
19
|
const n = $e.find((r) => j[r] === t);
|
|
20
20
|
return n && (e[t] = n), e;
|
|
@@ -22,21 +22,21 @@ const q = Object.values(j), $e = Object.keys(j), ne = q.reduce(
|
|
|
22
22
|
{}
|
|
23
23
|
);
|
|
24
24
|
q.reduce(
|
|
25
|
-
(e, t) => (e[t] =
|
|
25
|
+
(e, t) => (e[t] = ne[re[t]], e),
|
|
26
26
|
{}
|
|
27
27
|
);
|
|
28
28
|
q.reduce(
|
|
29
|
-
(e, t) => (e[t] = de[
|
|
29
|
+
(e, t) => (e[t] = de[re[t]], e),
|
|
30
30
|
{}
|
|
31
31
|
);
|
|
32
32
|
q.reduce(
|
|
33
33
|
(e, t) => {
|
|
34
|
-
const n = `${
|
|
35
|
-
return e[t] =
|
|
34
|
+
const n = `${re[t]}Hex`;
|
|
35
|
+
return e[t] = ne[n], e;
|
|
36
36
|
},
|
|
37
37
|
{}
|
|
38
38
|
);
|
|
39
|
-
class
|
|
39
|
+
class ce extends Error {
|
|
40
40
|
constructor(t, n, r) {
|
|
41
41
|
const s = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", a = `${s} ${i}`.trim(), c = a ? `status code ${a}` : "an unknown error";
|
|
42
42
|
super(`Request failed with ${c}`), Object.defineProperty(this, "response", {
|
|
@@ -67,25 +67,25 @@ class Te extends Error {
|
|
|
67
67
|
}), this.name = "TimeoutError", this.request = t;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const x = (e) => e !== null && typeof e == "object", M = (...e) => {
|
|
71
71
|
for (const t of e)
|
|
72
|
-
if ((!
|
|
72
|
+
if ((!x(t) || Array.isArray(t)) && t !== void 0)
|
|
73
73
|
throw new TypeError("The `options` argument must be an object");
|
|
74
|
-
return
|
|
74
|
+
return se({}, ...e);
|
|
75
75
|
}, Ae = (e = {}, t = {}) => {
|
|
76
76
|
const n = new globalThis.Headers(e), r = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
77
77
|
for (const [i, a] of s.entries())
|
|
78
78
|
r && a === "undefined" || a === void 0 ? n.delete(i) : n.set(i, a);
|
|
79
79
|
return n;
|
|
80
|
-
},
|
|
80
|
+
}, se = (...e) => {
|
|
81
81
|
let t = {}, n = {};
|
|
82
82
|
for (const r of e)
|
|
83
83
|
if (Array.isArray(r))
|
|
84
84
|
Array.isArray(t) || (t = []), t = [...t, ...r];
|
|
85
|
-
else if (
|
|
85
|
+
else if (x(r)) {
|
|
86
86
|
for (let [s, i] of Object.entries(r))
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
x(i) && s in t && (i = se(t[s], i)), t = { ...t, [s]: i };
|
|
88
|
+
x(r.headers) && (n = Ae(n, r.headers), t.headers = n);
|
|
89
89
|
}
|
|
90
90
|
return t;
|
|
91
91
|
}, ve = (() => {
|
|
@@ -99,7 +99,7 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
|
|
|
99
99
|
return e = !0, "half";
|
|
100
100
|
}
|
|
101
101
|
}).headers.has("Content-Type")), e && !t;
|
|
102
|
-
})(), Me = typeof globalThis.AbortController == "function", He = typeof globalThis.ReadableStream == "function",
|
|
102
|
+
})(), Me = typeof globalThis.AbortController == "function", He = typeof globalThis.ReadableStream == "function", xe = typeof globalThis.FormData == "function", pe = ["get", "post", "put", "patch", "head", "delete"], Fe = {
|
|
103
103
|
json: "application/json",
|
|
104
104
|
text: "text/*",
|
|
105
105
|
formData: "multipart/form-data",
|
|
@@ -132,7 +132,7 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
|
|
|
132
132
|
window: !0,
|
|
133
133
|
dispatcher: !0,
|
|
134
134
|
duplex: !0
|
|
135
|
-
}, ke = (e) => pe.includes(e) ? e.toUpperCase() : e, je = ["get", "put", "head", "delete", "options", "trace"], qe = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503],
|
|
135
|
+
}, ke = (e) => pe.includes(e) ? e.toUpperCase() : e, je = ["get", "put", "head", "delete", "options", "trace"], qe = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503], le = {
|
|
136
136
|
limit: 2,
|
|
137
137
|
methods: je,
|
|
138
138
|
statusCodes: qe,
|
|
@@ -143,7 +143,7 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
|
|
|
143
143
|
}, Xe = (e = {}) => {
|
|
144
144
|
if (typeof e == "number")
|
|
145
145
|
return {
|
|
146
|
-
...
|
|
146
|
+
...le,
|
|
147
147
|
limit: e
|
|
148
148
|
};
|
|
149
149
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -151,7 +151,7 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
|
|
|
151
151
|
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
152
152
|
throw new Error("retry.statusCodes must be an array");
|
|
153
153
|
return {
|
|
154
|
-
...
|
|
154
|
+
...le,
|
|
155
155
|
...e,
|
|
156
156
|
afterStatusCodes: me
|
|
157
157
|
};
|
|
@@ -183,9 +183,9 @@ const Je = (e, t) => {
|
|
|
183
183
|
!(r in We) && !(r in Ge) && !(r in e) && (n[r] = t[r]);
|
|
184
184
|
return n;
|
|
185
185
|
};
|
|
186
|
-
class
|
|
186
|
+
class G {
|
|
187
187
|
static create(t, n) {
|
|
188
|
-
const r = new
|
|
188
|
+
const r = new G(t, n), s = async () => {
|
|
189
189
|
if (typeof r._options.timeout == "number" && r._options.timeout > K)
|
|
190
190
|
throw new RangeError(`The \`timeout\` option cannot be greater than ${K}`);
|
|
191
191
|
await Promise.resolve();
|
|
@@ -195,7 +195,7 @@ class x {
|
|
|
195
195
|
o instanceof globalThis.Response && (a = o);
|
|
196
196
|
}
|
|
197
197
|
if (r._decorateResponse(a), !a.ok && r._options.throwHttpErrors) {
|
|
198
|
-
let c = new
|
|
198
|
+
let c = new ce(a, r.request, r._options);
|
|
199
199
|
for (const o of r._options.hooks.beforeError)
|
|
200
200
|
c = await o(c);
|
|
201
201
|
throw c;
|
|
@@ -209,7 +209,7 @@ class x {
|
|
|
209
209
|
}
|
|
210
210
|
return a;
|
|
211
211
|
}, i = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(s) : s();
|
|
212
|
-
for (const [a, c] of Object.entries(
|
|
212
|
+
for (const [a, c] of Object.entries(Fe))
|
|
213
213
|
i[a] = async () => {
|
|
214
214
|
r.request.headers.set("accept", r.request.headers.get("accept") || c);
|
|
215
215
|
const o = (await i).clone();
|
|
@@ -255,7 +255,7 @@ class x {
|
|
|
255
255
|
credentials: this._input.credentials || "same-origin",
|
|
256
256
|
...n,
|
|
257
257
|
headers: Ae(this._input.headers, n.headers),
|
|
258
|
-
hooks:
|
|
258
|
+
hooks: se({
|
|
259
259
|
beforeRequest: [],
|
|
260
260
|
beforeRetry: [],
|
|
261
261
|
beforeError: [],
|
|
@@ -286,13 +286,13 @@ class x {
|
|
|
286
286
|
}
|
|
287
287
|
if (ve && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
288
288
|
const r = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, r);
|
|
289
|
-
(
|
|
289
|
+
(xe && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
|
|
290
290
|
}
|
|
291
291
|
this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
|
|
292
292
|
}
|
|
293
293
|
_calculateRetryDelay(t) {
|
|
294
294
|
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof Te)) {
|
|
295
|
-
if (t instanceof
|
|
295
|
+
if (t instanceof ce) {
|
|
296
296
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
297
297
|
return 0;
|
|
298
298
|
const r = t.response.headers.get("Retry-After");
|
|
@@ -379,29 +379,29 @@ class x {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
/*! MIT License © Sindre Sorhus */
|
|
382
|
-
const
|
|
383
|
-
const t = (n, r) =>
|
|
382
|
+
const z = (e) => {
|
|
383
|
+
const t = (n, r) => G.create(n, M(e, r));
|
|
384
384
|
for (const n of pe)
|
|
385
|
-
t[n] = (r, s) =>
|
|
386
|
-
return t.create = (n) =>
|
|
387
|
-
}, Ee =
|
|
388
|
-
let
|
|
385
|
+
t[n] = (r, s) => G.create(r, M(e, s, { method: n }));
|
|
386
|
+
return t.create = (n) => z(M(n)), t.extend = (n) => z(M(e, n)), t.stop = Se, t;
|
|
387
|
+
}, Ee = z();
|
|
388
|
+
let F;
|
|
389
389
|
const m = {
|
|
390
|
-
CachedPrices: `${
|
|
391
|
-
GasRates: `${
|
|
392
|
-
Quote: `${
|
|
393
|
-
Txn: `${
|
|
394
|
-
TokenlistProviders: `${
|
|
395
|
-
TokenList: `${
|
|
396
|
-
Thorname: `${
|
|
397
|
-
}, Re = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" },
|
|
398
|
-
|
|
390
|
+
CachedPrices: `${f.ThorswapApi}/tokenlist/cached-price`,
|
|
391
|
+
GasRates: `${f.ThorswapApi}/resource-worker/gasPrice/getAll`,
|
|
392
|
+
Quote: `${f.ThorswapApi}/aggregator/tokens/quote`,
|
|
393
|
+
Txn: `${f.ThorswapApi}/apiusage/v2/txn`,
|
|
394
|
+
TokenlistProviders: `${f.ThorswapApi}/tokenlist/providers`,
|
|
395
|
+
TokenList: `${f.ThorswapStatic}/token-list`,
|
|
396
|
+
Thorname: `${f.ThorswapApi}/thorname`
|
|
397
|
+
}, Re = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, ue = () => F || (F = Ee.create({ headers: Re }), F), mt = ({ apiKey: e, ...t }) => {
|
|
398
|
+
F = Ee.create({
|
|
399
399
|
...t,
|
|
400
400
|
headers: { ...Re, ...t.headers, "x-api-key": e }
|
|
401
401
|
});
|
|
402
402
|
}, S = {
|
|
403
|
-
get: (e, t) =>
|
|
404
|
-
post: (e, t) =>
|
|
403
|
+
get: (e, t) => ue().get(e, t).json(),
|
|
404
|
+
post: (e, t) => ue().post(e, t).json()
|
|
405
405
|
}, Qe = ({ tokens: e, ...t }) => {
|
|
406
406
|
const n = new URLSearchParams();
|
|
407
407
|
return e.filter((r, s, i) => i.findIndex((a) => a === r) === s).forEach((r) => n.append("tokens", JSON.stringify(r))), t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), S.post(m.CachedPrices, {
|
|
@@ -558,8 +558,8 @@ function _t({
|
|
|
558
558
|
poolUnits: t,
|
|
559
559
|
assetDepth: n
|
|
560
560
|
}) {
|
|
561
|
-
const r = A(e), s = A(t), i = A(n), a = r.mul(i), c = s.mul(s).mul(2), o = s.mul(r).mul(2), _ = r.mul(r), h = a.mul(c.sub(o).add(_)),
|
|
562
|
-
return h.div(
|
|
561
|
+
const r = A(e), s = A(t), i = A(n), a = r.mul(i), c = s.mul(s).mul(2), o = s.mul(r).mul(2), _ = r.mul(r), h = a.mul(c.sub(o).add(_)), y = s.mul(s).mul(s);
|
|
562
|
+
return h.div(y);
|
|
563
563
|
}
|
|
564
564
|
function Nt({
|
|
565
565
|
percent: e,
|
|
@@ -578,7 +578,7 @@ function Ct({
|
|
|
578
578
|
return _t({ assetDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
|
|
579
579
|
}
|
|
580
580
|
function A(e) {
|
|
581
|
-
return
|
|
581
|
+
return E.fromBigInt(BigInt(e), d.THOR);
|
|
582
582
|
}
|
|
583
583
|
function ht({
|
|
584
584
|
liquidityUnits: e,
|
|
@@ -612,8 +612,8 @@ function Ot({
|
|
|
612
612
|
runeAmount: s,
|
|
613
613
|
assetAmount: i
|
|
614
614
|
}) {
|
|
615
|
-
const a = new
|
|
616
|
-
if (
|
|
615
|
+
const a = new E({ value: e, decimal: 8 }), c = new E({ value: n, decimal: 8 }), o = new E({ value: t, decimal: 8 }), _ = new E({ value: s, decimal: 8 }), h = new E({ value: i, decimal: 8 }), y = _.mul(c), ae = h.mul(a), ge = _.mul(h), Oe = a.mul(c), De = o.mul(y.add(ae.add(ge.mul(2)))), Pe = y.add(ae.add(Oe.mul(2))), oe = De.div(Pe), X = A(r).add(oe);
|
|
616
|
+
if (oe.getBaseValue("number") === 0)
|
|
617
617
|
return X.div(o).getBaseValue("number");
|
|
618
618
|
const be = o.add(X);
|
|
619
619
|
return X.div(be).getBaseValue("number");
|
|
@@ -631,20 +631,20 @@ function Dt({
|
|
|
631
631
|
}
|
|
632
632
|
const Pt = (e, t) => {
|
|
633
633
|
switch (e) {
|
|
634
|
-
case
|
|
635
|
-
case
|
|
634
|
+
case I.LEAVE:
|
|
635
|
+
case I.BOND: {
|
|
636
636
|
const { address: n } = t;
|
|
637
637
|
return `${e}:${n}`;
|
|
638
638
|
}
|
|
639
|
-
case
|
|
639
|
+
case I.UNBOND: {
|
|
640
640
|
const { address: n, unbondAmount: r } = t;
|
|
641
641
|
return `${e}:${n}:${r}`;
|
|
642
642
|
}
|
|
643
|
-
case
|
|
643
|
+
case I.THORNAME_REGISTER: {
|
|
644
644
|
const { name: n, chain: r, address: s, owner: i } = t;
|
|
645
645
|
return `${e}:${n}:${r}:${s}${i ? `:${i}` : ""}`;
|
|
646
646
|
}
|
|
647
|
-
case
|
|
647
|
+
case I.DEPOSIT: {
|
|
648
648
|
const { chain: n, symbol: r, address: s, singleSide: i } = t;
|
|
649
649
|
return i ? `${e}:${n}/${r}` : `${e}:${((c, o) => {
|
|
650
650
|
switch (c) {
|
|
@@ -659,12 +659,12 @@ const Pt = (e, t) => {
|
|
|
659
659
|
}
|
|
660
660
|
})(n, r)}:${s || ""}`;
|
|
661
661
|
}
|
|
662
|
-
case
|
|
662
|
+
case I.WITHDRAW: {
|
|
663
663
|
const { chain: n, ticker: r, symbol: s, basisPoints: i, targetAssetString: a, singleSide: c } = t, o = n === "ETH" && r !== "ETH" ? `${r}-${s.slice(-3)}` : s, _ = !c && a ? `:${a}` : "";
|
|
664
664
|
return `${e}:${n}${c ? "/" : "."}${o}:${i}${_}`;
|
|
665
665
|
}
|
|
666
|
-
case
|
|
667
|
-
case
|
|
666
|
+
case I.OPEN_LOAN:
|
|
667
|
+
case I.CLOSE_LOAN: {
|
|
668
668
|
const { asset: n, address: r } = t;
|
|
669
669
|
return `${e}:${n}:${r}`;
|
|
670
670
|
}
|
|
@@ -686,23 +686,23 @@ function yt(e) {
|
|
|
686
686
|
function wt([e, t, n, r, s]) {
|
|
687
687
|
return `${e}'/${t}'/${n}'/${r}${typeof s != "number" ? "" : `/${s}`}`;
|
|
688
688
|
}
|
|
689
|
-
const
|
|
689
|
+
const _e = [...Object.values(l), "TERRA"];
|
|
690
690
|
function dt(e = "") {
|
|
691
691
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
692
|
-
if (
|
|
692
|
+
if (_e.includes(n))
|
|
693
693
|
return !0;
|
|
694
694
|
const [r] = t.split("/");
|
|
695
|
-
if (
|
|
695
|
+
if (_e.includes(r))
|
|
696
696
|
return !0;
|
|
697
697
|
throw new Error(
|
|
698
698
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
699
699
|
);
|
|
700
700
|
}
|
|
701
|
-
const
|
|
702
|
-
function
|
|
701
|
+
const U = 8, C = (e) => 10n ** BigInt(e), w = (e) => Math.log10(parseFloat(e.toString()));
|
|
702
|
+
function W({
|
|
703
703
|
value: e,
|
|
704
|
-
bigIntDecimal: t =
|
|
705
|
-
decimal: n =
|
|
704
|
+
bigIntDecimal: t = U,
|
|
705
|
+
decimal: n = U
|
|
706
706
|
}) {
|
|
707
707
|
if (n === 0)
|
|
708
708
|
return e.toString();
|
|
@@ -717,24 +717,24 @@ function G({
|
|
|
717
717
|
""
|
|
718
718
|
);
|
|
719
719
|
}
|
|
720
|
-
var
|
|
721
|
-
const
|
|
720
|
+
var g, V, N, D, k, Ne, $, Z, v, ee;
|
|
721
|
+
const ie = class ie {
|
|
722
722
|
constructor(t) {
|
|
723
|
-
O(this,
|
|
724
|
-
O(this,
|
|
723
|
+
O(this, g);
|
|
724
|
+
O(this, N);
|
|
725
725
|
O(this, k);
|
|
726
|
-
O(this,
|
|
727
|
-
O(this,
|
|
726
|
+
O(this, $);
|
|
727
|
+
O(this, v);
|
|
728
728
|
p(this, "decimalMultiplier", 10n ** 8n);
|
|
729
729
|
p(this, "bigIntValue", 0n);
|
|
730
730
|
p(this, "decimal");
|
|
731
|
-
const n =
|
|
732
|
-
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier :
|
|
731
|
+
const n = te(t), r = typeof t == "object";
|
|
732
|
+
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : C(Math.max(he(H(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
|
|
733
733
|
}
|
|
734
734
|
static fromBigInt(t, n) {
|
|
735
|
-
return new
|
|
735
|
+
return new ie({
|
|
736
736
|
decimal: n,
|
|
737
|
-
value:
|
|
737
|
+
value: W({ value: t, bigIntDecimal: n, decimal: n })
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
740
|
static shiftDecimals({
|
|
@@ -743,7 +743,7 @@ const se = class se {
|
|
|
743
743
|
to: r
|
|
744
744
|
}) {
|
|
745
745
|
return this.fromBigInt(
|
|
746
|
-
t.getBaseValue("bigint") *
|
|
746
|
+
t.getBaseValue("bigint") * C(r) / C(n),
|
|
747
747
|
r
|
|
748
748
|
);
|
|
749
749
|
}
|
|
@@ -751,37 +751,37 @@ const se = class se {
|
|
|
751
751
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
752
752
|
}
|
|
753
753
|
add(...t) {
|
|
754
|
-
return T(this,
|
|
754
|
+
return T(this, g, V).call(this, "add", ...t);
|
|
755
755
|
}
|
|
756
756
|
sub(...t) {
|
|
757
|
-
return T(this,
|
|
757
|
+
return T(this, g, V).call(this, "sub", ...t);
|
|
758
758
|
}
|
|
759
759
|
mul(...t) {
|
|
760
|
-
return T(this,
|
|
760
|
+
return T(this, g, V).call(this, "mul", ...t);
|
|
761
761
|
}
|
|
762
762
|
div(...t) {
|
|
763
|
-
return T(this,
|
|
763
|
+
return T(this, g, V).call(this, "div", ...t);
|
|
764
764
|
}
|
|
765
765
|
gt(t) {
|
|
766
|
-
return T(this,
|
|
766
|
+
return T(this, N, D).call(this, "gt", t);
|
|
767
767
|
}
|
|
768
768
|
gte(t) {
|
|
769
|
-
return T(this,
|
|
769
|
+
return T(this, N, D).call(this, "gte", t);
|
|
770
770
|
}
|
|
771
771
|
lt(t) {
|
|
772
|
-
return T(this,
|
|
772
|
+
return T(this, N, D).call(this, "lt", t);
|
|
773
773
|
}
|
|
774
774
|
lte(t) {
|
|
775
|
-
return T(this,
|
|
775
|
+
return T(this, N, D).call(this, "lte", t);
|
|
776
776
|
}
|
|
777
777
|
eqValue(t) {
|
|
778
|
-
return T(this,
|
|
778
|
+
return T(this, N, D).call(this, "eqValue", t);
|
|
779
779
|
}
|
|
780
780
|
// @ts-expect-error False positive
|
|
781
781
|
getValue(t) {
|
|
782
782
|
const n = this.formatBigIntToSafeValue(
|
|
783
783
|
this.bigIntValue,
|
|
784
|
-
this.decimal ||
|
|
784
|
+
this.decimal || w(this.decimalMultiplier)
|
|
785
785
|
);
|
|
786
786
|
switch (t) {
|
|
787
787
|
case "number":
|
|
@@ -794,7 +794,7 @@ const se = class se {
|
|
|
794
794
|
}
|
|
795
795
|
// @ts-expect-error
|
|
796
796
|
getBaseValue(t) {
|
|
797
|
-
const n = this.decimalMultiplier /
|
|
797
|
+
const n = this.decimalMultiplier / C(this.decimal || d.THOR), r = this.bigIntValue / n;
|
|
798
798
|
switch (t) {
|
|
799
799
|
case "number":
|
|
800
800
|
return Number(r);
|
|
@@ -807,8 +807,8 @@ const se = class se {
|
|
|
807
807
|
getBigIntValue(t, n) {
|
|
808
808
|
if (!n && typeof t == "object")
|
|
809
809
|
return t.bigIntValue;
|
|
810
|
-
const r =
|
|
811
|
-
return s === "0" || s === "undefined" ? 0n : T(this,
|
|
810
|
+
const r = te(t), s = H(r);
|
|
811
|
+
return s === "0" || s === "undefined" ? 0n : T(this, v, ee).call(this, s, n);
|
|
812
812
|
}
|
|
813
813
|
toSignificant(t = 6) {
|
|
814
814
|
const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
|
|
@@ -854,9 +854,9 @@ const se = class se {
|
|
|
854
854
|
return `${n === "start" ? t : ""}${h}${n === "end" ? t : ""}`;
|
|
855
855
|
}
|
|
856
856
|
formatBigIntToSafeValue(t, n) {
|
|
857
|
-
const r = n || this.decimal ||
|
|
857
|
+
const r = n || this.decimal || U, s = Math.max(
|
|
858
858
|
r,
|
|
859
|
-
|
|
859
|
+
w(this.decimalMultiplier)
|
|
860
860
|
), i = t < 0n, a = t.toString().substring(i ? 1 : 0), c = s - (a.length - 1), o = c > 0 ? "0".repeat(c) + a : a, _ = o.length - s;
|
|
861
861
|
let h = o.slice(-s);
|
|
862
862
|
return parseInt(h[r]) >= 5 ? h = `${h.substring(0, r - 1)}${(parseInt(h[r - 1]) + 1).toString()}` : h = h.substring(0, r), `${i ? "-" : ""}${o.slice(
|
|
@@ -865,8 +865,8 @@ const se = class se {
|
|
|
865
865
|
)}.${h}`.replace(/\.?0*$/, "");
|
|
866
866
|
}
|
|
867
867
|
};
|
|
868
|
-
|
|
869
|
-
const r = T(this,
|
|
868
|
+
g = new WeakSet(), V = function(t, ...n) {
|
|
869
|
+
const r = T(this, $, Z).call(this, this, ...n), s = Math.max(r, w(this.decimalMultiplier)), i = C(s), a = n.reduce(
|
|
870
870
|
(o, _) => {
|
|
871
871
|
const h = this.getBigIntValue(_, s);
|
|
872
872
|
switch (t) {
|
|
@@ -887,19 +887,19 @@ C = new WeakSet(), y = function(t, ...n) {
|
|
|
887
887
|
},
|
|
888
888
|
//normalize is to precision multiplier base
|
|
889
889
|
this.bigIntValue * i / this.decimalMultiplier
|
|
890
|
-
), c =
|
|
890
|
+
), c = W({
|
|
891
891
|
bigIntDecimal: s,
|
|
892
892
|
decimal: s,
|
|
893
893
|
value: a
|
|
894
894
|
});
|
|
895
895
|
return new this.constructor({
|
|
896
|
-
decimalMultiplier:
|
|
896
|
+
decimalMultiplier: C(s),
|
|
897
897
|
decimal: this.decimal,
|
|
898
898
|
value: c,
|
|
899
899
|
identifier: this.toString()
|
|
900
900
|
});
|
|
901
|
-
},
|
|
902
|
-
const r = T(this,
|
|
901
|
+
}, N = new WeakSet(), D = function(t, ...n) {
|
|
902
|
+
const r = T(this, $, Z).call(this, this, ...n), s = this.getBigIntValue(n[0], r), i = this.getBigIntValue(this, r);
|
|
903
903
|
switch (t) {
|
|
904
904
|
case "gt":
|
|
905
905
|
return i > s;
|
|
@@ -913,34 +913,45 @@ C = new WeakSet(), y = function(t, ...n) {
|
|
|
913
913
|
return i === s;
|
|
914
914
|
}
|
|
915
915
|
}, k = new WeakSet(), Ne = function(t) {
|
|
916
|
-
const n =
|
|
917
|
-
this.bigIntValue = T(this,
|
|
918
|
-
},
|
|
919
|
-
const n = t.map((r) => typeof r == "object" ? r.decimal ||
|
|
920
|
-
return Math.max(...n,
|
|
921
|
-
},
|
|
922
|
-
const r = n ?
|
|
916
|
+
const n = H(t) || "0";
|
|
917
|
+
this.bigIntValue = T(this, v, ee).call(this, n);
|
|
918
|
+
}, $ = new WeakSet(), Z = function(...t) {
|
|
919
|
+
const n = t.map((r) => typeof r == "object" ? r.decimal || w(r.decimalMultiplier) : he(H(r))).filter(Boolean);
|
|
920
|
+
return Math.max(...n, U);
|
|
921
|
+
}, v = new WeakSet(), ee = function(t, n) {
|
|
922
|
+
const r = n ? C(n) : this.decimalMultiplier, s = w(r), [i = "", a = ""] = t.split(".");
|
|
923
923
|
return BigInt(`${i}${a.padEnd(s, "0")}`);
|
|
924
924
|
};
|
|
925
|
-
let
|
|
925
|
+
let L = ie;
|
|
926
926
|
const Tt = Intl.NumberFormat("fullwide", {
|
|
927
927
|
useGrouping: !1,
|
|
928
928
|
maximumFractionDigits: 20
|
|
929
929
|
});
|
|
930
|
-
function
|
|
931
|
-
const n = `${typeof e == "number" ? Tt.format(e) :
|
|
930
|
+
function H(e) {
|
|
931
|
+
const n = `${typeof e == "number" ? Tt.format(e) : te(e)}`.replaceAll(",", ".").split(".");
|
|
932
932
|
return n.length > 1 ? `${n.slice(0, -1).join("")}.${n.at(-1)}` : n[0];
|
|
933
933
|
}
|
|
934
|
-
function
|
|
934
|
+
function he(e) {
|
|
935
935
|
var n;
|
|
936
936
|
const t = ((n = e.split(".")[1]) == null ? void 0 : n.length) || 0;
|
|
937
|
-
return Math.max(t,
|
|
937
|
+
return Math.max(t, U);
|
|
938
938
|
}
|
|
939
|
-
function
|
|
939
|
+
function te(e) {
|
|
940
940
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
941
941
|
}
|
|
942
|
-
|
|
943
|
-
|
|
942
|
+
class E extends L {
|
|
943
|
+
eq(t) {
|
|
944
|
+
return this.eqValue(t);
|
|
945
|
+
}
|
|
946
|
+
static fromBigInt(t, n) {
|
|
947
|
+
return new E({
|
|
948
|
+
decimal: n,
|
|
949
|
+
value: W({ value: t, bigIntDecimal: n, decimal: n })
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
const P = /* @__PURE__ */ new Map();
|
|
954
|
+
class R extends L {
|
|
944
955
|
constructor({
|
|
945
956
|
value: n,
|
|
946
957
|
decimal: r,
|
|
@@ -958,7 +969,7 @@ class g extends W {
|
|
|
958
969
|
p(this, "tax");
|
|
959
970
|
p(this, "ticker");
|
|
960
971
|
p(this, "type");
|
|
961
|
-
const o =
|
|
972
|
+
const o = B(c || `${i}.${a}`);
|
|
962
973
|
this.type = ot(o), this.tax = s, this.chain = o.chain, this.ticker = o.ticker, this.symbol = o.symbol, this.address = o.address, this.isSynthetic = o.isSynthetic, this.isGasAsset = o.isGasAsset;
|
|
963
974
|
}
|
|
964
975
|
toString() {
|
|
@@ -990,33 +1001,56 @@ class g extends W {
|
|
|
990
1001
|
return J(n, r);
|
|
991
1002
|
}
|
|
992
1003
|
static fromStringSync(n, r = 0) {
|
|
993
|
-
const { chain: s, isSynthetic: i } =
|
|
1004
|
+
const { chain: s, isSynthetic: i } = B(n), a = P.get(n.toUpperCase());
|
|
994
1005
|
if (i)
|
|
995
|
-
return
|
|
1006
|
+
return Q(n, r);
|
|
996
1007
|
const { tax: c, decimal: o, identifier: _ } = a || {
|
|
997
1008
|
decimal: d[s],
|
|
998
1009
|
identifier: n
|
|
999
1010
|
};
|
|
1000
|
-
return new
|
|
1011
|
+
return new R({
|
|
1001
1012
|
tax: c,
|
|
1002
|
-
value:
|
|
1013
|
+
value: b(r, o),
|
|
1003
1014
|
identifier: i ? n : _,
|
|
1004
1015
|
decimal: i ? 8 : o
|
|
1005
1016
|
});
|
|
1006
1017
|
}
|
|
1018
|
+
static async fromStringWithBase(n, r = 0, s = d.THOR) {
|
|
1019
|
+
const i = L.shiftDecimals({
|
|
1020
|
+
value: E.fromBigInt(BigInt(r)),
|
|
1021
|
+
from: 0,
|
|
1022
|
+
to: s
|
|
1023
|
+
}).getBaseValue("string");
|
|
1024
|
+
return (await R.fromString(n, r)).set(i);
|
|
1025
|
+
}
|
|
1026
|
+
static fromStringWithBaseSync(n, r = 0, s = d.THOR) {
|
|
1027
|
+
const { chain: i, isSynthetic: a } = B(n), c = P.get(n.toUpperCase());
|
|
1028
|
+
if (a)
|
|
1029
|
+
return Q(n, r);
|
|
1030
|
+
const { tax: o, decimal: _, identifier: h } = c || {
|
|
1031
|
+
decimal: d[i],
|
|
1032
|
+
identifier: n
|
|
1033
|
+
};
|
|
1034
|
+
return new R({
|
|
1035
|
+
tax: o,
|
|
1036
|
+
value: b(BigInt(r), s),
|
|
1037
|
+
identifier: h,
|
|
1038
|
+
decimal: _
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1007
1041
|
static fromIdentifierSync(n, r = 0) {
|
|
1008
|
-
const { chain: s, isSynthetic: i } =
|
|
1042
|
+
const { chain: s, isSynthetic: i } = B(n), a = P.get(n);
|
|
1009
1043
|
if (i)
|
|
1010
|
-
return
|
|
1044
|
+
return Q(n, r);
|
|
1011
1045
|
const { tax: c, decimal: o, identifier: _ } = a || {
|
|
1012
1046
|
decimal: d[s],
|
|
1013
1047
|
identifier: n
|
|
1014
1048
|
};
|
|
1015
|
-
return new
|
|
1049
|
+
return new R({ tax: c, decimal: o, identifier: _, value: b(r, o) });
|
|
1016
1050
|
}
|
|
1017
1051
|
static fromChainOrSignature(n, r = 0) {
|
|
1018
1052
|
const { decimal: s, identifier: i } = at(n);
|
|
1019
|
-
return new
|
|
1053
|
+
return new R({ value: b(r, s), decimal: s, identifier: i });
|
|
1020
1054
|
}
|
|
1021
1055
|
static loadStaticAssets() {
|
|
1022
1056
|
return new Promise(
|
|
@@ -1026,7 +1060,7 @@ class g extends W {
|
|
|
1026
1060
|
Object.values(s).forEach((i) => {
|
|
1027
1061
|
var a;
|
|
1028
1062
|
(a = i == null ? void 0 : i.tokens) == null || a.forEach(({ identifier: c, chain: o, ..._ }) => {
|
|
1029
|
-
|
|
1063
|
+
P.set(c.toUpperCase(), {
|
|
1030
1064
|
identifier: c,
|
|
1031
1065
|
decimal: "decimals" in _ ? _.decimals : d[o]
|
|
1032
1066
|
});
|
|
@@ -1044,7 +1078,7 @@ class g extends W {
|
|
|
1044
1078
|
}
|
|
1045
1079
|
}
|
|
1046
1080
|
function Vt(e) {
|
|
1047
|
-
const t =
|
|
1081
|
+
const t = R.fromChainOrSignature(e);
|
|
1048
1082
|
switch (e) {
|
|
1049
1083
|
case l.Bitcoin:
|
|
1050
1084
|
case l.Litecoin:
|
|
@@ -1066,23 +1100,23 @@ function Vt(e) {
|
|
|
1066
1100
|
}
|
|
1067
1101
|
async function J(e, t = 0) {
|
|
1068
1102
|
dt(e);
|
|
1069
|
-
const n =
|
|
1070
|
-
return n ||
|
|
1103
|
+
const n = P.get(e.toUpperCase()), r = (n == null ? void 0 : n.decimal) || await it(B(e));
|
|
1104
|
+
return n || P.set(e.toUpperCase(), { identifier: e, decimal: r }), new R({ decimal: r, value: b(t, r), identifier: e });
|
|
1071
1105
|
}
|
|
1072
|
-
function
|
|
1106
|
+
function Q(e, t = 0) {
|
|
1073
1107
|
const [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1074
1108
|
if (!n || !r)
|
|
1075
1109
|
throw new Error("Invalid asset identifier");
|
|
1076
|
-
return new
|
|
1110
|
+
return new R({
|
|
1077
1111
|
decimal: 8,
|
|
1078
|
-
value:
|
|
1112
|
+
value: b(t, 8),
|
|
1079
1113
|
identifier: `${l.THORChain}.${n}/${r}`
|
|
1080
1114
|
});
|
|
1081
1115
|
}
|
|
1082
|
-
function
|
|
1083
|
-
return typeof e == "bigint" ?
|
|
1116
|
+
function b(e, t) {
|
|
1117
|
+
return typeof e == "bigint" ? W({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1084
1118
|
}
|
|
1085
|
-
function
|
|
1119
|
+
function B(e) {
|
|
1086
1120
|
const t = e.slice(0, 14).includes("/"), [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1087
1121
|
if (t && (!n || !r))
|
|
1088
1122
|
throw new Error("Invalid asset identifier");
|
|
@@ -1165,33 +1199,22 @@ class Ce extends Error {
|
|
|
1165
1199
|
n && console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: At[t], message: t } }), Object.setPrototypeOf(this, Ce.prototype);
|
|
1166
1200
|
}
|
|
1167
1201
|
}
|
|
1168
|
-
class I extends W {
|
|
1169
|
-
eq(t) {
|
|
1170
|
-
return this.eqValue(t);
|
|
1171
|
-
}
|
|
1172
|
-
static fromBigInt(t, n) {
|
|
1173
|
-
return new I({
|
|
1174
|
-
decimal: n,
|
|
1175
|
-
value: G({ value: t, bigIntDecimal: n, decimal: n })
|
|
1176
|
-
});
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
1202
|
export {
|
|
1180
1203
|
m as ApiEndpoints,
|
|
1181
|
-
|
|
1182
|
-
|
|
1204
|
+
R as AssetValue,
|
|
1205
|
+
L as BigIntArithmetics,
|
|
1183
1206
|
S as RequestClient,
|
|
1184
1207
|
et as StreamingSwapProgressStatus,
|
|
1185
1208
|
Et as SwapKitApi,
|
|
1186
1209
|
Ce as SwapKitError,
|
|
1187
|
-
|
|
1210
|
+
E as SwapKitNumber,
|
|
1188
1211
|
ze as TransactionType,
|
|
1189
1212
|
Ze as TxStatus,
|
|
1190
1213
|
It as assetFromString,
|
|
1191
1214
|
Re as defaultRequestHeaders,
|
|
1192
1215
|
wt as derivationPathToString,
|
|
1193
1216
|
ft as filterAssets,
|
|
1194
|
-
|
|
1217
|
+
W as formatBigIntToSafeValue,
|
|
1195
1218
|
Rt as gasFeeMultiplier,
|
|
1196
1219
|
ot as getAssetType,
|
|
1197
1220
|
_t as getAsymmetricAssetShare,
|