@swapkit/helpers 1.0.0-rc.70 → 1.0.0-rc.72

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.es.js CHANGED
@@ -1,44 +1,42 @@
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) => {
1
+ var $e = Object.defineProperty;
2
+ var ve = (e, t, n) => t in e ? $e(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var _ = (e, t, n) => (ve(e, typeof t != "symbol" ? t + "" : t, n), n), Ie = (e, t, n) => {
4
4
  if (!t.has(e))
5
5
  throw TypeError("Cannot " + n);
6
6
  };
7
- var O = (e, t, n) => {
7
+ var R = (e, t, n) => {
8
8
  if (t.has(e))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
10
  t instanceof WeakSet ? t.add(e) : t.set(e, n);
11
11
  };
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(
12
+ var p = (e, t, n) => (Ie(e, t, "access private method"), n);
13
+ import { FeeOption as K, BaseDecimal as d, Chain as l, EVMChains as Ne, ChainToRPC as Be, MemoType as C, ChainToChainId as De } from "@swapkit/types";
14
+ var F = /* @__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))(F || {}), 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 || {}), S = /* @__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))(S || {});
15
+ const G = Object.values(F), Ve = Object.keys(F), re = G.reduce(
18
16
  (e, t) => {
19
- const n = $e.find((r) => j[r] === t);
17
+ const n = Ve.find((r) => F[r] === t);
20
18
  return n && (e[t] = n), e;
21
19
  },
22
20
  {}
23
21
  );
24
- q.reduce(
25
- (e, t) => (e[t] = te[ne[t]], e),
22
+ G.reduce(
23
+ (e, t) => (e[t] = ne[re[t]], e),
26
24
  {}
27
25
  );
28
- q.reduce(
29
- (e, t) => (e[t] = de[ne[t]], e),
26
+ G.reduce(
27
+ (e, t) => (e[t] = de[re[t]], e),
30
28
  {}
31
29
  );
32
- q.reduce(
30
+ G.reduce(
33
31
  (e, t) => {
34
- const n = `${ne[t]}Hex`;
35
- return e[t] = te[n], e;
32
+ const n = `${re[t]}Hex`;
33
+ return e[t] = ne[n], e;
36
34
  },
37
35
  {}
38
36
  );
39
- class oe extends Error {
37
+ class ae extends Error {
40
38
  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";
39
+ const s = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", o = `${s} ${i}`.trim(), c = o ? `status code ${o}` : "an unknown error";
42
40
  super(`Request failed with ${c}`), Object.defineProperty(this, "response", {
43
41
  enumerable: !0,
44
42
  configurable: !0,
@@ -57,7 +55,7 @@ class oe extends Error {
57
55
  }), this.name = "HTTPError", this.response = t, this.request = n, this.options = r;
58
56
  }
59
57
  }
60
- class Te extends Error {
58
+ class pe extends Error {
61
59
  constructor(t) {
62
60
  super("Request timed out"), Object.defineProperty(this, "request", {
63
61
  enumerable: !0,
@@ -67,28 +65,28 @@ class Te extends Error {
67
65
  }), this.name = "TimeoutError", this.request = t;
68
66
  }
69
67
  }
70
- const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
68
+ const k = (e) => e !== null && typeof e == "object", x = (...e) => {
71
69
  for (const t of e)
72
- if ((!M(t) || Array.isArray(t)) && t !== void 0)
70
+ if ((!k(t) || Array.isArray(t)) && t !== void 0)
73
71
  throw new TypeError("The `options` argument must be an object");
74
- return re({}, ...e);
75
- }, Ae = (e = {}, t = {}) => {
72
+ return se({}, ...e);
73
+ }, me = (e = {}, t = {}) => {
76
74
  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);
75
+ for (const [i, o] of s.entries())
76
+ r && o === "undefined" || o === void 0 ? n.delete(i) : n.set(i, o);
79
77
  return n;
80
- }, re = (...e) => {
78
+ }, se = (...e) => {
81
79
  let t = {}, n = {};
82
80
  for (const r of e)
83
81
  if (Array.isArray(r))
84
82
  Array.isArray(t) || (t = []), t = [...t, ...r];
85
- else if (M(r)) {
83
+ else if (k(r)) {
86
84
  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);
85
+ k(i) && s in t && (i = se(t[s], i)), t = { ...t, [s]: i };
86
+ k(r.headers) && (n = me(n, r.headers), t.headers = n);
89
87
  }
90
88
  return t;
91
- }, ve = (() => {
89
+ }, He = (() => {
92
90
  let e = !1, t = !1;
93
91
  const n = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
94
92
  return n && r && (t = new globalThis.Request("https://empty.invalid", {
@@ -99,13 +97,13 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
99
97
  return e = !0, "half";
100
98
  }
101
99
  }).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 = {
100
+ })(), xe = typeof globalThis.AbortController == "function", Me = typeof globalThis.ReadableStream == "function", ke = typeof globalThis.FormData == "function", _e = ["get", "post", "put", "patch", "head", "delete"], Le = {
103
101
  json: "application/json",
104
102
  text: "text/*",
105
103
  formData: "multipart/form-data",
106
104
  arrayBuffer: "*/*",
107
105
  blob: "*/*"
108
- }, K = 2147483647, Se = Symbol("stop"), Ge = {
106
+ }, J = 2147483647, Te = Symbol("stop"), We = {
109
107
  json: !0,
110
108
  parseJson: !0,
111
109
  searchParams: !0,
@@ -116,7 +114,7 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
116
114
  throwHttpErrors: !0,
117
115
  onDownloadProgress: !0,
118
116
  fetch: !0
119
- }, We = {
117
+ }, Ue = {
120
118
  method: !0,
121
119
  headers: !0,
122
120
  body: !0,
@@ -132,15 +130,15 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
132
130
  window: !0,
133
131
  dispatcher: !0,
134
132
  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 = {
133
+ }, je = (e) => _e.includes(e) ? e.toUpperCase() : e, qe = ["get", "put", "head", "delete", "options", "trace"], Fe = [408, 413, 429, 500, 502, 503, 504], fe = [413, 429, 503], ce = {
136
134
  limit: 2,
137
- methods: je,
138
- statusCodes: qe,
139
- afterStatusCodes: me,
135
+ methods: qe,
136
+ statusCodes: Fe,
137
+ afterStatusCodes: fe,
140
138
  maxRetryAfter: Number.POSITIVE_INFINITY,
141
139
  backoffLimit: Number.POSITIVE_INFINITY,
142
140
  delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
143
- }, Xe = (e = {}) => {
141
+ }, Ge = (e = {}) => {
144
142
  if (typeof e == "number")
145
143
  return {
146
144
  ...ce,
@@ -153,16 +151,16 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
153
151
  return {
154
152
  ...ce,
155
153
  ...e,
156
- afterStatusCodes: me
154
+ afterStatusCodes: fe
157
155
  };
158
156
  };
159
- async function Ye(e, t, n, r) {
157
+ async function Xe(e, t, n, r) {
160
158
  return new Promise((s, i) => {
161
- const a = setTimeout(() => {
162
- n && n.abort(), i(new Te(e));
159
+ const o = setTimeout(() => {
160
+ n && n.abort(), i(new pe(e));
163
161
  }, r.timeout);
164
162
  r.fetch(e, t).then(s).catch(i).then(() => {
165
- clearTimeout(a);
163
+ clearTimeout(o);
166
164
  });
167
165
  });
168
166
  }
@@ -180,46 +178,46 @@ async function Ke(e, { signal: t }) {
180
178
  const Je = (e, t) => {
181
179
  const n = {};
182
180
  for (const r in t)
183
- !(r in We) && !(r in Ge) && !(r in e) && (n[r] = t[r]);
181
+ !(r in Ue) && !(r in We) && !(r in e) && (n[r] = t[r]);
184
182
  return n;
185
183
  };
186
- class x {
184
+ class W {
187
185
  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}`);
186
+ const r = new W(t, n), s = async () => {
187
+ if (typeof r._options.timeout == "number" && r._options.timeout > J)
188
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${J}`);
191
189
  await Promise.resolve();
192
- let a = await r._fetch();
190
+ let o = await r._fetch();
193
191
  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);
192
+ const a = await c(r.request, r._options, r._decorateResponse(o.clone()));
193
+ a instanceof globalThis.Response && (o = a);
196
194
  }
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);
195
+ if (r._decorateResponse(o), !o.ok && r._options.throwHttpErrors) {
196
+ let c = new ae(o, r.request, r._options);
197
+ for (const a of r._options.hooks.beforeError)
198
+ c = await a(c);
201
199
  throw c;
202
200
  }
203
201
  if (r._options.onDownloadProgress) {
204
202
  if (typeof r._options.onDownloadProgress != "function")
205
203
  throw new TypeError("The `onDownloadProgress` option must be a function");
206
- if (!He)
204
+ if (!Me)
207
205
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
208
- return r._stream(a.clone(), r._options.onDownloadProgress);
206
+ return r._stream(o.clone(), r._options.onDownloadProgress);
209
207
  }
210
- return a;
208
+ return o;
211
209
  }, 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 () => {
210
+ for (const [o, c] of Object.entries(Le))
211
+ i[o] = async () => {
214
212
  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)
213
+ const a = (await i).clone();
214
+ if (o === "json") {
215
+ if (a.status === 204 || (await a.clone().arrayBuffer()).byteLength === 0)
218
216
  return "";
219
217
  if (n.parseJson)
220
- return n.parseJson(await o.text());
218
+ return n.parseJson(await a.text());
221
219
  }
222
- return o[a]();
220
+ return a[o]();
223
221
  };
224
222
  return i;
225
223
  }
@@ -254,17 +252,17 @@ class x {
254
252
  // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
255
253
  credentials: this._input.credentials || "same-origin",
256
254
  ...n,
257
- headers: Ae(this._input.headers, n.headers),
258
- hooks: re({
255
+ headers: me(this._input.headers, n.headers),
256
+ hooks: se({
259
257
  beforeRequest: [],
260
258
  beforeRetry: [],
261
259
  beforeError: [],
262
260
  afterResponse: []
263
261
  }, n.hooks),
264
- method: ke(n.method ?? this._input.method),
262
+ method: je(n.method ?? this._input.method),
265
263
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
266
264
  prefixUrl: String(n.prefixUrl || ""),
267
- retry: Xe(n.retry),
265
+ retry: Ge(n.retry),
268
266
  throwHttpErrors: n.throwHttpErrors !== !1,
269
267
  timeout: n.timeout ?? 1e4,
270
268
  fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
@@ -275,7 +273,7 @@ class x {
275
273
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
276
274
  this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
277
275
  }
278
- if (Me) {
276
+ if (xe) {
279
277
  if (this.abortController = new globalThis.AbortController(), this._options.signal) {
280
278
  const r = this._options.signal;
281
279
  this._options.signal.addEventListener("abort", () => {
@@ -284,15 +282,15 @@ class x {
284
282
  }
285
283
  this._options.signal = this.abortController.signal;
286
284
  }
287
- if (ve && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
285
+ if (He && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
288
286
  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);
287
+ (ke && 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
288
  }
291
289
  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
290
  }
293
291
  _calculateRetryDelay(t) {
294
- if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof Te)) {
295
- if (t instanceof oe) {
292
+ if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof pe)) {
293
+ if (t instanceof ae) {
296
294
  if (!this._options.retry.statusCodes.includes(t.response.status))
297
295
  return 0;
298
296
  const r = t.response.headers.get("Retry-After");
@@ -315,7 +313,7 @@ class x {
315
313
  try {
316
314
  return await t();
317
315
  } catch (n) {
318
- const r = Math.min(this._calculateRetryDelay(n), K);
316
+ const r = Math.min(this._calculateRetryDelay(n), J);
319
317
  if (r !== 0 && this._retryCount > 0) {
320
318
  await Ke(r, { signal: this._options.signal });
321
319
  for (const s of this._options.hooks.beforeRetry)
@@ -324,7 +322,7 @@ class x {
324
322
  options: this._options,
325
323
  error: n,
326
324
  retryCount: this._retryCount
327
- }) === Se)
325
+ }) === Te)
328
326
  return;
329
327
  return this._retry(t);
330
328
  }
@@ -342,7 +340,7 @@ class x {
342
340
  return r;
343
341
  }
344
342
  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);
343
+ return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Xe(this.request.clone(), t, this.abortController, this._options);
346
344
  }
347
345
  /* istanbul ignore next */
348
346
  _stream(t, n) {
@@ -354,20 +352,20 @@ class x {
354
352
  headers: t.headers
355
353
  })) : new globalThis.Response(new globalThis.ReadableStream({
356
354
  async start(i) {
357
- const a = t.body.getReader();
355
+ const o = t.body.getReader();
358
356
  n && n({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
359
357
  async function c() {
360
- const { done: o, value: _ } = await a.read();
361
- if (o) {
358
+ const { done: a, value: u } = await o.read();
359
+ if (a) {
362
360
  i.close();
363
361
  return;
364
362
  }
365
363
  if (n) {
366
- s += _.byteLength;
364
+ s += u.byteLength;
367
365
  const h = r === 0 ? 0 : s / r;
368
- n({ percent: h, transferredBytes: s, totalBytes: r }, _);
366
+ n({ percent: h, transferredBytes: s, totalBytes: r }, u);
369
367
  }
370
- i.enqueue(_), await c();
368
+ i.enqueue(u), await c();
371
369
  }
372
370
  await c();
373
371
  }
@@ -379,50 +377,54 @@ class x {
379
377
  }
380
378
  }
381
379
  /*! 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({
380
+ const z = (e) => {
381
+ const t = (n, r) => W.create(n, x(e, r));
382
+ for (const n of _e)
383
+ t[n] = (r, s) => W.create(r, x(e, s, { method: n }));
384
+ return t.create = (n) => z(x(n)), t.extend = (n) => z(x(e, n)), t.stop = Te, t;
385
+ }, ge = z();
386
+ let L;
387
+ const f = {
388
+ CachedPrices: `${S.ThorswapApi}/tokenlist/cached-price`,
389
+ GasRates: `${S.ThorswapApi}/resource-worker/gasPrice/getAll`,
390
+ Quote: `${S.ThorswapApi}/aggregator/tokens/quote`,
391
+ Txn: `${S.ThorswapApi}/apiusage/v2/txn`,
392
+ TokenlistProviders: `${S.ThorswapApi}/tokenlist/providers`,
393
+ TokenList: `${S.ThorswapStatic}/token-list`,
394
+ Thorname: `${S.ThorswapApi}/thorname`
395
+ }, Ae = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, le = () => L || (L = ge.create({ headers: Ae }), L), ft = ({ apiKey: e, ...t }) => {
396
+ L = ge.create({
399
397
  ...t,
400
- headers: { ...Re, ...t.headers, "x-api-key": e }
398
+ headers: { ...Ae, ...t.headers, "x-api-key": e }
401
399
  });
402
- }, S = {
400
+ }, T = {
403
401
  get: (e, t) => le().get(e, t).json(),
404
402
  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, {
403
+ }, Ye = ({ tokens: e, ...t }) => {
404
+ const n = new URLSearchParams(), r = e.filter(
405
+ (s, i, o) => o.findIndex((c) => c === s) === i
406
+ );
407
+ for (const s of r)
408
+ n.append("tokens", JSON.stringify(s));
409
+ return t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), T.post(f.CachedPrices, {
408
410
  body: n.toString(),
409
411
  headers: { "Content-Type": "application/x-www-form-urlencoded" }
410
412
  });
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 } })
413
+ }, gt = {
414
+ getCachedPrices: Ye,
415
+ getQuote: (e) => T.get(f.Quote, { searchParams: e }),
416
+ getGasRates: () => T.get(f.GasRates),
417
+ getTxnDetails: (e) => T.get(f.Txn, { searchParams: e }),
418
+ getTokenlistProviders: () => T.get(f.TokenlistProviders),
419
+ getTokenList: (e) => T.get(`${f.TokenList}/${e}.json`),
420
+ getThornameAddresses: (e) => T.get(`${f.Thorname}/${e}`),
421
+ getThornameRegisteredChains: (e) => T.get(`${f.Thorname}/chains/${e}`),
422
+ getThornameRlookup: (e, t) => T.get(`${f.Thorname}/rlookup`, { searchParams: { address: e, chain: t } })
421
423
  };
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 }) => {
424
+ var Qe = /* @__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))(Qe || {}), 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 || {}), Ze = /* @__PURE__ */ ((e) => (e[e.NOT_STARTED = 0] = "NOT_STARTED", e[e.SUCCESS = 1] = "SUCCESS", e[e.REFUNDED = 2] = "REFUNDED", e))(Ze || {});
425
+ const et = "0x313ce567", Ce = async ({ chain: e, to: t }) => {
424
426
  try {
425
- const { result: n } = await S.post(Ue[e], {
427
+ const { result: n } = await T.post(Be[e], {
426
428
  headers: {
427
429
  accept: "*/*",
428
430
  "content-type": "application/json",
@@ -432,37 +434,37 @@ const tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
432
434
  id: 44,
433
435
  jsonrpc: "2.0",
434
436
  method: "eth_call",
435
- params: [{ to: t.toLowerCase(), data: tt }, "latest"]
437
+ params: [{ to: t.toLowerCase(), data: et }, "latest"]
436
438
  })
437
439
  });
438
440
  return parseInt(BigInt(n).toString());
439
441
  } catch (n) {
440
442
  return console.error(n), d[e];
441
443
  }
442
- }, nt = async (e) => {
444
+ }, tt = (e) => {
443
445
  if (e === l.Ethereum)
444
446
  return d.ETH;
445
447
  const [, t] = e.split("-");
446
- return t != null && t.startsWith("0x") ? Ie({ chain: l.Ethereum, to: t }) : d.ETH;
447
- }, rt = async (e) => {
448
+ return t != null && t.startsWith("0x") ? Ce({ chain: l.Ethereum, to: t }) : d.ETH;
449
+ }, nt = (e) => {
448
450
  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
+ return t != null && t.startsWith("0x") ? Ce({ chain: l.Avalanche, to: t.toLowerCase() }) : d.AVAX;
452
+ }, rt = (e) => e === l.BinanceSmartChain ? d.BSC : d.BSC, st = ({ chain: e, symbol: t }) => {
451
453
  switch (e) {
452
454
  case l.Ethereum:
453
- return nt(t);
455
+ return tt(t);
454
456
  case l.Avalanche:
455
- return rt(t);
457
+ return nt(t);
456
458
  case l.BinanceSmartChain:
457
- return st(t);
459
+ return rt(t);
458
460
  default:
459
461
  return d[e];
460
462
  }
461
- }, Rt = {
462
- [Y.Average]: 1.2,
463
- [Y.Fast]: 1.5,
464
- [Y.Fastest]: 2
465
- }, fe = ({ chain: e, symbol: t }) => {
463
+ }, At = {
464
+ [K.Average]: 1.2,
465
+ [K.Fast]: 1.5,
466
+ [K.Fastest]: 2
467
+ }, Se = ({ chain: e, symbol: t }) => {
466
468
  switch (e) {
467
469
  case l.Arbitrum:
468
470
  case l.Optimism:
@@ -482,7 +484,7 @@ const tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
482
484
  default:
483
485
  return t === e;
484
486
  }
485
- }, at = (e) => {
487
+ }, it = (e) => {
486
488
  switch (e) {
487
489
  case `${l.Ethereum}.THOR`:
488
490
  return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
@@ -528,57 +530,57 @@ const tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
528
530
  default:
529
531
  return "Native";
530
532
  }
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];
533
+ }, Ct = (e) => {
534
+ var o;
535
+ const [t, ...n] = e.split("."), r = e.includes("/"), s = n.join("."), i = (o = s == null ? void 0 : s.split("-")) == null ? void 0 : o[0];
534
536
  return { chain: t, symbol: s, ticker: i, synth: r };
535
- }, ct = new RegExp(
537
+ }, at = new RegExp(
536
538
  /(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
537
539
  "gmi"
538
- ), lt = (e) => {
540
+ ), ct = (e) => {
539
541
  const [t, n] = e.split(".");
540
- if (!Be.includes(t))
542
+ if (!Ne.includes(t))
541
543
  return !0;
542
544
  const [, r] = n.split("-");
543
- return fe({ chain: t, symbol: n }) || !!r;
544
- }, ft = (e) => e.filter(({ chain: t, value: n, symbol: r }) => {
545
+ return Se({ chain: t, symbol: n }) || !!r;
546
+ }, St = (e) => e.filter(({ chain: t, value: n, symbol: r }) => {
545
547
  const s = `${t}.${r}`;
546
- return !ct.test(s) && lt(s) && n !== "0";
548
+ return !at.test(s) && ct(s) && n !== "0";
547
549
  });
548
- function ut({
550
+ function lt({
549
551
  liquidityUnits: e,
550
552
  poolUnits: t,
551
553
  runeDepth: n
552
554
  }) {
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
+ const r = m(e), s = m(t), i = m(n), o = r.mul(i), c = s.mul(s).mul(2), a = s.mul(r).mul(2), u = r.mul(r), h = s.mul(s).mul(s);
556
+ return o.mul(c.sub(a).add(u)).div(h);
555
557
  }
556
- function _t({
558
+ function ut({
557
559
  liquidityUnits: e,
558
560
  poolUnits: t,
559
561
  assetDepth: n
560
562
  }) {
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
+ const r = m(e), s = m(t), i = m(n), o = r.mul(i), c = s.mul(s).mul(2), a = s.mul(r).mul(2), u = r.mul(r), h = o.mul(c.sub(a).add(u)), $ = s.mul(s).mul(s);
564
+ return h.div($);
563
565
  }
564
- function Nt({
566
+ function bt({
565
567
  percent: e,
566
568
  runeDepth: t,
567
569
  liquidityUnits: n,
568
570
  poolUnits: r
569
571
  }) {
570
- return ut({ runeDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
572
+ return lt({ runeDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
571
573
  }
572
- function Ct({
574
+ function yt({
573
575
  percent: e,
574
576
  assetDepth: t,
575
577
  liquidityUnits: n,
576
578
  poolUnits: r
577
579
  }) {
578
- return _t({ assetDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
580
+ return ut({ assetDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
579
581
  }
580
- function A(e) {
581
- return I.fromBigInt(BigInt(e), d.THOR);
582
+ function m(e) {
583
+ return g.fromBigInt(BigInt(e), d.THOR);
582
584
  }
583
585
  function ht({
584
586
  liquidityUnits: e,
@@ -587,11 +589,11 @@ function ht({
587
589
  assetDepth: r
588
590
  }) {
589
591
  return {
590
- assetAmount: A(r).mul(e).div(t),
591
- runeAmount: A(n).mul(e).div(t)
592
+ assetAmount: m(r).mul(e).div(t),
593
+ runeAmount: m(n).mul(e).div(t)
592
594
  };
593
595
  }
594
- function gt({
596
+ function wt({
595
597
  liquidityUnits: e,
596
598
  poolUnits: t,
597
599
  runeDepth: n,
@@ -600,11 +602,11 @@ function gt({
600
602
  }) {
601
603
  return Object.fromEntries(
602
604
  Object.entries(ht({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: r })).map(
603
- ([i, a]) => [i, a.mul(s)]
605
+ ([i, o]) => [i, o.mul(s)]
604
606
  )
605
607
  );
606
608
  }
607
- function Ot({
609
+ function Rt({
608
610
  runeDepth: e,
609
611
  poolUnits: t,
610
612
  assetDepth: n,
@@ -612,13 +614,13 @@ function Ot({
612
614
  runeAmount: s,
613
615
  assetAmount: i
614
616
  }) {
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");
617
+ const o = new g({ value: e, decimal: 8 }), c = new g({ value: n, decimal: 8 }), a = new g({ value: t, decimal: 8 }), u = new g({ value: s, decimal: 8 }), h = new g({ value: i, decimal: 8 }), $ = u.mul(c), ie = h.mul(o), we = u.mul(h), Re = o.mul(c), Ee = a.mul($.add(ie.add(we.mul(2)))), Pe = $.add(ie.add(Re.mul(2))), oe = Ee.div(Pe), X = m(r).add(oe);
618
+ if (oe.getBaseValue("number") === 0)
619
+ return X.div(a).getBaseValue("number");
620
+ const Oe = a.add(X);
621
+ return X.div(Oe).getBaseValue("number");
620
622
  }
621
- function Dt({
623
+ function Et({
622
624
  runeAmount: e,
623
625
  assetAmount: t,
624
626
  runeDepth: n,
@@ -626,27 +628,27 @@ function Dt({
626
628
  }) {
627
629
  if (e === "0" || t === "0" || n === "0" || r === "0")
628
630
  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
+ const s = m(n), i = m(r), o = m(t), c = m(e), a = o.mul(s).sub(i.mul(c)), u = i.mul(c).add(s.mul(i));
632
+ return Math.abs(a.div(u).getBaseValue("number"));
631
633
  }
632
634
  const Pt = (e, t) => {
633
635
  switch (e) {
634
- case E.LEAVE:
635
- case E.BOND: {
636
+ case C.LEAVE:
637
+ case C.BOND: {
636
638
  const { address: n } = t;
637
639
  return `${e}:${n}`;
638
640
  }
639
- case E.UNBOND: {
641
+ case C.UNBOND: {
640
642
  const { address: n, unbondAmount: r } = t;
641
643
  return `${e}:${n}:${r}`;
642
644
  }
643
- case E.THORNAME_REGISTER: {
645
+ case C.THORNAME_REGISTER: {
644
646
  const { name: n, chain: r, address: s, owner: i } = t;
645
647
  return `${e}:${n}:${r}:${s}${i ? `:${i}` : ""}`;
646
648
  }
647
- case E.DEPOSIT: {
649
+ case C.DEPOSIT: {
648
650
  const { chain: n, symbol: r, address: s, singleSide: i } = t;
649
- return i ? `${e}:${n}/${r}` : `${e}:${((c, o) => {
651
+ return i ? `${e}:${n}/${r}` : `${e}:${((c, a) => {
650
652
  switch (c) {
651
653
  case l.Litecoin:
652
654
  return "l";
@@ -655,16 +657,16 @@ const Pt = (e, t) => {
655
657
  case l.BitcoinCash:
656
658
  return "c";
657
659
  default:
658
- return `${c}.${o}`;
660
+ return `${c}.${a}`;
659
661
  }
660
662
  })(n, r)}:${s || ""}`;
661
663
  }
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}${_}`;
664
+ case C.WITHDRAW: {
665
+ const { chain: n, ticker: r, symbol: s, basisPoints: i, targetAssetString: o, singleSide: c } = t, a = n === "ETH" && r !== "ETH" ? `${r}-${s.slice(-3)}` : s, u = !c && o ? `:${o}` : "";
666
+ return `${e}:${n}${c ? "/" : "."}${a}:${i}${u}`;
665
667
  }
666
- case E.OPEN_LOAN:
667
- case E.CLOSE_LOAN: {
668
+ case C.OPEN_LOAN:
669
+ case C.CLOSE_LOAN: {
668
670
  const { asset: n, address: r } = t;
669
671
  return `${e}:${n}:${r}`;
670
672
  }
@@ -672,18 +674,18 @@ const Pt = (e, t) => {
672
674
  return "";
673
675
  }
674
676
  };
675
- function bt(e) {
677
+ function Ot(e) {
676
678
  if (e < 0)
677
679
  throw new Error("Invalid number of year");
678
680
  return 10 + e;
679
681
  }
680
- function yt(e) {
682
+ function $t(e) {
681
683
  if (e.length > 30)
682
684
  return !1;
683
685
  const t = /^[a-zA-Z0-9+_-]+$/g;
684
686
  return !!e.match(t);
685
687
  }
686
- function wt([e, t, n, r, s]) {
688
+ function vt([e, t, n, r, s]) {
687
689
  return `${e}'/${t}'/${n}'/${r}${typeof s != "number" ? "" : `/${s}`}`;
688
690
  }
689
691
  const ue = [...Object.values(l), "TERRA"];
@@ -698,8 +700,8 @@ function dt(e = "") {
698
700
  `Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
699
701
  );
700
702
  }
701
- const B = 8, N = (e) => 10n ** BigInt(e), b = (e) => Math.log10(parseFloat(e.toString()));
702
- function G({
703
+ const B = 8, y = (e) => 10n ** BigInt(e), v = (e) => Math.log10(parseFloat(e.toString()));
704
+ function U({
703
705
  value: e,
704
706
  bigIntDecimal: t = B,
705
707
  decimal: n = B
@@ -710,31 +712,31 @@ function G({
710
712
  let s = e.toString().substring(r ? 1 : 0);
711
713
  const i = n - (s.length - 1);
712
714
  i > 0 && (s = "0".repeat(i) + s);
713
- const a = s.length - n;
715
+ const o = s.length - n;
714
716
  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(
717
+ 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, o)}.${c}`.replace(
716
718
  /\.?0*$/,
717
719
  ""
718
720
  );
719
721
  }
720
- var C, y, f, D, k, Ne, U, z, L, Z;
721
- const se = class se {
722
+ var w, I, b, E, j, be, V, Z, H, ee;
723
+ const q = class q {
722
724
  constructor(t) {
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);
725
+ R(this, w);
726
+ R(this, b);
727
+ R(this, j);
728
+ R(this, V);
729
+ R(this, H);
730
+ _(this, "decimalMultiplier", 10n ** 8n);
731
+ _(this, "bigIntValue", 0n);
732
+ _(this, "decimal");
733
+ const n = te(t), r = typeof t == "object";
734
+ this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : y(Math.max(he(M(n)), this.decimal || 0)), p(this, j, be).call(this, n);
733
735
  }
734
736
  static fromBigInt(t, n) {
735
- return new se({
737
+ return new q({
736
738
  decimal: n,
737
- value: G({ value: t, bigIntDecimal: n, decimal: n })
739
+ value: U({ value: t, bigIntDecimal: n, decimal: n })
738
740
  });
739
741
  }
740
742
  static shiftDecimals({
@@ -742,8 +744,8 @@ const se = class se {
742
744
  from: n,
743
745
  to: r
744
746
  }) {
745
- return this.fromBigInt(
746
- t.getBaseValue("bigint") * N(r) / N(n),
747
+ return q.fromBigInt(
748
+ t.getBaseValue("bigint") * y(r) / y(n),
747
749
  r
748
750
  );
749
751
  }
@@ -751,37 +753,37 @@ const se = class se {
751
753
  return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
752
754
  }
753
755
  add(...t) {
754
- return T(this, C, y).call(this, "add", ...t);
756
+ return p(this, w, I).call(this, "add", ...t);
755
757
  }
756
758
  sub(...t) {
757
- return T(this, C, y).call(this, "sub", ...t);
759
+ return p(this, w, I).call(this, "sub", ...t);
758
760
  }
759
761
  mul(...t) {
760
- return T(this, C, y).call(this, "mul", ...t);
762
+ return p(this, w, I).call(this, "mul", ...t);
761
763
  }
762
764
  div(...t) {
763
- return T(this, C, y).call(this, "div", ...t);
765
+ return p(this, w, I).call(this, "div", ...t);
764
766
  }
765
767
  gt(t) {
766
- return T(this, f, D).call(this, "gt", t);
768
+ return p(this, b, E).call(this, "gt", t);
767
769
  }
768
770
  gte(t) {
769
- return T(this, f, D).call(this, "gte", t);
771
+ return p(this, b, E).call(this, "gte", t);
770
772
  }
771
773
  lt(t) {
772
- return T(this, f, D).call(this, "lt", t);
774
+ return p(this, b, E).call(this, "lt", t);
773
775
  }
774
776
  lte(t) {
775
- return T(this, f, D).call(this, "lte", t);
777
+ return p(this, b, E).call(this, "lte", t);
776
778
  }
777
779
  eqValue(t) {
778
- return T(this, f, D).call(this, "eqValue", t);
780
+ return p(this, b, E).call(this, "eqValue", t);
779
781
  }
780
782
  // @ts-expect-error False positive
781
783
  getValue(t) {
782
784
  const n = this.formatBigIntToSafeValue(
783
785
  this.bigIntValue,
784
- this.decimal || b(this.decimalMultiplier)
786
+ this.decimal || v(this.decimalMultiplier)
785
787
  );
786
788
  switch (t) {
787
789
  case "number":
@@ -794,7 +796,7 @@ const se = class se {
794
796
  }
795
797
  // @ts-expect-error
796
798
  getBaseValue(t) {
797
- const n = this.decimalMultiplier / N(this.decimal || d.THOR), r = this.bigIntValue / n;
799
+ const n = this.decimalMultiplier / y(this.decimal || d.THOR), r = this.bigIntValue / n;
798
800
  switch (t) {
799
801
  case "number":
800
802
  return Number(r);
@@ -807,8 +809,8 @@ const se = class se {
807
809
  getBigIntValue(t, n) {
808
810
  if (!n && typeof t == "object")
809
811
  return t.bigIntValue;
810
- const r = ee(t), s = v(r);
811
- return s === "0" || s === "undefined" ? 0n : T(this, L, Z).call(this, s, n);
812
+ const r = te(t), s = M(r);
813
+ return s === "0" || s === "undefined" ? 0n : p(this, H, ee).call(this, s, n);
812
814
  }
813
815
  toSignificant(t = 6) {
814
816
  const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
@@ -821,9 +823,9 @@ const se = class se {
821
823
  t - s.length,
822
824
  "0"
823
825
  );
824
- const c = parseInt(i), o = `${c}`.slice(0, t);
825
- return `0.${o.padStart(
826
- i.length - `${c}`.length + o.length,
826
+ const c = parseInt(i), a = `${c}`.slice(0, t);
827
+ return `0.${a.padStart(
828
+ i.length - `${c}`.length + a.length,
827
829
  "0"
828
830
  )}`;
829
831
  }
@@ -831,9 +833,9 @@ const se = class se {
831
833
  const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
832
834
  if (parseInt(s))
833
835
  return `${s}.${i.slice(0, t)}`.padEnd(t, "0");
834
- const a = parseInt(i), c = `${a}`.slice(0, t);
836
+ const o = parseInt(i), c = `${o}`.slice(0, t);
835
837
  return `0.${c.padStart(
836
- i.length - `${a}`.length + c.length,
838
+ i.length - `${o}`.length + c.length,
837
839
  "0"
838
840
  )}`;
839
841
  }
@@ -841,8 +843,8 @@ const se = class se {
841
843
  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
844
  if (!i)
843
845
  return this.getValue("string");
844
- const a = 10 ** (s * 3);
845
- return `${(n / a).toFixed(t)}${i}`;
846
+ const o = 10 ** (s * 3);
847
+ return `${(n / o).toFixed(t)}${i}`;
846
848
  }
847
849
  toCurrency(t = "$", {
848
850
  currencyPosition: n = "start",
@@ -850,56 +852,56 @@ const se = class se {
850
852
  decimalSeparator: s = ".",
851
853
  thousandSeparator: i = ","
852
854
  } = {}) {
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)}` : ""}`;
855
+ const o = this.getValue("number"), [c, a = ""] = o.toFixed(6).split("."), u = c.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = c || a ? c === "0" ? `${parseFloat(`0.${a}`)}`.replace(".", s) : `${u}${parseInt(a) ? `${s}${a.slice(0, r)}` : ""}` : "0.00";
854
856
  return `${n === "start" ? t : ""}${h}${n === "end" ? t : ""}`;
855
857
  }
856
858
  formatBigIntToSafeValue(t, n) {
857
859
  const r = n || this.decimal || B, s = Math.max(
858
860
  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(
861
+ v(this.decimalMultiplier)
862
+ ), i = t < 0n, o = t.toString().substring(i ? 1 : 0), c = s - (o.length - 1), a = c > 0 ? "0".repeat(c) + o : o, u = a.length - s;
863
+ let h = a.slice(-s);
864
+ return parseInt(h[r]) >= 5 ? h = `${h.substring(0, r - 1)}${(parseInt(h[r - 1]) + 1).toString()}` : h = h.substring(0, r), `${i ? "-" : ""}${a.slice(
863
865
  0,
864
- _
866
+ u
865
867
  )}.${h}`.replace(/\.?0*$/, "");
866
868
  }
867
869
  };
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);
870
+ w = new WeakSet(), I = function(t, ...n) {
871
+ const r = p(this, V, Z).call(this, this, ...n), s = Math.max(r, v(this.decimalMultiplier)), i = y(s), o = n.reduce(
872
+ (a, u) => {
873
+ const h = this.getBigIntValue(u, s);
872
874
  switch (t) {
873
875
  case "add":
874
- return o + h;
876
+ return a + h;
875
877
  case "sub":
876
- return o - h;
878
+ return a - h;
877
879
  case "mul":
878
- return o * h / i;
880
+ return a * h / i;
879
881
  case "div": {
880
882
  if (h === 0n)
881
883
  throw new RangeError("Division by zero");
882
- return o * i / h;
884
+ return a * i / h;
883
885
  }
884
886
  default:
885
- return o;
887
+ return a;
886
888
  }
887
889
  },
888
890
  //normalize is to precision multiplier base
889
891
  this.bigIntValue * i / this.decimalMultiplier
890
- ), c = G({
892
+ ), c = U({
891
893
  bigIntDecimal: s,
892
894
  decimal: s,
893
- value: a
895
+ value: o
894
896
  });
895
897
  return new this.constructor({
896
- decimalMultiplier: N(s),
898
+ decimalMultiplier: y(s),
897
899
  decimal: this.decimal,
898
900
  value: c,
899
901
  identifier: this.toString()
900
902
  });
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
+ }, b = new WeakSet(), E = function(t, ...n) {
904
+ const r = p(this, V, Z).call(this, this, ...n), s = this.getBigIntValue(n[0], r), i = this.getBigIntValue(this, r);
903
905
  switch (t) {
904
906
  case "gt":
905
907
  return i > s;
@@ -912,54 +914,65 @@ C = new WeakSet(), y = function(t, ...n) {
912
914
  case "eqValue":
913
915
  return i === s;
914
916
  }
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);
917
+ }, j = new WeakSet(), be = function(t) {
918
+ const n = M(t) || "0";
919
+ this.bigIntValue = p(this, H, ee).call(this, n);
920
+ }, V = new WeakSet(), Z = function(...t) {
921
+ const n = t.map((r) => typeof r == "object" ? r.decimal || v(r.decimalMultiplier) : he(M(r))).filter(Boolean);
920
922
  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")}`);
923
+ }, H = new WeakSet(), ee = function(t, n) {
924
+ const r = n ? y(n) : this.decimalMultiplier, s = v(r), [i = "", o = ""] = t.split(".");
925
+ return BigInt(`${i}${o.padEnd(s, "0")}`);
924
926
  };
925
- let W = se;
926
- const Tt = Intl.NumberFormat("fullwide", {
927
+ let D = q;
928
+ const pt = Intl.NumberFormat("fullwide", {
927
929
  useGrouping: !1,
928
930
  maximumFractionDigits: 20
929
931
  });
930
- function v(e) {
931
- const n = `${typeof e == "number" ? Tt.format(e) : ee(e)}`.replaceAll(",", ".").split(".");
932
+ function M(e) {
933
+ const n = `${typeof e == "number" ? pt.format(e) : te(e)}`.replaceAll(",", ".").split(".");
932
934
  return n.length > 1 ? `${n.slice(0, -1).join("")}.${n.at(-1)}` : n[0];
933
935
  }
934
- function _e(e) {
936
+ function he(e) {
935
937
  var n;
936
938
  const t = ((n = e.split(".")[1]) == null ? void 0 : n.length) || 0;
937
939
  return Math.max(t, B);
938
940
  }
939
- function ee(e) {
941
+ function te(e) {
940
942
  return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
941
943
  }
942
- const w = /* @__PURE__ */ new Map();
943
- class g extends W {
944
+ class g extends D {
945
+ eq(t) {
946
+ return this.eqValue(t);
947
+ }
948
+ static fromBigInt(t, n) {
949
+ return new g({
950
+ decimal: n,
951
+ value: U({ value: t, bigIntDecimal: n, decimal: n })
952
+ });
953
+ }
954
+ }
955
+ const P = /* @__PURE__ */ new Map();
956
+ class A extends D {
944
957
  constructor({
945
958
  value: n,
946
959
  decimal: r,
947
960
  tax: s,
948
961
  chain: i,
949
- symbol: a,
962
+ symbol: o,
950
963
  identifier: c
951
964
  }) {
952
965
  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;
966
+ _(this, "address");
967
+ _(this, "chain");
968
+ _(this, "isGasAsset", !1);
969
+ _(this, "isSynthetic", !1);
970
+ _(this, "symbol");
971
+ _(this, "tax");
972
+ _(this, "ticker");
973
+ _(this, "type");
974
+ const a = N(c || `${i}.${o}`);
975
+ this.type = ot(a), this.tax = s, this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset;
963
976
  }
964
977
  toString() {
965
978
  return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
@@ -971,67 +984,89 @@ class g extends W {
971
984
  return this.chain === n && this.symbol === r;
972
985
  }
973
986
  chainId() {
974
- return Le[this.chain];
987
+ return De[this.chain];
975
988
  }
976
989
  // THOR.RUNE
977
990
  // THOR.ETH.ETH
978
991
  // ETH.THOR-0x1234567890
979
992
  static fromUrl(n, r = 0) {
980
- const [s, i, a] = n.split(".");
981
- if (!s || !i)
993
+ const [s, i, o] = n.split(".");
994
+ if (!(s && i))
982
995
  throw new Error("Invalid asset url");
983
- const c = s === l.THORChain && a ? `${s}.${i}/${a}` : n;
984
- return J(c, r);
996
+ const c = s === l.THORChain && o ? `${s}.${i}/${o}` : n;
997
+ return Y(c, r);
985
998
  }
986
999
  static fromString(n, r = 0) {
987
- return J(n, r);
1000
+ return Y(n, r);
988
1001
  }
989
1002
  static fromIdentifier(n, r = 0) {
990
- return J(n, r);
1003
+ return Y(n, r);
991
1004
  }
992
1005
  static fromStringSync(n, r = 0) {
993
- const { chain: s, isSynthetic: i } = F(n), a = w.get(n.toUpperCase());
1006
+ const { chain: s, isSynthetic: i } = N(n), o = P.get(n.toUpperCase());
994
1007
  if (i)
995
- return he(n, r);
996
- const { tax: c, decimal: o, identifier: _ } = a || {
1008
+ return Q(n, r);
1009
+ const { tax: c, decimal: a, identifier: u } = o || {
997
1010
  decimal: d[s],
998
1011
  identifier: n
999
1012
  };
1000
- return new g({
1013
+ return new A({
1001
1014
  tax: c,
1002
- value: V(r, o),
1003
- identifier: i ? n : _,
1004
- decimal: i ? 8 : o
1015
+ value: O(r, a),
1016
+ identifier: i ? n : u,
1017
+ decimal: i ? 8 : a
1018
+ });
1019
+ }
1020
+ static async fromStringWithBase(n, r = 0, s = d.THOR) {
1021
+ const i = D.shiftDecimals({
1022
+ value: g.fromBigInt(BigInt(r)),
1023
+ from: 0,
1024
+ to: s
1025
+ }).getBaseValue("string");
1026
+ return (await A.fromString(n, r)).set(i);
1027
+ }
1028
+ static fromStringWithBaseSync(n, r = 0, s = d.THOR) {
1029
+ const { chain: i, isSynthetic: o } = N(n), c = P.get(n.toUpperCase());
1030
+ if (o)
1031
+ return Q(n, r);
1032
+ const { tax: a, decimal: u, identifier: h } = c || {
1033
+ decimal: d[i],
1034
+ identifier: n
1035
+ };
1036
+ return new A({
1037
+ tax: a,
1038
+ value: O(BigInt(r), s),
1039
+ identifier: h,
1040
+ decimal: u
1005
1041
  });
1006
1042
  }
1007
1043
  static fromIdentifierSync(n, r = 0) {
1008
- const { chain: s, isSynthetic: i } = F(n), a = w.get(n);
1044
+ const { chain: s, isSynthetic: i } = N(n), o = P.get(n);
1009
1045
  if (i)
1010
- return he(n, r);
1011
- const { tax: c, decimal: o, identifier: _ } = a || {
1046
+ return Q(n, r);
1047
+ const { tax: c, decimal: a, identifier: u } = o || {
1012
1048
  decimal: d[s],
1013
1049
  identifier: n
1014
1050
  };
1015
- return new g({ tax: c, decimal: o, identifier: _, value: V(r, o) });
1051
+ return new A({ tax: c, decimal: a, identifier: u, value: O(r, a) });
1016
1052
  }
1017
1053
  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 });
1054
+ const { decimal: s, identifier: i } = it(n);
1055
+ return new A({ value: O(r, s), decimal: s, identifier: i });
1020
1056
  }
1021
1057
  static loadStaticAssets() {
1022
1058
  return new Promise(
1023
- async (n, r) => {
1059
+ (n, r) => {
1024
1060
  try {
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 });
1061
+ import("@swapkit/tokens").then((s) => {
1062
+ for (const i of Object.values(s))
1063
+ for (const { identifier: o, chain: c, ...a } of i.tokens)
1064
+ P.set(o.toUpperCase(), {
1065
+ identifier: o,
1066
+ decimal: "decimals" in a ? a.decimals : d[c]
1067
+ });
1068
+ n({ ok: !0 });
1069
+ });
1035
1070
  } catch (s) {
1036
1071
  console.error(s), r({
1037
1072
  ok: !1,
@@ -1043,8 +1078,8 @@ class g extends W {
1043
1078
  );
1044
1079
  }
1045
1080
  }
1046
- function Vt(e) {
1047
- const t = g.fromChainOrSignature(e);
1081
+ function It(e) {
1082
+ const t = A.fromChainOrSignature(e);
1048
1083
  switch (e) {
1049
1084
  case l.Bitcoin:
1050
1085
  case l.Litecoin:
@@ -1064,39 +1099,39 @@ function Vt(e) {
1064
1099
  return t.set(1e-8);
1065
1100
  }
1066
1101
  }
1067
- async function J(e, t = 0) {
1102
+ async function Y(e, t = 0) {
1068
1103
  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 });
1104
+ const n = P.get(e.toUpperCase()), r = (n == null ? void 0 : n.decimal) || await st(N(e));
1105
+ return n || P.set(e.toUpperCase(), { identifier: e, decimal: r }), new A({ decimal: r, value: O(t, r), identifier: e });
1071
1106
  }
1072
- function he(e, t = 0) {
1107
+ function Q(e, t = 0) {
1073
1108
  const [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1074
- if (!n || !r)
1109
+ if (!(n && r))
1075
1110
  throw new Error("Invalid asset identifier");
1076
- return new g({
1111
+ return new A({
1077
1112
  decimal: 8,
1078
- value: V(t, 8),
1113
+ value: O(t, 8),
1079
1114
  identifier: `${l.THORChain}.${n}/${r}`
1080
1115
  });
1081
1116
  }
1082
- function V(e, t) {
1083
- return typeof e == "bigint" ? G({ value: e, bigIntDecimal: t, decimal: t }) : e;
1117
+ function O(e, t) {
1118
+ return typeof e == "bigint" ? U({ value: e, bigIntDecimal: t, decimal: t }) : e;
1084
1119
  }
1085
- function F(e) {
1120
+ function N(e) {
1086
1121
  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))
1122
+ if (t && !(n && r))
1088
1123
  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(".");
1124
+ const s = e.includes(".") && !t ? e : `${l.THORChain}.${r}`, [i, ...o] = s.split("."), [c, a] = (t ? r : o.join(".")).split("-"), u = t ? r : o.join(".");
1090
1125
  return {
1091
- address: o == null ? void 0 : o.toLowerCase(),
1126
+ address: a == null ? void 0 : a.toLowerCase(),
1092
1127
  chain: i,
1093
- isGasAsset: fe({ chain: i, symbol: _ }),
1128
+ isGasAsset: Se({ chain: i, symbol: u }),
1094
1129
  isSynthetic: t,
1095
- symbol: (t ? `${n}/` : "") + (o ? `${c}-${(o == null ? void 0 : o.toLowerCase()) ?? ""}` : _),
1130
+ symbol: (t ? `${n}/` : "") + (a ? `${c}-${(a == null ? void 0 : a.toLowerCase()) ?? ""}` : u),
1096
1131
  ticker: c
1097
1132
  };
1098
1133
  }
1099
- const At = {
1134
+ const mt = {
1100
1135
  /**
1101
1136
  * Core
1102
1137
  */
@@ -1129,6 +1164,7 @@ const At = {
1129
1164
  core_swap_contract_not_supported: 10205,
1130
1165
  core_swap_transaction_error: 10206,
1131
1166
  core_swap_quote_mode_not_supported: 10207,
1167
+ core_swap_provider_not_found: 10208,
1132
1168
  /**
1133
1169
  * Core - Transaction
1134
1170
  */
@@ -1155,60 +1191,61 @@ const At = {
1155
1191
  wallet_ledger_get_address_error: 20003,
1156
1192
  wallet_ledger_device_not_found: 20004,
1157
1193
  wallet_ledger_device_locked: 20005,
1194
+ /**
1195
+ * Chainflip
1196
+ */
1197
+ chainflip_channel_error: 30001,
1198
+ /**
1199
+ * THORChain
1200
+ */
1158
1201
  /**
1159
1202
  * Helpers
1160
1203
  */
1161
1204
  helpers_number_different_decimals: 99101
1162
1205
  };
1163
- class Ce extends Error {
1206
+ class ye extends Error {
1164
1207
  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);
1166
- }
1167
- }
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
- });
1208
+ n && console.error(n, {
1209
+ stack: n == null ? void 0 : n.stack,
1210
+ message: n == null ? void 0 : n.message
1211
+ }), super(t, {
1212
+ cause: { code: mt[t], message: t }
1213
+ }), Object.setPrototypeOf(this, ye.prototype);
1177
1214
  }
1178
1215
  }
1179
1216
  export {
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,
1217
+ f as ApiEndpoints,
1218
+ A as AssetValue,
1219
+ D as BigIntArithmetics,
1220
+ T as RequestClient,
1221
+ Ze as StreamingSwapProgressStatus,
1222
+ gt as SwapKitApi,
1223
+ ye as SwapKitError,
1224
+ g as SwapKitNumber,
1225
+ Qe as TransactionType,
1226
+ ze as TxStatus,
1227
+ Ct as assetFromString,
1228
+ Ae as defaultRequestHeaders,
1229
+ vt as derivationPathToString,
1230
+ St as filterAssets,
1231
+ U as formatBigIntToSafeValue,
1232
+ At as gasFeeMultiplier,
1196
1233
  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,
1234
+ ut as getAsymmetricAssetShare,
1235
+ yt as getAsymmetricAssetWithdrawAmount,
1236
+ lt as getAsymmetricRuneShare,
1237
+ bt as getAsymmetricRuneWithdrawAmount,
1238
+ it as getCommonAssetInfo,
1239
+ st as getDecimal,
1240
+ Rt as getEstimatedPoolShare,
1241
+ Et as getLiquiditySlippage,
1205
1242
  Pt as getMemoFor,
1206
- Vt as getMinAmountByChain,
1243
+ It as getMinAmountByChain,
1207
1244
  ht as getSymmetricPoolShare,
1208
- gt as getSymmetricWithdraw,
1209
- bt as getTHORNameCost,
1210
- fe as isGasAsset,
1211
- mt as setRequestClientConfig,
1212
- yt as validateTHORName
1245
+ wt as getSymmetricWithdraw,
1246
+ Ot as getTHORNameCost,
1247
+ Se as isGasAsset,
1248
+ ft as setRequestClientConfig,
1249
+ $t as validateTHORName
1213
1250
  };
1214
1251
  //# sourceMappingURL=index.es.js.map