@swapkit/helpers 1.0.0-rc.64 → 1.0.0-rc.65

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
@@ -13,23 +13,23 @@ var T = (e, t, n) => (Ve(e, t, "access private method"), n);
13
13
  import { FeeOption as Y, BaseDecimal as d, Chain as a, EVMChainList as Be, ChainToRPC as Ue, MemoType as E, ChainToChainId as Le } from "@swapkit/types";
14
14
  var l = /* @__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.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))(l || {});
15
15
  l.INVALID_INPUT_PARAMETERS + "", l.UNKNOWN_PROVIDERS + "", l.CANNOT_FIND_INBOUND_ADDRESS + "", l.NO_INBOUND_ADDRESSES + "", l.CHAIN_HALTED_OR_UNSUPPORTED + "", l.MISSING_INPUT_PARAMETER + "", l.INVALID_TYPE_GENERIC + "", l.INVALID_NUMBER_STRING + "", l.INVALID_NUMBER + "", l.INVALID_BOOLEAN + "", l.INVALID_OBJECT + "", l.INVALID_ARRAY + "", l.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.SELL_BUY_ASSETS_ARE_THE_SAME + "", l.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", l.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", l.AFF_ADDRESS_TOO_LONG + "", l.AFF_BPS_INTEGER_MAX_500 + "", l.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", l.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", l.PREFERRED_PROVIDER_NOT_SUPPORTED + "", l.SOURCE_ADDRESS_SMART_CONTRACT + "", l.DESTINATION_ADDRESS_SMART_CONTRACT + "", l.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.INVALID_PROVIDER + "", l.MISSING_CROSS_CHAIN_PROVIDER + "", l.MISSING_AVAX_PROVIDER + "", l.MISSING_BSC_PROVIDER + "", l.MISSING_ETH_PROVIDER + "", l.MISSING_ARB_PROVIDER + "", l.INVALID_PROVIDER_FOR_SWAP_OUT + "", l.INVALID_CHAIN + "", l.INVALID_ASSET + "", l.UNSUPPORTED_CHAIN + "", l.UNSUPPORTED_ASSET + "", l.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", l.THORNODE_QUOTE_GENERIC_ERROR + "", l.INVALID_SOURCE_ADDRESS + "", l.INVALID_DESTINATION_ADDRESS + "", l.NOT_ENOUGH_SYNTH_BALANCE + "", l.SYNTH_MINTING_CAP_REACHED + "", l.INVALID_QUOTE_MODE + "", l.NO_QUOTES + "", l.SERVICE_UNAVAILABLE_GENERIC + "", l.MISSING_GAS_DATA_GENERIC + "", l.MISSING_TOKEN_INFO_GENERIC + "", l.CANT_FIND_TOKEN_LIST + "", l.NO_PRICE + "", l.PRICE_IS_STALE + "", l.ADDRESS_NOT_WHITELISTED + "", l.ADDRESS_ALREADY_CLAIMED + "";
16
- var q = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(q || {}), 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.Cosmos = "cosmoshub-4", 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.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.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", 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.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 j = Object.values(q), $e = Object.keys(q), ne = j.reduce(
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.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", 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.Cosmos = "cosmoshub-4", 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.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.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", 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.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), ve = Object.keys(j), ne = q.reduce(
18
18
  (e, t) => {
19
- const n = $e.find((s) => q[s] === t);
19
+ const n = ve.find((r) => j[r] === t);
20
20
  return n && (e[t] = n), e;
21
21
  },
22
22
  {}
23
23
  );
24
- j.reduce(
24
+ q.reduce(
25
25
  (e, t) => (e[t] = te[ne[t]], e),
26
26
  {}
27
27
  );
28
- j.reduce(
28
+ q.reduce(
29
29
  (e, t) => (e[t] = de[ne[t]], e),
30
30
  {}
31
31
  );
32
- j.reduce(
32
+ q.reduce(
33
33
  (e, t) => {
34
34
  const n = `${ne[t]}Hex`;
35
35
  return e[t] = te[n], e;
@@ -37,8 +37,8 @@ j.reduce(
37
37
  {}
38
38
  );
39
39
  class oe extends Error {
40
- constructor(t, n, s) {
41
- const r = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", o = `${r} ${i}`.trim(), u = o ? `status code ${o}` : "an unknown error";
40
+ constructor(t, n, r) {
41
+ const s = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", o = `${s} ${i}`.trim(), u = o ? `status code ${o}` : "an unknown error";
42
42
  super(`Request failed with ${u}`), Object.defineProperty(this, "response", {
43
43
  enumerable: !0,
44
44
  configurable: !0,
@@ -54,7 +54,7 @@ class oe extends Error {
54
54
  configurable: !0,
55
55
  writable: !0,
56
56
  value: void 0
57
- }), this.name = "HTTPError", this.response = t, this.request = n, this.options = s;
57
+ }), this.name = "HTTPError", this.response = t, this.request = n, this.options = r;
58
58
  }
59
59
  }
60
60
  class Te extends Error {
@@ -67,31 +67,31 @@ class Te extends Error {
67
67
  }), this.name = "TimeoutError", this.request = t;
68
68
  }
69
69
  }
70
- const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
70
+ const M = (e) => e !== null && typeof e == "object", v = (...e) => {
71
71
  for (const t of e)
72
72
  if ((!M(t) || Array.isArray(t)) && t !== void 0)
73
73
  throw new TypeError("The `options` argument must be an object");
74
- return se({}, ...e);
74
+ return re({}, ...e);
75
75
  }, Ae = (e = {}, t = {}) => {
76
- const n = new globalThis.Headers(e), s = t instanceof globalThis.Headers, r = new globalThis.Headers(t);
77
- for (const [i, o] of r.entries())
78
- s && o === "undefined" || o === void 0 ? n.delete(i) : n.set(i, o);
76
+ const n = new globalThis.Headers(e), r = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
77
+ for (const [i, o] of s.entries())
78
+ r && o === "undefined" || o === void 0 ? n.delete(i) : n.set(i, o);
79
79
  return n;
80
- }, se = (...e) => {
80
+ }, re = (...e) => {
81
81
  let t = {}, n = {};
82
- for (const s of e)
83
- if (Array.isArray(s))
84
- Array.isArray(t) || (t = []), t = [...t, ...s];
85
- else if (M(s)) {
86
- for (let [r, i] of Object.entries(s))
87
- M(i) && r in t && (i = se(t[r], i)), t = { ...t, [r]: i };
88
- M(s.headers) && (n = Ae(n, s.headers), t.headers = n);
82
+ for (const r of e)
83
+ if (Array.isArray(r))
84
+ Array.isArray(t) || (t = []), t = [...t, ...r];
85
+ else if (M(r)) {
86
+ for (let [s, i] of Object.entries(r))
87
+ M(i) && s in t && (i = re(t[s], i)), t = { ...t, [s]: i };
88
+ M(r.headers) && (n = Ae(n, r.headers), t.headers = n);
89
89
  }
90
90
  return t;
91
- }, ve = (() => {
91
+ }, $e = (() => {
92
92
  let e = !1, t = !1;
93
- const n = typeof globalThis.ReadableStream == "function", s = typeof globalThis.Request == "function";
94
- return n && s && (t = new globalThis.Request("https://empty.invalid", {
93
+ const n = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
94
+ return n && r && (t = new globalThis.Request("https://empty.invalid", {
95
95
  body: new globalThis.ReadableStream(),
96
96
  method: "POST",
97
97
  // @ts-expect-error - Types are outdated.
@@ -132,10 +132,10 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
132
132
  window: !0,
133
133
  dispatcher: !0,
134
134
  duplex: !0
135
- }, ke = (e) => pe.includes(e) ? e.toUpperCase() : e, qe = ["get", "put", "head", "delete", "options", "trace"], je = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503], ce = {
135
+ }, ke = (e) => pe.includes(e) ? e.toUpperCase() : e, je = ["get", "put", "head", "delete", "options", "trace"], qe = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503], ce = {
136
136
  limit: 2,
137
- methods: qe,
138
- statusCodes: je,
137
+ methods: je,
138
+ statusCodes: qe,
139
139
  afterStatusCodes: me,
140
140
  maxRetryAfter: Number.POSITIVE_INFINITY,
141
141
  backoffLimit: Number.POSITIVE_INFINITY,
@@ -156,62 +156,62 @@ const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
156
156
  afterStatusCodes: me
157
157
  };
158
158
  };
159
- async function Ye(e, t, n, s) {
160
- return new Promise((r, i) => {
159
+ async function Ye(e, t, n, r) {
160
+ return new Promise((s, i) => {
161
161
  const o = setTimeout(() => {
162
162
  n && n.abort(), i(new Te(e));
163
- }, s.timeout);
164
- s.fetch(e, t).then(r).catch(i).then(() => {
163
+ }, r.timeout);
164
+ r.fetch(e, t).then(s).catch(i).then(() => {
165
165
  clearTimeout(o);
166
166
  });
167
167
  });
168
168
  }
169
169
  async function Ke(e, { signal: t }) {
170
- return new Promise((n, s) => {
171
- t && (t.throwIfAborted(), t.addEventListener("abort", r, { once: !0 }));
172
- function r() {
173
- clearTimeout(i), s(t.reason);
170
+ return new Promise((n, r) => {
171
+ t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
172
+ function s() {
173
+ clearTimeout(i), r(t.reason);
174
174
  }
175
175
  const i = setTimeout(() => {
176
- t == null || t.removeEventListener("abort", r), n();
176
+ t == null || t.removeEventListener("abort", s), n();
177
177
  }, e);
178
178
  });
179
179
  }
180
180
  const Je = (e, t) => {
181
181
  const n = {};
182
- for (const s in t)
183
- !(s in We) && !(s in Ge) && !(s in e) && (n[s] = t[s]);
182
+ for (const r in t)
183
+ !(r in We) && !(r in Ge) && !(r in e) && (n[r] = t[r]);
184
184
  return n;
185
185
  };
186
186
  class F {
187
187
  static create(t, n) {
188
- const s = new F(t, n), r = async () => {
189
- if (typeof s._options.timeout == "number" && s._options.timeout > K)
188
+ const r = new F(t, n), s = async () => {
189
+ if (typeof r._options.timeout == "number" && r._options.timeout > K)
190
190
  throw new RangeError(`The \`timeout\` option cannot be greater than ${K}`);
191
191
  await Promise.resolve();
192
- let o = await s._fetch();
193
- for (const u of s._options.hooks.afterResponse) {
194
- const c = await u(s.request, s._options, s._decorateResponse(o.clone()));
192
+ let o = await r._fetch();
193
+ for (const u of r._options.hooks.afterResponse) {
194
+ const c = await u(r.request, r._options, r._decorateResponse(o.clone()));
195
195
  c instanceof globalThis.Response && (o = c);
196
196
  }
197
- if (s._decorateResponse(o), !o.ok && s._options.throwHttpErrors) {
198
- let u = new oe(o, s.request, s._options);
199
- for (const c of s._options.hooks.beforeError)
197
+ if (r._decorateResponse(o), !o.ok && r._options.throwHttpErrors) {
198
+ let u = new oe(o, r.request, r._options);
199
+ for (const c of r._options.hooks.beforeError)
200
200
  u = await c(u);
201
201
  throw u;
202
202
  }
203
- if (s._options.onDownloadProgress) {
204
- if (typeof s._options.onDownloadProgress != "function")
203
+ if (r._options.onDownloadProgress) {
204
+ if (typeof r._options.onDownloadProgress != "function")
205
205
  throw new TypeError("The `onDownloadProgress` option must be a function");
206
206
  if (!He)
207
207
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
208
- return s._stream(o.clone(), s._options.onDownloadProgress);
208
+ return r._stream(o.clone(), r._options.onDownloadProgress);
209
209
  }
210
210
  return o;
211
- }, i = s._options.retry.methods.includes(s.request.method.toLowerCase()) ? s._retry(r) : r();
211
+ }, i = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(s) : s();
212
212
  for (const [o, u] of Object.entries(Fe))
213
213
  i[o] = async () => {
214
- s.request.headers.set("accept", s.request.headers.get("accept") || u);
214
+ r.request.headers.set("accept", r.request.headers.get("accept") || u);
215
215
  const c = (await i).clone();
216
216
  if (o === "json") {
217
217
  if (c.status === 204 || (await c.clone().arrayBuffer()).byteLength === 0)
@@ -255,7 +255,7 @@ class F {
255
255
  credentials: this._input.credentials || "same-origin",
256
256
  ...n,
257
257
  headers: Ae(this._input.headers, n.headers),
258
- hooks: se({
258
+ hooks: re({
259
259
  beforeRequest: [],
260
260
  beforeRetry: [],
261
261
  beforeError: [],
@@ -277,16 +277,16 @@ class F {
277
277
  }
278
278
  if (Me) {
279
279
  if (this.abortController = new globalThis.AbortController(), this._options.signal) {
280
- const s = this._options.signal;
280
+ const r = this._options.signal;
281
281
  this._options.signal.addEventListener("abort", () => {
282
- this.abortController.abort(s.reason);
282
+ this.abortController.abort(r.reason);
283
283
  });
284
284
  }
285
285
  this._options.signal = this.abortController.signal;
286
286
  }
287
- if (ve && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
288
- const s = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), r = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, s);
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(r, { ...this.request }), this._options);
287
+ if ($e && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
288
+ const r = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, r);
289
+ (xe && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
290
290
  }
291
291
  this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
292
292
  }
@@ -295,10 +295,10 @@ class F {
295
295
  if (t instanceof oe) {
296
296
  if (!this._options.retry.statusCodes.includes(t.response.status))
297
297
  return 0;
298
- const s = t.response.headers.get("Retry-After");
299
- if (s && this._options.retry.afterStatusCodes.includes(t.response.status)) {
300
- let r = Number(s);
301
- return Number.isNaN(r) ? r = Date.parse(s) - Date.now() : r *= 1e3, this._options.retry.maxRetryAfter !== void 0 && r > this._options.retry.maxRetryAfter ? 0 : r;
298
+ const r = t.response.headers.get("Retry-After");
299
+ if (r && this._options.retry.afterStatusCodes.includes(t.response.status)) {
300
+ let s = Number(r);
301
+ return Number.isNaN(s) ? s = Date.parse(r) - Date.now() : s *= 1e3, this._options.retry.maxRetryAfter !== void 0 && s > this._options.retry.maxRetryAfter ? 0 : s;
302
302
  }
303
303
  if (t.response.status === 413)
304
304
  return 0;
@@ -315,11 +315,11 @@ class F {
315
315
  try {
316
316
  return await t();
317
317
  } catch (n) {
318
- const s = Math.min(this._calculateRetryDelay(n), K);
319
- if (s !== 0 && this._retryCount > 0) {
320
- await Ke(s, { signal: this._options.signal });
321
- for (const r of this._options.hooks.beforeRetry)
322
- if (await r({
318
+ const r = Math.min(this._calculateRetryDelay(n), K);
319
+ if (r !== 0 && this._retryCount > 0) {
320
+ await Ke(r, { signal: this._options.signal });
321
+ for (const s of this._options.hooks.beforeRetry)
322
+ if (await s({
323
323
  request: this.request,
324
324
  options: this._options,
325
325
  error: n,
@@ -333,29 +333,29 @@ class F {
333
333
  }
334
334
  async _fetch() {
335
335
  for (const n of this._options.hooks.beforeRequest) {
336
- const s = await n(this.request, this._options);
337
- if (s instanceof Request) {
338
- this.request = s;
336
+ const r = await n(this.request, this._options);
337
+ if (r instanceof Request) {
338
+ this.request = r;
339
339
  break;
340
340
  }
341
- if (s instanceof Response)
342
- return s;
341
+ if (r instanceof Response)
342
+ return r;
343
343
  }
344
344
  const t = Je(this.request, this._options);
345
345
  return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ye(this.request.clone(), t, this.abortController, this._options);
346
346
  }
347
347
  /* istanbul ignore next */
348
348
  _stream(t, n) {
349
- const s = Number(t.headers.get("content-length")) || 0;
350
- let r = 0;
351
- return t.status === 204 ? (n && n({ percent: 1, totalBytes: s, transferredBytes: r }, new Uint8Array()), new globalThis.Response(null, {
349
+ const r = Number(t.headers.get("content-length")) || 0;
350
+ let s = 0;
351
+ return t.status === 204 ? (n && n({ percent: 1, totalBytes: r, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
352
352
  status: t.status,
353
353
  statusText: t.statusText,
354
354
  headers: t.headers
355
355
  })) : new globalThis.Response(new globalThis.ReadableStream({
356
356
  async start(i) {
357
357
  const o = t.body.getReader();
358
- n && n({ percent: 0, transferredBytes: 0, totalBytes: s }, new Uint8Array());
358
+ n && n({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
359
359
  async function u() {
360
360
  const { done: c, value: _ } = await o.read();
361
361
  if (c) {
@@ -363,9 +363,9 @@ class F {
363
363
  return;
364
364
  }
365
365
  if (n) {
366
- r += _.byteLength;
367
- const h = s === 0 ? 0 : r / s;
368
- n({ percent: h, transferredBytes: r, totalBytes: s }, _);
366
+ s += _.byteLength;
367
+ const h = r === 0 ? 0 : s / r;
368
+ n({ percent: h, transferredBytes: s, totalBytes: r }, _);
369
369
  }
370
370
  i.enqueue(_), await u();
371
371
  }
@@ -380,10 +380,10 @@ class F {
380
380
  }
381
381
  /*! MIT License © Sindre Sorhus */
382
382
  const Q = (e) => {
383
- const t = (n, s) => F.create(n, $(e, s));
383
+ const t = (n, r) => F.create(n, v(e, r));
384
384
  for (const n of pe)
385
- t[n] = (s, r) => F.create(s, $(e, r, { method: n }));
386
- return t.create = (n) => Q($(n)), t.extend = (n) => Q($(e, n)), t.stop = Se, t;
385
+ t[n] = (r, s) => F.create(r, v(e, s, { method: n }));
386
+ return t.create = (n) => Q(v(n)), t.extend = (n) => Q(v(e, n)), t.stop = Se, t;
387
387
  }, Ee = Q();
388
388
  let H;
389
389
  const m = {
@@ -404,7 +404,7 @@ const m = {
404
404
  post: (e, t) => ue().post(e, t).json()
405
405
  }, Qe = ({ tokens: e, ...t }) => {
406
406
  const n = new URLSearchParams();
407
- return e.filter((s, r, i) => i.findIndex((o) => o === s) === r).forEach((s) => n.append("tokens", JSON.stringify(s))), t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), S.post(m.CachedPrices, {
407
+ return e.filter((r, s, i) => i.findIndex((o) => o === r) === s).forEach((r) => n.append("tokens", JSON.stringify(r))), t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), S.post(m.CachedPrices, {
408
408
  body: n.toString(),
409
409
  headers: { "Content-Type": "application/x-www-form-urlencoded" }
410
410
  });
@@ -444,17 +444,17 @@ const tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
444
444
  return d.ETH;
445
445
  const [, t] = e.split("-");
446
446
  return t != null && t.startsWith("0x") ? Ie({ chain: a.Ethereum, to: t }) : d.ETH;
447
- }, st = async (e) => {
447
+ }, rt = async (e) => {
448
448
  const [, t] = e.split("-");
449
449
  return t != null && t.startsWith("0x") ? Ie({ chain: a.Avalanche, to: t.toLowerCase() }) : d.AVAX;
450
- }, rt = async (e) => e === a.BinanceSmartChain ? d.BSC : d.BSC, it = async ({ chain: e, symbol: t }) => {
450
+ }, st = async (e) => e === a.BinanceSmartChain ? d.BSC : d.BSC, it = async ({ chain: e, symbol: t }) => {
451
451
  switch (e) {
452
452
  case a.Ethereum:
453
453
  return nt(t);
454
454
  case a.Avalanche:
455
- return st(t);
456
- case a.BinanceSmartChain:
457
455
  return rt(t);
456
+ case a.BinanceSmartChain:
457
+ return st(t);
458
458
  default:
459
459
  return d[e];
460
460
  }
@@ -551,8 +551,8 @@ const tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
551
551
  }
552
552
  }, It = (e) => {
553
553
  var o;
554
- const [t, ...n] = e.split("."), s = e.includes("/"), r = n.join("."), i = (o = r == null ? void 0 : r.split("-")) == null ? void 0 : o[0];
555
- return { chain: t, symbol: r, ticker: i, synth: s };
554
+ const [t, ...n] = e.split("."), r = e.includes("/"), s = n.join("."), i = (o = s == null ? void 0 : s.split("-")) == null ? void 0 : o[0];
555
+ return { chain: t, symbol: s, ticker: i, synth: r };
556
556
  }, ct = new RegExp(
557
557
  /(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
558
558
  "gmi"
@@ -560,8 +560,8 @@ const tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
560
560
  const [t, n] = e.split(".");
561
561
  if (!Be.includes(t))
562
562
  return !0;
563
- const [, s] = n.split("-");
564
- return fe({ chain: t, symbol: n }) || !!s;
563
+ const [, r] = n.split("-");
564
+ return fe({ chain: t, symbol: n }) || !!r;
565
565
  }, ft = (e) => e.filter((t) => {
566
566
  const n = `${t.chain}.${t.symbol}`;
567
567
  return !ct.test(n) && ut(n) && t.value !== "0";
@@ -571,7 +571,7 @@ function lt({
571
571
  poolUnits: t,
572
572
  runeDepth: n
573
573
  }) {
574
- const s = A(e), r = A(t), i = A(n), o = s.mul(i), u = r.mul(r).mul(2), c = r.mul(s).mul(2), _ = s.mul(s), h = r.mul(r).mul(r);
574
+ const r = A(e), s = A(t), i = A(n), o = r.mul(i), u = s.mul(s).mul(2), c = s.mul(r).mul(2), _ = r.mul(r), h = s.mul(s).mul(s);
575
575
  return o.mul(u.sub(c).add(_)).div(h);
576
576
  }
577
577
  function _t({
@@ -579,24 +579,24 @@ function _t({
579
579
  poolUnits: t,
580
580
  assetDepth: n
581
581
  }) {
582
- const s = A(e), r = A(t), i = A(n), o = s.mul(i), u = r.mul(r).mul(2), c = r.mul(s).mul(2), _ = s.mul(s), h = o.mul(u.sub(c).add(_)), P = r.mul(r).mul(r);
582
+ const r = A(e), s = A(t), i = A(n), o = r.mul(i), u = s.mul(s).mul(2), c = s.mul(r).mul(2), _ = r.mul(r), h = o.mul(u.sub(c).add(_)), P = s.mul(s).mul(s);
583
583
  return h.div(P);
584
584
  }
585
585
  function Nt({
586
586
  percent: e,
587
587
  runeDepth: t,
588
588
  liquidityUnits: n,
589
- poolUnits: s
589
+ poolUnits: r
590
590
  }) {
591
- return lt({ runeDepth: t, liquidityUnits: n, poolUnits: s }).mul(e);
591
+ return lt({ runeDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
592
592
  }
593
593
  function Ct({
594
594
  percent: e,
595
595
  assetDepth: t,
596
596
  liquidityUnits: n,
597
- poolUnits: s
597
+ poolUnits: r
598
598
  }) {
599
- return _t({ assetDepth: t, liquidityUnits: n, poolUnits: s }).mul(e);
599
+ return _t({ assetDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
600
600
  }
601
601
  function A(e) {
602
602
  return I.fromBigInt(BigInt(e), d.THOR);
@@ -605,10 +605,10 @@ function ht({
605
605
  liquidityUnits: e,
606
606
  poolUnits: t,
607
607
  runeDepth: n,
608
- assetDepth: s
608
+ assetDepth: r
609
609
  }) {
610
610
  return {
611
- assetAmount: A(s).mul(e).div(t),
611
+ assetAmount: A(r).mul(e).div(t),
612
612
  runeAmount: A(n).mul(e).div(t)
613
613
  };
614
614
  }
@@ -616,12 +616,12 @@ function gt({
616
616
  liquidityUnits: e,
617
617
  poolUnits: t,
618
618
  runeDepth: n,
619
- assetDepth: s,
620
- percent: r
619
+ assetDepth: r,
620
+ percent: s
621
621
  }) {
622
622
  return Object.fromEntries(
623
- Object.entries(ht({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: s })).map(
624
- ([i, o]) => [i, o.mul(r)]
623
+ Object.entries(ht({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: r })).map(
624
+ ([i, o]) => [i, o.mul(s)]
625
625
  )
626
626
  );
627
627
  }
@@ -629,11 +629,11 @@ function Ot({
629
629
  runeDepth: e,
630
630
  poolUnits: t,
631
631
  assetDepth: n,
632
- liquidityUnits: s,
633
- runeAmount: r,
632
+ liquidityUnits: r,
633
+ runeAmount: s,
634
634
  assetAmount: i
635
635
  }) {
636
- const o = new I({ value: e, decimal: 8 }), u = new I({ value: n, decimal: 8 }), c = new I({ value: t, decimal: 8 }), _ = new I({ value: r, decimal: 8 }), h = new I({ value: i, decimal: 8 }), P = _.mul(u), ie = h.mul(o), ge = _.mul(h), Oe = o.mul(u), De = c.mul(P.add(ie.add(ge.mul(2)))), Pe = P.add(ie.add(Oe.mul(2))), ae = De.div(Pe), X = A(s).add(ae);
636
+ const o = new I({ value: e, decimal: 8 }), u = new I({ value: n, decimal: 8 }), c = new I({ value: t, decimal: 8 }), _ = new I({ value: s, decimal: 8 }), h = new I({ value: i, decimal: 8 }), P = _.mul(u), ie = h.mul(o), ge = _.mul(h), Oe = o.mul(u), De = c.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);
637
637
  if (ae.getBaseValue("number") === 0)
638
638
  return X.div(c).getBaseValue("number");
639
639
  const be = c.add(X);
@@ -643,11 +643,11 @@ function Dt({
643
643
  runeAmount: e,
644
644
  assetAmount: t,
645
645
  runeDepth: n,
646
- assetDepth: s
646
+ assetDepth: r
647
647
  }) {
648
- if (e === "0" || t === "0" || n === "0" || s === "0")
648
+ if (e === "0" || t === "0" || n === "0" || r === "0")
649
649
  return 0;
650
- const r = A(n), i = A(s), o = A(t), u = A(e), c = o.mul(r).sub(i.mul(u)), _ = i.mul(u).add(r.mul(i));
650
+ const s = A(n), i = A(r), o = A(t), u = A(e), c = o.mul(s).sub(i.mul(u)), _ = i.mul(u).add(s.mul(i));
651
651
  return Math.abs(c.div(_).getBaseValue("number"));
652
652
  }
653
653
  const Pt = (e, t) => {
@@ -658,16 +658,16 @@ const Pt = (e, t) => {
658
658
  return `${e}:${n}`;
659
659
  }
660
660
  case E.UNBOND: {
661
- const { address: n, unbondAmount: s } = t;
662
- return `${e}:${n}:${s}`;
661
+ const { address: n, unbondAmount: r } = t;
662
+ return `${e}:${n}:${r}`;
663
663
  }
664
664
  case E.THORNAME_REGISTER: {
665
- const { name: n, chain: s, address: r, owner: i } = t;
666
- return `${e}:${n}:${s}:${r}${i ? `:${i}` : ""}`;
665
+ const { name: n, chain: r, address: s, owner: i } = t;
666
+ return `${e}:${n}:${r}:${s}${i ? `:${i}` : ""}`;
667
667
  }
668
668
  case E.DEPOSIT: {
669
- const { chain: n, symbol: s, address: r, singleSide: i } = t;
670
- return i ? `${e}:${n}/${s}::t:0` : `${e}:${((u, c) => {
669
+ const { chain: n, symbol: r, address: s, singleSide: i } = t;
670
+ return i ? `${e}:${n}/${r}::t:0` : `${e}:${((u, c) => {
671
671
  switch (u) {
672
672
  case a.Litecoin:
673
673
  return "l";
@@ -678,16 +678,16 @@ const Pt = (e, t) => {
678
678
  default:
679
679
  return `${u}.${c}`;
680
680
  }
681
- })(n, s)}:${r || ""}:t:0`;
681
+ })(n, r)}:${s || ""}:t:0`;
682
682
  }
683
683
  case E.WITHDRAW: {
684
- const { chain: n, ticker: s, symbol: r, basisPoints: i, targetAssetString: o, singleSide: u } = t, c = n === "ETH" && s !== "ETH" ? `${s}-${r.slice(-3)}` : r, _ = !u && o ? `:${o}` : "";
684
+ const { chain: n, ticker: r, symbol: s, basisPoints: i, targetAssetString: o, singleSide: u } = t, c = n === "ETH" && r !== "ETH" ? `${r}-${s.slice(-3)}` : s, _ = !u && o ? `:${o}` : "";
685
685
  return `${e}:${n}${u ? "/" : "."}${c}:${i}${_}`;
686
686
  }
687
687
  case E.OPEN_LOAN:
688
688
  case E.CLOSE_LOAN: {
689
- const { asset: n, address: s } = t;
690
- return `${e}:${n}:${s}`;
689
+ const { asset: n, address: r } = t;
690
+ return `${e}:${n}:${r}`;
691
691
  }
692
692
  default:
693
693
  return "";
@@ -704,16 +704,16 @@ function yt(e) {
704
704
  const t = /^[a-zA-Z0-9+_-]+$/g;
705
705
  return !!e.match(t);
706
706
  }
707
- function wt([e, t, n, s, r]) {
708
- return `${e}'/${t}'/${n}'/${s}${typeof r != "number" ? "" : `/${r}`}`;
707
+ function wt([e, t, n, r, s]) {
708
+ return `${e}'/${t}'/${n}'/${r}${typeof s != "number" ? "" : `/${s}`}`;
709
709
  }
710
710
  const le = [...Object.values(a), "TERRA"];
711
711
  function dt(e = "") {
712
712
  const t = e.toUpperCase(), [n] = t.split(".");
713
713
  if (le.includes(n))
714
714
  return !0;
715
- const [s] = t.split("/");
716
- if (le.includes(s))
715
+ const [r] = t.split("/");
716
+ if (le.includes(r))
717
717
  return !0;
718
718
  throw new Error(
719
719
  `Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
@@ -727,19 +727,19 @@ function G({
727
727
  }) {
728
728
  if (n === 0)
729
729
  return e.toString();
730
- const s = e < 0n;
731
- let r = e.toString().substring(s ? 1 : 0);
732
- const i = n - (r.length - 1);
733
- i > 0 && (r = "0".repeat(i) + r);
734
- const o = r.length - n;
735
- let u = r.slice(-n);
736
- return parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${s ? "-" : ""}${r.slice(0, o)}.${u}`.replace(
730
+ const r = e < 0n;
731
+ let s = e.toString().substring(r ? 1 : 0);
732
+ const i = n - (s.length - 1);
733
+ i > 0 && (s = "0".repeat(i) + s);
734
+ const o = s.length - n;
735
+ let u = s.slice(-n);
736
+ return parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${r ? "-" : ""}${s.slice(0, o)}.${u}`.replace(
737
737
  /\.?0*$/,
738
738
  ""
739
739
  );
740
740
  }
741
741
  var C, y, f, D, k, Ne, U, z, L, Z;
742
- const re = class re {
742
+ const se = class se {
743
743
  constructor(t) {
744
744
  O(this, C);
745
745
  O(this, f);
@@ -749,11 +749,11 @@ const re = class re {
749
749
  p(this, "decimalMultiplier", 10n ** 8n);
750
750
  p(this, "bigIntValue", 0n);
751
751
  p(this, "decimal");
752
- const n = ee(t), s = typeof t == "object";
753
- this.decimal = s ? t.decimal : void 0, this.decimalMultiplier = s && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e(v(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
752
+ const n = ee(t), r = typeof t == "object";
753
+ this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e($(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
754
754
  }
755
755
  static fromBigInt(t, n) {
756
- return new re({
756
+ return new se({
757
757
  decimal: n,
758
758
  value: G({ value: t, bigIntDecimal: n, decimal: n })
759
759
  });
@@ -761,11 +761,11 @@ const re = class re {
761
761
  static shiftDecimals({
762
762
  value: t,
763
763
  from: n,
764
- to: s
764
+ to: r
765
765
  }) {
766
766
  return this.fromBigInt(
767
- t.getBaseValue("bigint") * N(s) / N(n),
768
- s
767
+ t.getBaseValue("bigint") * N(r) / N(n),
768
+ r
769
769
  );
770
770
  }
771
771
  set(t) {
@@ -815,31 +815,31 @@ const re = class re {
815
815
  }
816
816
  // @ts-expect-error
817
817
  getBaseValue(t) {
818
- const n = this.decimalMultiplier / N(this.decimal || d.THOR), s = this.bigIntValue / n;
818
+ const n = this.decimalMultiplier / N(this.decimal || d.THOR), r = this.bigIntValue / n;
819
819
  switch (t) {
820
820
  case "number":
821
- return Number(s);
821
+ return Number(r);
822
822
  case "string":
823
- return s.toString();
823
+ return r.toString();
824
824
  case "bigint":
825
- return s;
825
+ return r;
826
826
  }
827
827
  }
828
828
  getBigIntValue(t, n) {
829
829
  if (!n && typeof t == "object")
830
830
  return t.bigIntValue;
831
- const s = ee(t), r = v(s);
832
- return r === "0" || r === "undefined" ? 0n : T(this, L, Z).call(this, r, n);
831
+ const r = ee(t), s = $(r);
832
+ return s === "0" || s === "undefined" ? 0n : T(this, L, Z).call(this, s, n);
833
833
  }
834
834
  toSignificant(t = 6) {
835
- const [n, s] = this.getValue("string").split("."), r = n || "", i = s || "";
836
- if ((parseInt(r) ? r.length + i.length : i.length) <= t)
835
+ const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
836
+ if ((parseInt(s) ? s.length + i.length : i.length) <= t)
837
837
  return this.getValue("string");
838
- if (r.length >= t)
839
- return r.slice(0, t).padEnd(r.length, "0");
840
- if (parseInt(r))
841
- return `${r}.${i.slice(0, t - r.length)}`.padEnd(
842
- t - r.length,
838
+ if (s.length >= t)
839
+ return s.slice(0, t).padEnd(s.length, "0");
840
+ if (parseInt(s))
841
+ return `${s}.${i.slice(0, t - s.length)}`.padEnd(
842
+ t - s.length,
843
843
  "0"
844
844
  );
845
845
  const u = parseInt(i), c = `${u}`.slice(0, t);
@@ -849,9 +849,9 @@ const re = class re {
849
849
  )}`;
850
850
  }
851
851
  toFixed(t = 6) {
852
- const [n, s] = this.getValue("string").split("."), r = n || "", i = s || "";
853
- if (parseInt(r))
854
- return `${r}.${i.slice(0, t)}`.padEnd(t, "0");
852
+ const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
853
+ if (parseInt(s))
854
+ return `${s}.${i.slice(0, t)}`.padEnd(t, "0");
855
855
  const o = parseInt(i), u = `${o}`.slice(0, t);
856
856
  return `0.${u.padStart(
857
857
  i.length - `${o}`.length + u.length,
@@ -859,37 +859,37 @@ const re = class re {
859
859
  )}`;
860
860
  }
861
861
  toAbbreviation(t = 2) {
862
- const n = this.getValue("number"), s = ["", "K", "M", "B", "T", "Q", "Qi", "S"], r = Math.floor(Math.log10(Math.abs(n)) / 3), i = s[r];
862
+ 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];
863
863
  if (!i)
864
864
  return this.getValue("string");
865
- const o = 10 ** (r * 3);
865
+ const o = 10 ** (s * 3);
866
866
  return `${(n / o).toFixed(t)}${i}`;
867
867
  }
868
868
  toCurrency(t = "$", {
869
869
  currencyPosition: n = "start",
870
- decimal: s = 2,
871
- decimalSeparator: r = ".",
870
+ decimal: r = 2,
871
+ decimalSeparator: s = ".",
872
872
  thousandSeparator: i = ","
873
873
  } = {}) {
874
- const o = this.getValue("number"), [u, c = ""] = o.toFixed(6).split("."), _ = u.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = !u && !c ? "0.00" : u === "0" ? `${parseFloat(`0.${c}`)}`.replace(".", r) : `${_}${parseInt(c) ? `${r}${c.slice(0, s)}` : ""}`;
874
+ const o = this.getValue("number"), [u, c = ""] = o.toFixed(6).split("."), _ = u.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = !u && !c ? "0.00" : u === "0" ? `${parseFloat(`0.${c}`)}`.replace(".", s) : `${_}${parseInt(c) ? `${s}${c.slice(0, r)}` : ""}`;
875
875
  return `${n === "start" ? t : ""}${h}${n === "end" ? t : ""}`;
876
876
  }
877
877
  formatBigIntToSafeValue(t, n) {
878
- const s = n || this.decimal || B, r = Math.max(
879
- s,
878
+ const r = n || this.decimal || B, s = Math.max(
879
+ r,
880
880
  b(this.decimalMultiplier)
881
- ), i = t < 0n, o = t.toString().substring(i ? 1 : 0), u = r - (o.length - 1), c = u > 0 ? "0".repeat(u) + o : o, _ = c.length - r;
882
- let h = c.slice(-r);
883
- return parseInt(h[s]) >= 5 ? h = `${h.substring(0, s - 1)}${(parseInt(h[s - 1]) + 1).toString()}` : h = h.substring(0, s), `${i ? "-" : ""}${c.slice(
881
+ ), i = t < 0n, o = t.toString().substring(i ? 1 : 0), u = s - (o.length - 1), c = u > 0 ? "0".repeat(u) + o : o, _ = c.length - s;
882
+ let h = c.slice(-s);
883
+ return parseInt(h[r]) >= 5 ? h = `${h.substring(0, r - 1)}${(parseInt(h[r - 1]) + 1).toString()}` : h = h.substring(0, r), `${i ? "-" : ""}${c.slice(
884
884
  0,
885
885
  _
886
886
  )}.${h}`.replace(/\.?0*$/, "");
887
887
  }
888
888
  };
889
889
  C = new WeakSet(), y = function(t, ...n) {
890
- const s = T(this, U, z).call(this, this, ...n), r = Math.max(s, b(this.decimalMultiplier)), i = N(r), o = n.reduce(
890
+ const r = T(this, U, z).call(this, this, ...n), s = Math.max(r, b(this.decimalMultiplier)), i = N(s), o = n.reduce(
891
891
  (c, _) => {
892
- const h = this.getBigIntValue(_, r);
892
+ const h = this.getBigIntValue(_, s);
893
893
  switch (t) {
894
894
  case "add":
895
895
  return c + h;
@@ -909,46 +909,46 @@ C = new WeakSet(), y = function(t, ...n) {
909
909
  //normalize is to precision multiplier base
910
910
  this.bigIntValue * i / this.decimalMultiplier
911
911
  ), u = G({
912
- bigIntDecimal: r,
913
- decimal: r,
912
+ bigIntDecimal: s,
913
+ decimal: s,
914
914
  value: o
915
915
  });
916
916
  return new this.constructor({
917
- decimalMultiplier: N(r),
917
+ decimalMultiplier: N(s),
918
918
  decimal: this.decimal,
919
919
  value: u,
920
920
  identifier: this.toString()
921
921
  });
922
922
  }, f = new WeakSet(), D = function(t, ...n) {
923
- const s = T(this, U, z).call(this, this, ...n), r = this.getBigIntValue(n[0], s), i = this.getBigIntValue(this, s);
923
+ const r = T(this, U, z).call(this, this, ...n), s = this.getBigIntValue(n[0], r), i = this.getBigIntValue(this, r);
924
924
  switch (t) {
925
925
  case "gt":
926
- return i > r;
926
+ return i > s;
927
927
  case "gte":
928
- return i >= r;
928
+ return i >= s;
929
929
  case "lt":
930
- return i < r;
930
+ return i < s;
931
931
  case "lte":
932
- return i <= r;
932
+ return i <= s;
933
933
  case "eqValue":
934
- return i === r;
934
+ return i === s;
935
935
  }
936
936
  }, k = new WeakSet(), Ne = function(t) {
937
- const n = v(t) || "0";
937
+ const n = $(t) || "0";
938
938
  this.bigIntValue = T(this, L, Z).call(this, n);
939
939
  }, U = new WeakSet(), z = function(...t) {
940
- const n = t.map((s) => typeof s == "object" ? s.decimal || b(s.decimalMultiplier) : _e(v(s))).filter(Boolean);
940
+ const n = t.map((r) => typeof r == "object" ? r.decimal || b(r.decimalMultiplier) : _e($(r))).filter(Boolean);
941
941
  return Math.max(...n, B);
942
942
  }, L = new WeakSet(), Z = function(t, n) {
943
- const s = n ? N(n) : this.decimalMultiplier, r = b(s), [i = "", o = ""] = t.split(".");
944
- return BigInt(`${i}${o.padEnd(r, "0")}`);
943
+ const r = n ? N(n) : this.decimalMultiplier, s = b(r), [i = "", o = ""] = t.split(".");
944
+ return BigInt(`${i}${o.padEnd(s, "0")}`);
945
945
  };
946
- let W = re;
946
+ let W = se;
947
947
  const Tt = Intl.NumberFormat("fullwide", {
948
948
  useGrouping: !1,
949
949
  maximumFractionDigits: 20
950
950
  });
951
- function v(e) {
951
+ function $(e) {
952
952
  const n = `${typeof e == "number" ? Tt.format(e) : ee(e)}`.replaceAll(",", ".").split(".");
953
953
  return n.length > 1 ? `${n.slice(0, -1).join("")}.${n.at(-1)}` : n[0];
954
954
  }
@@ -964,13 +964,13 @@ const w = /* @__PURE__ */ new Map();
964
964
  class g extends W {
965
965
  constructor({
966
966
  value: n,
967
- decimal: s,
968
- tax: r,
967
+ decimal: r,
968
+ tax: s,
969
969
  chain: i,
970
970
  symbol: o,
971
971
  identifier: u
972
972
  }) {
973
- super(typeof n == "object" ? n : { decimal: s, value: n });
973
+ super(typeof n == "object" ? n : { decimal: r, value: n });
974
974
  p(this, "address");
975
975
  p(this, "chain");
976
976
  p(this, "isGasAsset", !1);
@@ -980,7 +980,7 @@ class g extends W {
980
980
  p(this, "ticker");
981
981
  p(this, "type");
982
982
  const c = x(u || `${i}.${o}`);
983
- this.type = ot(c), this.tax = r, this.chain = c.chain, this.ticker = c.ticker, this.symbol = c.symbol, this.address = c.address, this.isSynthetic = c.isSynthetic, this.isGasAsset = c.isGasAsset;
983
+ this.type = ot(c), this.tax = s, this.chain = c.chain, this.ticker = c.ticker, this.symbol = c.symbol, this.address = c.address, this.isSynthetic = c.isSynthetic, this.isGasAsset = c.isGasAsset;
984
984
  }
985
985
  toString() {
986
986
  return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
@@ -988,8 +988,8 @@ class g extends W {
988
988
  toUrl() {
989
989
  return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
990
990
  }
991
- eq({ chain: n, symbol: s }) {
992
- return this.chain === n && this.symbol === s;
991
+ eq({ chain: n, symbol: r }) {
992
+ return this.chain === n && this.symbol === r;
993
993
  }
994
994
  chainId() {
995
995
  return Le[this.chain];
@@ -997,54 +997,54 @@ class g extends W {
997
997
  // THOR.RUNE
998
998
  // THOR.ETH.ETH
999
999
  // ETH.THOR-0x1234567890
1000
- static fromUrl(n, s = 0) {
1001
- const [r, i, o] = n.split(".");
1002
- if (!r || !i)
1000
+ static fromUrl(n, r = 0) {
1001
+ const [s, i, o] = n.split(".");
1002
+ if (!s || !i)
1003
1003
  throw new Error("Invalid asset url");
1004
- const u = r === a.THORChain && o ? `${r}.${i}/${o}` : n;
1005
- return J(u, s);
1004
+ const u = s === a.THORChain && o ? `${s}.${i}/${o}` : n;
1005
+ return J(u, r);
1006
1006
  }
1007
- static fromString(n, s = 0) {
1008
- return J(n, s);
1007
+ static fromString(n, r = 0) {
1008
+ return J(n, r);
1009
1009
  }
1010
- static fromIdentifier(n, s = 0) {
1011
- return J(n, s);
1010
+ static fromIdentifier(n, r = 0) {
1011
+ return J(n, r);
1012
1012
  }
1013
- static fromStringSync(n, s = 0) {
1014
- const { chain: r, isSynthetic: i } = x(n), o = w.get(n.toUpperCase());
1013
+ static fromStringSync(n, r = 0) {
1014
+ const { chain: s, isSynthetic: i } = x(n), o = w.get(n.toUpperCase());
1015
1015
  if (i)
1016
- return he(n, s);
1016
+ return he(n, r);
1017
1017
  const { tax: u, decimal: c, identifier: _ } = o || {
1018
- decimal: d[r],
1018
+ decimal: d[s],
1019
1019
  identifier: n
1020
1020
  };
1021
1021
  return new g({
1022
1022
  tax: u,
1023
- value: V(s, c),
1023
+ value: V(r, c),
1024
1024
  identifier: i ? n : _,
1025
1025
  decimal: i ? 8 : c
1026
1026
  });
1027
1027
  }
1028
- static fromIdentifierSync(n, s = 0) {
1029
- const { chain: r, isSynthetic: i } = x(n), o = w.get(n);
1028
+ static fromIdentifierSync(n, r = 0) {
1029
+ const { chain: s, isSynthetic: i } = x(n), o = w.get(n);
1030
1030
  if (i)
1031
- return he(n, s);
1031
+ return he(n, r);
1032
1032
  const { tax: u, decimal: c, identifier: _ } = o || {
1033
- decimal: d[r],
1033
+ decimal: d[s],
1034
1034
  identifier: n
1035
1035
  };
1036
- return new g({ tax: u, decimal: c, identifier: _, value: V(s, c) });
1036
+ return new g({ tax: u, decimal: c, identifier: _, value: V(r, c) });
1037
1037
  }
1038
- static fromChainOrSignature(n, s = 0) {
1039
- const { decimal: r, identifier: i } = at(n);
1040
- return new g({ value: V(s, r), decimal: r, identifier: i });
1038
+ static fromChainOrSignature(n, r = 0) {
1039
+ const { decimal: s, identifier: i } = at(n);
1040
+ return new g({ value: V(r, s), decimal: s, identifier: i });
1041
1041
  }
1042
1042
  static loadStaticAssets() {
1043
1043
  return new Promise(
1044
- async (n, s) => {
1044
+ async (n, r) => {
1045
1045
  try {
1046
- const r = await import("@swapkit/tokens");
1047
- Object.values(r).forEach((i) => {
1046
+ const s = await import("@swapkit/tokens");
1047
+ Object.values(s).forEach((i) => {
1048
1048
  var o;
1049
1049
  (o = i == null ? void 0 : i.tokens) == null || o.forEach(({ identifier: u, chain: c, ..._ }) => {
1050
1050
  w.set(u.toUpperCase(), {
@@ -1053,10 +1053,10 @@ class g extends W {
1053
1053
  });
1054
1054
  });
1055
1055
  }), n({ ok: !0 });
1056
- } catch (r) {
1057
- console.error(r), s({
1056
+ } catch (s) {
1057
+ console.error(s), r({
1058
1058
  ok: !1,
1059
- error: r,
1059
+ error: s,
1060
1060
  message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
1061
1061
  });
1062
1062
  }
@@ -1087,27 +1087,27 @@ function Vt(e) {
1087
1087
  }
1088
1088
  async function J(e, t = 0) {
1089
1089
  dt(e);
1090
- const n = w.get(e.toUpperCase()), s = (n == null ? void 0 : n.decimal) || await it(x(e));
1091
- return n || w.set(e.toUpperCase(), { identifier: e, decimal: s }), new g({ decimal: s, value: V(t, s), identifier: e });
1090
+ const n = w.get(e.toUpperCase()), r = (n == null ? void 0 : n.decimal) || await it(x(e));
1091
+ return n || w.set(e.toUpperCase(), { identifier: e, decimal: r }), new g({ decimal: r, value: V(t, r), identifier: e });
1092
1092
  }
1093
1093
  function he(e, t = 0) {
1094
- const [n, s] = e.split(".")[0].toUpperCase() === a.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1095
- if (!n || !s)
1094
+ const [n, r] = e.split(".")[0].toUpperCase() === a.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1095
+ if (!n || !r)
1096
1096
  throw new Error("Invalid asset identifier");
1097
1097
  return new g({
1098
1098
  decimal: 8,
1099
1099
  value: V(t, 8),
1100
- identifier: `${a.THORChain}.${n}/${s}`
1100
+ identifier: `${a.THORChain}.${n}/${r}`
1101
1101
  });
1102
1102
  }
1103
1103
  function V(e, t) {
1104
1104
  return typeof e == "bigint" ? G({ value: e, bigIntDecimal: t, decimal: t }) : e;
1105
1105
  }
1106
1106
  function x(e) {
1107
- const t = e.slice(0, 14).includes("/"), [n, s] = e.split(".")[0].toUpperCase() === a.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1108
- if (t && (!n || !s))
1107
+ const t = e.slice(0, 14).includes("/"), [n, r] = e.split(".")[0].toUpperCase() === a.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1108
+ if (t && (!n || !r))
1109
1109
  throw new Error("Invalid asset identifier");
1110
- const r = e.includes(".") && !t ? e : `${a.THORChain}.${s}`, [i, o] = r.split("."), [u, c] = (t ? s : o).split("-");
1110
+ const s = e.includes(".") && !t ? e : `${a.THORChain}.${r}`, [i, o] = s.split("."), [u, c] = (t ? r : o).split("-");
1111
1111
  return {
1112
1112
  address: c == null ? void 0 : c.toLowerCase(),
1113
1113
  chain: i,
@@ -1166,11 +1166,16 @@ const At = {
1166
1166
  core_transaction_deposit_insufficient_funds_error: 10311,
1167
1167
  core_transaction_deposit_gas_error: 10312,
1168
1168
  core_transaction_invalid_sender_address: 10313,
1169
- core_transaction_deposit_server_error: 10313,
1169
+ core_transaction_deposit_server_error: 10314,
1170
+ core_transaction_user_rejected: 10315,
1170
1171
  /**
1171
1172
  * Wallets
1172
1173
  */
1173
1174
  wallet_ledger_connection_error: 20001,
1175
+ wallet_ledger_connection_claimed: 20002,
1176
+ wallet_ledger_get_address_error: 20003,
1177
+ wallet_ledger_device_not_found: 20004,
1178
+ wallet_ledger_device_locked: 20005,
1174
1179
  /**
1175
1180
  * Helpers
1176
1181
  */
@@ -1178,7 +1183,7 @@ const At = {
1178
1183
  };
1179
1184
  class Ce extends Error {
1180
1185
  constructor(t, n) {
1181
- 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);
1186
+ 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);
1182
1187
  }
1183
1188
  }
1184
1189
  class I extends W {