@swapkit/helpers 1.0.0-rc.7 → 1.0.0-rc.70
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 +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +94 -73
- package/dist/index.es.js +988 -498
- package/dist/index.es.js.map +1 -0
- package/package.json +16 -13
- package/src/helpers/__tests__/memo.test.ts +3 -3
- package/src/helpers/asset.ts +56 -56
- package/src/helpers/liquidity.ts +46 -38
- package/src/helpers/memo.ts +19 -16
- package/src/helpers/others.ts +6 -54
- package/src/helpers/validators.ts +4 -3
- package/src/index.ts +2 -0
- package/src/modules/__tests__/assetValue.test.ts +145 -38
- package/src/modules/__tests__/bigIntArithmetics.test.ts +30 -0
- package/src/modules/__tests__/swapKitNumber.test.ts +174 -48
- package/src/modules/assetValue.ts +169 -145
- package/src/modules/bigIntArithmetics.ts +185 -116
- package/src/modules/swapKitError.ts +13 -4
- package/src/modules/swapKitNumber.ts +8 -1
- package/src/types.ts +30 -0
package/dist/index.es.js
CHANGED
|
@@ -1,592 +1,1037 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
if (!t.has(
|
|
5
|
-
throw TypeError("Cannot " +
|
|
1
|
+
var ye = Object.defineProperty;
|
|
2
|
+
var we = (e, t, n) => t in e ? ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var p = (e, t, n) => (we(e, typeof t != "symbol" ? t + "" : t, n), n), Ve = (e, t, n) => {
|
|
4
|
+
if (!t.has(e))
|
|
5
|
+
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (t.has(
|
|
7
|
+
var O = (e, t, n) => {
|
|
8
|
+
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
t instanceof WeakSet ? t.add(
|
|
10
|
+
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
import { FeeOption as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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 E, ChainToChainId as Le } from "@swapkit/types";
|
|
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
|
+
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 || {}), te = /* @__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))(te || {}), 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 || {}), R = /* @__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))(R || {});
|
|
17
|
+
const q = Object.values(j), $e = Object.keys(j), ne = q.reduce(
|
|
18
|
+
(e, t) => {
|
|
19
|
+
const n = $e.find((r) => j[r] === t);
|
|
20
|
+
return n && (e[t] = n), e;
|
|
21
|
+
},
|
|
22
|
+
{}
|
|
23
|
+
);
|
|
24
|
+
q.reduce(
|
|
25
|
+
(e, t) => (e[t] = te[ne[t]], e),
|
|
26
|
+
{}
|
|
27
|
+
);
|
|
28
|
+
q.reduce(
|
|
29
|
+
(e, t) => (e[t] = de[ne[t]], e),
|
|
30
|
+
{}
|
|
31
|
+
);
|
|
32
|
+
q.reduce(
|
|
33
|
+
(e, t) => {
|
|
34
|
+
const n = `${ne[t]}Hex`;
|
|
35
|
+
return e[t] = te[n], e;
|
|
36
|
+
},
|
|
37
|
+
{}
|
|
38
|
+
);
|
|
39
|
+
class oe extends Error {
|
|
40
|
+
constructor(t, n, r) {
|
|
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
|
+
super(`Request failed with ${c}`), Object.defineProperty(this, "response", {
|
|
43
|
+
enumerable: !0,
|
|
44
|
+
configurable: !0,
|
|
45
|
+
writable: !0,
|
|
46
|
+
value: void 0
|
|
47
|
+
}), Object.defineProperty(this, "request", {
|
|
48
|
+
enumerable: !0,
|
|
49
|
+
configurable: !0,
|
|
50
|
+
writable: !0,
|
|
51
|
+
value: void 0
|
|
52
|
+
}), Object.defineProperty(this, "options", {
|
|
53
|
+
enumerable: !0,
|
|
54
|
+
configurable: !0,
|
|
55
|
+
writable: !0,
|
|
56
|
+
value: void 0
|
|
57
|
+
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = r;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class Te extends Error {
|
|
61
|
+
constructor(t) {
|
|
62
|
+
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
63
|
+
enumerable: !0,
|
|
64
|
+
configurable: !0,
|
|
65
|
+
writable: !0,
|
|
66
|
+
value: void 0
|
|
67
|
+
}), this.name = "TimeoutError", this.request = t;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
|
|
71
|
+
for (const t of e)
|
|
72
|
+
if ((!M(t) || Array.isArray(t)) && t !== void 0)
|
|
73
|
+
throw new TypeError("The `options` argument must be an object");
|
|
74
|
+
return re({}, ...e);
|
|
75
|
+
}, Ae = (e = {}, t = {}) => {
|
|
76
|
+
const n = new globalThis.Headers(e), r = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
77
|
+
for (const [i, a] of s.entries())
|
|
78
|
+
r && a === "undefined" || a === void 0 ? n.delete(i) : n.set(i, a);
|
|
79
|
+
return n;
|
|
80
|
+
}, re = (...e) => {
|
|
81
|
+
let t = {}, n = {};
|
|
82
|
+
for (const r of e)
|
|
83
|
+
if (Array.isArray(r))
|
|
84
|
+
Array.isArray(t) || (t = []), t = [...t, ...r];
|
|
85
|
+
else if (M(r)) {
|
|
86
|
+
for (let [s, i] of Object.entries(r))
|
|
87
|
+
M(i) && s in t && (i = re(t[s], i)), t = { ...t, [s]: i };
|
|
88
|
+
M(r.headers) && (n = Ae(n, r.headers), t.headers = n);
|
|
89
|
+
}
|
|
90
|
+
return t;
|
|
91
|
+
}, ve = (() => {
|
|
92
|
+
let e = !1, t = !1;
|
|
93
|
+
const n = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
|
|
94
|
+
return n && r && (t = new globalThis.Request("https://empty.invalid", {
|
|
95
|
+
body: new globalThis.ReadableStream(),
|
|
96
|
+
method: "POST",
|
|
97
|
+
// @ts-expect-error - Types are outdated.
|
|
98
|
+
get duplex() {
|
|
99
|
+
return e = !0, "half";
|
|
100
|
+
}
|
|
101
|
+
}).headers.has("Content-Type")), e && !t;
|
|
102
|
+
})(), Me = typeof globalThis.AbortController == "function", He = typeof globalThis.ReadableStream == "function", Fe = typeof globalThis.FormData == "function", pe = ["get", "post", "put", "patch", "head", "delete"], xe = {
|
|
103
|
+
json: "application/json",
|
|
104
|
+
text: "text/*",
|
|
105
|
+
formData: "multipart/form-data",
|
|
106
|
+
arrayBuffer: "*/*",
|
|
107
|
+
blob: "*/*"
|
|
108
|
+
}, K = 2147483647, Se = Symbol("stop"), Ge = {
|
|
109
|
+
json: !0,
|
|
110
|
+
parseJson: !0,
|
|
111
|
+
searchParams: !0,
|
|
112
|
+
prefixUrl: !0,
|
|
113
|
+
retry: !0,
|
|
114
|
+
timeout: !0,
|
|
115
|
+
hooks: !0,
|
|
116
|
+
throwHttpErrors: !0,
|
|
117
|
+
onDownloadProgress: !0,
|
|
118
|
+
fetch: !0
|
|
119
|
+
}, We = {
|
|
120
|
+
method: !0,
|
|
121
|
+
headers: !0,
|
|
122
|
+
body: !0,
|
|
123
|
+
mode: !0,
|
|
124
|
+
credentials: !0,
|
|
125
|
+
cache: !0,
|
|
126
|
+
redirect: !0,
|
|
127
|
+
referrer: !0,
|
|
128
|
+
referrerPolicy: !0,
|
|
129
|
+
integrity: !0,
|
|
130
|
+
keepalive: !0,
|
|
131
|
+
signal: !0,
|
|
132
|
+
window: !0,
|
|
133
|
+
dispatcher: !0,
|
|
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], ce = {
|
|
136
|
+
limit: 2,
|
|
137
|
+
methods: je,
|
|
138
|
+
statusCodes: qe,
|
|
139
|
+
afterStatusCodes: me,
|
|
140
|
+
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
141
|
+
backoffLimit: Number.POSITIVE_INFINITY,
|
|
142
|
+
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
143
|
+
}, Xe = (e = {}) => {
|
|
144
|
+
if (typeof e == "number")
|
|
145
|
+
return {
|
|
146
|
+
...ce,
|
|
147
|
+
limit: e
|
|
148
|
+
};
|
|
149
|
+
if (e.methods && !Array.isArray(e.methods))
|
|
150
|
+
throw new Error("retry.methods must be an array");
|
|
151
|
+
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
152
|
+
throw new Error("retry.statusCodes must be an array");
|
|
153
|
+
return {
|
|
154
|
+
...ce,
|
|
155
|
+
...e,
|
|
156
|
+
afterStatusCodes: me
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
async function Ye(e, t, n, r) {
|
|
160
|
+
return new Promise((s, i) => {
|
|
161
|
+
const a = setTimeout(() => {
|
|
162
|
+
n && n.abort(), i(new Te(e));
|
|
163
|
+
}, r.timeout);
|
|
164
|
+
r.fetch(e, t).then(s).catch(i).then(() => {
|
|
165
|
+
clearTimeout(a);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
async function Ke(e, { signal: t }) {
|
|
170
|
+
return new Promise((n, r) => {
|
|
171
|
+
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
|
|
172
|
+
function s() {
|
|
173
|
+
clearTimeout(i), r(t.reason);
|
|
174
|
+
}
|
|
175
|
+
const i = setTimeout(() => {
|
|
176
|
+
t == null || t.removeEventListener("abort", s), n();
|
|
177
|
+
}, e);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const Je = (e, t) => {
|
|
181
|
+
const n = {};
|
|
182
|
+
for (const r in t)
|
|
183
|
+
!(r in We) && !(r in Ge) && !(r in e) && (n[r] = t[r]);
|
|
184
|
+
return n;
|
|
185
|
+
};
|
|
186
|
+
class x {
|
|
187
|
+
static create(t, n) {
|
|
188
|
+
const r = new x(t, n), s = async () => {
|
|
189
|
+
if (typeof r._options.timeout == "number" && r._options.timeout > K)
|
|
190
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${K}`);
|
|
191
|
+
await Promise.resolve();
|
|
192
|
+
let a = await r._fetch();
|
|
193
|
+
for (const c of r._options.hooks.afterResponse) {
|
|
194
|
+
const o = await c(r.request, r._options, r._decorateResponse(a.clone()));
|
|
195
|
+
o instanceof globalThis.Response && (a = o);
|
|
196
|
+
}
|
|
197
|
+
if (r._decorateResponse(a), !a.ok && r._options.throwHttpErrors) {
|
|
198
|
+
let c = new oe(a, r.request, r._options);
|
|
199
|
+
for (const o of r._options.hooks.beforeError)
|
|
200
|
+
c = await o(c);
|
|
201
|
+
throw c;
|
|
202
|
+
}
|
|
203
|
+
if (r._options.onDownloadProgress) {
|
|
204
|
+
if (typeof r._options.onDownloadProgress != "function")
|
|
205
|
+
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
206
|
+
if (!He)
|
|
207
|
+
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
208
|
+
return r._stream(a.clone(), r._options.onDownloadProgress);
|
|
209
|
+
}
|
|
210
|
+
return a;
|
|
211
|
+
}, i = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(s) : s();
|
|
212
|
+
for (const [a, c] of Object.entries(xe))
|
|
213
|
+
i[a] = async () => {
|
|
214
|
+
r.request.headers.set("accept", r.request.headers.get("accept") || c);
|
|
215
|
+
const o = (await i).clone();
|
|
216
|
+
if (a === "json") {
|
|
217
|
+
if (o.status === 204 || (await o.clone().arrayBuffer()).byteLength === 0)
|
|
218
|
+
return "";
|
|
219
|
+
if (n.parseJson)
|
|
220
|
+
return n.parseJson(await o.text());
|
|
221
|
+
}
|
|
222
|
+
return o[a]();
|
|
223
|
+
};
|
|
224
|
+
return i;
|
|
225
|
+
}
|
|
226
|
+
// eslint-disable-next-line complexity
|
|
227
|
+
constructor(t, n = {}) {
|
|
228
|
+
if (Object.defineProperty(this, "request", {
|
|
229
|
+
enumerable: !0,
|
|
230
|
+
configurable: !0,
|
|
231
|
+
writable: !0,
|
|
232
|
+
value: void 0
|
|
233
|
+
}), Object.defineProperty(this, "abortController", {
|
|
234
|
+
enumerable: !0,
|
|
235
|
+
configurable: !0,
|
|
236
|
+
writable: !0,
|
|
237
|
+
value: void 0
|
|
238
|
+
}), Object.defineProperty(this, "_retryCount", {
|
|
239
|
+
enumerable: !0,
|
|
240
|
+
configurable: !0,
|
|
241
|
+
writable: !0,
|
|
242
|
+
value: 0
|
|
243
|
+
}), Object.defineProperty(this, "_input", {
|
|
244
|
+
enumerable: !0,
|
|
245
|
+
configurable: !0,
|
|
246
|
+
writable: !0,
|
|
247
|
+
value: void 0
|
|
248
|
+
}), Object.defineProperty(this, "_options", {
|
|
249
|
+
enumerable: !0,
|
|
250
|
+
configurable: !0,
|
|
251
|
+
writable: !0,
|
|
252
|
+
value: void 0
|
|
253
|
+
}), this._input = t, this._options = {
|
|
254
|
+
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
255
|
+
credentials: this._input.credentials || "same-origin",
|
|
256
|
+
...n,
|
|
257
|
+
headers: Ae(this._input.headers, n.headers),
|
|
258
|
+
hooks: re({
|
|
259
|
+
beforeRequest: [],
|
|
260
|
+
beforeRetry: [],
|
|
261
|
+
beforeError: [],
|
|
262
|
+
afterResponse: []
|
|
263
|
+
}, n.hooks),
|
|
264
|
+
method: ke(n.method ?? this._input.method),
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
266
|
+
prefixUrl: String(n.prefixUrl || ""),
|
|
267
|
+
retry: Xe(n.retry),
|
|
268
|
+
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
269
|
+
timeout: n.timeout ?? 1e4,
|
|
270
|
+
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
271
|
+
}, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
|
|
272
|
+
throw new TypeError("`input` must be a string, URL, or Request");
|
|
273
|
+
if (this._options.prefixUrl && typeof this._input == "string") {
|
|
274
|
+
if (this._input.startsWith("/"))
|
|
275
|
+
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
276
|
+
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
277
|
+
}
|
|
278
|
+
if (Me) {
|
|
279
|
+
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
280
|
+
const r = this._options.signal;
|
|
281
|
+
this._options.signal.addEventListener("abort", () => {
|
|
282
|
+
this.abortController.abort(r.reason);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
this._options.signal = this.abortController.signal;
|
|
286
|
+
}
|
|
287
|
+
if (ve && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
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
|
+
(Fe && 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
|
+
}
|
|
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
|
+
}
|
|
293
|
+
_calculateRetryDelay(t) {
|
|
294
|
+
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof Te)) {
|
|
295
|
+
if (t instanceof oe) {
|
|
296
|
+
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
297
|
+
return 0;
|
|
298
|
+
const r = t.response.headers.get("Retry-After");
|
|
299
|
+
if (r && this._options.retry.afterStatusCodes.includes(t.response.status)) {
|
|
300
|
+
let s = Number(r);
|
|
301
|
+
return Number.isNaN(s) ? s = Date.parse(r) - Date.now() : s *= 1e3, this._options.retry.maxRetryAfter !== void 0 && s > this._options.retry.maxRetryAfter ? 0 : s;
|
|
302
|
+
}
|
|
303
|
+
if (t.response.status === 413)
|
|
304
|
+
return 0;
|
|
305
|
+
}
|
|
306
|
+
const n = this._options.retry.delay(this._retryCount);
|
|
307
|
+
return Math.min(this._options.retry.backoffLimit, n);
|
|
308
|
+
}
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
_decorateResponse(t) {
|
|
312
|
+
return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
|
|
313
|
+
}
|
|
314
|
+
async _retry(t) {
|
|
315
|
+
try {
|
|
316
|
+
return await t();
|
|
317
|
+
} catch (n) {
|
|
318
|
+
const r = Math.min(this._calculateRetryDelay(n), K);
|
|
319
|
+
if (r !== 0 && this._retryCount > 0) {
|
|
320
|
+
await Ke(r, { signal: this._options.signal });
|
|
321
|
+
for (const s of this._options.hooks.beforeRetry)
|
|
322
|
+
if (await s({
|
|
323
|
+
request: this.request,
|
|
324
|
+
options: this._options,
|
|
325
|
+
error: n,
|
|
326
|
+
retryCount: this._retryCount
|
|
327
|
+
}) === Se)
|
|
328
|
+
return;
|
|
329
|
+
return this._retry(t);
|
|
330
|
+
}
|
|
331
|
+
throw n;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
async _fetch() {
|
|
335
|
+
for (const n of this._options.hooks.beforeRequest) {
|
|
336
|
+
const r = await n(this.request, this._options);
|
|
337
|
+
if (r instanceof Request) {
|
|
338
|
+
this.request = r;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
if (r instanceof Response)
|
|
342
|
+
return r;
|
|
343
|
+
}
|
|
344
|
+
const t = Je(this.request, this._options);
|
|
345
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ye(this.request.clone(), t, this.abortController, this._options);
|
|
346
|
+
}
|
|
347
|
+
/* istanbul ignore next */
|
|
348
|
+
_stream(t, n) {
|
|
349
|
+
const r = Number(t.headers.get("content-length")) || 0;
|
|
350
|
+
let s = 0;
|
|
351
|
+
return t.status === 204 ? (n && n({ percent: 1, totalBytes: r, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
|
|
352
|
+
status: t.status,
|
|
353
|
+
statusText: t.statusText,
|
|
354
|
+
headers: t.headers
|
|
355
|
+
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
356
|
+
async start(i) {
|
|
357
|
+
const a = t.body.getReader();
|
|
358
|
+
n && n({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
|
|
359
|
+
async function c() {
|
|
360
|
+
const { done: o, value: _ } = await a.read();
|
|
361
|
+
if (o) {
|
|
362
|
+
i.close();
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (n) {
|
|
366
|
+
s += _.byteLength;
|
|
367
|
+
const h = r === 0 ? 0 : s / r;
|
|
368
|
+
n({ percent: h, transferredBytes: s, totalBytes: r }, _);
|
|
369
|
+
}
|
|
370
|
+
i.enqueue(_), await c();
|
|
371
|
+
}
|
|
372
|
+
await c();
|
|
373
|
+
}
|
|
374
|
+
}), {
|
|
375
|
+
status: t.status,
|
|
376
|
+
statusText: t.statusText,
|
|
377
|
+
headers: t.headers
|
|
43
378
|
});
|
|
44
|
-
return r ? s.text() : s.json();
|
|
45
|
-
} catch {
|
|
46
|
-
return {};
|
|
47
379
|
}
|
|
48
|
-
}
|
|
380
|
+
}
|
|
381
|
+
/*! MIT License © Sindre Sorhus */
|
|
382
|
+
const Q = (e) => {
|
|
383
|
+
const t = (n, r) => x.create(n, $(e, r));
|
|
384
|
+
for (const n of pe)
|
|
385
|
+
t[n] = (r, s) => x.create(r, $(e, s, { method: n }));
|
|
386
|
+
return t.create = (n) => Q($(n)), t.extend = (n) => Q($(e, n)), t.stop = Se, t;
|
|
387
|
+
}, Ee = Q();
|
|
388
|
+
let H;
|
|
389
|
+
const m = {
|
|
390
|
+
CachedPrices: `${R.ThorswapApi}/tokenlist/cached-price`,
|
|
391
|
+
GasRates: `${R.ThorswapApi}/resource-worker/gasPrice/getAll`,
|
|
392
|
+
Quote: `${R.ThorswapApi}/aggregator/tokens/quote`,
|
|
393
|
+
Txn: `${R.ThorswapApi}/apiusage/v2/txn`,
|
|
394
|
+
TokenlistProviders: `${R.ThorswapApi}/tokenlist/providers`,
|
|
395
|
+
TokenList: `${R.ThorswapStatic}/token-list`,
|
|
396
|
+
Thorname: `${R.ThorswapApi}/thorname`
|
|
397
|
+
}, Re = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, le = () => H || (H = Ee.create({ headers: Re }), H), mt = ({ apiKey: e, ...t }) => {
|
|
398
|
+
H = Ee.create({
|
|
399
|
+
...t,
|
|
400
|
+
headers: { ...Re, ...t.headers, "x-api-key": e }
|
|
401
|
+
});
|
|
402
|
+
}, S = {
|
|
403
|
+
get: (e, t) => le().get(e, t).json(),
|
|
404
|
+
post: (e, t) => le().post(e, t).json()
|
|
405
|
+
}, Qe = ({ tokens: e, ...t }) => {
|
|
406
|
+
const n = new URLSearchParams();
|
|
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, {
|
|
408
|
+
body: n.toString(),
|
|
409
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
410
|
+
});
|
|
411
|
+
}, Et = {
|
|
412
|
+
getCachedPrices: Qe,
|
|
413
|
+
getQuote: (e) => S.get(m.Quote, { searchParams: e }),
|
|
414
|
+
getGasRates: () => S.get(m.GasRates),
|
|
415
|
+
getTxnDetails: (e) => S.get(m.Txn, { searchParams: e }),
|
|
416
|
+
getTokenlistProviders: () => S.get(m.TokenlistProviders),
|
|
417
|
+
getTokenList: (e) => S.get(`${m.TokenList}/${e}.json`),
|
|
418
|
+
getThornameAddresses: (e) => S.get(`${m.Thorname}/${e}`),
|
|
419
|
+
getThornameRegisteredChains: (e) => S.get(`${m.Thorname}/chains/${e}`),
|
|
420
|
+
getThornameRlookup: (e, t) => S.get(`${m.Thorname}/rlookup`, { searchParams: { address: e, chain: t } })
|
|
421
|
+
};
|
|
422
|
+
var ze = /* @__PURE__ */ ((e) => (e.SWAP_TC_TO_TC = "SWAP:TC-TC", e.SWAP_ETH_TO_TC = "SWAP:ERC20-TC", e.SWAP_TC_TO_ETH = "SWAP:TC-ERC20", e.SWAP_ETH_TO_ETH = "SWAP:ERC20-ERC20", e.SWAP_AVAX_TO_TC = "SWAP:AVAX-TC", e.SWAP_TC_TO_AVAX = "SWAP:TC-AVAX", e.SWAP_AVAX_TO_AVAX = "SWAP:AVAX-AVAX", e.SWAP_ETH_TO_AVAX = "SWAP:ETH-AVAX", e.SWAP_AVAX_TO_ETH = "SWAP:AVAX-ETH", e.SWAP_TC_TO_GAIA = "SWAP:TC-GAIA", e.SWAP_GAIA_TO_TC = "SWAP:GAIA-TC", e.SWAP_TC_TO_BNB = "SWAP:TC-BNB", e.SWAP_BNB_TO_TC = "SWAP:BNB-TC", e.SWAP_TC_TO_BTC = "SWAP:TC-BTC", e.SWAP_BTC_TO_TC = "SWAP:BTC-TC", e.SWAP_TC_TO_BCH = "SWAP:TC-BCH", e.SWAP_BCH_TO_TC = "SWAP:BCH-TC", e.SWAP_TC_TO_LTC = "SWAP:TC-LTC", e.SWAP_LTC_TO_TC = "SWAP:LTC-TC", e.SWAP_TC_TO_DOGE = "SWAP:TC-DOGE", e.SWAP_DOGE_TO_TC = "SWAP:DOGE-TC", e.TC_STATUS = "TC:STATUS", e.TC_TRANSFER = "TC:TRANSFER", e.TC_DEPOSIT = "TC:DEPOSIT", e.TC_SEND = "TC:SEND", e.TC_SWITCH = "TC:SWITCH", e.TC_LP_ADD = "TC:ADDLIQUIDITY", e.TC_LP_WITHDRAW = "TC:WITHDRAW", e.TC_TNS_CREATE = "TC:TNS-CREATE", e.TC_TNS_EXTEND = "TC:TNS-EXTEND", e.TC_TNS_UPDATE = "TC:TNS-UPDATE", e.TC_SAVINGS_ADD = "TC:ADDSAVINGS", e.TC_SAVINGS_WITHDRAW = "TC:WITHDRAWSAVINGS", e.TC_LENDING_OPEN = "TC:LENDINGOPEN", e.TC_LENDING_CLOSE = "TC:LENDINGCLOSE", e.ETH_APPROVAL = "ETH:APPROVAL", e.ETH_STATUS = "ETH:STATUS", e.ETH_TRANSFER_TO_TC = "ETH:TRANSFER:IN", e.ETH_TRANSFER_FROM_TC = "ETH:TRANSFER:OUT", e.AVAX_APPROVAL = "AVAX:APPROVAL", e.AVAX_STATUS = "AVAX:STATUS", e.AVAX_TRANSFER_TO_TC = "AVAX:TRANSFER:IN", e.AVAX_TRANSFER_FROM_TC = "AVAX:TRANSFER:OUT", e.BSC_APPROVAL = "BSC:APPROVAL", e.BSC_STATUS = "BSC:STATUS", e.BSC_TRANSFER_TO_TC = "BSC:TRANSFER:IN", e.BSC_TRANSFER_FROM_TC = "BSC:TRANSFER:OUT", e.APPROVAL = "APPROVAL", e.STATUS = "STATUS", e.TRANSFER_TO_TC = "TRANSFER:IN", e.TRANSFER_FROM_TC = "TRANSFER:OUT", e.UNSUPPORTED = "UNSUPPORTED", e.TC_LENDING = "TC:LENDING", e))(ze || {}), Ze = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.SUCCESS = "success", e.CANCELLED = "cancelled", e.REFUNDED = "refunded", e.REPLACED = "replaced", e.ERROR = "error", e.UNKNOWN = "unknown", e.NOT_STARTED = "not_started", e.NOT_FOUND = "not_found", e.RETRIES_EXCEEDED = "retries_exceeded", e.STREAMING = "streaming", e))(Ze || {}), et = /* @__PURE__ */ ((e) => (e[e.NOT_STARTED = 0] = "NOT_STARTED", e[e.SUCCESS = 1] = "SUCCESS", e[e.REFUNDED = 2] = "REFUNDED", e))(et || {});
|
|
423
|
+
const tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
|
|
49
424
|
try {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
425
|
+
const { result: n } = await S.post(Ue[e], {
|
|
426
|
+
headers: {
|
|
427
|
+
accept: "*/*",
|
|
428
|
+
"content-type": "application/json",
|
|
429
|
+
"cache-control": "no-cache"
|
|
430
|
+
},
|
|
431
|
+
body: JSON.stringify({
|
|
55
432
|
id: 44,
|
|
56
|
-
jsonrpc: "2.0"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return parseInt(BigInt(
|
|
62
|
-
} catch (
|
|
63
|
-
return console.error(
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
68
|
-
const [, t] =
|
|
69
|
-
return t != null && t.startsWith("0x") ?
|
|
70
|
-
},
|
|
71
|
-
const [, t] =
|
|
72
|
-
return t != null && t.startsWith("0x") ?
|
|
73
|
-
},
|
|
74
|
-
switch (
|
|
75
|
-
case
|
|
76
|
-
return
|
|
77
|
-
case
|
|
78
|
-
return
|
|
79
|
-
case
|
|
80
|
-
return
|
|
433
|
+
jsonrpc: "2.0",
|
|
434
|
+
method: "eth_call",
|
|
435
|
+
params: [{ to: t.toLowerCase(), data: tt }, "latest"]
|
|
436
|
+
})
|
|
437
|
+
});
|
|
438
|
+
return parseInt(BigInt(n).toString());
|
|
439
|
+
} catch (n) {
|
|
440
|
+
return console.error(n), d[e];
|
|
441
|
+
}
|
|
442
|
+
}, nt = async (e) => {
|
|
443
|
+
if (e === l.Ethereum)
|
|
444
|
+
return d.ETH;
|
|
445
|
+
const [, t] = e.split("-");
|
|
446
|
+
return t != null && t.startsWith("0x") ? Ie({ chain: l.Ethereum, to: t }) : d.ETH;
|
|
447
|
+
}, rt = async (e) => {
|
|
448
|
+
const [, t] = e.split("-");
|
|
449
|
+
return t != null && t.startsWith("0x") ? Ie({ chain: l.Avalanche, to: t.toLowerCase() }) : d.AVAX;
|
|
450
|
+
}, st = async (e) => e === l.BinanceSmartChain ? d.BSC : d.BSC, it = async ({ chain: e, symbol: t }) => {
|
|
451
|
+
switch (e) {
|
|
452
|
+
case l.Ethereum:
|
|
453
|
+
return nt(t);
|
|
454
|
+
case l.Avalanche:
|
|
455
|
+
return rt(t);
|
|
456
|
+
case l.BinanceSmartChain:
|
|
457
|
+
return st(t);
|
|
81
458
|
default:
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
},
|
|
89
|
-
switch (
|
|
90
|
-
case
|
|
91
|
-
case
|
|
92
|
-
case i.Litecoin:
|
|
93
|
-
case i.Dogecoin:
|
|
94
|
-
case i.Binance:
|
|
95
|
-
case i.Ethereum:
|
|
96
|
-
case i.Avalanche:
|
|
97
|
-
return t === n;
|
|
98
|
-
case i.Arbitrum:
|
|
99
|
-
case i.Optimism:
|
|
459
|
+
return d[e];
|
|
460
|
+
}
|
|
461
|
+
}, Rt = {
|
|
462
|
+
[Y.Average]: 1.2,
|
|
463
|
+
[Y.Fast]: 1.5,
|
|
464
|
+
[Y.Fastest]: 2
|
|
465
|
+
}, fe = ({ chain: e, symbol: t }) => {
|
|
466
|
+
switch (e) {
|
|
467
|
+
case l.Arbitrum:
|
|
468
|
+
case l.Optimism:
|
|
100
469
|
return t === "ETH";
|
|
101
|
-
case
|
|
470
|
+
case l.Maya:
|
|
102
471
|
return t === "CACAO";
|
|
103
|
-
case
|
|
472
|
+
case l.Kujira:
|
|
104
473
|
return t === "KUJI";
|
|
105
|
-
case
|
|
474
|
+
case l.Cosmos:
|
|
106
475
|
return t === "ATOM";
|
|
107
|
-
case
|
|
476
|
+
case l.Polygon:
|
|
108
477
|
return t === "MATIC";
|
|
109
|
-
case
|
|
478
|
+
case l.BinanceSmartChain:
|
|
110
479
|
return t === "BNB";
|
|
111
|
-
case
|
|
480
|
+
case l.THORChain:
|
|
112
481
|
return t === "RUNE";
|
|
482
|
+
default:
|
|
483
|
+
return t === e;
|
|
113
484
|
}
|
|
114
|
-
},
|
|
115
|
-
switch (
|
|
116
|
-
case
|
|
485
|
+
}, at = (e) => {
|
|
486
|
+
switch (e) {
|
|
487
|
+
case `${l.Ethereum}.THOR`:
|
|
117
488
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
118
|
-
case
|
|
489
|
+
case `${l.Ethereum}.vTHOR`:
|
|
119
490
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
120
|
-
case
|
|
121
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
122
|
-
case
|
|
123
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
124
|
-
case
|
|
125
|
-
return { identifier: "BSC.BNB", decimal:
|
|
126
|
-
case
|
|
127
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
128
|
-
case
|
|
491
|
+
case l.Cosmos:
|
|
492
|
+
return { identifier: "GAIA.ATOM", decimal: d[e] };
|
|
493
|
+
case l.THORChain:
|
|
494
|
+
return { identifier: "THOR.RUNE", decimal: d[e] };
|
|
495
|
+
case l.BinanceSmartChain:
|
|
496
|
+
return { identifier: "BSC.BNB", decimal: d[e] };
|
|
497
|
+
case l.Maya:
|
|
498
|
+
return { identifier: "MAYA.CACAO", decimal: d.MAYA };
|
|
499
|
+
case `${l.Maya}.MAYA`:
|
|
129
500
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
130
|
-
case
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
case i.Binance:
|
|
137
|
-
case i.Avalanche:
|
|
138
|
-
case i.Polygon:
|
|
139
|
-
case i.Bitcoin:
|
|
140
|
-
case i.Ethereum:
|
|
141
|
-
return { identifier: `${n}.${n}`, decimal: m[n] };
|
|
142
|
-
}
|
|
143
|
-
}, mt = ({ chain: n, symbol: t }) => {
|
|
501
|
+
case `${l.Kujira}.USK`:
|
|
502
|
+
return { identifier: `${l.Kujira}.USK`, decimal: 6 };
|
|
503
|
+
default:
|
|
504
|
+
return { identifier: `${e}.${e}`, decimal: d[e] };
|
|
505
|
+
}
|
|
506
|
+
}, ot = ({ chain: e, symbol: t }) => {
|
|
144
507
|
if (t.includes("/"))
|
|
145
508
|
return "Synth";
|
|
146
|
-
switch (
|
|
147
|
-
case
|
|
148
|
-
|
|
149
|
-
case
|
|
150
|
-
|
|
151
|
-
case
|
|
152
|
-
|
|
509
|
+
switch (e) {
|
|
510
|
+
case l.Cosmos:
|
|
511
|
+
return t === "ATOM" ? "Native" : l.Cosmos;
|
|
512
|
+
case l.Kujira:
|
|
513
|
+
return t === l.Kujira ? "Native" : l.Kujira;
|
|
514
|
+
case l.Binance:
|
|
515
|
+
return t === l.Binance ? "Native" : "BEP2";
|
|
516
|
+
case l.BinanceSmartChain:
|
|
517
|
+
return t === l.Binance ? "Native" : "BEP20";
|
|
518
|
+
case l.Ethereum:
|
|
519
|
+
return t === l.Ethereum ? "Native" : "ERC20";
|
|
520
|
+
case l.Avalanche:
|
|
521
|
+
return t === l.Avalanche ? "Native" : l.Avalanche;
|
|
522
|
+
case l.Polygon:
|
|
523
|
+
return t === l.Polygon ? "Native" : "POLYGON";
|
|
524
|
+
case l.Arbitrum:
|
|
525
|
+
return [l.Ethereum, l.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
526
|
+
case l.Optimism:
|
|
527
|
+
return [l.Ethereum, l.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
528
|
+
default:
|
|
153
529
|
return "Native";
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
case i.BinanceSmartChain:
|
|
161
|
-
return t === i.Binance ? "Native" : "BEP20";
|
|
162
|
-
case i.Ethereum:
|
|
163
|
-
return t === i.Ethereum ? "Native" : "ERC20";
|
|
164
|
-
case i.Avalanche:
|
|
165
|
-
return t === i.Avalanche ? "Native" : i.Avalanche;
|
|
166
|
-
case i.Polygon:
|
|
167
|
-
return t === i.Polygon ? "Native" : "POLYGON";
|
|
168
|
-
case i.Arbitrum:
|
|
169
|
-
return [i.Ethereum, i.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
170
|
-
case i.Optimism:
|
|
171
|
-
return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
172
|
-
}
|
|
173
|
-
}, yt = (n) => {
|
|
174
|
-
var c;
|
|
175
|
-
const [t, ...e] = n.split("."), r = n.includes("/"), s = e.join("."), a = (c = s == null ? void 0 : s.split("-")) == null ? void 0 : c[0];
|
|
176
|
-
return { chain: t, symbol: s, ticker: a, synth: r };
|
|
177
|
-
}, gt = new RegExp(
|
|
530
|
+
}
|
|
531
|
+
}, It = (e) => {
|
|
532
|
+
var a;
|
|
533
|
+
const [t, ...n] = e.split("."), r = e.includes("/"), s = n.join("."), i = (a = s == null ? void 0 : s.split("-")) == null ? void 0 : a[0];
|
|
534
|
+
return { chain: t, symbol: s, ticker: i, synth: r };
|
|
535
|
+
}, ct = new RegExp(
|
|
178
536
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
179
537
|
"gmi"
|
|
180
|
-
),
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
538
|
+
), lt = (e) => {
|
|
539
|
+
const [t, n] = e.split(".");
|
|
540
|
+
if (!Be.includes(t))
|
|
541
|
+
return !0;
|
|
542
|
+
const [, r] = n.split("-");
|
|
543
|
+
return fe({ chain: t, symbol: n }) || !!r;
|
|
544
|
+
}, ft = (e) => e.filter(({ chain: t, value: n, symbol: r }) => {
|
|
545
|
+
const s = `${t}.${r}`;
|
|
546
|
+
return !ct.test(s) && lt(s) && n !== "0";
|
|
547
|
+
});
|
|
548
|
+
function ut({
|
|
549
|
+
liquidityUnits: e,
|
|
184
550
|
poolUnits: t,
|
|
185
|
-
runeDepth:
|
|
186
|
-
})
|
|
187
|
-
const r =
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
|
|
551
|
+
runeDepth: n
|
|
552
|
+
}) {
|
|
553
|
+
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 = s.mul(s).mul(s);
|
|
554
|
+
return a.mul(c.sub(o).add(_)).div(h);
|
|
555
|
+
}
|
|
556
|
+
function _t({
|
|
557
|
+
liquidityUnits: e,
|
|
191
558
|
poolUnits: t,
|
|
192
|
-
assetDepth:
|
|
193
|
-
})
|
|
194
|
-
const r =
|
|
195
|
-
return
|
|
196
|
-
}
|
|
197
|
-
|
|
559
|
+
assetDepth: n
|
|
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(_)), P = s.mul(s).mul(s);
|
|
562
|
+
return h.div(P);
|
|
563
|
+
}
|
|
564
|
+
function Nt({
|
|
565
|
+
percent: e,
|
|
198
566
|
runeDepth: t,
|
|
199
|
-
liquidityUnits:
|
|
567
|
+
liquidityUnits: n,
|
|
200
568
|
poolUnits: r
|
|
201
|
-
})
|
|
202
|
-
|
|
569
|
+
}) {
|
|
570
|
+
return ut({ runeDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
|
|
571
|
+
}
|
|
572
|
+
function Ct({
|
|
573
|
+
percent: e,
|
|
203
574
|
assetDepth: t,
|
|
204
|
-
liquidityUnits: e,
|
|
205
|
-
poolUnits: r
|
|
206
|
-
}) => pt({ assetDepth: t, liquidityUnits: e, poolUnits: r }).mul(n), h = (n) => new bt({ value: n, decimal: m.THOR }), ft = ({
|
|
207
575
|
liquidityUnits: n,
|
|
576
|
+
poolUnits: r
|
|
577
|
+
}) {
|
|
578
|
+
return _t({ assetDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
|
|
579
|
+
}
|
|
580
|
+
function A(e) {
|
|
581
|
+
return I.fromBigInt(BigInt(e), d.THOR);
|
|
582
|
+
}
|
|
583
|
+
function ht({
|
|
584
|
+
liquidityUnits: e,
|
|
208
585
|
poolUnits: t,
|
|
209
|
-
runeDepth:
|
|
586
|
+
runeDepth: n,
|
|
210
587
|
assetDepth: r
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
588
|
+
}) {
|
|
589
|
+
return {
|
|
590
|
+
assetAmount: A(r).mul(e).div(t),
|
|
591
|
+
runeAmount: A(n).mul(e).div(t)
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function gt({
|
|
595
|
+
liquidityUnits: e,
|
|
216
596
|
poolUnits: t,
|
|
217
|
-
runeDepth:
|
|
597
|
+
runeDepth: n,
|
|
218
598
|
assetDepth: r,
|
|
219
599
|
percent: s
|
|
220
|
-
})
|
|
221
|
-
Object.
|
|
222
|
-
(
|
|
223
|
-
|
|
224
|
-
)
|
|
225
|
-
|
|
600
|
+
}) {
|
|
601
|
+
return Object.fromEntries(
|
|
602
|
+
Object.entries(ht({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: r })).map(
|
|
603
|
+
([i, a]) => [i, a.mul(s)]
|
|
604
|
+
)
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
function Ot({
|
|
608
|
+
runeDepth: e,
|
|
226
609
|
poolUnits: t,
|
|
227
|
-
assetDepth:
|
|
610
|
+
assetDepth: n,
|
|
228
611
|
liquidityUnits: r,
|
|
229
612
|
runeAmount: s,
|
|
230
|
-
assetAmount:
|
|
231
|
-
})
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
return
|
|
235
|
-
const
|
|
236
|
-
return
|
|
237
|
-
}
|
|
238
|
-
|
|
613
|
+
assetAmount: i
|
|
614
|
+
}) {
|
|
615
|
+
const a = new I({ value: e, decimal: 8 }), c = new I({ value: n, decimal: 8 }), o = new I({ value: t, decimal: 8 }), _ = new I({ value: s, decimal: 8 }), h = new I({ value: i, decimal: 8 }), P = _.mul(c), ie = h.mul(a), ge = _.mul(h), Oe = a.mul(c), De = o.mul(P.add(ie.add(ge.mul(2)))), Pe = P.add(ie.add(Oe.mul(2))), ae = De.div(Pe), X = A(r).add(ae);
|
|
616
|
+
if (ae.getBaseValue("number") === 0)
|
|
617
|
+
return X.div(o).getBaseValue("number");
|
|
618
|
+
const be = o.add(X);
|
|
619
|
+
return X.div(be).getBaseValue("number");
|
|
620
|
+
}
|
|
621
|
+
function Dt({
|
|
622
|
+
runeAmount: e,
|
|
239
623
|
assetAmount: t,
|
|
240
|
-
runeDepth:
|
|
624
|
+
runeDepth: n,
|
|
241
625
|
assetDepth: r
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
case
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return `${n}:${e}`;
|
|
626
|
+
}) {
|
|
627
|
+
if (e === "0" || t === "0" || n === "0" || r === "0")
|
|
628
|
+
return 0;
|
|
629
|
+
const s = A(n), i = A(r), a = A(t), c = A(e), o = a.mul(s).sub(i.mul(c)), _ = i.mul(c).add(s.mul(i));
|
|
630
|
+
return Math.abs(o.div(_).getBaseValue("number"));
|
|
631
|
+
}
|
|
632
|
+
const Pt = (e, t) => {
|
|
633
|
+
switch (e) {
|
|
634
|
+
case E.LEAVE:
|
|
635
|
+
case E.BOND: {
|
|
636
|
+
const { address: n } = t;
|
|
637
|
+
return `${e}:${n}`;
|
|
255
638
|
}
|
|
256
|
-
case
|
|
257
|
-
const { address:
|
|
258
|
-
return `${
|
|
639
|
+
case E.UNBOND: {
|
|
640
|
+
const { address: n, unbondAmount: r } = t;
|
|
641
|
+
return `${e}:${n}:${r}`;
|
|
259
642
|
}
|
|
260
|
-
case
|
|
261
|
-
const { name:
|
|
262
|
-
return `${
|
|
643
|
+
case E.THORNAME_REGISTER: {
|
|
644
|
+
const { name: n, chain: r, address: s, owner: i } = t;
|
|
645
|
+
return `${e}:${n}:${r}:${s}${i ? `:${i}` : ""}`;
|
|
263
646
|
}
|
|
264
|
-
case
|
|
265
|
-
const { chain:
|
|
266
|
-
return
|
|
647
|
+
case E.DEPOSIT: {
|
|
648
|
+
const { chain: n, symbol: r, address: s, singleSide: i } = t;
|
|
649
|
+
return i ? `${e}:${n}/${r}` : `${e}:${((c, o) => {
|
|
650
|
+
switch (c) {
|
|
651
|
+
case l.Litecoin:
|
|
652
|
+
return "l";
|
|
653
|
+
case l.Dogecoin:
|
|
654
|
+
return "d";
|
|
655
|
+
case l.BitcoinCash:
|
|
656
|
+
return "c";
|
|
657
|
+
default:
|
|
658
|
+
return `${c}.${o}`;
|
|
659
|
+
}
|
|
660
|
+
})(n, r)}:${s || ""}`;
|
|
267
661
|
}
|
|
268
|
-
case
|
|
269
|
-
const { chain:
|
|
270
|
-
return `${
|
|
662
|
+
case E.WITHDRAW: {
|
|
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
|
+
return `${e}:${n}${c ? "/" : "."}${o}:${i}${_}`;
|
|
271
665
|
}
|
|
272
|
-
case
|
|
273
|
-
case
|
|
274
|
-
const { asset:
|
|
275
|
-
return `${
|
|
666
|
+
case E.OPEN_LOAN:
|
|
667
|
+
case E.CLOSE_LOAN: {
|
|
668
|
+
const { asset: n, address: r } = t;
|
|
669
|
+
return `${e}:${n}:${r}`;
|
|
276
670
|
}
|
|
277
671
|
default:
|
|
278
672
|
return "";
|
|
279
673
|
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (
|
|
674
|
+
};
|
|
675
|
+
function bt(e) {
|
|
676
|
+
if (e < 0)
|
|
677
|
+
throw new Error("Invalid number of year");
|
|
678
|
+
return 10 + e;
|
|
679
|
+
}
|
|
680
|
+
function yt(e) {
|
|
681
|
+
if (e.length > 30)
|
|
682
|
+
return !1;
|
|
683
|
+
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
684
|
+
return !!e.match(t);
|
|
685
|
+
}
|
|
686
|
+
function wt([e, t, n, r, s]) {
|
|
687
|
+
return `${e}'/${t}'/${n}'/${r}${typeof s != "number" ? "" : `/${s}`}`;
|
|
688
|
+
}
|
|
689
|
+
const ue = [...Object.values(l), "TERRA"];
|
|
690
|
+
function dt(e = "") {
|
|
691
|
+
const t = e.toUpperCase(), [n] = t.split(".");
|
|
692
|
+
if (ue.includes(n))
|
|
283
693
|
return !0;
|
|
284
694
|
const [r] = t.split("/");
|
|
285
|
-
if (
|
|
695
|
+
if (ue.includes(r))
|
|
286
696
|
return !0;
|
|
287
697
|
throw new Error(
|
|
288
|
-
`Invalid identifier: ${
|
|
698
|
+
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
289
699
|
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
700
|
+
}
|
|
701
|
+
const B = 8, N = (e) => 10n ** BigInt(e), b = (e) => Math.log10(parseFloat(e.toString()));
|
|
702
|
+
function G({
|
|
703
|
+
value: e,
|
|
704
|
+
bigIntDecimal: t = B,
|
|
705
|
+
decimal: n = B
|
|
295
706
|
}) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
707
|
+
if (n === 0)
|
|
708
|
+
return e.toString();
|
|
709
|
+
const r = e < 0n;
|
|
710
|
+
let s = e.toString().substring(r ? 1 : 0);
|
|
711
|
+
const i = n - (s.length - 1);
|
|
712
|
+
i > 0 && (s = "0".repeat(i) + s);
|
|
713
|
+
const a = s.length - n;
|
|
714
|
+
let c = s.slice(-n);
|
|
715
|
+
return parseInt(c[t]) >= 5 ? c = `${c.substring(0, t - 1)}${(parseInt(c[t - 1]) + 1).toString()}` : c = c.substring(0, t), `${r ? "-" : ""}${s.slice(0, a)}.${c}`.replace(
|
|
303
716
|
/\.?0*$/,
|
|
304
717
|
""
|
|
305
718
|
);
|
|
306
719
|
}
|
|
307
|
-
var
|
|
308
|
-
const
|
|
720
|
+
var C, y, f, D, k, Ne, U, z, L, Z;
|
|
721
|
+
const se = class se {
|
|
309
722
|
constructor(t) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return new B({
|
|
326
|
-
decimal: e,
|
|
327
|
-
value: U({ value: t, bigIntDecimal: e, decimal: e })
|
|
723
|
+
O(this, C);
|
|
724
|
+
O(this, f);
|
|
725
|
+
O(this, k);
|
|
726
|
+
O(this, U);
|
|
727
|
+
O(this, L);
|
|
728
|
+
p(this, "decimalMultiplier", 10n ** 8n);
|
|
729
|
+
p(this, "bigIntValue", 0n);
|
|
730
|
+
p(this, "decimal");
|
|
731
|
+
const n = ee(t), r = typeof t == "object";
|
|
732
|
+
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e(v(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
|
|
733
|
+
}
|
|
734
|
+
static fromBigInt(t, n) {
|
|
735
|
+
return new se({
|
|
736
|
+
decimal: n,
|
|
737
|
+
value: G({ value: t, bigIntDecimal: n, decimal: n })
|
|
328
738
|
});
|
|
329
739
|
}
|
|
330
740
|
static shiftDecimals({
|
|
331
741
|
value: t,
|
|
332
|
-
from:
|
|
742
|
+
from: n,
|
|
333
743
|
to: r
|
|
334
744
|
}) {
|
|
335
|
-
return
|
|
336
|
-
|
|
745
|
+
return this.fromBigInt(
|
|
746
|
+
t.getBaseValue("bigint") * N(r) / N(n),
|
|
337
747
|
r
|
|
338
748
|
);
|
|
339
749
|
}
|
|
340
|
-
/**
|
|
341
|
-
* @deprecated Use `getBaseValue('string')` instead
|
|
342
|
-
*/
|
|
343
|
-
get baseValue() {
|
|
344
|
-
return this.getBaseValue("string");
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* @deprecated Use `getBaseValue('number')` instead
|
|
348
|
-
*/
|
|
349
|
-
get baseValueNumber() {
|
|
350
|
-
return this.getBaseValue("number");
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* @deprecated Use `getBaseValue('bigint')` instead
|
|
354
|
-
*/
|
|
355
|
-
get baseValueBigInt() {
|
|
356
|
-
return this.getBaseValue("bigint");
|
|
357
|
-
}
|
|
358
750
|
set(t) {
|
|
359
751
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
360
752
|
}
|
|
361
753
|
add(...t) {
|
|
362
|
-
return
|
|
754
|
+
return T(this, C, y).call(this, "add", ...t);
|
|
363
755
|
}
|
|
364
756
|
sub(...t) {
|
|
365
|
-
return
|
|
757
|
+
return T(this, C, y).call(this, "sub", ...t);
|
|
366
758
|
}
|
|
367
759
|
mul(...t) {
|
|
368
|
-
return
|
|
760
|
+
return T(this, C, y).call(this, "mul", ...t);
|
|
369
761
|
}
|
|
370
762
|
div(...t) {
|
|
371
|
-
return
|
|
763
|
+
return T(this, C, y).call(this, "div", ...t);
|
|
372
764
|
}
|
|
373
765
|
gt(t) {
|
|
374
|
-
return this
|
|
766
|
+
return T(this, f, D).call(this, "gt", t);
|
|
375
767
|
}
|
|
376
768
|
gte(t) {
|
|
377
|
-
return this
|
|
769
|
+
return T(this, f, D).call(this, "gte", t);
|
|
378
770
|
}
|
|
379
771
|
lt(t) {
|
|
380
|
-
return this
|
|
772
|
+
return T(this, f, D).call(this, "lt", t);
|
|
381
773
|
}
|
|
382
774
|
lte(t) {
|
|
383
|
-
return this
|
|
775
|
+
return T(this, f, D).call(this, "lte", t);
|
|
384
776
|
}
|
|
385
777
|
eqValue(t) {
|
|
386
|
-
return this
|
|
778
|
+
return T(this, f, D).call(this, "eqValue", t);
|
|
387
779
|
}
|
|
780
|
+
// @ts-expect-error False positive
|
|
388
781
|
getValue(t) {
|
|
389
|
-
const
|
|
782
|
+
const n = this.formatBigIntToSafeValue(
|
|
390
783
|
this.bigIntValue,
|
|
391
|
-
this.decimal ||
|
|
784
|
+
this.decimal || b(this.decimalMultiplier)
|
|
392
785
|
);
|
|
393
786
|
switch (t) {
|
|
394
787
|
case "number":
|
|
395
|
-
return Number(
|
|
788
|
+
return Number(n);
|
|
396
789
|
case "string":
|
|
397
|
-
return
|
|
398
|
-
|
|
399
|
-
return this.bigIntValue;
|
|
790
|
+
return n;
|
|
791
|
+
case "bigint":
|
|
792
|
+
return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
|
|
400
793
|
}
|
|
401
794
|
}
|
|
795
|
+
// @ts-expect-error
|
|
402
796
|
getBaseValue(t) {
|
|
403
|
-
const
|
|
797
|
+
const n = this.decimalMultiplier / N(this.decimal || d.THOR), r = this.bigIntValue / n;
|
|
404
798
|
switch (t) {
|
|
405
799
|
case "number":
|
|
406
800
|
return Number(r);
|
|
407
801
|
case "string":
|
|
408
802
|
return r.toString();
|
|
409
|
-
|
|
410
|
-
return
|
|
803
|
+
case "bigint":
|
|
804
|
+
return r;
|
|
411
805
|
}
|
|
412
806
|
}
|
|
413
|
-
getBigIntValue(t,
|
|
414
|
-
if (!
|
|
807
|
+
getBigIntValue(t, n) {
|
|
808
|
+
if (!n && typeof t == "object")
|
|
415
809
|
return t.bigIntValue;
|
|
416
|
-
const r =
|
|
417
|
-
return s === "0" || s === "undefined" ? 0n :
|
|
418
|
-
}
|
|
419
|
-
formatBigIntToSafeValue(t, e) {
|
|
420
|
-
const r = e || this.decimal || T, s = Math.max(
|
|
421
|
-
r,
|
|
422
|
-
v(this.decimalMultiplier)
|
|
423
|
-
), a = t < 0n, c = t.toString().substring(a ? 1 : 0), o = s - (c.length - 1), u = o > 0 ? "0".repeat(o) + c : c, l = u.length - s;
|
|
424
|
-
let d = u.slice(-s);
|
|
425
|
-
return parseInt(d[r]) >= 5 ? d = `${d.substring(0, r - 1)}${(parseInt(d[r - 1]) + 1).toString()}` : d = d.substring(0, r), `${a ? "-" : ""}${u.slice(
|
|
426
|
-
0,
|
|
427
|
-
l
|
|
428
|
-
)}.${d}`.replace(/\.?0*$/, "");
|
|
810
|
+
const r = ee(t), s = v(r);
|
|
811
|
+
return s === "0" || s === "undefined" ? 0n : T(this, L, Z).call(this, s, n);
|
|
429
812
|
}
|
|
430
813
|
toSignificant(t = 6) {
|
|
431
|
-
const [
|
|
432
|
-
if (
|
|
814
|
+
const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
|
|
815
|
+
if ((parseInt(s) ? s.length + i.length : i.length) <= t)
|
|
433
816
|
return this.getValue("string");
|
|
434
817
|
if (s.length >= t)
|
|
435
818
|
return s.slice(0, t).padEnd(s.length, "0");
|
|
436
819
|
if (parseInt(s))
|
|
437
|
-
return `${s}.${
|
|
438
|
-
|
|
820
|
+
return `${s}.${i.slice(0, t - s.length)}`.padEnd(
|
|
821
|
+
t - s.length,
|
|
439
822
|
"0"
|
|
440
823
|
);
|
|
441
|
-
const
|
|
442
|
-
return `0.${
|
|
443
|
-
|
|
824
|
+
const c = parseInt(i), o = `${c}`.slice(0, t);
|
|
825
|
+
return `0.${o.padStart(
|
|
826
|
+
i.length - `${c}`.length + o.length,
|
|
444
827
|
"0"
|
|
445
828
|
)}`;
|
|
446
829
|
}
|
|
830
|
+
toFixed(t = 6) {
|
|
831
|
+
const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
|
|
832
|
+
if (parseInt(s))
|
|
833
|
+
return `${s}.${i.slice(0, t)}`.padEnd(t, "0");
|
|
834
|
+
const a = parseInt(i), c = `${a}`.slice(0, t);
|
|
835
|
+
return `0.${c.padStart(
|
|
836
|
+
i.length - `${a}`.length + c.length,
|
|
837
|
+
"0"
|
|
838
|
+
)}`;
|
|
839
|
+
}
|
|
840
|
+
toAbbreviation(t = 2) {
|
|
841
|
+
const n = this.getValue("number"), r = ["", "K", "M", "B", "T", "Q", "Qi", "S"], s = Math.floor(Math.log10(Math.abs(n)) / 3), i = r[s];
|
|
842
|
+
if (!i)
|
|
843
|
+
return this.getValue("string");
|
|
844
|
+
const a = 10 ** (s * 3);
|
|
845
|
+
return `${(n / a).toFixed(t)}${i}`;
|
|
846
|
+
}
|
|
847
|
+
toCurrency(t = "$", {
|
|
848
|
+
currencyPosition: n = "start",
|
|
849
|
+
decimal: r = 2,
|
|
850
|
+
decimalSeparator: s = ".",
|
|
851
|
+
thousandSeparator: i = ","
|
|
852
|
+
} = {}) {
|
|
853
|
+
const a = this.getValue("number"), [c, o = ""] = a.toFixed(6).split("."), _ = c.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = !c && !o ? "0.00" : c === "0" ? `${parseFloat(`0.${o}`)}`.replace(".", s) : `${_}${parseInt(o) ? `${s}${o.slice(0, r)}` : ""}`;
|
|
854
|
+
return `${n === "start" ? t : ""}${h}${n === "end" ? t : ""}`;
|
|
855
|
+
}
|
|
856
|
+
formatBigIntToSafeValue(t, n) {
|
|
857
|
+
const r = n || this.decimal || B, s = Math.max(
|
|
858
|
+
r,
|
|
859
|
+
b(this.decimalMultiplier)
|
|
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
|
+
let h = o.slice(-s);
|
|
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(
|
|
863
|
+
0,
|
|
864
|
+
_
|
|
865
|
+
)}.${h}`.replace(/\.?0*$/, "");
|
|
866
|
+
}
|
|
447
867
|
};
|
|
448
|
-
|
|
449
|
-
const r =
|
|
450
|
-
(o,
|
|
451
|
-
const
|
|
868
|
+
C = new WeakSet(), y = function(t, ...n) {
|
|
869
|
+
const r = T(this, U, z).call(this, this, ...n), s = Math.max(r, b(this.decimalMultiplier)), i = N(s), a = n.reduce(
|
|
870
|
+
(o, _) => {
|
|
871
|
+
const h = this.getBigIntValue(_, s);
|
|
452
872
|
switch (t) {
|
|
453
873
|
case "add":
|
|
454
|
-
return o +
|
|
874
|
+
return o + h;
|
|
455
875
|
case "sub":
|
|
456
|
-
return o -
|
|
876
|
+
return o - h;
|
|
457
877
|
case "mul":
|
|
458
|
-
return o *
|
|
878
|
+
return o * h / i;
|
|
459
879
|
case "div": {
|
|
460
|
-
if (
|
|
880
|
+
if (h === 0n)
|
|
461
881
|
throw new RangeError("Division by zero");
|
|
462
|
-
return o *
|
|
882
|
+
return o * i / h;
|
|
463
883
|
}
|
|
464
884
|
default:
|
|
465
885
|
return o;
|
|
466
886
|
}
|
|
467
887
|
},
|
|
468
888
|
//normalize is to precision multiplier base
|
|
469
|
-
this.bigIntValue *
|
|
470
|
-
), c =
|
|
471
|
-
bigIntDecimal:
|
|
472
|
-
decimal:
|
|
889
|
+
this.bigIntValue * i / this.decimalMultiplier
|
|
890
|
+
), c = G({
|
|
891
|
+
bigIntDecimal: s,
|
|
892
|
+
decimal: s,
|
|
473
893
|
value: a
|
|
474
894
|
});
|
|
475
|
-
return new this.constructor({
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
).
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
895
|
+
return new this.constructor({
|
|
896
|
+
decimalMultiplier: N(s),
|
|
897
|
+
decimal: this.decimal,
|
|
898
|
+
value: c,
|
|
899
|
+
identifier: this.toString()
|
|
900
|
+
});
|
|
901
|
+
}, f = new WeakSet(), D = function(t, ...n) {
|
|
902
|
+
const r = T(this, U, z).call(this, this, ...n), s = this.getBigIntValue(n[0], r), i = this.getBigIntValue(this, r);
|
|
903
|
+
switch (t) {
|
|
904
|
+
case "gt":
|
|
905
|
+
return i > s;
|
|
906
|
+
case "gte":
|
|
907
|
+
return i >= s;
|
|
908
|
+
case "lt":
|
|
909
|
+
return i < s;
|
|
910
|
+
case "lte":
|
|
911
|
+
return i <= s;
|
|
912
|
+
case "eqValue":
|
|
913
|
+
return i === s;
|
|
914
|
+
}
|
|
915
|
+
}, k = new WeakSet(), Ne = function(t) {
|
|
916
|
+
const n = v(t) || "0";
|
|
917
|
+
this.bigIntValue = T(this, L, Z).call(this, n);
|
|
918
|
+
}, U = new WeakSet(), z = function(...t) {
|
|
919
|
+
const n = t.map((r) => typeof r == "object" ? r.decimal || b(r.decimalMultiplier) : _e(v(r))).filter(Boolean);
|
|
920
|
+
return Math.max(...n, B);
|
|
921
|
+
}, L = new WeakSet(), Z = function(t, n) {
|
|
922
|
+
const r = n ? N(n) : this.decimalMultiplier, s = b(r), [i = "", a = ""] = t.split(".");
|
|
923
|
+
return BigInt(`${i}${a.padEnd(s, "0")}`);
|
|
497
924
|
};
|
|
498
|
-
let
|
|
499
|
-
|
|
500
|
-
|
|
925
|
+
let W = se;
|
|
926
|
+
const Tt = Intl.NumberFormat("fullwide", {
|
|
927
|
+
useGrouping: !1,
|
|
928
|
+
maximumFractionDigits: 20
|
|
929
|
+
});
|
|
930
|
+
function v(e) {
|
|
931
|
+
const n = `${typeof e == "number" ? Tt.format(e) : ee(e)}`.replaceAll(",", ".").split(".");
|
|
932
|
+
return n.length > 1 ? `${n.slice(0, -1).join("")}.${n.at(-1)}` : n[0];
|
|
501
933
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const r = this.isSynthetic ? this.ticker : `${this.chain}.${this.ticker}`;
|
|
532
|
-
return e ? r : (
|
|
533
|
-
// THOR.ETH/ETH | ETH.USDT-0x1234567890
|
|
534
|
-
`${this.chain}.${this.symbol}`
|
|
535
|
-
);
|
|
934
|
+
function _e(e) {
|
|
935
|
+
var n;
|
|
936
|
+
const t = ((n = e.split(".")[1]) == null ? void 0 : n.length) || 0;
|
|
937
|
+
return Math.max(t, B);
|
|
938
|
+
}
|
|
939
|
+
function ee(e) {
|
|
940
|
+
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
941
|
+
}
|
|
942
|
+
const w = /* @__PURE__ */ new Map();
|
|
943
|
+
class g extends W {
|
|
944
|
+
constructor({
|
|
945
|
+
value: n,
|
|
946
|
+
decimal: r,
|
|
947
|
+
tax: s,
|
|
948
|
+
chain: i,
|
|
949
|
+
symbol: a,
|
|
950
|
+
identifier: c
|
|
951
|
+
}) {
|
|
952
|
+
super(typeof n == "object" ? n : { decimal: r, value: n });
|
|
953
|
+
p(this, "address");
|
|
954
|
+
p(this, "chain");
|
|
955
|
+
p(this, "isGasAsset", !1);
|
|
956
|
+
p(this, "isSynthetic", !1);
|
|
957
|
+
p(this, "symbol");
|
|
958
|
+
p(this, "tax");
|
|
959
|
+
p(this, "ticker");
|
|
960
|
+
p(this, "type");
|
|
961
|
+
const o = F(c || `${i}.${a}`);
|
|
962
|
+
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;
|
|
536
963
|
}
|
|
537
|
-
|
|
538
|
-
return this.
|
|
964
|
+
toString() {
|
|
965
|
+
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
539
966
|
}
|
|
540
|
-
|
|
541
|
-
return
|
|
967
|
+
toUrl() {
|
|
968
|
+
return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
|
|
542
969
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
e
|
|
546
|
-
);
|
|
547
|
-
return a ? new f({ decimal: s, identifier: a, value: r }) : void 0;
|
|
970
|
+
eq({ chain: n, symbol: r }) {
|
|
971
|
+
return this.chain === n && this.symbol === r;
|
|
548
972
|
}
|
|
549
|
-
|
|
550
|
-
return
|
|
973
|
+
chainId() {
|
|
974
|
+
return Le[this.chain];
|
|
551
975
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
976
|
+
// THOR.RUNE
|
|
977
|
+
// THOR.ETH.ETH
|
|
978
|
+
// ETH.THOR-0x1234567890
|
|
979
|
+
static fromUrl(n, r = 0) {
|
|
980
|
+
const [s, i, a] = n.split(".");
|
|
981
|
+
if (!s || !i)
|
|
982
|
+
throw new Error("Invalid asset url");
|
|
983
|
+
const c = s === l.THORChain && a ? `${s}.${i}/${a}` : n;
|
|
984
|
+
return J(c, r);
|
|
555
985
|
}
|
|
556
|
-
static
|
|
557
|
-
|
|
558
|
-
return new f({ value: r, decimal: s, identifier: a });
|
|
986
|
+
static fromString(n, r = 0) {
|
|
987
|
+
return J(n, r);
|
|
559
988
|
}
|
|
560
|
-
static
|
|
561
|
-
|
|
562
|
-
return new f({ value: a, identifier: e, decimal: s });
|
|
989
|
+
static fromIdentifier(n, r = 0) {
|
|
990
|
+
return J(n, r);
|
|
563
991
|
}
|
|
564
|
-
static
|
|
565
|
-
const s =
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
992
|
+
static fromStringSync(n, r = 0) {
|
|
993
|
+
const { chain: s, isSynthetic: i } = F(n), a = w.get(n.toUpperCase());
|
|
994
|
+
if (i)
|
|
995
|
+
return he(n, r);
|
|
996
|
+
const { tax: c, decimal: o, identifier: _ } = a || {
|
|
997
|
+
decimal: d[s],
|
|
998
|
+
identifier: n
|
|
999
|
+
};
|
|
1000
|
+
return new g({
|
|
1001
|
+
tax: c,
|
|
1002
|
+
value: V(r, o),
|
|
1003
|
+
identifier: i ? n : _,
|
|
1004
|
+
decimal: i ? 8 : o
|
|
569
1005
|
});
|
|
570
|
-
return new f({ ...s, value: a });
|
|
571
1006
|
}
|
|
572
|
-
static
|
|
1007
|
+
static fromIdentifierSync(n, r = 0) {
|
|
1008
|
+
const { chain: s, isSynthetic: i } = F(n), a = w.get(n);
|
|
1009
|
+
if (i)
|
|
1010
|
+
return he(n, r);
|
|
1011
|
+
const { tax: c, decimal: o, identifier: _ } = a || {
|
|
1012
|
+
decimal: d[s],
|
|
1013
|
+
identifier: n
|
|
1014
|
+
};
|
|
1015
|
+
return new g({ tax: c, decimal: o, identifier: _, value: V(r, o) });
|
|
1016
|
+
}
|
|
1017
|
+
static fromChainOrSignature(n, r = 0) {
|
|
1018
|
+
const { decimal: s, identifier: i } = at(n);
|
|
1019
|
+
return new g({ value: V(r, s), decimal: s, identifier: i });
|
|
1020
|
+
}
|
|
1021
|
+
static loadStaticAssets() {
|
|
573
1022
|
return new Promise(
|
|
574
|
-
async (
|
|
1023
|
+
async (n, r) => {
|
|
575
1024
|
try {
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
u.set(d, { identifier: d, decimal: R });
|
|
587
|
-
}), u),
|
|
588
|
-
/* @__PURE__ */ new Map()
|
|
589
|
-
), e({ ok: !0 });
|
|
1025
|
+
const s = await import("@swapkit/tokens");
|
|
1026
|
+
Object.values(s).forEach((i) => {
|
|
1027
|
+
var a;
|
|
1028
|
+
(a = i == null ? void 0 : i.tokens) == null || a.forEach(({ identifier: c, chain: o, ..._ }) => {
|
|
1029
|
+
w.set(c.toUpperCase(), {
|
|
1030
|
+
identifier: c,
|
|
1031
|
+
decimal: "decimals" in _ ? _.decimals : d[o]
|
|
1032
|
+
});
|
|
1033
|
+
});
|
|
1034
|
+
}), n({ ok: !0 });
|
|
590
1035
|
} catch (s) {
|
|
591
1036
|
console.error(s), r({
|
|
592
1037
|
ok: !1,
|
|
@@ -598,35 +1043,60 @@ class f extends y {
|
|
|
598
1043
|
);
|
|
599
1044
|
}
|
|
600
1045
|
}
|
|
601
|
-
|
|
602
|
-
const t =
|
|
603
|
-
switch (
|
|
604
|
-
case
|
|
605
|
-
case
|
|
606
|
-
case
|
|
607
|
-
return t.
|
|
608
|
-
case
|
|
609
|
-
return t.
|
|
610
|
-
case
|
|
611
|
-
case
|
|
612
|
-
return t.
|
|
613
|
-
case
|
|
614
|
-
case
|
|
615
|
-
return t.
|
|
1046
|
+
function Vt(e) {
|
|
1047
|
+
const t = g.fromChainOrSignature(e);
|
|
1048
|
+
switch (e) {
|
|
1049
|
+
case l.Bitcoin:
|
|
1050
|
+
case l.Litecoin:
|
|
1051
|
+
case l.BitcoinCash:
|
|
1052
|
+
return t.set(10001e-8);
|
|
1053
|
+
case l.Dogecoin:
|
|
1054
|
+
return t.set(1.00000001);
|
|
1055
|
+
case l.Avalanche:
|
|
1056
|
+
case l.Ethereum:
|
|
1057
|
+
return t.set(1e-8);
|
|
1058
|
+
case l.THORChain:
|
|
1059
|
+
case l.Maya:
|
|
1060
|
+
return t.set(0);
|
|
1061
|
+
case l.Cosmos:
|
|
1062
|
+
return t.set(1e-6);
|
|
616
1063
|
default:
|
|
617
|
-
return t.
|
|
1064
|
+
return t.set(1e-8);
|
|
618
1065
|
}
|
|
619
|
-
}
|
|
620
|
-
|
|
1066
|
+
}
|
|
1067
|
+
async function J(e, t = 0) {
|
|
1068
|
+
dt(e);
|
|
1069
|
+
const n = w.get(e.toUpperCase()), r = (n == null ? void 0 : n.decimal) || await it(F(e));
|
|
1070
|
+
return n || w.set(e.toUpperCase(), { identifier: e, decimal: r }), new g({ decimal: r, value: V(t, r), identifier: e });
|
|
1071
|
+
}
|
|
1072
|
+
function he(e, t = 0) {
|
|
1073
|
+
const [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1074
|
+
if (!n || !r)
|
|
1075
|
+
throw new Error("Invalid asset identifier");
|
|
1076
|
+
return new g({
|
|
1077
|
+
decimal: 8,
|
|
1078
|
+
value: V(t, 8),
|
|
1079
|
+
identifier: `${l.THORChain}.${n}/${r}`
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
function V(e, t) {
|
|
1083
|
+
return typeof e == "bigint" ? G({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1084
|
+
}
|
|
1085
|
+
function F(e) {
|
|
1086
|
+
const t = e.slice(0, 14).includes("/"), [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1087
|
+
if (t && (!n || !r))
|
|
1088
|
+
throw new Error("Invalid asset identifier");
|
|
1089
|
+
const s = e.includes(".") && !t ? e : `${l.THORChain}.${r}`, [i, ...a] = s.split("."), [c, o] = (t ? r : a.join(".")).split("-"), _ = t ? r : a.join(".");
|
|
621
1090
|
return {
|
|
622
|
-
address:
|
|
623
|
-
chain:
|
|
624
|
-
isGasAsset:
|
|
1091
|
+
address: o == null ? void 0 : o.toLowerCase(),
|
|
1092
|
+
chain: i,
|
|
1093
|
+
isGasAsset: fe({ chain: i, symbol: _ }),
|
|
625
1094
|
isSynthetic: t,
|
|
626
|
-
symbol:
|
|
627
|
-
ticker:
|
|
1095
|
+
symbol: (t ? `${n}/` : "") + (o ? `${c}-${(o == null ? void 0 : o.toLowerCase()) ?? ""}` : _),
|
|
1096
|
+
ticker: c
|
|
628
1097
|
};
|
|
629
|
-
}
|
|
1098
|
+
}
|
|
1099
|
+
const At = {
|
|
630
1100
|
/**
|
|
631
1101
|
* Core
|
|
632
1102
|
*/
|
|
@@ -647,6 +1117,7 @@ const Pt = (n) => {
|
|
|
647
1117
|
core_wallet_trezor_not_installed: 10106,
|
|
648
1118
|
core_wallet_keplr_not_installed: 10107,
|
|
649
1119
|
core_wallet_okx_not_installed: 10108,
|
|
1120
|
+
core_wallet_keepkey_not_installed: 10109,
|
|
650
1121
|
/**
|
|
651
1122
|
* Core - Swap
|
|
652
1123
|
*/
|
|
@@ -673,52 +1144,71 @@ const Pt = (n) => {
|
|
|
673
1144
|
core_transaction_deposit_to_pool_error: 10310,
|
|
674
1145
|
core_transaction_deposit_insufficient_funds_error: 10311,
|
|
675
1146
|
core_transaction_deposit_gas_error: 10312,
|
|
676
|
-
|
|
1147
|
+
core_transaction_invalid_sender_address: 10313,
|
|
1148
|
+
core_transaction_deposit_server_error: 10314,
|
|
1149
|
+
core_transaction_user_rejected: 10315,
|
|
677
1150
|
/**
|
|
678
1151
|
* Wallets
|
|
679
1152
|
*/
|
|
680
1153
|
wallet_ledger_connection_error: 20001,
|
|
1154
|
+
wallet_ledger_connection_claimed: 20002,
|
|
1155
|
+
wallet_ledger_get_address_error: 20003,
|
|
1156
|
+
wallet_ledger_device_not_found: 20004,
|
|
1157
|
+
wallet_ledger_device_locked: 20005,
|
|
681
1158
|
/**
|
|
682
1159
|
* Helpers
|
|
683
1160
|
*/
|
|
684
1161
|
helpers_number_different_decimals: 99101
|
|
685
1162
|
};
|
|
686
|
-
class
|
|
687
|
-
constructor(t,
|
|
688
|
-
console.error(
|
|
1163
|
+
class Ce extends Error {
|
|
1164
|
+
constructor(t, n) {
|
|
1165
|
+
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);
|
|
689
1166
|
}
|
|
690
1167
|
}
|
|
691
|
-
class
|
|
1168
|
+
class I extends W {
|
|
692
1169
|
eq(t) {
|
|
693
1170
|
return this.eqValue(t);
|
|
694
1171
|
}
|
|
1172
|
+
static fromBigInt(t, n) {
|
|
1173
|
+
return new I({
|
|
1174
|
+
decimal: n,
|
|
1175
|
+
value: G({ value: t, bigIntDecimal: n, decimal: n })
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
695
1178
|
}
|
|
696
1179
|
export {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
Vt as
|
|
1180
|
+
m as ApiEndpoints,
|
|
1181
|
+
g as AssetValue,
|
|
1182
|
+
W as BigIntArithmetics,
|
|
1183
|
+
S as RequestClient,
|
|
1184
|
+
et as StreamingSwapProgressStatus,
|
|
1185
|
+
Et as SwapKitApi,
|
|
1186
|
+
Ce as SwapKitError,
|
|
1187
|
+
I as SwapKitNumber,
|
|
1188
|
+
ze as TransactionType,
|
|
1189
|
+
Ze as TxStatus,
|
|
1190
|
+
It as assetFromString,
|
|
1191
|
+
Re as defaultRequestHeaders,
|
|
1192
|
+
wt as derivationPathToString,
|
|
1193
|
+
ft as filterAssets,
|
|
1194
|
+
G as formatBigIntToSafeValue,
|
|
1195
|
+
Rt as gasFeeMultiplier,
|
|
1196
|
+
ot as getAssetType,
|
|
1197
|
+
_t as getAsymmetricAssetShare,
|
|
1198
|
+
Ct as getAsymmetricAssetWithdrawAmount,
|
|
1199
|
+
ut as getAsymmetricRuneShare,
|
|
1200
|
+
Nt as getAsymmetricRuneWithdrawAmount,
|
|
1201
|
+
at as getCommonAssetInfo,
|
|
1202
|
+
it as getDecimal,
|
|
1203
|
+
Ot as getEstimatedPoolShare,
|
|
1204
|
+
Dt as getLiquiditySlippage,
|
|
1205
|
+
Pt as getMemoFor,
|
|
1206
|
+
Vt as getMinAmountByChain,
|
|
1207
|
+
ht as getSymmetricPoolShare,
|
|
1208
|
+
gt as getSymmetricWithdraw,
|
|
1209
|
+
bt as getTHORNameCost,
|
|
1210
|
+
fe as isGasAsset,
|
|
1211
|
+
mt as setRequestClientConfig,
|
|
1212
|
+
yt as validateTHORName
|
|
724
1213
|
};
|
|
1214
|
+
//# sourceMappingURL=index.es.js.map
|