@swapkit/helpers 1.0.0-rc.71 → 1.0.0-rc.73

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 I, 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 || {}), ne = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(ne || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), f = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(f || {});
17
- const q = Object.values(j), $e = Object.keys(j), re = q.reduce(
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(
22
+ G.reduce(
25
23
  (e, t) => (e[t] = ne[re[t]], e),
26
24
  {}
27
25
  );
28
- q.reduce(
26
+ G.reduce(
29
27
  (e, t) => (e[t] = de[re[t]], e),
30
28
  {}
31
29
  );
32
- q.reduce(
30
+ G.reduce(
33
31
  (e, t) => {
34
32
  const n = `${re[t]}Hex`;
35
33
  return e[t] = ne[n], e;
36
34
  },
37
35
  {}
38
36
  );
39
- class ce 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 ce 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 x = (e) => e !== null && typeof e == "object", M = (...e) => {
68
+ const M = (e) => e !== null && typeof e == "object", x = (...e) => {
71
69
  for (const t of e)
72
- if ((!x(t) || Array.isArray(t)) && t !== void 0)
70
+ if ((!M(t) || Array.isArray(t)) && t !== void 0)
73
71
  throw new TypeError("The `options` argument must be an object");
74
72
  return se({}, ...e);
75
- }, Ae = (e = {}, t = {}) => {
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
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 (x(r)) {
83
+ else if (M(r)) {
86
84
  for (let [s, i] of Object.entries(r))
87
- x(i) && s in t && (i = se(t[s], i)), t = { ...t, [s]: i };
88
- x(r.headers) && (n = Ae(n, r.headers), t.headers = n);
85
+ M(i) && s in t && (i = se(t[s], i)), t = { ...t, [s]: i };
86
+ M(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 x = (e) => e !== null && typeof e == "object", M = (...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", xe = typeof globalThis.FormData == "function", pe = ["get", "post", "put", "patch", "head", "delete"], Fe = {
100
+ })(), xe = typeof globalThis.AbortController == "function", ke = typeof globalThis.ReadableStream == "function", Me = 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 x = (e) => e !== null && typeof e == "object", M = (...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,18 +130,18 @@ const x = (e) => e !== null && typeof e == "object", M = (...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], le = {
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
- ...le,
144
+ ...ce,
147
145
  limit: e
148
146
  };
149
147
  if (e.methods && !Array.isArray(e.methods))
@@ -151,18 +149,18 @@ const x = (e) => e !== null && typeof e == "object", M = (...e) => {
151
149
  if (e.statusCodes && !Array.isArray(e.statusCodes))
152
150
  throw new Error("retry.statusCodes must be an array");
153
151
  return {
154
- ...le,
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 G {
184
+ class W {
187
185
  static create(t, n) {
188
- const r = new G(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 ce(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 (!ke)
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(Fe))
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 G {
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),
255
+ headers: me(this._input.headers, n.headers),
258
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 G {
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 G {
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
- (xe && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
287
+ (Me && 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 ce) {
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 G {
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 G {
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 G {
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 G {
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
  }
@@ -380,49 +378,53 @@ class G {
380
378
  }
381
379
  /*! MIT License © Sindre Sorhus */
382
380
  const z = (e) => {
383
- const t = (n, r) => G.create(n, M(e, r));
384
- for (const n of pe)
385
- t[n] = (r, s) => G.create(r, M(e, s, { method: n }));
386
- return t.create = (n) => z(M(n)), t.extend = (n) => z(M(e, n)), t.stop = Se, t;
387
- }, Ee = z();
388
- let F;
389
- const m = {
390
- CachedPrices: `${f.ThorswapApi}/tokenlist/cached-price`,
391
- GasRates: `${f.ThorswapApi}/resource-worker/gasPrice/getAll`,
392
- Quote: `${f.ThorswapApi}/aggregator/tokens/quote`,
393
- Txn: `${f.ThorswapApi}/apiusage/v2/txn`,
394
- TokenlistProviders: `${f.ThorswapApi}/tokenlist/providers`,
395
- TokenList: `${f.ThorswapStatic}/token-list`,
396
- Thorname: `${f.ThorswapApi}/thorname`
397
- }, Re = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, ue = () => F || (F = Ee.create({ headers: Re }), F), mt = ({ apiKey: e, ...t }) => {
398
- F = Ee.create({
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 = {
403
- get: (e, t) => ue().get(e, t).json(),
404
- post: (e, t) => ue().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, {
400
+ }, T = {
401
+ get: (e, t) => le().get(e, t).json(),
402
+ post: (e, t) => le().post(e, t).json()
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(_)), y = s.mul(s).mul(s);
562
- return h.div(y);
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 E.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 E({ value: e, decimal: 8 }), c = new E({ value: n, decimal: 8 }), o = new E({ value: t, decimal: 8 }), _ = new E({ value: s, decimal: 8 }), h = new E({ value: i, decimal: 8 }), y = _.mul(c), ae = h.mul(a), ge = _.mul(h), Oe = a.mul(c), De = o.mul(y.add(ae.add(ge.mul(2)))), Pe = y.add(ae.add(Oe.mul(2))), oe = De.div(Pe), X = A(r).add(oe);
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);
616
618
  if (oe.getBaseValue("number") === 0)
617
- return X.div(o).getBaseValue("number");
618
- const be = o.add(X);
619
- return X.div(be).getBaseValue("number");
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 I.LEAVE:
635
- case I.BOND: {
636
+ case C.LEAVE:
637
+ case C.BOND: {
636
638
  const { address: n } = t;
637
639
  return `${e}:${n}`;
638
640
  }
639
- case I.UNBOND: {
641
+ case C.UNBOND: {
640
642
  const { address: n, unbondAmount: r } = t;
641
643
  return `${e}:${n}:${r}`;
642
644
  }
643
- case I.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 I.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 I.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 I.OPEN_LOAN:
667
- case I.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,37 +674,37 @@ 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
- const _e = [...Object.values(l), "TERRA"];
691
+ const ue = [...Object.values(l), "TERRA"];
690
692
  function dt(e = "") {
691
693
  const t = e.toUpperCase(), [n] = t.split(".");
692
- if (_e.includes(n))
694
+ if (ue.includes(n))
693
695
  return !0;
694
696
  const [r] = t.split("/");
695
- if (_e.includes(r))
697
+ if (ue.includes(r))
696
698
  return !0;
697
699
  throw new Error(
698
700
  `Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
699
701
  );
700
702
  }
701
- const U = 8, C = (e) => 10n ** BigInt(e), w = (e) => Math.log10(parseFloat(e.toString()));
702
- function W({
703
+ const B = 8, y = (e) => 10n ** BigInt(e), v = (e) => Math.log10(parseFloat(e.toString()));
704
+ function U({
703
705
  value: e,
704
- bigIntDecimal: t = U,
705
- decimal: n = U
706
+ bigIntDecimal: t = B,
707
+ decimal: n = B
706
708
  }) {
707
709
  if (n === 0)
708
710
  return e.toString();
@@ -710,31 +712,31 @@ function W({
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 g, V, N, D, k, Ne, $, Z, v, ee;
721
- const ie = class ie {
722
+ var w, I, b, E, j, be, V, Z, H, ee;
723
+ const q = class q {
722
724
  constructor(t) {
723
- O(this, g);
724
- O(this, N);
725
- O(this, k);
726
- O(this, $);
727
- O(this, v);
728
- p(this, "decimalMultiplier", 10n ** 8n);
729
- p(this, "bigIntValue", 0n);
730
- p(this, "decimal");
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");
731
733
  const n = te(t), r = typeof t == "object";
732
- this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : C(Math.max(he(H(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
734
+ this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : y(Math.max(he(k(n)), this.decimal || 0)), p(this, j, be).call(this, n);
733
735
  }
734
736
  static fromBigInt(t, n) {
735
- return new ie({
737
+ return new q({
736
738
  decimal: n,
737
- value: W({ 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 ie = class ie {
742
744
  from: n,
743
745
  to: r
744
746
  }) {
745
- return this.fromBigInt(
746
- t.getBaseValue("bigint") * C(r) / C(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 ie = class ie {
751
753
  return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
752
754
  }
753
755
  add(...t) {
754
- return T(this, g, V).call(this, "add", ...t);
756
+ return p(this, w, I).call(this, "add", ...t);
755
757
  }
756
758
  sub(...t) {
757
- return T(this, g, V).call(this, "sub", ...t);
759
+ return p(this, w, I).call(this, "sub", ...t);
758
760
  }
759
761
  mul(...t) {
760
- return T(this, g, V).call(this, "mul", ...t);
762
+ return p(this, w, I).call(this, "mul", ...t);
761
763
  }
762
764
  div(...t) {
763
- return T(this, g, V).call(this, "div", ...t);
765
+ return p(this, w, I).call(this, "div", ...t);
764
766
  }
765
767
  gt(t) {
766
- return T(this, N, 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, N, 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, N, 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, N, 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, N, 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 || w(this.decimalMultiplier)
786
+ this.decimal || v(this.decimalMultiplier)
785
787
  );
786
788
  switch (t) {
787
789
  case "number":
@@ -794,7 +796,7 @@ const ie = class ie {
794
796
  }
795
797
  // @ts-expect-error
796
798
  getBaseValue(t) {
797
- const n = this.decimalMultiplier / C(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 ie = class ie {
807
809
  getBigIntValue(t, n) {
808
810
  if (!n && typeof t == "object")
809
811
  return t.bigIntValue;
810
- const r = te(t), s = H(r);
811
- return s === "0" || s === "undefined" ? 0n : T(this, v, ee).call(this, s, n);
812
+ const r = te(t), s = k(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 ie = class ie {
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 ie = class ie {
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 ie = class ie {
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 ie = class ie {
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
- const r = n || this.decimal || U, s = Math.max(
859
+ const r = n || this.decimal || B, s = Math.max(
858
860
  r,
859
- w(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
- g = new WeakSet(), V = function(t, ...n) {
869
- const r = T(this, $, Z).call(this, this, ...n), s = Math.max(r, w(this.decimalMultiplier)), i = C(s), a = n.reduce(
870
- (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 = W({
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: C(s),
898
+ decimalMultiplier: y(s),
897
899
  decimal: this.decimal,
898
900
  value: c,
899
901
  identifier: this.toString()
900
902
  });
901
- }, N = new WeakSet(), D = function(t, ...n) {
902
- const r = T(this, $, Z).call(this, this, ...n), s = this.getBigIntValue(n[0], r), i = this.getBigIntValue(this, r);
903
+ }, 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,65 +914,65 @@ g = new WeakSet(), V = function(t, ...n) {
912
914
  case "eqValue":
913
915
  return i === s;
914
916
  }
915
- }, k = new WeakSet(), Ne = function(t) {
916
- const n = H(t) || "0";
917
- this.bigIntValue = T(this, v, ee).call(this, n);
918
- }, $ = new WeakSet(), Z = function(...t) {
919
- const n = t.map((r) => typeof r == "object" ? r.decimal || w(r.decimalMultiplier) : he(H(r))).filter(Boolean);
920
- return Math.max(...n, U);
921
- }, v = new WeakSet(), ee = function(t, n) {
922
- const r = n ? C(n) : this.decimalMultiplier, s = w(r), [i = "", a = ""] = t.split(".");
923
- return BigInt(`${i}${a.padEnd(s, "0")}`);
917
+ }, j = new WeakSet(), be = function(t) {
918
+ const n = k(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(k(r))).filter(Boolean);
922
+ return Math.max(...n, B);
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 L = ie;
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 H(e) {
931
- const n = `${typeof e == "number" ? Tt.format(e) : te(e)}`.replaceAll(",", ".").split(".");
932
+ function k(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
936
  function he(e) {
935
937
  var n;
936
938
  const t = ((n = e.split(".")[1]) == null ? void 0 : n.length) || 0;
937
- return Math.max(t, U);
939
+ return Math.max(t, B);
938
940
  }
939
941
  function te(e) {
940
942
  return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
941
943
  }
942
- class E extends L {
944
+ class g extends D {
943
945
  eq(t) {
944
946
  return this.eqValue(t);
945
947
  }
946
948
  static fromBigInt(t, n) {
947
- return new E({
949
+ return new g({
948
950
  decimal: n,
949
- value: W({ value: t, bigIntDecimal: n, decimal: n })
951
+ value: U({ value: t, bigIntDecimal: n, decimal: n })
950
952
  });
951
953
  }
952
954
  }
953
955
  const P = /* @__PURE__ */ new Map();
954
- class R extends L {
956
+ class A extends D {
955
957
  constructor({
956
958
  value: n,
957
959
  decimal: r,
958
960
  tax: s,
959
961
  chain: i,
960
- symbol: a,
962
+ symbol: o,
961
963
  identifier: c
962
964
  }) {
963
965
  super(typeof n == "object" ? n : { decimal: r, value: n });
964
- p(this, "address");
965
- p(this, "chain");
966
- p(this, "isGasAsset", !1);
967
- p(this, "isSynthetic", !1);
968
- p(this, "symbol");
969
- p(this, "tax");
970
- p(this, "ticker");
971
- p(this, "type");
972
- const o = B(c || `${i}.${a}`);
973
- this.type = ot(o), this.tax = s, this.chain = o.chain, this.ticker = o.ticker, this.symbol = o.symbol, this.address = o.address, this.isSynthetic = o.isSynthetic, this.isGasAsset = o.isGasAsset;
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;
974
976
  }
975
977
  toString() {
976
978
  return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
@@ -982,90 +984,89 @@ class R extends L {
982
984
  return this.chain === n && this.symbol === r;
983
985
  }
984
986
  chainId() {
985
- return Le[this.chain];
987
+ return De[this.chain];
986
988
  }
987
989
  // THOR.RUNE
988
990
  // THOR.ETH.ETH
989
991
  // ETH.THOR-0x1234567890
990
992
  static fromUrl(n, r = 0) {
991
- const [s, i, a] = n.split(".");
992
- if (!s || !i)
993
+ const [s, i, o] = n.split(".");
994
+ if (!(s && i))
993
995
  throw new Error("Invalid asset url");
994
- const c = s === l.THORChain && a ? `${s}.${i}/${a}` : n;
995
- return J(c, r);
996
+ const c = s === l.THORChain && o ? `${s}.${i}/${o}` : n;
997
+ return Y(c, r);
996
998
  }
997
999
  static fromString(n, r = 0) {
998
- return J(n, r);
1000
+ return Y(n, r);
999
1001
  }
1000
1002
  static fromIdentifier(n, r = 0) {
1001
- return J(n, r);
1003
+ return Y(n, r);
1002
1004
  }
1003
1005
  static fromStringSync(n, r = 0) {
1004
- const { chain: s, isSynthetic: i } = B(n), a = P.get(n.toUpperCase());
1006
+ const { chain: s, isSynthetic: i } = N(n), o = P.get(n.toUpperCase());
1005
1007
  if (i)
1006
1008
  return Q(n, r);
1007
- const { tax: c, decimal: o, identifier: _ } = a || {
1009
+ const { tax: c, decimal: a, identifier: u } = o || {
1008
1010
  decimal: d[s],
1009
1011
  identifier: n
1010
1012
  };
1011
- return new R({
1013
+ return new A({
1012
1014
  tax: c,
1013
- value: b(r, o),
1014
- identifier: i ? n : _,
1015
- decimal: i ? 8 : o
1015
+ value: O(r, a),
1016
+ identifier: i ? n : u,
1017
+ decimal: i ? 8 : a
1016
1018
  });
1017
1019
  }
1018
1020
  static async fromStringWithBase(n, r = 0, s = d.THOR) {
1019
- const i = L.shiftDecimals({
1020
- value: E.fromBigInt(BigInt(r)),
1021
+ const i = D.shiftDecimals({
1022
+ value: g.fromBigInt(BigInt(r)),
1021
1023
  from: 0,
1022
1024
  to: s
1023
1025
  }).getBaseValue("string");
1024
- return (await R.fromString(n, r)).set(i);
1026
+ return (await A.fromString(n, r)).set(i);
1025
1027
  }
1026
1028
  static fromStringWithBaseSync(n, r = 0, s = d.THOR) {
1027
- const { chain: i, isSynthetic: a } = B(n), c = P.get(n.toUpperCase());
1028
- if (a)
1029
+ const { chain: i, isSynthetic: o } = N(n), c = P.get(n.toUpperCase());
1030
+ if (o)
1029
1031
  return Q(n, r);
1030
- const { tax: o, decimal: _, identifier: h } = c || {
1032
+ const { tax: a, decimal: u, identifier: h } = c || {
1031
1033
  decimal: d[i],
1032
1034
  identifier: n
1033
1035
  };
1034
- return new R({
1035
- tax: o,
1036
- value: b(BigInt(r), s),
1036
+ return new A({
1037
+ tax: a,
1038
+ value: O(BigInt(r), s),
1037
1039
  identifier: h,
1038
- decimal: _
1040
+ decimal: u
1039
1041
  });
1040
1042
  }
1041
1043
  static fromIdentifierSync(n, r = 0) {
1042
- const { chain: s, isSynthetic: i } = B(n), a = P.get(n);
1044
+ const { chain: s, isSynthetic: i } = N(n), o = P.get(n);
1043
1045
  if (i)
1044
1046
  return Q(n, r);
1045
- const { tax: c, decimal: o, identifier: _ } = a || {
1047
+ const { tax: c, decimal: a, identifier: u } = o || {
1046
1048
  decimal: d[s],
1047
1049
  identifier: n
1048
1050
  };
1049
- return new R({ tax: c, decimal: o, identifier: _, value: b(r, o) });
1051
+ return new A({ tax: c, decimal: a, identifier: u, value: O(r, a) });
1050
1052
  }
1051
1053
  static fromChainOrSignature(n, r = 0) {
1052
- const { decimal: s, identifier: i } = at(n);
1053
- return new R({ value: b(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 });
1054
1056
  }
1055
1057
  static loadStaticAssets() {
1056
1058
  return new Promise(
1057
- async (n, r) => {
1059
+ (n, r) => {
1058
1060
  try {
1059
- const s = await import("@swapkit/tokens");
1060
- Object.values(s).forEach((i) => {
1061
- var a;
1062
- (a = i == null ? void 0 : i.tokens) == null || a.forEach(({ identifier: c, chain: o, ..._ }) => {
1063
- P.set(c.toUpperCase(), {
1064
- identifier: c,
1065
- decimal: "decimals" in _ ? _.decimals : d[o]
1066
- });
1067
- });
1068
- }), 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
+ });
1069
1070
  } catch (s) {
1070
1071
  console.error(s), r({
1071
1072
  ok: !1,
@@ -1077,8 +1078,8 @@ class R extends L {
1077
1078
  );
1078
1079
  }
1079
1080
  }
1080
- function Vt(e) {
1081
- const t = R.fromChainOrSignature(e);
1081
+ function It(e) {
1082
+ const t = A.fromChainOrSignature(e);
1082
1083
  switch (e) {
1083
1084
  case l.Bitcoin:
1084
1085
  case l.Litecoin:
@@ -1098,39 +1099,39 @@ function Vt(e) {
1098
1099
  return t.set(1e-8);
1099
1100
  }
1100
1101
  }
1101
- async function J(e, t = 0) {
1102
+ async function Y(e, t = 0) {
1102
1103
  dt(e);
1103
- const n = P.get(e.toUpperCase()), r = (n == null ? void 0 : n.decimal) || await it(B(e));
1104
- return n || P.set(e.toUpperCase(), { identifier: e, decimal: r }), new R({ decimal: r, value: b(t, r), identifier: e });
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 });
1105
1106
  }
1106
1107
  function Q(e, t = 0) {
1107
1108
  const [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1108
- if (!n || !r)
1109
+ if (!(n && r))
1109
1110
  throw new Error("Invalid asset identifier");
1110
- return new R({
1111
+ return new A({
1111
1112
  decimal: 8,
1112
- value: b(t, 8),
1113
+ value: O(t, 8),
1113
1114
  identifier: `${l.THORChain}.${n}/${r}`
1114
1115
  });
1115
1116
  }
1116
- function b(e, t) {
1117
- return typeof e == "bigint" ? W({ 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;
1118
1119
  }
1119
- function B(e) {
1120
+ function N(e) {
1120
1121
  const t = e.slice(0, 14).includes("/"), [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1121
- if (t && (!n || !r))
1122
+ if (t && !(n && r))
1122
1123
  throw new Error("Invalid asset identifier");
1123
- 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(".");
1124
1125
  return {
1125
- address: o == null ? void 0 : o.toLowerCase(),
1126
+ address: a == null ? void 0 : a.toLowerCase(),
1126
1127
  chain: i,
1127
- isGasAsset: fe({ chain: i, symbol: _ }),
1128
+ isGasAsset: Se({ chain: i, symbol: u }),
1128
1129
  isSynthetic: t,
1129
- symbol: (t ? `${n}/` : "") + (o ? `${c}-${(o == null ? void 0 : o.toLowerCase()) ?? ""}` : _),
1130
+ symbol: (t ? `${n}/` : "") + (a ? `${c}-${(a == null ? void 0 : a.toLowerCase()) ?? ""}` : u),
1130
1131
  ticker: c
1131
1132
  };
1132
1133
  }
1133
- const At = {
1134
+ const mt = {
1134
1135
  /**
1135
1136
  * Core
1136
1137
  */
@@ -1163,6 +1164,7 @@ const At = {
1163
1164
  core_swap_contract_not_supported: 10205,
1164
1165
  core_swap_transaction_error: 10206,
1165
1166
  core_swap_quote_mode_not_supported: 10207,
1167
+ core_swap_provider_not_found: 10208,
1166
1168
  /**
1167
1169
  * Core - Transaction
1168
1170
  */
@@ -1189,49 +1191,62 @@ const At = {
1189
1191
  wallet_ledger_get_address_error: 20003,
1190
1192
  wallet_ledger_device_not_found: 20004,
1191
1193
  wallet_ledger_device_locked: 20005,
1194
+ /**
1195
+ * Chainflip
1196
+ */
1197
+ chainflip_channel_error: 30001,
1198
+ chainflip_broker_recipient_error: 30002,
1199
+ /**
1200
+ * THORChain
1201
+ */
1192
1202
  /**
1193
1203
  * Helpers
1194
1204
  */
1195
1205
  helpers_number_different_decimals: 99101
1196
1206
  };
1197
- class Ce extends Error {
1207
+ class ye extends Error {
1198
1208
  constructor(t, n) {
1199
- n && console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: At[t], message: t } }), Object.setPrototypeOf(this, Ce.prototype);
1209
+ n && console.error(n, {
1210
+ stack: n == null ? void 0 : n.stack,
1211
+ message: n == null ? void 0 : n.message
1212
+ }), super(t, {
1213
+ cause: { code: mt[t], message: t }
1214
+ }), Object.setPrototypeOf(this, ye.prototype);
1200
1215
  }
1201
1216
  }
1202
1217
  export {
1203
- m as ApiEndpoints,
1204
- R as AssetValue,
1205
- L as BigIntArithmetics,
1206
- S as RequestClient,
1207
- et as StreamingSwapProgressStatus,
1208
- Et as SwapKitApi,
1209
- Ce as SwapKitError,
1210
- E as SwapKitNumber,
1211
- ze as TransactionType,
1212
- Ze as TxStatus,
1213
- It as assetFromString,
1214
- Re as defaultRequestHeaders,
1215
- wt as derivationPathToString,
1216
- ft as filterAssets,
1217
- W as formatBigIntToSafeValue,
1218
- Rt as gasFeeMultiplier,
1218
+ f as ApiEndpoints,
1219
+ A as AssetValue,
1220
+ D as BigIntArithmetics,
1221
+ T as RequestClient,
1222
+ Ze as StreamingSwapProgressStatus,
1223
+ gt as SwapKitApi,
1224
+ ye as SwapKitError,
1225
+ g as SwapKitNumber,
1226
+ Qe as TransactionType,
1227
+ ze as TxStatus,
1228
+ Ct as assetFromString,
1229
+ Ae as defaultRequestHeaders,
1230
+ vt as derivationPathToString,
1231
+ St as filterAssets,
1232
+ U as formatBigIntToSafeValue,
1233
+ At as gasFeeMultiplier,
1219
1234
  ot as getAssetType,
1220
- _t as getAsymmetricAssetShare,
1221
- Ct as getAsymmetricAssetWithdrawAmount,
1222
- ut as getAsymmetricRuneShare,
1223
- Nt as getAsymmetricRuneWithdrawAmount,
1224
- at as getCommonAssetInfo,
1225
- it as getDecimal,
1226
- Ot as getEstimatedPoolShare,
1227
- Dt as getLiquiditySlippage,
1235
+ ut as getAsymmetricAssetShare,
1236
+ yt as getAsymmetricAssetWithdrawAmount,
1237
+ lt as getAsymmetricRuneShare,
1238
+ bt as getAsymmetricRuneWithdrawAmount,
1239
+ it as getCommonAssetInfo,
1240
+ st as getDecimal,
1241
+ Rt as getEstimatedPoolShare,
1242
+ Et as getLiquiditySlippage,
1228
1243
  Pt as getMemoFor,
1229
- Vt as getMinAmountByChain,
1244
+ It as getMinAmountByChain,
1230
1245
  ht as getSymmetricPoolShare,
1231
- gt as getSymmetricWithdraw,
1232
- bt as getTHORNameCost,
1233
- fe as isGasAsset,
1234
- mt as setRequestClientConfig,
1235
- yt as validateTHORName
1246
+ wt as getSymmetricWithdraw,
1247
+ Ot as getTHORNameCost,
1248
+ Se as isGasAsset,
1249
+ ft as setRequestClientConfig,
1250
+ $t as validateTHORName
1236
1251
  };
1237
1252
  //# sourceMappingURL=index.es.js.map