Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swapkit/helpers

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swapkit/helpers - npm Package Compare versions

Comparing version 1.0.0-rc.68 to 1.0.0-rc.69

743

dist/index.es.js

@@ -13,9 +13,9 @@ var ye = Object.defineProperty;

var T = (e, t, n) => (Ve(e, t, "access private method"), n);
import { FeeOption as Y, BaseDecimal as d, Chain as a, EVMChainList as Be, ChainToRPC as Le, MemoType as E, ChainToChainId as Ue } from "@swapkit/types";
import { FeeOption as Y, BaseDecimal as d, Chain as l, EVMChainList as Be, ChainToRPC as Ue, MemoType as E, ChainToChainId as Le } from "@swapkit/types";
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 || {});
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 + "";
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.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(j || {}), te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(te || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.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.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), R = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(R || {});
const q = Object.values(j), ve = Object.keys(j), ne = q.reduce(
var j = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(j || {}), te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(te || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), R = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(R || {});
const q = Object.values(j), $e = Object.keys(j), ne = q.reduce(
(e, t) => {
const n = ve.find((s) => j[s] === t);
const n = $e.find((r) => j[r] === t);
return n && (e[t] = n), e;

@@ -41,5 +41,5 @@ },

class oe extends Error {
constructor(t, n, s) {
const r = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", o = `${r} ${i}`.trim(), l = o ? `status code ${o}` : "an unknown error";
super(`Request failed with ${l}`), Object.defineProperty(this, "response", {
constructor(t, n, r) {
const s = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", a = `${s} ${i}`.trim(), c = a ? `status code ${a}` : "an unknown error";
super(`Request failed with ${c}`), Object.defineProperty(this, "response", {
enumerable: !0,

@@ -59,3 +59,3 @@ configurable: !0,

value: void 0
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = s;
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = r;
}

@@ -73,27 +73,27 @@ }

}
const M = (e) => e !== null && typeof e == "object", v = (...e) => {
const M = (e) => e !== null && typeof e == "object", $ = (...e) => {
for (const t of e)
if ((!M(t) || Array.isArray(t)) && t !== void 0)
throw new TypeError("The `options` argument must be an object");
return se({}, ...e);
return re({}, ...e);
}, Ae = (e = {}, t = {}) => {
const n = new globalThis.Headers(e), s = t instanceof globalThis.Headers, r = new globalThis.Headers(t);
for (const [i, o] of r.entries())
s && o === "undefined" || o === void 0 ? n.delete(i) : n.set(i, o);
const n = new globalThis.Headers(e), r = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
for (const [i, a] of s.entries())
r && a === "undefined" || a === void 0 ? n.delete(i) : n.set(i, a);
return n;
}, se = (...e) => {
}, re = (...e) => {
let t = {}, n = {};
for (const s of e)
if (Array.isArray(s))
Array.isArray(t) || (t = []), t = [...t, ...s];
else if (M(s)) {
for (let [r, i] of Object.entries(s))
M(i) && r in t && (i = se(t[r], i)), t = { ...t, [r]: i };
M(s.headers) && (n = Ae(n, s.headers), t.headers = n);
for (const r of e)
if (Array.isArray(r))
Array.isArray(t) || (t = []), t = [...t, ...r];
else if (M(r)) {
for (let [s, i] of Object.entries(r))
M(i) && s in t && (i = re(t[s], i)), t = { ...t, [s]: i };
M(r.headers) && (n = Ae(n, r.headers), t.headers = n);
}
return t;
}, $e = (() => {
}, ve = (() => {
let e = !1, t = !1;
const n = typeof globalThis.ReadableStream == "function", s = typeof globalThis.Request == "function";
return n && s && (t = new globalThis.Request("https://empty.invalid", {
const n = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
return n && r && (t = new globalThis.Request("https://empty.invalid", {
body: new globalThis.ReadableStream(),

@@ -163,9 +163,9 @@ method: "POST",

};
async function Ye(e, t, n, s) {
return new Promise((r, i) => {
const o = setTimeout(() => {
async function Ye(e, t, n, r) {
return new Promise((s, i) => {
const a = setTimeout(() => {
n && n.abort(), i(new Te(e));
}, s.timeout);
s.fetch(e, t).then(r).catch(i).then(() => {
clearTimeout(o);
}, r.timeout);
r.fetch(e, t).then(s).catch(i).then(() => {
clearTimeout(a);
});

@@ -175,9 +175,9 @@ });

async function Ke(e, { signal: t }) {
return new Promise((n, s) => {
t && (t.throwIfAborted(), t.addEventListener("abort", r, { once: !0 }));
function r() {
clearTimeout(i), s(t.reason);
return new Promise((n, r) => {
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
function s() {
clearTimeout(i), r(t.reason);
}
const i = setTimeout(() => {
t == null || t.removeEventListener("abort", r), n();
t == null || t.removeEventListener("abort", s), n();
}, e);

@@ -188,4 +188,4 @@ });

const n = {};
for (const s in t)
!(s in We) && !(s in Ge) && !(s in e) && (n[s] = t[s]);
for (const r in t)
!(r in We) && !(r in Ge) && !(r in e) && (n[r] = t[r]);
return n;

@@ -195,37 +195,37 @@ };

static create(t, n) {
const s = new x(t, n), r = async () => {
if (typeof s._options.timeout == "number" && s._options.timeout > K)
const r = new x(t, n), s = async () => {
if (typeof r._options.timeout == "number" && r._options.timeout > K)
throw new RangeError(`The \`timeout\` option cannot be greater than ${K}`);
await Promise.resolve();
let o = await s._fetch();
for (const l of s._options.hooks.afterResponse) {
const c = await l(s.request, s._options, s._decorateResponse(o.clone()));
c instanceof globalThis.Response && (o = c);
let a = await r._fetch();
for (const c of r._options.hooks.afterResponse) {
const o = await c(r.request, r._options, r._decorateResponse(a.clone()));
o instanceof globalThis.Response && (a = o);
}
if (s._decorateResponse(o), !o.ok && s._options.throwHttpErrors) {
let l = new oe(o, s.request, s._options);
for (const c of s._options.hooks.beforeError)
l = await c(l);
throw l;
if (r._decorateResponse(a), !a.ok && r._options.throwHttpErrors) {
let c = new oe(a, r.request, r._options);
for (const o of r._options.hooks.beforeError)
c = await o(c);
throw c;
}
if (s._options.onDownloadProgress) {
if (typeof s._options.onDownloadProgress != "function")
if (r._options.onDownloadProgress) {
if (typeof r._options.onDownloadProgress != "function")
throw new TypeError("The `onDownloadProgress` option must be a function");
if (!He)
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
return s._stream(o.clone(), s._options.onDownloadProgress);
return r._stream(a.clone(), r._options.onDownloadProgress);
}
return o;
}, i = s._options.retry.methods.includes(s.request.method.toLowerCase()) ? s._retry(r) : r();
for (const [o, l] of Object.entries(xe))
i[o] = async () => {
s.request.headers.set("accept", s.request.headers.get("accept") || l);
const c = (await i).clone();
if (o === "json") {
if (c.status === 204 || (await c.clone().arrayBuffer()).byteLength === 0)
return a;
}, i = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(s) : s();
for (const [a, c] of Object.entries(xe))
i[a] = async () => {
r.request.headers.set("accept", r.request.headers.get("accept") || c);
const o = (await i).clone();
if (a === "json") {
if (o.status === 204 || (await o.clone().arrayBuffer()).byteLength === 0)
return "";
if (n.parseJson)
return n.parseJson(await c.text());
return n.parseJson(await o.text());
}
return c[o]();
return o[a]();
};

@@ -266,3 +266,3 @@ return i;

headers: Ae(this._input.headers, n.headers),
hooks: se({
hooks: re({
beforeRequest: [],

@@ -289,5 +289,5 @@ beforeRetry: [],

if (this.abortController = new globalThis.AbortController(), this._options.signal) {
const s = this._options.signal;
const r = this._options.signal;
this._options.signal.addEventListener("abort", () => {
this.abortController.abort(s.reason);
this.abortController.abort(r.reason);
});

@@ -297,5 +297,5 @@ }

}
if ($e && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
const s = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), r = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, s);
(Fe && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(r, { ...this.request }), this._options);
if (ve && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
const r = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, r);
(Fe && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
}

@@ -309,6 +309,6 @@ 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 }));

return 0;
const s = t.response.headers.get("Retry-After");
if (s && this._options.retry.afterStatusCodes.includes(t.response.status)) {
let r = Number(s);
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;
const r = t.response.headers.get("Retry-After");
if (r && this._options.retry.afterStatusCodes.includes(t.response.status)) {
let s = Number(r);
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;
}

@@ -330,7 +330,7 @@ if (t.response.status === 413)

} catch (n) {
const s = Math.min(this._calculateRetryDelay(n), K);
if (s !== 0 && this._retryCount > 0) {
await Ke(s, { signal: this._options.signal });
for (const r of this._options.hooks.beforeRetry)
if (await r({
const r = Math.min(this._calculateRetryDelay(n), K);
if (r !== 0 && this._retryCount > 0) {
await Ke(r, { signal: this._options.signal });
for (const s of this._options.hooks.beforeRetry)
if (await s({
request: this.request,

@@ -349,9 +349,9 @@ options: this._options,

for (const n of this._options.hooks.beforeRequest) {
const s = await n(this.request, this._options);
if (s instanceof Request) {
this.request = s;
const r = await n(this.request, this._options);
if (r instanceof Request) {
this.request = r;
break;
}
if (s instanceof Response)
return s;
if (r instanceof Response)
return r;
}

@@ -363,5 +363,5 @@ const t = Je(this.request, this._options);

_stream(t, n) {
const s = Number(t.headers.get("content-length")) || 0;
let r = 0;
return t.status === 204 ? (n && n({ percent: 1, totalBytes: s, transferredBytes: r }, new Uint8Array()), new globalThis.Response(null, {
const r = Number(t.headers.get("content-length")) || 0;
let s = 0;
return t.status === 204 ? (n && n({ percent: 1, totalBytes: r, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
status: t.status,

@@ -372,7 +372,7 @@ statusText: t.statusText,

async start(i) {
const o = t.body.getReader();
n && n({ percent: 0, transferredBytes: 0, totalBytes: s }, new Uint8Array());
async function l() {
const { done: c, value: _ } = await o.read();
if (c) {
const a = t.body.getReader();
n && n({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
async function c() {
const { done: o, value: _ } = await a.read();
if (o) {
i.close();

@@ -382,9 +382,9 @@ return;

if (n) {
r += _.byteLength;
const h = s === 0 ? 0 : r / s;
n({ percent: h, transferredBytes: r, totalBytes: s }, _);
s += _.byteLength;
const h = r === 0 ? 0 : s / r;
n({ percent: h, transferredBytes: s, totalBytes: r }, _);
}
i.enqueue(_), await l();
i.enqueue(_), await c();
}
await l();
await c();
}

@@ -400,6 +400,6 @@ }), {

const Q = (e) => {
const t = (n, s) => x.create(n, v(e, s));
const t = (n, r) => x.create(n, $(e, r));
for (const n of pe)
t[n] = (s, r) => x.create(s, v(e, r, { method: n }));
return t.create = (n) => Q(v(n)), t.extend = (n) => Q(v(e, n)), t.stop = Se, t;
t[n] = (r, s) => x.create(r, $(e, s, { method: n }));
return t.create = (n) => Q($(n)), t.extend = (n) => Q($(e, n)), t.stop = Se, t;
}, Ee = Q();

@@ -425,3 +425,3 @@ let H;

const n = new URLSearchParams();
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, {
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, {
body: n.toString(),

@@ -444,3 +444,3 @@ headers: { "Content-Type": "application/x-www-form-urlencoded" }

try {
const { result: n } = await S.post(Le[e], {
const { result: n } = await S.post(Ue[e], {
headers: {

@@ -463,17 +463,17 @@ accept: "*/*",

}, nt = async (e) => {
if (e === a.Ethereum)
if (e === l.Ethereum)
return d.ETH;
const [, t] = e.split("-");
return t != null && t.startsWith("0x") ? Ie({ chain: a.Ethereum, to: t }) : d.ETH;
}, st = async (e) => {
return t != null && t.startsWith("0x") ? Ie({ chain: l.Ethereum, to: t }) : d.ETH;
}, rt = async (e) => {
const [, t] = e.split("-");
return t != null && t.startsWith("0x") ? Ie({ chain: a.Avalanche, to: t.toLowerCase() }) : d.AVAX;
}, rt = async (e) => e === a.BinanceSmartChain ? d.BSC : d.BSC, it = async ({ chain: e, symbol: t }) => {
return t != null && t.startsWith("0x") ? Ie({ chain: l.Avalanche, to: t.toLowerCase() }) : d.AVAX;
}, st = async (e) => e === l.BinanceSmartChain ? d.BSC : d.BSC, it = async ({ chain: e, symbol: t }) => {
switch (e) {
case a.Ethereum:
case l.Ethereum:
return nt(t);
case a.Avalanche:
case l.Avalanche:
return rt(t);
case l.BinanceSmartChain:
return st(t);
case a.BinanceSmartChain:
return rt(t);
default:

@@ -488,59 +488,39 @@ return d[e];

switch (e) {
case a.Bitcoin:
case a.BitcoinCash:
case a.Litecoin:
case a.Dogecoin:
case a.Binance:
case a.Ethereum:
case a.Avalanche:
case a.Polkadot:
case a.Chainflip:
return t === e;
case a.Arbitrum:
case a.Optimism:
case l.Arbitrum:
case l.Optimism:
return t === "ETH";
case a.Maya:
case l.Maya:
return t === "CACAO";
case a.Kujira:
case l.Kujira:
return t === "KUJI";
case a.Cosmos:
case l.Cosmos:
return t === "ATOM";
case a.Polygon:
case l.Polygon:
return t === "MATIC";
case a.BinanceSmartChain:
case l.BinanceSmartChain:
return t === "BNB";
case a.THORChain:
case l.THORChain:
return t === "RUNE";
default:
return t === e;
}
}, at = (e) => {
switch (e) {
case `${a.Ethereum}.THOR`:
case `${l.Ethereum}.THOR`:
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
case `${a.Ethereum}.vTHOR`:
case `${l.Ethereum}.vTHOR`:
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
case a.Cosmos:
case l.Cosmos:
return { identifier: "GAIA.ATOM", decimal: d[e] };
case a.THORChain:
case l.THORChain:
return { identifier: "THOR.RUNE", decimal: d[e] };
case a.BinanceSmartChain:
case l.BinanceSmartChain:
return { identifier: "BSC.BNB", decimal: d[e] };
case a.Maya:
case l.Maya:
return { identifier: "MAYA.CACAO", decimal: d.MAYA };
case `${a.Maya}.MAYA`:
case `${l.Maya}.MAYA`:
return { identifier: "MAYA.MAYA", decimal: 4 };
case `${a.Kujira}.USK`:
return { identifier: `${a.Kujira}.USK`, decimal: 6 };
case a.Kujira:
case a.Arbitrum:
case a.Optimism:
case a.BitcoinCash:
case a.Litecoin:
case a.Dogecoin:
case a.Binance:
case a.Avalanche:
case a.Chainflip:
case a.Polygon:
case a.Polkadot:
case a.Bitcoin:
case a.Ethereum:
case `${l.Kujira}.USK`:
return { identifier: `${l.Kujira}.USK`, decimal: 6 };
default:
return { identifier: `${e}.${e}`, decimal: d[e] };

@@ -552,34 +532,27 @@ }

switch (e) {
case a.Bitcoin:
case a.BitcoinCash:
case a.Dogecoin:
case a.Litecoin:
case a.Maya:
case a.THORChain:
case a.Polkadot:
case a.Chainflip:
case l.Cosmos:
return t === "ATOM" ? "Native" : l.Cosmos;
case l.Kujira:
return t === l.Kujira ? "Native" : l.Kujira;
case l.Binance:
return t === l.Binance ? "Native" : "BEP2";
case l.BinanceSmartChain:
return t === l.Binance ? "Native" : "BEP20";
case l.Ethereum:
return t === l.Ethereum ? "Native" : "ERC20";
case l.Avalanche:
return t === l.Avalanche ? "Native" : l.Avalanche;
case l.Polygon:
return t === l.Polygon ? "Native" : "POLYGON";
case l.Arbitrum:
return [l.Ethereum, l.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
case l.Optimism:
return [l.Ethereum, l.Optimism].includes(t) ? "Native" : "OPTIMISM";
default:
return "Native";
case a.Cosmos:
return t === "ATOM" ? "Native" : a.Cosmos;
case a.Kujira:
return t === a.Kujira ? "Native" : a.Kujira;
case a.Binance:
return t === a.Binance ? "Native" : "BEP2";
case a.BinanceSmartChain:
return t === a.Binance ? "Native" : "BEP20";
case a.Ethereum:
return t === a.Ethereum ? "Native" : "ERC20";
case a.Avalanche:
return t === a.Avalanche ? "Native" : a.Avalanche;
case a.Polygon:
return t === a.Polygon ? "Native" : "POLYGON";
case a.Arbitrum:
return [a.Ethereum, a.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
case a.Optimism:
return [a.Ethereum, a.Optimism].includes(t) ? "Native" : "OPTIMISM";
}
}, It = (e) => {
var o;
const [t, ...n] = e.split("."), s = e.includes("/"), r = n.join("."), i = (o = r == null ? void 0 : r.split("-")) == null ? void 0 : o[0];
return { chain: t, symbol: r, ticker: i, synth: s };
var a;
const [t, ...n] = e.split("."), r = e.includes("/"), s = n.join("."), i = (a = s == null ? void 0 : s.split("-")) == null ? void 0 : a[0];
return { chain: t, symbol: s, ticker: i, synth: r };
}, ct = new RegExp(

@@ -592,7 +565,7 @@ /(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,

return !0;
const [, s] = n.split("-");
return fe({ chain: t, symbol: n }) || !!s;
}, ft = (e) => e.filter((t) => {
const n = `${t.chain}.${t.symbol}`;
return !ct.test(n) && lt(n) && t.value !== "0";
const [, r] = n.split("-");
return fe({ chain: t, symbol: n }) || !!r;
}, ft = (e) => e.filter(({ chain: t, value: n, symbol: r }) => {
const s = `${t}.${r}`;
return !ct.test(s) && lt(s) && n !== "0";
});

@@ -604,4 +577,4 @@ function ut({

}) {
const s = A(e), r = A(t), i = A(n), o = s.mul(i), l = r.mul(r).mul(2), c = r.mul(s).mul(2), _ = s.mul(s), h = r.mul(r).mul(r);
return o.mul(l.sub(c).add(_)).div(h);
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);
return a.mul(c.sub(o).add(_)).div(h);
}

@@ -613,20 +586,20 @@ function _t({

}) {
const s = A(e), r = A(t), i = A(n), o = s.mul(i), l = r.mul(r).mul(2), c = r.mul(s).mul(2), _ = s.mul(s), h = o.mul(l.sub(c).add(_)), P = r.mul(r).mul(r);
const r = A(e), s = A(t), i = A(n), a = r.mul(i), c = s.mul(s).mul(2), o = s.mul(r).mul(2), _ = r.mul(r), h = a.mul(c.sub(o).add(_)), P = s.mul(s).mul(s);
return h.div(P);
}
function Ct({
function Nt({
percent: e,
runeDepth: t,
liquidityUnits: n,
poolUnits: s
poolUnits: r
}) {
return ut({ runeDepth: t, liquidityUnits: n, poolUnits: s }).mul(e);
return ut({ runeDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
}
function Nt({
function Ct({
percent: e,
assetDepth: t,
liquidityUnits: n,
poolUnits: s
poolUnits: r
}) {
return _t({ assetDepth: t, liquidityUnits: n, poolUnits: s }).mul(e);
return _t({ assetDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
}

@@ -640,6 +613,6 @@ function A(e) {

runeDepth: n,
assetDepth: s
assetDepth: r
}) {
return {
assetAmount: A(s).mul(e).div(t),
assetAmount: A(r).mul(e).div(t),
runeAmount: A(n).mul(e).div(t)

@@ -652,8 +625,8 @@ };

runeDepth: n,
assetDepth: s,
percent: r
assetDepth: r,
percent: s
}) {
return Object.fromEntries(
Object.entries(ht({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: s })).map(
([i, o]) => [i, o.mul(r)]
Object.entries(ht({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: r })).map(
([i, a]) => [i, a.mul(s)]
)

@@ -666,10 +639,10 @@ );

assetDepth: n,
liquidityUnits: s,
runeAmount: r,
liquidityUnits: r,
runeAmount: s,
assetAmount: i
}) {
const o = new I({ value: e, decimal: 8 }), l = 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(l), ie = h.mul(o), ge = _.mul(h), Oe = o.mul(l), 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);
const a = new I({ value: e, decimal: 8 }), c = new I({ value: n, decimal: 8 }), o = new I({ value: t, decimal: 8 }), _ = new I({ value: s, decimal: 8 }), h = new I({ value: i, decimal: 8 }), P = _.mul(c), ie = h.mul(a), ge = _.mul(h), Oe = a.mul(c), De = o.mul(P.add(ie.add(ge.mul(2)))), Pe = P.add(ie.add(Oe.mul(2))), ae = De.div(Pe), X = A(r).add(ae);
if (ae.getBaseValue("number") === 0)
return X.div(c).getBaseValue("number");
const be = c.add(X);
return X.div(o).getBaseValue("number");
const be = o.add(X);
return X.div(be).getBaseValue("number");

@@ -681,8 +654,8 @@ }

runeDepth: n,
assetDepth: s
assetDepth: r
}) {
if (e === "0" || t === "0" || n === "0" || s === "0")
if (e === "0" || t === "0" || n === "0" || r === "0")
return 0;
const r = A(n), i = A(s), o = A(t), l = A(e), c = o.mul(r).sub(i.mul(l)), _ = i.mul(l).add(r.mul(i));
return Math.abs(c.div(_).getBaseValue("number"));
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));
return Math.abs(o.div(_).getBaseValue("number"));
}

@@ -697,32 +670,32 @@ const Pt = (e, t) => {

case E.UNBOND: {
const { address: n, unbondAmount: s } = t;
return `${e}:${n}:${s}`;
const { address: n, unbondAmount: r } = t;
return `${e}:${n}:${r}`;
}
case E.THORNAME_REGISTER: {
const { name: n, chain: s, address: r, owner: i } = t;
return `${e}:${n}:${s}:${r}${i ? `:${i}` : ""}`;
const { name: n, chain: r, address: s, owner: i } = t;
return `${e}:${n}:${r}:${s}${i ? `:${i}` : ""}`;
}
case E.DEPOSIT: {
const { chain: n, symbol: s, address: r, singleSide: i } = t;
return i ? `${e}:${n}/${s}::t:0` : `${e}:${((l, c) => {
switch (l) {
case a.Litecoin:
const { chain: n, symbol: r, address: s, singleSide: i } = t;
return i ? `${e}:${n}/${r}::t:0` : `${e}:${((c, o) => {
switch (c) {
case l.Litecoin:
return "l";
case a.Dogecoin:
case l.Dogecoin:
return "d";
case a.BitcoinCash:
case l.BitcoinCash:
return "c";
default:
return `${l}.${c}`;
return `${c}.${o}`;
}
})(n, s)}:${r || ""}:t:0`;
})(n, r)}:${s || ""}:t:0`;
}
case E.WITHDRAW: {
const { chain: n, ticker: s, symbol: r, basisPoints: i, targetAssetString: o, singleSide: l } = t, c = n === "ETH" && s !== "ETH" ? `${s}-${r.slice(-3)}` : r, _ = !l && o ? `:${o}` : "";
return `${e}:${n}${l ? "/" : "."}${c}:${i}${_}`;
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}` : "";
return `${e}:${n}${c ? "/" : "."}${o}:${i}${_}`;
}
case E.OPEN_LOAN:
case E.CLOSE_LOAN: {
const { asset: n, address: s } = t;
return `${e}:${n}:${s}`;
const { asset: n, address: r } = t;
return `${e}:${n}:${r}`;
}

@@ -744,6 +717,6 @@ default:

}
function wt([e, t, n, s, r]) {
return `${e}'/${t}'/${n}'/${s}${typeof r != "number" ? "" : `/${r}`}`;
function wt([e, t, n, r, s]) {
return `${e}'/${t}'/${n}'/${r}${typeof s != "number" ? "" : `/${s}`}`;
}
const ue = [...Object.values(a), "TERRA"];
const ue = [...Object.values(l), "TERRA"];
function dt(e = "") {

@@ -753,4 +726,4 @@ const t = e.toUpperCase(), [n] = t.split(".");

return !0;
const [s] = t.split("/");
if (ue.includes(s))
const [r] = t.split("/");
if (ue.includes(r))
return !0;

@@ -761,3 +734,3 @@ throw new Error(

}
const B = 8, C = (e) => 10n ** BigInt(e), b = (e) => Math.log10(parseFloat(e.toString()));
const B = 8, N = (e) => 10n ** BigInt(e), b = (e) => Math.log10(parseFloat(e.toString()));
function G({

@@ -770,9 +743,9 @@ value: e,

return e.toString();
const s = e < 0n;
let r = e.toString().substring(s ? 1 : 0);
const i = n - (r.length - 1);
i > 0 && (r = "0".repeat(i) + r);
const o = r.length - n;
let l = r.slice(-n);
return parseInt(l[t]) >= 5 ? l = `${l.substring(0, t - 1)}${(parseInt(l[t - 1]) + 1).toString()}` : l = l.substring(0, t), `${s ? "-" : ""}${r.slice(0, o)}.${l}`.replace(
const r = e < 0n;
let s = e.toString().substring(r ? 1 : 0);
const i = n - (s.length - 1);
i > 0 && (s = "0".repeat(i) + s);
const a = s.length - n;
let c = s.slice(-n);
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(
/\.?0*$/,

@@ -782,18 +755,18 @@ ""

}
var N, y, f, D, k, Ce, L, z, U, Z;
const re = class re {
var C, y, f, D, k, Ne, U, z, L, Z;
const se = class se {
constructor(t) {
O(this, N);
O(this, C);
O(this, f);
O(this, k);
O(this, U);
O(this, L);
O(this, U);
p(this, "decimalMultiplier", 10n ** 8n);
p(this, "bigIntValue", 0n);
p(this, "decimal");
const n = ee(t), s = typeof t == "object";
this.decimal = s ? t.decimal : void 0, this.decimalMultiplier = s && "decimalMultiplier" in t ? t.decimalMultiplier : C(Math.max(_e($(n)), this.decimal || 0)), T(this, k, Ce).call(this, n);
const n = ee(t), r = typeof t == "object";
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e(v(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
}
static fromBigInt(t, n) {
return new re({
return new se({
decimal: n,

@@ -806,7 +779,7 @@ value: G({ value: t, bigIntDecimal: n, decimal: n })

from: n,
to: s
to: r
}) {
return this.fromBigInt(
t.getBaseValue("bigint") * C(s) / C(n),
s
t.getBaseValue("bigint") * N(r) / N(n),
r
);

@@ -818,12 +791,12 @@ }

add(...t) {
return T(this, N, y).call(this, "add", ...t);
return T(this, C, y).call(this, "add", ...t);
}
sub(...t) {
return T(this, N, y).call(this, "sub", ...t);
return T(this, C, y).call(this, "sub", ...t);
}
mul(...t) {
return T(this, N, y).call(this, "mul", ...t);
return T(this, C, y).call(this, "mul", ...t);
}
div(...t) {
return T(this, N, y).call(this, "div", ...t);
return T(this, C, y).call(this, "div", ...t);
}

@@ -862,10 +835,10 @@ gt(t) {

getBaseValue(t) {
const n = this.decimalMultiplier / C(this.decimal || d.THOR), s = this.bigIntValue / n;
const n = this.decimalMultiplier / N(this.decimal || d.THOR), r = this.bigIntValue / n;
switch (t) {
case "number":
return Number(s);
return Number(r);
case "string":
return s.toString();
return r.toString();
case "bigint":
return s;
return r;
}

@@ -876,19 +849,19 @@ }

return t.bigIntValue;
const s = ee(t), r = $(s);
return r === "0" || r === "undefined" ? 0n : T(this, U, Z).call(this, r, n);
const r = ee(t), s = v(r);
return s === "0" || s === "undefined" ? 0n : T(this, L, Z).call(this, s, n);
}
toSignificant(t = 6) {
const [n, s] = this.getValue("string").split("."), r = n || "", i = s || "";
if ((parseInt(r) ? r.length + i.length : i.length) <= t)
const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
if ((parseInt(s) ? s.length + i.length : i.length) <= t)
return this.getValue("string");
if (r.length >= t)
return r.slice(0, t).padEnd(r.length, "0");
if (parseInt(r))
return `${r}.${i.slice(0, t - r.length)}`.padEnd(
t - r.length,
if (s.length >= t)
return s.slice(0, t).padEnd(s.length, "0");
if (parseInt(s))
return `${s}.${i.slice(0, t - s.length)}`.padEnd(
t - s.length,
"0"
);
const l = parseInt(i), c = `${l}`.slice(0, t);
return `0.${c.padStart(
i.length - `${l}`.length + c.length,
const c = parseInt(i), o = `${c}`.slice(0, t);
return `0.${o.padStart(
i.length - `${c}`.length + o.length,
"0"

@@ -898,8 +871,8 @@ )}`;

toFixed(t = 6) {
const [n, s] = this.getValue("string").split("."), r = n || "", i = s || "";
if (parseInt(r))
return `${r}.${i.slice(0, t)}`.padEnd(t, "0");
const o = parseInt(i), l = `${o}`.slice(0, t);
return `0.${l.padStart(
i.length - `${o}`.length + l.length,
const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
if (parseInt(s))
return `${s}.${i.slice(0, t)}`.padEnd(t, "0");
const a = parseInt(i), c = `${a}`.slice(0, t);
return `0.${c.padStart(
i.length - `${a}`.length + c.length,
"0"

@@ -909,24 +882,24 @@ )}`;

toAbbreviation(t = 2) {
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];
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];
if (!i)
return this.getValue("string");
const o = 10 ** (r * 3);
return `${(n / o).toFixed(t)}${i}`;
const a = 10 ** (s * 3);
return `${(n / a).toFixed(t)}${i}`;
}
toCurrency(t = "$", {
currencyPosition: n = "start",
decimal: s = 2,
decimalSeparator: r = ".",
decimal: r = 2,
decimalSeparator: s = ".",
thousandSeparator: i = ","
} = {}) {
const o = this.getValue("number"), [l, c = ""] = o.toFixed(6).split("."), _ = l.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = !l && !c ? "0.00" : l === "0" ? `${parseFloat(`0.${c}`)}`.replace(".", r) : `${_}${parseInt(c) ? `${r}${c.slice(0, s)}` : ""}`;
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)}` : ""}`;
return `${n === "start" ? t : ""}${h}${n === "end" ? t : ""}`;
}
formatBigIntToSafeValue(t, n) {
const s = n || this.decimal || B, r = Math.max(
s,
const r = n || this.decimal || B, s = Math.max(
r,
b(this.decimalMultiplier)
), i = t < 0n, o = t.toString().substring(i ? 1 : 0), l = r - (o.length - 1), c = l > 0 ? "0".repeat(l) + o : o, _ = c.length - r;
let h = c.slice(-r);
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(
), 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;
let h = o.slice(-s);
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(
0,

@@ -937,20 +910,20 @@ _

};
N = new WeakSet(), y = function(t, ...n) {
const s = T(this, L, z).call(this, this, ...n), r = Math.max(s, b(this.decimalMultiplier)), i = C(r), o = n.reduce(
(c, _) => {
const h = this.getBigIntValue(_, r);
C = new WeakSet(), y = function(t, ...n) {
const r = T(this, U, z).call(this, this, ...n), s = Math.max(r, b(this.decimalMultiplier)), i = N(s), a = n.reduce(
(o, _) => {
const h = this.getBigIntValue(_, s);
switch (t) {
case "add":
return c + h;
return o + h;
case "sub":
return c - h;
return o - h;
case "mul":
return c * h / i;
return o * h / i;
case "div": {
if (h === 0n)
throw new RangeError("Division by zero");
return c * i / h;
return o * i / h;
}
default:
return c;
return o;
}

@@ -960,38 +933,38 @@ },

this.bigIntValue * i / this.decimalMultiplier
), l = G({
bigIntDecimal: r,
decimal: r,
value: o
), c = G({
bigIntDecimal: s,
decimal: s,
value: a
});
return new this.constructor({
decimalMultiplier: C(r),
decimalMultiplier: N(s),
decimal: this.decimal,
value: l,
value: c,
identifier: this.toString()
});
}, f = new WeakSet(), D = function(t, ...n) {
const s = T(this, L, z).call(this, this, ...n), r = this.getBigIntValue(n[0], s), i = this.getBigIntValue(this, s);
const r = T(this, U, z).call(this, this, ...n), s = this.getBigIntValue(n[0], r), i = this.getBigIntValue(this, r);
switch (t) {
case "gt":
return i > r;
return i > s;
case "gte":
return i >= r;
return i >= s;
case "lt":
return i < r;
return i < s;
case "lte":
return i <= r;
return i <= s;
case "eqValue":
return i === r;
return i === s;
}
}, k = new WeakSet(), Ce = function(t) {
const n = $(t) || "0";
this.bigIntValue = T(this, U, Z).call(this, n);
}, L = new WeakSet(), z = function(...t) {
const n = t.map((s) => typeof s == "object" ? s.decimal || b(s.decimalMultiplier) : _e($(s))).filter(Boolean);
}, k = new WeakSet(), Ne = function(t) {
const n = v(t) || "0";
this.bigIntValue = T(this, L, Z).call(this, n);
}, U = new WeakSet(), z = function(...t) {
const n = t.map((r) => typeof r == "object" ? r.decimal || b(r.decimalMultiplier) : _e(v(r))).filter(Boolean);
return Math.max(...n, B);
}, U = new WeakSet(), Z = function(t, n) {
const s = n ? C(n) : this.decimalMultiplier, r = b(s), [i = "", o = ""] = t.split(".");
return BigInt(`${i}${o.padEnd(r, "0")}`);
}, L = new WeakSet(), Z = function(t, n) {
const r = n ? N(n) : this.decimalMultiplier, s = b(r), [i = "", a = ""] = t.split(".");
return BigInt(`${i}${a.padEnd(s, "0")}`);
};
let W = re;
let W = se;
const Tt = Intl.NumberFormat("fullwide", {

@@ -1001,3 +974,3 @@ useGrouping: !1,

});
function $(e) {
function v(e) {
const n = `${typeof e == "number" ? Tt.format(e) : ee(e)}`.replaceAll(",", ".").split(".");

@@ -1018,9 +991,9 @@ return n.length > 1 ? `${n.slice(0, -1).join("")}.${n.at(-1)}` : n[0];

value: n,
decimal: s,
tax: r,
decimal: r,
tax: s,
chain: i,
symbol: o,
identifier: l
symbol: a,
identifier: c
}) {
super(typeof n == "object" ? n : { decimal: s, value: n });
super(typeof n == "object" ? n : { decimal: r, value: n });
p(this, "address");

@@ -1034,4 +1007,4 @@ p(this, "chain");

p(this, "type");
const c = F(l || `${i}.${o}`);
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;
const o = F(c || `${i}.${a}`);
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;
}

@@ -1044,7 +1017,7 @@ toString() {

}
eq({ chain: n, symbol: s }) {
return this.chain === n && this.symbol === s;
eq({ chain: n, symbol: r }) {
return this.chain === n && this.symbol === r;
}
chainId() {
return Ue[this.chain];
return Le[this.chain];
}

@@ -1054,62 +1027,62 @@ // THOR.RUNE

// ETH.THOR-0x1234567890
static fromUrl(n, s = 0) {
const [r, i, o] = n.split(".");
if (!r || !i)
static fromUrl(n, r = 0) {
const [s, i, a] = n.split(".");
if (!s || !i)
throw new Error("Invalid asset url");
const l = r === a.THORChain && o ? `${r}.${i}/${o}` : n;
return J(l, s);
const c = s === l.THORChain && a ? `${s}.${i}/${a}` : n;
return J(c, r);
}
static fromString(n, s = 0) {
return J(n, s);
static fromString(n, r = 0) {
return J(n, r);
}
static fromIdentifier(n, s = 0) {
return J(n, s);
static fromIdentifier(n, r = 0) {
return J(n, r);
}
static fromStringSync(n, s = 0) {
const { chain: r, isSynthetic: i } = F(n), o = w.get(n.toUpperCase());
static fromStringSync(n, r = 0) {
const { chain: s, isSynthetic: i } = F(n), a = w.get(n.toUpperCase());
if (i)
return he(n, s);
const { tax: l, decimal: c, identifier: _ } = o || {
decimal: d[r],
return he(n, r);
const { tax: c, decimal: o, identifier: _ } = a || {
decimal: d[s],
identifier: n
};
return new g({
tax: l,
value: V(s, c),
tax: c,
value: V(r, o),
identifier: i ? n : _,
decimal: i ? 8 : c
decimal: i ? 8 : o
});
}
static fromIdentifierSync(n, s = 0) {
const { chain: r, isSynthetic: i } = F(n), o = w.get(n);
static fromIdentifierSync(n, r = 0) {
const { chain: s, isSynthetic: i } = F(n), a = w.get(n);
if (i)
return he(n, s);
const { tax: l, decimal: c, identifier: _ } = o || {
decimal: d[r],
return he(n, r);
const { tax: c, decimal: o, identifier: _ } = a || {
decimal: d[s],
identifier: n
};
return new g({ tax: l, decimal: c, identifier: _, value: V(s, c) });
return new g({ tax: c, decimal: o, identifier: _, value: V(r, o) });
}
static fromChainOrSignature(n, s = 0) {
const { decimal: r, identifier: i } = at(n);
return new g({ value: V(s, r), decimal: r, identifier: i });
static fromChainOrSignature(n, r = 0) {
const { decimal: s, identifier: i } = at(n);
return new g({ value: V(r, s), decimal: s, identifier: i });
}
static loadStaticAssets() {
return new Promise(
async (n, s) => {
async (n, r) => {
try {
const r = await import("@swapkit/tokens");
Object.values(r).forEach((i) => {
var o;
(o = i == null ? void 0 : i.tokens) == null || o.forEach(({ identifier: l, chain: c, ..._ }) => {
w.set(l.toUpperCase(), {
identifier: l,
decimal: "decimals" in _ ? _.decimals : d[c]
const s = await import("@swapkit/tokens");
Object.values(s).forEach((i) => {
var a;
(a = i == null ? void 0 : i.tokens) == null || a.forEach(({ identifier: c, chain: o, ..._ }) => {
w.set(c.toUpperCase(), {
identifier: c,
decimal: "decimals" in _ ? _.decimals : d[o]
});
});
}), n({ ok: !0 });
} catch (r) {
console.error(r), s({
} catch (s) {
console.error(s), r({
ok: !1,
error: r,
error: s,
message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"

@@ -1125,15 +1098,15 @@ });

switch (e) {
case a.Bitcoin:
case a.Litecoin:
case a.BitcoinCash:
case l.Bitcoin:
case l.Litecoin:
case l.BitcoinCash:
return t.set(10001e-8);
case a.Dogecoin:
case l.Dogecoin:
return t.set(1.00000001);
case a.Avalanche:
case a.Ethereum:
case l.Avalanche:
case l.Ethereum:
return t.set(1e-8);
case a.THORChain:
case a.Maya:
case l.THORChain:
case l.Maya:
return t.set(0);
case a.Cosmos:
case l.Cosmos:
return t.set(1e-6);

@@ -1146,8 +1119,8 @@ default:

dt(e);
const n = w.get(e.toUpperCase()), s = (n == null ? void 0 : n.decimal) || await it(F(e));
return n || w.set(e.toUpperCase(), { identifier: e, decimal: s }), new g({ decimal: s, value: V(t, s), identifier: e });
const n = w.get(e.toUpperCase()), r = (n == null ? void 0 : n.decimal) || await it(F(e));
return n || w.set(e.toUpperCase(), { identifier: e, decimal: r }), new g({ decimal: r, value: V(t, r), identifier: e });
}
function he(e, t = 0) {
const [n, s] = e.split(".")[0].toUpperCase() === a.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
if (!n || !s)
const [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
if (!n || !r)
throw new Error("Invalid asset identifier");

@@ -1157,3 +1130,3 @@ return new g({

value: V(t, 8),
identifier: `${a.THORChain}.${n}/${s}`
identifier: `${l.THORChain}.${n}/${r}`
});

@@ -1165,13 +1138,13 @@ }

function F(e) {
const t = e.slice(0, 14).includes("/"), [n, s] = e.split(".")[0].toUpperCase() === a.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
if (t && (!n || !s))
const t = e.slice(0, 14).includes("/"), [n, r] = e.split(".")[0].toUpperCase() === l.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
if (t && (!n || !r))
throw new Error("Invalid asset identifier");
const r = e.includes(".") && !t ? e : `${a.THORChain}.${s}`, [i, ...o] = r.split("."), [l, c] = (t ? s : o.join(".")).split("-"), _ = t ? s : o.join(".");
const s = e.includes(".") && !t ? e : `${l.THORChain}.${r}`, [i, ...a] = s.split("."), [c, o] = (t ? r : a.join(".")).split("-"), _ = t ? r : a.join(".");
return {
address: c == null ? void 0 : c.toLowerCase(),
address: o == null ? void 0 : o.toLowerCase(),
chain: i,
isGasAsset: fe({ chain: i, symbol: _ }),
isSynthetic: t,
symbol: (t ? `${n}/` : "") + (c ? `${l}-${(c == null ? void 0 : c.toLowerCase()) ?? ""}` : _),
ticker: l
symbol: (t ? `${n}/` : "") + (o ? `${c}-${(o == null ? void 0 : o.toLowerCase()) ?? ""}` : _),
ticker: c
};

@@ -1243,5 +1216,5 @@ }

};
class Ne extends Error {
class Ce extends Error {
constructor(t, n) {
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, Ne.prototype);
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);
}

@@ -1267,3 +1240,3 @@ }

Et as SwapKitApi,
Ne as SwapKitError,
Ce as SwapKitError,
I as SwapKitNumber,

@@ -1280,5 +1253,5 @@ ze as TransactionType,

_t as getAsymmetricAssetShare,
Nt as getAsymmetricAssetWithdrawAmount,
Ct as getAsymmetricAssetWithdrawAmount,
ut as getAsymmetricRuneShare,
Ct as getAsymmetricRuneWithdrawAmount,
Nt as getAsymmetricRuneWithdrawAmount,
at as getCommonAssetInfo,

@@ -1285,0 +1258,0 @@ it as getDecimal,

@@ -5,3 +5,3 @@ {

"dependencies": {
"@swapkit/api": "1.0.0-rc.37"
"@swapkit/api": "1.0.0-rc.38"
},

@@ -14,3 +14,3 @@ "devDependencies": {

"@swapkit/tokens": "1.0.0-rc.34",
"@swapkit/types": "1.0.0-rc.36"
"@swapkit/types": "1.0.0-rc.37"
},

@@ -22,3 +22,3 @@ "eslintConfig": {

"@swapkit/tokens": "1.0.0-rc.34",
"@swapkit/types": "1.0.0-rc.36"
"@swapkit/types": "1.0.0-rc.37"
},

@@ -48,3 +48,3 @@ "exports": {

"types": "./dist/index.d.ts",
"version": "1.0.0-rc.68",
"version": "1.0.0-rc.69",
"scripts": {

@@ -51,0 +51,0 @@ "build": "vite build",

@@ -81,23 +81,9 @@ import { RequestClient } from '@swapkit/api';

switch (chain) {
case Chain.Bitcoin:
case Chain.BitcoinCash:
case Chain.Litecoin:
case Chain.Dogecoin:
case Chain.Binance:
case Chain.Ethereum:
case Chain.Avalanche:
case Chain.Polkadot:
case Chain.Chainflip:
return symbol === chain;
case Chain.Arbitrum:
case Chain.Optimism:
return 'ETH' === symbol;
return symbol === 'ETH';
case Chain.Maya:
return symbol === 'CACAO';
case Chain.Kujira:
return symbol === 'KUJI';
case Chain.Cosmos:

@@ -111,2 +97,5 @@ return symbol === 'ATOM';

return symbol === 'RUNE';
default:
return symbol === chain;
}

@@ -138,15 +127,3 @@ };

case Chain.Kujira:
case Chain.Arbitrum:
case Chain.Optimism:
case Chain.BitcoinCash:
case Chain.Litecoin:
case Chain.Dogecoin:
case Chain.Binance:
case Chain.Avalanche:
case Chain.Chainflip:
case Chain.Polygon:
case Chain.Polkadot:
case Chain.Bitcoin:
case Chain.Ethereum:
default:
return { identifier: `${assetString}.${assetString}`, decimal: BaseDecimal[assetString] };

@@ -160,12 +137,2 @@ }

switch (chain) {
case Chain.Bitcoin:
case Chain.BitcoinCash:
case Chain.Dogecoin:
case Chain.Litecoin:
case Chain.Maya:
case Chain.THORChain:
case Chain.Polkadot:
case Chain.Chainflip:
return 'Native';
case Chain.Cosmos:

@@ -190,2 +157,5 @@ return symbol === 'ATOM' ? 'Native' : Chain.Cosmos;

return [Chain.Ethereum, Chain.Optimism].includes(symbol as Chain) ? 'Native' : 'OPTIMISM';
default:
return 'Native';
}

@@ -224,10 +194,8 @@ };

) =>
tokens.filter((token) => {
const assetString = `${token.chain}.${token.symbol}`;
tokens.filter(({ chain, value, symbol }) => {
const assetString = `${chain}.${symbol}`;
return (
!potentialScamRegex.test(assetString) &&
evmAssetHasAddress(assetString) &&
token.value !== '0'
!potentialScamRegex.test(assetString) && evmAssetHasAddress(assetString) && value !== '0'
);
});

@@ -6,3 +6,3 @@ import { Chain } from '@swapkit/types';

export function validateIdentifier(identifier: string = '') {
export function validateIdentifier(identifier = '') {
const uppercasedIdentifier = identifier.toUpperCase();

@@ -9,0 +9,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc