New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@coinmasters/helpers

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coinmasters/helpers - npm Package Compare versions

Comparing version 11.0.20 to 11.0.21

1014

dist/index.es.js

@@ -1,17 +0,17 @@

var bt = Object.defineProperty;
var yt = (r, t, e) => t in r ? bt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
var _ = (r, t, e) => (yt(r, typeof t != "symbol" ? t + "" : t, e), e), wt = (r, t, e) => {
if (!t.has(r))
throw TypeError("Cannot " + e);
var be = Object.defineProperty;
var ye = (r, e, t) => e in r ? be(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var _ = (r, e, t) => (ye(r, typeof e != "symbol" ? e + "" : e, t), t), we = (r, e, t) => {
if (!e.has(r))
throw TypeError("Cannot " + t);
};
var S = (r, t, e) => {
if (t.has(r))
var S = (r, e, t) => {
if (e.has(r))
throw TypeError("Cannot add the same private member more than once");
t instanceof WeakSet ? t.add(r) : t.set(r, e);
e instanceof WeakSet ? e.add(r) : e.set(r, t);
};
var m = (r, t, e) => (wt(r, t, "access private method"), e);
import { FeeOption as L, BaseDecimal as d, Chain as i, EVMChainList as At, ChainToRPC as vt, MemoType as b } from "@coinmasters/types";
const Tt = "0x313ce567", at = async ({ chain: r, to: t }) => {
var m = (r, e, t) => (we(r, e, "access private method"), t);
import { FeeOption as L, BaseDecimal as d, Chain as a, EVMChainList as Ae, ChainToRPC as ve, MemoType as b } from "@coinmasters/types";
const Te = "0x313ce567", ae = async ({ chain: r, to: e }) => {
try {
const { result: e } = await te.post(vt[r], {
const { result: t } = await et.post(ve[r], {
headers: {

@@ -26,64 +26,64 @@ accept: "*/*",

method: "eth_call",
params: [{ to: t.toLowerCase(), data: Tt }, "latest"]
params: [{ to: e.toLowerCase(), data: Te }, "latest"]
})
});
return parseInt(BigInt(e).toString());
} catch (e) {
return console.error(e), d[r];
return parseInt(BigInt(t).toString());
} catch (t) {
return console.error(t), d[r];
}
}, $t = async (r) => {
if (r === i.Ethereum)
}, $e = async (r) => {
if (r === a.Ethereum)
return d.ETH;
const [, t] = r.split("-");
return t != null && t.startsWith("0x") ? at({ chain: i.Ethereum, to: t }) : d.ETH;
}, Rt = async (r) => {
const [, t] = r.split("-");
return t != null && t.startsWith("0x") ? at({ chain: i.Avalanche, to: t.toLowerCase() }) : d.AVAX;
}, St = async (r) => r === i.BinanceSmartChain ? d.BSC : d.BSC, Ct = async ({ chain: r, symbol: t }) => {
const [, e] = r.split("-");
return e != null && e.startsWith("0x") ? ae({ chain: a.Ethereum, to: e }) : d.ETH;
}, Re = async (r) => {
const [, e] = r.split("-");
return e != null && e.startsWith("0x") ? ae({ chain: a.Avalanche, to: e.toLowerCase() }) : d.AVAX;
}, Se = async (r) => r === a.BinanceSmartChain ? d.BSC : d.BSC, Ce = async ({ chain: r, symbol: e }) => {
switch (r) {
case i.Ethereum:
return $t(t);
case i.Avalanche:
return Rt(t);
case i.BinanceSmartChain:
return St(t);
case a.Ethereum:
return $e(e);
case a.Avalanche:
return Re(e);
case a.BinanceSmartChain:
return Se(e);
default:
return d[r];
}
}, ae = {
}, at = {
[L.Average]: 1.2,
[L.Fast]: 1.5,
[L.Fastest]: 2
}, ot = ({ chain: r, symbol: t }) => {
}, oe = ({ chain: r, symbol: e }) => {
switch (r) {
case i.Bitcoin:
case i.BitcoinCash:
case i.Dash:
case i.Digibyte:
case i.Zcash:
case i.Ripple:
case i.Litecoin:
case i.Dogecoin:
case i.Binance:
case i.Ethereum:
case i.Avalanche:
return t === r;
case i.Arbitrum:
case i.Optimism:
case i.Base:
return t === "ETH";
case i.Mayachain:
return t === "CACAO";
case i.Kujira:
return t === "KUJI";
case i.Cosmos:
return t === "ATOM";
case i.Polygon:
return t === "MATIC";
case i.BinanceSmartChain:
return t === "BNB";
case i.THORChain:
return t === "RUNE";
case a.Bitcoin:
case a.BitcoinCash:
case a.Dash:
case a.Digibyte:
case a.Zcash:
case a.Ripple:
case a.Litecoin:
case a.Dogecoin:
case a.Binance:
case a.Ethereum:
case a.Avalanche:
return e === r;
case a.Arbitrum:
case a.Optimism:
case a.Base:
return e === "ETH";
case a.Mayachain:
return e === "CACAO";
case a.Kujira:
return e === "KUJI";
case a.Cosmos:
return e === "ATOM";
case a.Polygon:
return e === "MATIC";
case a.BinanceSmartChain:
return e === "BNB";
case a.THORChain:
return e === "RUNE";
}
}, It = (r) => {
}, Ie = (r) => {
switch (r) {

@@ -94,181 +94,181 @@ case "ETH.THOR":

return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
case i.Cosmos:
case a.Cosmos:
return { identifier: "GAIA.ATOM", decimal: d[r] };
case i.THORChain:
case a.THORChain:
return { identifier: "THOR.RUNE", decimal: d[r] };
case i.BinanceSmartChain:
case a.BinanceSmartChain:
return { identifier: "BSC.BNB", decimal: d[r] };
case i.Mayachain:
case a.Mayachain:
return { identifier: "MAYA.CACAO", decimal: d.MAYA };
case "MAYA.MAYA":
return { identifier: "MAYA.MAYA", decimal: 4 };
case i.Arbitrum:
case a.Arbitrum:
return { identifier: "ARB.ETH", decimal: 18 };
case i.Base:
case a.Base:
return { identifier: "BASE.ETH", decimal: 18 };
case i.Optimism:
case a.Optimism:
return { identifier: "OP.ETH", decimal: 18 };
case i.Avalanche:
case a.Avalanche:
return { identifier: "AVAX.ETH", decimal: 18 };
case i.Ripple:
case i.Kujira:
case i.BitcoinCash:
case i.Zcash:
case i.Dash:
case i.Litecoin:
case i.Dogecoin:
case i.Binance:
case i.Polygon:
case i.Bitcoin:
case i.Ethereum:
case a.Ripple:
case a.Kujira:
case a.BitcoinCash:
case a.Zcash:
case a.Dash:
case a.Litecoin:
case a.Dogecoin:
case a.Binance:
case a.Polygon:
case a.Bitcoin:
case a.Ethereum:
return { identifier: `${r}.${r}`, decimal: d[r] };
}
}, Et = ({ chain: r, symbol: t }) => {
if (t.includes("/"))
}, Ee = ({ chain: r, symbol: e }) => {
if (e.includes("/"))
return "Synth";
switch (r) {
case i.Bitcoin:
case i.BitcoinCash:
case i.Dogecoin:
case i.Dash:
case i.Zcash:
case i.Litecoin:
case i.Mayachain:
case i.THORChain:
case a.Bitcoin:
case a.BitcoinCash:
case a.Dogecoin:
case a.Dash:
case a.Zcash:
case a.Litecoin:
case a.Mayachain:
case a.THORChain:
return "Native";
case i.Osmosis:
case a.Osmosis:
return "Native";
case i.Cosmos:
return t === "ATOM" ? "Native" : i.Cosmos;
case i.Kujira:
return t === i.Kujira ? "Native" : i.Kujira;
case i.Binance:
return t === i.Binance ? "Native" : "BEP2";
case i.BinanceSmartChain:
return t === i.Binance ? "Native" : "BEP20";
case i.Ethereum:
return t === i.Ethereum ? "Native" : "ERC20";
case i.Avalanche:
return t === i.Avalanche ? "Native" : i.Avalanche;
case i.Polygon:
return t === i.Polygon ? "Native" : "POLYGON";
case i.Base:
return t === i.Ethereum ? "Native" : "ERC20";
case i.Arbitrum:
return [i.Ethereum, i.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
case i.Optimism:
return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
case a.Cosmos:
return e === "ATOM" ? "Native" : a.Cosmos;
case a.Kujira:
return e === a.Kujira ? "Native" : a.Kujira;
case a.Binance:
return e === a.Binance ? "Native" : "BEP2";
case a.BinanceSmartChain:
return e === a.Binance ? "Native" : "BEP20";
case a.Ethereum:
return e === a.Ethereum ? "Native" : "ERC20";
case a.Avalanche:
return e === a.Avalanche ? "Native" : a.Avalanche;
case a.Polygon:
return e === a.Polygon ? "Native" : "POLYGON";
case a.Base:
return e === a.Ethereum ? "Native" : "ERC20";
case a.Arbitrum:
return [a.Ethereum, a.Arbitrum].includes(e) ? "Native" : "ARBITRUM";
case a.Optimism:
return [a.Ethereum, a.Optimism].includes(e) ? "Native" : "OPTIMISM";
}
}, oe = (r) => {
}, ot = (r) => {
var o;
const [t, ...e] = r.split("."), s = r.includes("/"), n = e.join("."), a = (o = n == null ? void 0 : n.split("-")) == null ? void 0 : o[0];
return { chain: t, symbol: n, ticker: a, synth: s };
}, Ot = new RegExp(
const [e, ...t] = r.split("."), s = r.includes("/"), n = t.join("."), i = (o = n == null ? void 0 : n.split("-")) == null ? void 0 : o[0];
return { chain: e, symbol: n, ticker: i, synth: s };
}, Oe = new RegExp(
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
"gmi"
), Bt = (r) => {
const [t, e] = r.split(".");
if (!At.includes(t))
), Be = (r) => {
const [e, t] = r.split(".");
if (!Ae.includes(e))
return !0;
const [, s] = e.split("-");
return ot({ chain: t, symbol: e }) || !!s;
}, ce = (r) => r.filter((t) => {
const e = `${t.chain}.${t.symbol}`;
return !Ot.test(e) && Bt(e) && t.value !== "0";
}), Mt = ({
const [, s] = t.split("-");
return oe({ chain: e, symbol: t }) || !!s;
}, ct = (r) => r.filter((e) => {
const t = `${e.chain}.${e.symbol}`;
return !Oe.test(t) && Be(t) && e.value !== "0";
}), Me = ({
liquidityUnits: r,
poolUnits: t,
runeDepth: e
poolUnits: e,
runeDepth: t
}) => {
const s = p(r), n = p(t), a = p(e), o = s.mul(a), c = n.mul(n).mul(2), u = n.mul(s).mul(2), h = s.mul(s), l = n.mul(n).mul(n);
const s = p(r), n = p(e), i = p(t), o = s.mul(i), c = n.mul(n).mul(2), u = n.mul(s).mul(2), h = s.mul(s), l = n.mul(n).mul(n);
return o.mul(c.sub(u).add(h)).div(l);
}, kt = ({
}, ke = ({
liquidityUnits: r,
poolUnits: t,
assetDepth: e
poolUnits: e,
assetDepth: t
}) => {
const s = p(r), n = p(t), a = p(e), o = s.mul(a), c = n.mul(n).mul(2), u = n.mul(s).mul(2), h = s.mul(s), l = o.mul(c.sub(u).add(h)), f = n.mul(n).mul(n);
const s = p(r), n = p(e), i = p(t), o = s.mul(i), c = n.mul(n).mul(2), u = n.mul(s).mul(2), h = s.mul(s), l = o.mul(c.sub(u).add(h)), f = n.mul(n).mul(n);
return l.div(f);
}, ue = ({
}, ut = ({
percent: r,
runeDepth: t,
liquidityUnits: e,
runeDepth: e,
liquidityUnits: t,
poolUnits: s
}) => Mt({ runeDepth: t, liquidityUnits: e, poolUnits: s }).mul(r), le = ({
}) => Me({ runeDepth: e, liquidityUnits: t, poolUnits: s }).mul(r), lt = ({
percent: r,
assetDepth: t,
liquidityUnits: e,
assetDepth: e,
liquidityUnits: t,
poolUnits: s
}) => kt({ assetDepth: t, liquidityUnits: e, poolUnits: s }).mul(r), p = (r) => y.fromBigInt(BigInt(r), d.THOR), xt = ({
}) => ke({ assetDepth: e, liquidityUnits: t, poolUnits: s }).mul(r), p = (r) => y.fromBigInt(BigInt(r), d.THOR), xe = ({
liquidityUnits: r,
poolUnits: t,
runeDepth: e,
poolUnits: e,
runeDepth: t,
assetDepth: s
}) => ({
assetAmount: p(s).mul(r).div(t),
runeAmount: p(e).mul(r).div(t)
}), he = ({
assetAmount: p(s).mul(r).div(e),
runeAmount: p(t).mul(r).div(e)
}), ht = ({
liquidityUnits: r,
poolUnits: t,
runeDepth: e,
poolUnits: e,
runeDepth: t,
assetDepth: s,
percent: n
}) => Object.fromEntries(
Object.entries(xt({ liquidityUnits: r, poolUnits: t, runeDepth: e, assetDepth: s })).map(
([a, o]) => [a, o.mul(n)]
Object.entries(xe({ liquidityUnits: r, poolUnits: e, runeDepth: t, assetDepth: s })).map(
([i, o]) => [i, o.mul(n)]
)
), de = ({
), dt = ({
runeDepth: r,
poolUnits: t,
assetDepth: e,
poolUnits: e,
assetDepth: t,
liquidityUnits: s,
runeAmount: n,
assetAmount: a
assetAmount: i
}) => {
const o = new y({ value: r, decimal: 8 }), c = new y({ value: e, decimal: 8 }), u = new y({ value: t, decimal: 8 }), h = new y({ value: n, decimal: 8 }), l = new y({ value: a, decimal: 8 }), f = h.mul(c), g = l.mul(o), A = h.mul(l), R = o.mul(c), ft = u.mul(f.add(g.add(A.mul(2)))), _t = f.add(g.add(R.mul(2))), X = ft.div(_t), D = p(s).add(X);
const o = new y({ value: r, decimal: 8 }), c = new y({ value: t, decimal: 8 }), u = new y({ value: e, decimal: 8 }), h = new y({ value: n, decimal: 8 }), l = new y({ value: i, decimal: 8 }), f = h.mul(c), g = l.mul(o), A = h.mul(l), R = o.mul(c), fe = u.mul(f.add(g.add(A.mul(2)))), _e = f.add(g.add(R.mul(2))), X = fe.div(_e), D = p(s).add(X);
if (X.getBaseValue("number") === 0)
return D.div(u).getBaseValue("number");
const gt = u.add(D);
return D.div(gt).getBaseValue("number");
}, me = ({
const ge = u.add(D);
return D.div(ge).getBaseValue("number");
}, mt = ({
runeAmount: r,
assetAmount: t,
runeDepth: e,
assetAmount: e,
runeDepth: t,
assetDepth: s
}) => {
if (r === "0" || t === "0" || e === "0" || s === "0")
if (r === "0" || e === "0" || t === "0" || s === "0")
return 0;
const n = p(e), a = p(s), o = p(t), c = p(r), u = o.mul(n).sub(a.mul(c)), h = a.mul(c).add(n.mul(a));
const n = p(t), i = p(s), o = p(e), c = p(r), u = o.mul(n).sub(i.mul(c)), h = i.mul(c).add(n.mul(i));
return Math.abs(u.div(h).getBaseValue("number"));
}, qt = ({
}, qe = ({
symbol: r,
ticker: t,
chain: e
}) => e === "ETH" && t !== "ETH" ? `${t}-${r.slice(-3)}` : r, pe = (r, t) => {
ticker: e,
chain: t
}) => t === "ETH" && e !== "ETH" ? `${e}-${r.slice(-3)}` : r, pt = (r, e) => {
switch (r) {
case b.LEAVE:
case b.BOND: {
const { address: e } = t;
return `${r}:${e}`;
const { address: t } = e;
return `${r}:${t}`;
}
case b.UNBOND: {
const { address: e, unbondAmount: s } = t;
return `${r}:${e}:${s * 10 ** 8}`;
const { address: t, unbondAmount: s } = e;
return `${r}:${t}:${s * 10 ** 8}`;
}
case b.THORNAME_REGISTER: {
const { name: e, chain: s, address: n, owner: a } = t;
return `${r}:${e}:${s}:${n}${a ? `:${a}` : ""}`;
const { name: t, chain: s, address: n, owner: i } = e;
return `${r}:${t}:${s}:${n}${i ? `:${i}` : ""}`;
}
case b.DEPOSIT: {
const { chain: e, symbol: s, address: n, singleSide: a } = t;
return a ? `${r}:${e}/${s}::t:0` : `${r}:${e}.${s}:${n || ""}:t:0`;
const { chain: t, symbol: s, address: n, singleSide: i } = e;
return i ? `${r}:${t}/${s}::t:0` : `${r}:${t}.${s}:${n || ""}:t:0`;
}
case b.WITHDRAW: {
const { chain: e, ticker: s, symbol: n, basisPoints: a, targetAssetString: o, singleSide: c } = t, u = !c && o ? `:${o}` : "", h = qt({ chain: e, symbol: n, ticker: s });
return `${r}:${e}${c ? "/" : "."}${h}:${a}${u}`;
const { chain: t, ticker: s, symbol: n, basisPoints: i, targetAssetString: o, singleSide: c } = e, u = !c && o ? `:${o}` : "", h = qe({ chain: t, symbol: n, ticker: s });
return `${r}:${t}${c ? "/" : "."}${h}:${i}${u}`;
}
case b.OPEN_LOAN:
case b.CLOSE_LOAN: {
const { asset: e, address: s } = t;
return `${r}:${e}:${s}`;
const { asset: t, address: s } = e;
return `${r}:${t}:${s}`;
}

@@ -278,15 +278,15 @@ default:

}
}, fe = (r) => {
}, ft = (r) => {
if (r < 0)
throw new Error("Invalid number of year");
return 10 + r;
}, _e = (r) => {
}, _t = (r) => {
if (r.length > 30)
return !1;
const t = /^[a-zA-Z0-9+_-]+$/g;
return !!r.match(t);
}, ge = ([r, t, e, s, n]) => `${r}'/${t}'/${e}'/${s}${typeof n != "number" ? "" : `/${n}`}`;
const e = /^[a-zA-Z0-9+_-]+$/g;
return !!r.match(e);
}, gt = ([r, e, t, s, n]) => `${r}'/${e}'/${t}'/${s}${typeof n != "number" ? "" : `/${n}`}`;
class Q extends Error {
constructor(t, e, s) {
const n = t.status || t.status === 0 ? t.status : "", a = t.statusText || "", o = `${n} ${a}`.trim(), c = o ? `status code ${o}` : "an unknown error";
constructor(e, t, s) {
const n = e.status || e.status === 0 ? e.status : "", i = e.statusText || "", o = `${n} ${i}`.trim(), c = o ? `status code ${o}` : "an unknown error";
super(`Request failed with ${c}`), Object.defineProperty(this, "response", {

@@ -307,7 +307,7 @@ enumerable: !0,

value: void 0
}), this.name = "HTTPError", this.response = t, this.request = e, this.options = s;
}), this.name = "HTTPError", this.response = e, this.request = t, this.options = s;
}
}
class ct extends Error {
constructor(t) {
class ce extends Error {
constructor(e) {
super("Request timed out"), Object.defineProperty(this, "request", {

@@ -318,30 +318,30 @@ enumerable: !0,

value: void 0
}), this.name = "TimeoutError", this.request = t;
}), this.name = "TimeoutError", this.request = e;
}
}
const V = (r) => r !== null && typeof r == "object", x = (...r) => {
for (const t of r)
if ((!V(t) || Array.isArray(t)) && t !== void 0)
for (const e of r)
if ((!V(e) || Array.isArray(e)) && e !== void 0)
throw new TypeError("The `options` argument must be an object");
return K({}, ...r);
}, ut = (r = {}, t = {}) => {
const e = new globalThis.Headers(r), s = t instanceof globalThis.Headers, n = new globalThis.Headers(t);
for (const [a, o] of n.entries())
s && o === "undefined" || o === void 0 ? e.delete(a) : e.set(a, o);
return e;
}, ue = (r = {}, e = {}) => {
const t = new globalThis.Headers(r), s = e instanceof globalThis.Headers, n = new globalThis.Headers(e);
for (const [i, o] of n.entries())
s && o === "undefined" || o === void 0 ? t.delete(i) : t.set(i, o);
return t;
}, K = (...r) => {
let t = {}, e = {};
let e = {}, t = {};
for (const s of r)
if (Array.isArray(s))
Array.isArray(t) || (t = []), t = [...t, ...s];
Array.isArray(e) || (e = []), e = [...e, ...s];
else if (V(s)) {
for (let [n, a] of Object.entries(s))
V(a) && n in t && (a = K(t[n], a)), t = { ...t, [n]: a };
V(s.headers) && (e = ut(e, s.headers), t.headers = e);
for (let [n, i] of Object.entries(s))
V(i) && n in e && (i = K(e[n], i)), e = { ...e, [n]: i };
V(s.headers) && (t = ue(t, s.headers), e.headers = t);
}
return t;
}, Vt = (() => {
let r = !1, t = !1;
const e = typeof globalThis.ReadableStream == "function", s = typeof globalThis.Request == "function";
return e && s && (t = new globalThis.Request("https://empty.invalid", {
return e;
}, Ve = (() => {
let r = !1, e = !1;
const t = typeof globalThis.ReadableStream == "function", s = typeof globalThis.Request == "function";
return t && s && (e = new globalThis.Request("https://empty.invalid", {
body: new globalThis.ReadableStream(),

@@ -353,4 +353,4 @@ method: "POST",

}
}).headers.has("Content-Type")), r && !t;
})(), Pt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", Ht = typeof globalThis.FormData == "function", lt = ["get", "post", "put", "patch", "head", "delete"], jt = {
}).headers.has("Content-Type")), r && !e;
})(), Pe = typeof globalThis.AbortController == "function", Ne = typeof globalThis.ReadableStream == "function", He = typeof globalThis.FormData == "function", le = ["get", "post", "put", "patch", "head", "delete"], je = {
json: "application/json",

@@ -361,3 +361,3 @@ text: "text/*",

blob: "*/*"
}, U = 2147483647, ht = Symbol("stop"), Dt = {
}, U = 2147483647, he = Symbol("stop"), De = {
json: !0,

@@ -373,3 +373,3 @@ parseJson: !0,

fetch: !0
}, Lt = {
}, Le = {
method: !0,

@@ -390,14 +390,14 @@ headers: !0,

duplex: !0
}, Ut = (r) => lt.includes(r) ? r.toUpperCase() : r, Ft = ["get", "put", "head", "delete", "options", "trace"], Gt = [408, 413, 429, 500, 502, 503, 504], dt = [413, 429, 503], tt = {
}, Ue = (r) => le.includes(r) ? r.toUpperCase() : r, Fe = ["get", "put", "head", "delete", "options", "trace"], Ge = [408, 413, 429, 500, 502, 503, 504], de = [413, 429, 503], ee = {
limit: 2,
methods: Ft,
statusCodes: Gt,
afterStatusCodes: dt,
methods: Fe,
statusCodes: Ge,
afterStatusCodes: de,
maxRetryAfter: Number.POSITIVE_INFINITY,
backoffLimit: Number.POSITIVE_INFINITY,
delay: (r) => 0.3 * 2 ** (r - 1) * 1e3
}, Wt = (r = {}) => {
}, We = (r = {}) => {
if (typeof r == "number")
return {
...tt,
...ee,
limit: r

@@ -410,13 +410,13 @@ };

return {
...tt,
...ee,
...r,
afterStatusCodes: dt
afterStatusCodes: de
};
};
async function Yt(r, t, e, s) {
return new Promise((n, a) => {
async function Ye(r, e, t, s) {
return new Promise((n, i) => {
const o = setTimeout(() => {
e && e.abort(), a(new ct(r));
t && t.abort(), i(new ce(r));
}, s.timeout);
s.fetch(r, t).then(n).catch(a).then(() => {
s.fetch(r, e).then(n).catch(i).then(() => {
clearTimeout(o);

@@ -426,22 +426,22 @@ });

}
async function zt(r, { signal: t }) {
return new Promise((e, s) => {
t && (t.throwIfAborted(), t.addEventListener("abort", n, { once: !0 }));
async function ze(r, { signal: e }) {
return new Promise((t, s) => {
e && (e.throwIfAborted(), e.addEventListener("abort", n, { once: !0 }));
function n() {
clearTimeout(a), s(t.reason);
clearTimeout(i), s(e.reason);
}
const a = setTimeout(() => {
t == null || t.removeEventListener("abort", n), e();
const i = setTimeout(() => {
e == null || e.removeEventListener("abort", n), t();
}, r);
});
}
const Jt = (r, t) => {
const e = {};
for (const s in t)
!(s in Lt) && !(s in Dt) && !(s in r) && (e[s] = t[s]);
return e;
const Je = (r, e) => {
const t = {};
for (const s in e)
!(s in Le) && !(s in De) && !(s in r) && (t[s] = e[s]);
return t;
};
class N {
static create(t, e) {
const s = new N(t, e), n = async () => {
static create(e, t) {
const s = new N(e, t), n = async () => {
if (typeof s._options.timeout == "number" && s._options.timeout > U)

@@ -464,3 +464,3 @@ throw new RangeError(`The \`timeout\` option cannot be greater than ${U}`);

throw new TypeError("The `onDownloadProgress` option must be a function");
if (!Nt)
if (!Ne)
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");

@@ -471,3 +471,3 @@ return s._stream(c.clone(), s._options.onDownloadProgress);

}, o = s._options.retry.methods.includes(s.request.method.toLowerCase()) ? s._retry(n) : n();
for (const [c, u] of Object.entries(jt))
for (const [c, u] of Object.entries(je))
o[c] = async () => {

@@ -479,4 +479,4 @@ s.request.headers.set("accept", s.request.headers.get("accept") || u);

return "";
if (e.parseJson)
return e.parseJson(await l.text());
if (t.parseJson)
return t.parseJson(await l.text());
}

@@ -488,3 +488,3 @@ return l[c]();

// eslint-disable-next-line complexity
constructor(t, e = {}) {
constructor(e, t = {}) {
if (Object.defineProperty(this, "request", {

@@ -515,7 +515,7 @@ enumerable: !0,

value: void 0
}), this._input = t, this._options = {
}), this._input = e, this._options = {
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
credentials: this._input.credentials || "same-origin",
...e,
headers: ut(this._input.headers, e.headers),
...t,
headers: ue(this._input.headers, t.headers),
hooks: K({

@@ -526,10 +526,10 @@ beforeRequest: [],

afterResponse: []
}, e.hooks),
method: Ut(e.method ?? this._input.method),
}, t.hooks),
method: Ue(t.method ?? this._input.method),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
prefixUrl: String(e.prefixUrl || ""),
retry: Wt(e.retry),
throwHttpErrors: e.throwHttpErrors !== !1,
timeout: e.timeout ?? 1e4,
fetch: e.fetch ?? globalThis.fetch.bind(globalThis)
prefixUrl: String(t.prefixUrl || ""),
retry: We(t.retry),
throwHttpErrors: t.throwHttpErrors !== !1,
timeout: t.timeout ?? 1e4,
fetch: t.fetch ?? globalThis.fetch.bind(globalThis)
}, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))

@@ -542,3 +542,3 @@ throw new TypeError("`input` must be a string, URL, or Request");

}
if (Pt) {
if (Pe) {
if (this.abortController = new globalThis.AbortController(), this._options.signal) {

@@ -552,36 +552,36 @@ const s = this._options.signal;

}
if (Vt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
const n = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), a = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, n);
(Ht && 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(a, { ...this.request }), this._options);
if (Ve && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
const n = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, n);
(He && 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(i, { ...this.request }), this._options);
}
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 }));
}
_calculateRetryDelay(t) {
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof ct)) {
if (t instanceof Q) {
if (!this._options.retry.statusCodes.includes(t.response.status))
_calculateRetryDelay(e) {
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(e instanceof ce)) {
if (e instanceof Q) {
if (!this._options.retry.statusCodes.includes(e.response.status))
return 0;
const s = t.response.headers.get("Retry-After");
if (s && this._options.retry.afterStatusCodes.includes(t.response.status)) {
const s = e.response.headers.get("Retry-After");
if (s && this._options.retry.afterStatusCodes.includes(e.response.status)) {
let n = Number(s);
return Number.isNaN(n) ? n = Date.parse(s) - Date.now() : n *= 1e3, this._options.retry.maxRetryAfter !== void 0 && n > this._options.retry.maxRetryAfter ? 0 : n;
}
if (t.response.status === 413)
if (e.response.status === 413)
return 0;
}
const e = this._options.retry.delay(this._retryCount);
return Math.min(this._options.retry.backoffLimit, e);
const t = this._options.retry.delay(this._retryCount);
return Math.min(this._options.retry.backoffLimit, t);
}
return 0;
}
_decorateResponse(t) {
return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
_decorateResponse(e) {
return this._options.parseJson && (e.json = async () => this._options.parseJson(await e.text())), e;
}
async _retry(t) {
async _retry(e) {
try {
return await t();
} catch (e) {
const s = Math.min(this._calculateRetryDelay(e), U);
return await e();
} catch (t) {
const s = Math.min(this._calculateRetryDelay(t), U);
if (s !== 0 && this._retryCount > 0) {
await zt(s, { signal: this._options.signal });
await ze(s, { signal: this._options.signal });
for (const n of this._options.hooks.beforeRetry)

@@ -591,14 +591,14 @@ if (await n({

options: this._options,
error: e,
error: t,
retryCount: this._retryCount
}) === ht)
}) === he)
return;
return this._retry(t);
return this._retry(e);
}
throw e;
throw t;
}
}
async _fetch() {
for (const e of this._options.hooks.beforeRequest) {
const s = await e(this.request, this._options);
for (const t of this._options.hooks.beforeRequest) {
const s = await t(this.request, this._options);
if (s instanceof Request) {

@@ -611,29 +611,29 @@ this.request = s;

}
const t = Jt(this.request, this._options);
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Yt(this.request.clone(), t, this.abortController, this._options);
const e = Je(this.request, this._options);
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), e) : Ye(this.request.clone(), e, this.abortController, this._options);
}
/* istanbul ignore next */
_stream(t, e) {
const s = Number(t.headers.get("content-length")) || 0;
_stream(e, t) {
const s = Number(e.headers.get("content-length")) || 0;
let n = 0;
return t.status === 204 ? (e && e({ percent: 1, totalBytes: s, transferredBytes: n }, new Uint8Array()), new globalThis.Response(null, {
status: t.status,
statusText: t.statusText,
headers: t.headers
return e.status === 204 ? (t && t({ percent: 1, totalBytes: s, transferredBytes: n }, new Uint8Array()), new globalThis.Response(null, {
status: e.status,
statusText: e.statusText,
headers: e.headers
})) : new globalThis.Response(new globalThis.ReadableStream({
async start(a) {
const o = t.body.getReader();
e && e({ percent: 0, transferredBytes: 0, totalBytes: s }, new Uint8Array());
async start(i) {
const o = e.body.getReader();
t && t({ percent: 0, transferredBytes: 0, totalBytes: s }, new Uint8Array());
async function c() {
const { done: u, value: h } = await o.read();
if (u) {
a.close();
i.close();
return;
}
if (e) {
if (t) {
n += h.byteLength;
const l = s === 0 ? 0 : n / s;
e({ percent: l, transferredBytes: n, totalBytes: s }, h);
t({ percent: l, transferredBytes: n, totalBytes: s }, h);
}
a.enqueue(h), await c();
i.enqueue(h), await c();
}

@@ -643,5 +643,5 @@ await c();

}), {
status: t.status,
statusText: t.statusText,
headers: t.headers
status: e.status,
statusText: e.statusText,
headers: e.headers
});

@@ -652,11 +652,11 @@ }

const F = (r) => {
const t = (e, s) => N.create(e, x(r, s));
for (const e of lt)
t[e] = (s, n) => N.create(s, x(r, n, { method: e }));
return t.create = (e) => F(x(e)), t.extend = (e) => F(x(r, e)), t.stop = ht, t;
}, Kt = F(), Zt = Kt, Xt = typeof window < "u" ? {} : {
const e = (t, s) => N.create(t, x(r, s));
for (const t of le)
e[t] = (s, n) => N.create(s, x(r, n, { method: t }));
return e.create = (t) => F(x(t)), e.extend = (t) => F(x(r, t)), e.stop = he, e;
}, Ke = F(), Ze = Ke, Xe = typeof window < "u" ? {} : {
Referrer: "https://sk.thorswap.net",
Referer: "https://sk.thorswap.net"
}, Qt = {
headers: Xt,
}, Qe = {
headers: Xe,
timeout: 3e4,

@@ -672,12 +672,12 @@ // Example: 10000 milliseconds = 10 seconds

}
}, et = Zt.create(Qt), te = {
get: async (r, t) => et.get(r, t).json(),
post: async (r, t) => et.post(r, t).json()
}, te = Ze.create(Qe), et = {
get: async (r, e) => te.get(r, e).json(),
post: async (r, e) => te.post(r, e).json()
// Implement other methods (put, delete, patch, head) as needed
}, st = Object.values(i), ee = (r = "") => {
const t = r.toUpperCase(), [e] = t.split(".");
if (st.includes(e))
}, se = Object.values(a), tt = (r = "") => {
const e = r.toUpperCase(), [t] = e.split(".");
if (se.includes(t))
return !0;
const [s] = t.split("/");
if (st.includes(s))
const [s] = e.split("/");
if (se.includes(s))
return !0;

@@ -690,12 +690,12 @@ throw new Error(

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

@@ -705,5 +705,5 @@ ""

}
var $, E, w, C, j, mt, M, G, k, W;
var $, E, w, C, j, me, M, G, k, W;
const Z = class Z {
constructor(t) {
constructor(e) {
S(this, $);

@@ -717,62 +717,62 @@ S(this, w);

_(this, "decimal");
const e = Y(t), s = typeof t == "object";
this.decimal = s ? t.decimal : void 0, this.decimalMultiplier = s && "decimalMultiplier" in t ? t.decimalMultiplier : v(Math.max(rt(q(e)), this.decimal || 0)), m(this, j, mt).call(this, e);
const t = Y(e), s = typeof e == "object";
this.decimal = s ? e.decimal : void 0, this.decimalMultiplier = s && "decimalMultiplier" in e ? e.decimalMultiplier : v(Math.max(re(q(t)), this.decimal || 0)), m(this, j, me).call(this, t);
}
static fromBigInt(t, e) {
static fromBigInt(e, t) {
return new Z({
decimal: e,
value: H({ value: t, bigIntDecimal: e, decimal: e })
decimal: t,
value: H({ value: e, bigIntDecimal: t, decimal: t })
});
}
static shiftDecimals({
value: t,
from: e,
value: e,
from: t,
to: s
}) {
return this.fromBigInt(
t.getBaseValue("bigint") * v(s) / v(e),
e.getBaseValue("bigint") * v(s) / v(t),
s
);
}
set(t) {
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
set(e) {
return new this.constructor({ decimal: this.decimal, value: e, identifier: this.toString() });
}
add(...t) {
return m(this, $, E).call(this, "add", ...t);
add(...e) {
return m(this, $, E).call(this, "add", ...e);
}
sub(...t) {
return m(this, $, E).call(this, "sub", ...t);
sub(...e) {
return m(this, $, E).call(this, "sub", ...e);
}
mul(...t) {
return m(this, $, E).call(this, "mul", ...t);
mul(...e) {
return m(this, $, E).call(this, "mul", ...e);
}
div(...t) {
return m(this, $, E).call(this, "div", ...t);
div(...e) {
return m(this, $, E).call(this, "div", ...e);
}
gt(t) {
return m(this, w, C).call(this, "gt", t);
gt(e) {
return m(this, w, C).call(this, "gt", e);
}
gte(t) {
return m(this, w, C).call(this, "gte", t);
gte(e) {
return m(this, w, C).call(this, "gte", e);
}
lt(t) {
return m(this, w, C).call(this, "lt", t);
lt(e) {
return m(this, w, C).call(this, "lt", e);
}
lte(t) {
return m(this, w, C).call(this, "lte", t);
lte(e) {
return m(this, w, C).call(this, "lte", e);
}
eqValue(t) {
return m(this, w, C).call(this, "eqValue", t);
eqValue(e) {
return m(this, w, C).call(this, "eqValue", e);
}
// @ts-expect-error False positive
getValue(t) {
const e = this.formatBigIntToSafeValue(
getValue(e) {
const t = this.formatBigIntToSafeValue(
this.bigIntValue,
this.decimal || I(this.decimalMultiplier)
);
switch (t) {
switch (e) {
case "number":
return Number(e);
return Number(t);
case "string":
return e;
return t;
case "bigint":

@@ -783,5 +783,5 @@ return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;

// @ts-expect-error
getBaseValue(t) {
const e = this.decimalMultiplier / v(this.decimal || d.THOR), s = this.bigIntValue / e;
switch (t) {
getBaseValue(e) {
const t = this.decimalMultiplier / v(this.decimal || d.THOR), s = this.bigIntValue / t;
switch (e) {
case "number":

@@ -795,58 +795,58 @@ return Number(s);

}
getBigIntValue(t, e) {
if (!e && typeof t == "object")
return t.bigIntValue;
const s = Y(t), n = q(s);
return n === "0" || n === "undefined" ? 0n : m(this, k, W).call(this, n, e);
getBigIntValue(e, t) {
if (!t && typeof e == "object")
return e.bigIntValue;
const s = Y(e), n = q(s);
return n === "0" || n === "undefined" ? 0n : m(this, k, W).call(this, n, t);
}
toSignificant(t = 6) {
const [e, s] = this.getValue("string").split("."), n = e || "", a = s || "";
if ((parseInt(n) ? n.length + a.length : a.length) <= t)
toSignificant(e = 6) {
const [t, s] = this.getValue("string").split("."), n = t || "", i = s || "";
if ((parseInt(n) ? n.length + i.length : i.length) <= e)
return this.getValue("string");
if (n.length >= t)
return n.slice(0, t).padEnd(n.length, "0");
if (n.length >= e)
return n.slice(0, e).padEnd(n.length, "0");
if (parseInt(n))
return `${n}.${a.slice(0, t - n.length)}`.padEnd(
t - n.length,
return `${n}.${i.slice(0, e - n.length)}`.padEnd(
e - n.length,
"0"
);
const c = parseInt(a), u = `${c}`.slice(0, t);
const c = parseInt(i), u = `${c}`.slice(0, e);
return `0.${u.padStart(
a.length - `${c}`.length + u.length,
i.length - `${c}`.length + u.length,
"0"
)}`;
}
toFixed(t = 6) {
const [e, s] = this.getValue("string").split("."), n = e || "", a = s || "";
toFixed(e = 6) {
const [t, s] = this.getValue("string").split("."), n = t || "", i = s || "";
if (parseInt(n))
return `${n}.${a.slice(0, t)}`.padEnd(t, "0");
const o = parseInt(a), c = `${o}`.slice(0, t);
return `${n}.${i.slice(0, e)}`.padEnd(e, "0");
const o = parseInt(i), c = `${o}`.slice(0, e);
return `0.${c.padStart(
a.length - `${o}`.length + c.length,
i.length - `${o}`.length + c.length,
"0"
)}`;
}
toAbbreviation(t = 2) {
const e = this.getValue("number"), s = ["", "K", "M", "B", "T", "Q", "Qi", "S"], n = Math.floor(Math.log10(Math.abs(e)) / 3), a = s[n];
if (!a)
toAbbreviation(e = 2) {
const t = this.getValue("number"), s = ["", "K", "M", "B", "T", "Q", "Qi", "S"], n = Math.floor(Math.log10(Math.abs(t)) / 3), i = s[n];
if (!i)
return this.getValue("string");
const o = 10 ** (n * 3);
return `${(e / o).toFixed(t)}${a}`;
return `${(t / o).toFixed(e)}${i}`;
}
toCurrency(t = "$", {
currencyPosition: e = "start",
toCurrency(e = "$", {
currencyPosition: t = "start",
decimal: s = 2,
decimalSeparator: n = ".",
thousandSeparator: a = ","
thousandSeparator: i = ","
} = {}) {
const o = this.getValue("number"), [c, u = ""] = o.toFixed(6).split("."), h = c.replace(/\B(?=(\d{3})+(?!\d))/g, a), l = !c && !u ? "0.00" : c === "0" ? `${parseFloat(`0.${u}`)}`.replace(".", n) : `${h}${parseInt(u) ? `${n}${u.slice(0, s)}` : ""}`;
return `${e === "start" ? t : ""}${l}${e === "end" ? t : ""}`;
const o = this.getValue("number"), [c, u = ""] = o.toFixed(6).split("."), h = c.replace(/\B(?=(\d{3})+(?!\d))/g, i), l = !c && !u ? "0.00" : c === "0" ? `${parseFloat(`0.${u}`)}`.replace(".", n) : `${h}${parseInt(u) ? `${n}${u.slice(0, s)}` : ""}`;
return `${t === "start" ? e : ""}${l}${t === "end" ? e : ""}`;
}
formatBigIntToSafeValue(t, e) {
const s = e || this.decimal || O, n = Math.max(
formatBigIntToSafeValue(e, t) {
const s = t || this.decimal || O, n = Math.max(
s,
I(this.decimalMultiplier)
), a = t < 0n, o = t.toString().substring(a ? 1 : 0), c = n - (o.length - 1), u = c > 0 ? "0".repeat(c) + o : o, h = u.length - n;
), i = e < 0n, o = e.toString().substring(i ? 1 : 0), c = n - (o.length - 1), u = c > 0 ? "0".repeat(c) + o : o, h = u.length - n;
let l = u.slice(-n);
return parseInt(l[s]) >= 5 ? l = `${l.substring(0, s - 1)}${(parseInt(l[s - 1]) + 1).toString()}` : l = l.substring(0, s), `${a ? "-" : ""}${u.slice(
return parseInt(l[s]) >= 5 ? l = `${l.substring(0, s - 1)}${(parseInt(l[s - 1]) + 1).toString()}` : l = l.substring(0, s), `${i ? "-" : ""}${u.slice(
0,

@@ -857,7 +857,7 @@ h

};
$ = new WeakSet(), E = function(t, ...e) {
const s = m(this, M, G).call(this, this, ...e), n = Math.max(s, I(this.decimalMultiplier)), a = v(n), o = e.reduce(
$ = new WeakSet(), E = function(e, ...t) {
const s = m(this, M, G).call(this, this, ...t), n = Math.max(s, I(this.decimalMultiplier)), i = v(n), o = t.reduce(
(u, h) => {
const l = this.getBigIntValue(h, n);
switch (t) {
switch (e) {
case "add":

@@ -868,7 +868,7 @@ return u + l;

case "mul":
return u * l / a;
return u * l / i;
case "div": {
if (l === 0n)
throw new RangeError("Division by zero");
return u * a / l;
return u * i / l;
}

@@ -880,3 +880,3 @@ default:

//normalize is to precision multiplier base
this.bigIntValue * a / this.decimalMultiplier
this.bigIntValue * i / this.decimalMultiplier
), c = H({

@@ -893,28 +893,28 @@ bigIntDecimal: n,

});
}, w = new WeakSet(), C = function(t, ...e) {
const s = m(this, M, G).call(this, this, ...e), n = this.getBigIntValue(e[0], s), a = this.getBigIntValue(this, s);
switch (t) {
}, w = new WeakSet(), C = function(e, ...t) {
const s = m(this, M, G).call(this, this, ...t), n = this.getBigIntValue(t[0], s), i = this.getBigIntValue(this, s);
switch (e) {
case "gt":
return a > n;
return i > n;
case "gte":
return a >= n;
return i >= n;
case "lt":
return a < n;
return i < n;
case "lte":
return a <= n;
return i <= n;
case "eqValue":
return a === n;
return i === n;
}
}, j = new WeakSet(), mt = function(t) {
const e = q(t) || "0";
this.bigIntValue = m(this, k, W).call(this, e);
}, M = new WeakSet(), G = function(...t) {
const e = t.map((s) => typeof s == "object" ? s.decimal || I(s.decimalMultiplier) : rt(q(s))).filter(Boolean);
return Math.max(...e, O);
}, k = new WeakSet(), W = function(t, e) {
const s = e ? v(e) : this.decimalMultiplier, n = I(s), [a = "", o = ""] = t.split(".");
return BigInt(`${a}${o.padEnd(n, "0")}`);
}, j = new WeakSet(), me = function(e) {
const t = q(e) || "0";
this.bigIntValue = m(this, k, W).call(this, t);
}, M = new WeakSet(), G = function(...e) {
const t = e.map((s) => typeof s == "object" ? s.decimal || I(s.decimalMultiplier) : re(q(s))).filter(Boolean);
return Math.max(...t, O);
}, k = new WeakSet(), W = function(e, t) {
const s = t ? v(t) : this.decimalMultiplier, n = I(s), [i = "", o = ""] = e.split(".");
return BigInt(`${i}${o.padEnd(n, "0")}`);
};
let B = Z;
const se = Intl.NumberFormat("fullwide", {
const st = Intl.NumberFormat("fullwide", {
useGrouping: !1,

@@ -924,9 +924,9 @@ maximumFractionDigits: 20

function q(r) {
const e = `${typeof r == "number" ? se.format(r) : Y(r)}`.replaceAll(",", ".").split(".");
return e.length > 1 ? `${e.slice(0, -1).join("")}.${e.at(-1)}` : e[0];
const t = `${typeof r == "number" ? st.format(r) : Y(r)}`.replaceAll(",", ".").split(".");
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
}
function rt(r) {
var e;
const t = ((e = r.split(".")[1]) == null ? void 0 : e.length) || 0;
return Math.max(t, O);
function re(r) {
var t;
const e = ((t = r.split(".")[1]) == null ? void 0 : t.length) || 0;
return Math.max(e, O);
}

@@ -936,19 +936,20 @@ function Y(r) {

}
const P = (r, t) => typeof r == "bigint" ? H({ value: r, bigIntDecimal: t, decimal: t }) : r;
const P = (r, e) => typeof r == "bigint" ? H({ value: r, bigIntDecimal: e, decimal: e }) : r;
let z;
const nt = (r) => {
const ne = (r) => {
if (!z)
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
return z.get(r.toUpperCase()) || { decimal: d.THOR, identifier: "" };
}, it = async (r, t = 0) => {
ee(r);
const e = await Ct(J(r)), s = P(t, e);
return new T({ decimal: e, value: s, identifier: r });
}, ie = async (r, e = 0) => {
tt(r);
const t = await Ce(J(r)), s = P(e, t);
return new T({ decimal: t, value: s, identifier: r });
};
class T extends B {
constructor(e) {
const s = "identifier" in e ? e.identifier : `${e.chain}.${e.symbol}`;
super(
e.value instanceof B ? e.value : { decimal: e.decimal, value: e.value }
);
constructor(t) {
const s = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`;
console.log("identifier: ", s);
let n;
t.value instanceof B ? n = t.value : n = { decimal: t.decimal, value: t.value };
super(n);
_(this, "address");

@@ -962,9 +963,8 @@ _(this, "chain");

_(this, "type");
console.log("identifier: ", s);
const n = J(s);
console.log("assetInfo: ", n), this.type = Et(n), this.chain = n.chain, this.ticker = n.ticker, this.symbol = n.symbol, this.address = n.address, this.isSynthetic = n.isSynthetic, this.isGasAsset = n.isGasAsset, this.tax = e.tax;
const i = J(s);
console.log("assetInfo: ", i), this.type = Ee(i), this.chain = i.chain, this.ticker = i.ticker, this.symbol = i.symbol, this.address = i.address, this.isSynthetic = i.isSynthetic, this.isGasAsset = i.isGasAsset, this.tax = t.tax;
}
toString(e = !1) {
toString(t = !1) {
const s = this.isSynthetic ? this.symbol : this.ticker;
return e ? (
return t ? (
// ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044 | USDT

@@ -980,7 +980,7 @@ s

}
eq({ chain: e, symbol: s }) {
return this.chain === e && this.symbol === s;
eq({ chain: t, symbol: s }) {
return this.chain === t && this.symbol === s;
}
static async fromString(e, s = 0) {
return it(e, s);
static async fromString(t, s = 0) {
return ie(t, s);
}

@@ -1031,5 +1031,5 @@ // static fromStringSync(assetString: string, value: NumberPrimitives = 0) {

// }
static fromStringSync(e, s = 0) {
const { isSynthetic: n, symbol: a, chain: o, isGasAsset: c, ticker: u, address: h } = J(e);
console.log("getAssetInfo: ", { isSynthetic: n, symbol: a, chain: o, isGasAsset: c, ticker: u, address: h });
static fromStringSync(t, s = 0) {
const { isSynthetic: n, symbol: i, chain: o, isGasAsset: c, ticker: u, address: h } = J(t);
console.log("getAssetInfo: ", { isSynthetic: n, symbol: i, chain: o, isGasAsset: c, ticker: u, address: h });
const {

@@ -1039,3 +1039,3 @@ tax: l,

identifier: g
} = nt(e);
} = ne(t);
console.log("getStaticToken: ", { tax: l, decimal: f, tokenIdentifier: g });

@@ -1054,23 +1054,23 @@ const A = s === 0 ? BigInt(0) : P(s, f);

// Synthetic assets use a fixed decimal value
identifier: e,
identifier: t,
value: A
})) : R = void 0, R;
}
static async fromIdentifier(e, s = 0) {
return it(e, s);
static async fromIdentifier(t, s = 0) {
return ie(t, s);
}
static fromIdentifierSync(e, s = 0) {
const { decimal: n, identifier: a } = nt(e), o = P(s, n);
return new T({ decimal: n, identifier: a, value: o });
static fromIdentifierSync(t, s = 0) {
const { decimal: n, identifier: i } = ne(t), o = P(s, n);
return new T({ decimal: n, identifier: i, value: o });
}
static fromChainOrSignature(e, s = 0) {
const { decimal: n, identifier: a } = It(e);
if (!n || !a)
throw Error("unknown coin! " + e);
static fromChainOrSignature(t, s = 0) {
const { decimal: n, identifier: i } = Ie(t);
if (!n || !i)
throw Error("unknown coin! " + t);
const o = P(s, n);
return new T({ value: o, decimal: n, identifier: a });
return new T({ value: o, decimal: n, identifier: i });
}
static async loadStaticAssets() {
return new Promise(
async (e, s) => {
async (t, s) => {
try {

@@ -1081,6 +1081,6 @@ const {

ThorchainList: n,
NativeList: a,
NativeList: i,
...o
} = await import("@coinmasters/tokens");
z = [a, ...Object.values(o)].reduce(
z = [i, ...Object.values(o)].reduce(
(u, { tokens: h }) => (h.forEach(({ identifier: l, chain: f, ...g }) => {

@@ -1091,3 +1091,3 @@ const A = "decimals" in g ? g.decimals : d[f];

/* @__PURE__ */ new Map()
), e({ ok: !0 });
), t({ ok: !0 });
} catch (n) {

@@ -1104,35 +1104,35 @@ console.error(n), s({

}
const be = (r) => {
const t = T.fromChainOrSignature(r);
const bt = (r) => {
const e = T.fromChainOrSignature(r);
switch (r) {
case i.Bitcoin:
case i.Litecoin:
case i.Dash:
case i.Zcash:
case i.BitcoinCash:
return t.set(10001e-8);
case i.Dogecoin:
return t.set(1.00000001);
case i.Base:
case i.Arbitrum:
case i.Avalanche:
case i.Ethereum:
return t.set(1e-8);
case i.THORChain:
case i.Mayachain:
return t.set(1e-10);
case a.Bitcoin:
case a.Litecoin:
case a.Dash:
case a.Zcash:
case a.BitcoinCash:
return e.set(10001e-8);
case a.Dogecoin:
return e.set(1.00000001);
case a.Base:
case a.Arbitrum:
case a.Avalanche:
case a.Ethereum:
return e.set(1e-8);
case a.THORChain:
case a.Mayachain:
return e.set(1e-10);
default:
return t.set(1e-8);
return e.set(1e-8);
}
}, J = (r) => {
const t = r.slice(0, 14).includes("/"), [e, s] = r.split(".").pop().split("/"), n = r.includes(".") && !t ? r : `${i.THORChain}.${s}`, [a, o] = n.split("."), [c, u] = (t ? s : o).split("-");
const e = r.slice(0, 14).includes("/"), [t, s] = r.split(".").pop().split("/"), n = r.includes(".") && !e ? r : `${a.THORChain}.${s}`, [i, o] = n.split("."), [c, u] = (e ? s : o).split("-");
return {
address: u == null ? void 0 : u.toLowerCase(),
chain: a,
isGasAsset: ot({ chain: a, symbol: o }),
isSynthetic: t,
symbol: (t ? `${e}/` : "") + (u ? `${c}-${(u == null ? void 0 : u.toLowerCase()) ?? ""}` : o),
chain: i,
isGasAsset: oe({ chain: i, symbol: o }),
isSynthetic: e,
symbol: (e ? `${t}/` : "") + (u ? `${c}-${(u == null ? void 0 : u.toLowerCase()) ?? ""}` : o),
ticker: c
};
}, re = {
}, rt = {
/**

@@ -1196,15 +1196,15 @@ * Core

};
class pt extends Error {
constructor(t, e) {
console.error(e, { stack: e == null ? void 0 : e.stack, message: e == null ? void 0 : e.message }), super(t, { cause: { code: re[t], message: t } }), Object.setPrototypeOf(this, pt.prototype);
class pe extends Error {
constructor(e, t) {
console.error(t, { stack: t == null ? void 0 : t.stack, message: t == null ? void 0 : t.message }), super(e, { cause: { code: rt[e], message: e } }), Object.setPrototypeOf(this, pe.prototype);
}
}
class y extends B {
eq(t) {
return this.eqValue(t);
eq(e) {
return this.eqValue(e);
}
static fromBigInt(t, e) {
static fromBigInt(e, t) {
return new y({
decimal: e,
value: H({ value: t, bigIntDecimal: e, decimal: e })
decimal: t,
value: H({ value: e, bigIntDecimal: t, decimal: t })
});

@@ -1216,26 +1216,26 @@ }

B as BigIntArithmetics,
te as RequestClient,
pt as SwapKitError,
et as RequestClient,
pe as SwapKitError,
y as SwapKitNumber,
oe as assetFromString,
ge as derivationPathToString,
ce as filterAssets,
ot as assetFromString,
gt as derivationPathToString,
ct as filterAssets,
H as formatBigIntToSafeValue,
ae as gasFeeMultiplier,
Et as getAssetType,
kt as getAsymmetricAssetShare,
le as getAsymmetricAssetWithdrawAmount,
Mt as getAsymmetricRuneShare,
ue as getAsymmetricRuneWithdrawAmount,
It as getCommonAssetInfo,
Ct as getDecimal,
de as getEstimatedPoolShare,
me as getLiquiditySlippage,
pe as getMemoFor,
be as getMinAmountByChain,
xt as getSymmetricPoolShare,
he as getSymmetricWithdraw,
fe as getTHORNameCost,
ot as isGasAsset,
_e as validateTHORName
at as gasFeeMultiplier,
Ee as getAssetType,
ke as getAsymmetricAssetShare,
lt as getAsymmetricAssetWithdrawAmount,
Me as getAsymmetricRuneShare,
ut as getAsymmetricRuneWithdrawAmount,
Ie as getCommonAssetInfo,
Ce as getDecimal,
dt as getEstimatedPoolShare,
mt as getLiquiditySlippage,
pt as getMemoFor,
bt as getMinAmountByChain,
xe as getSymmetricPoolShare,
ht as getSymmetricWithdraw,
ft as getTHORNameCost,
oe as isGasAsset,
_t as validateTHORName
};

@@ -11,5 +11,5 @@ {

"vitest": "0.34.6",
"@internal/config": "2.7.20",
"@coinmasters/types": "4.7.20",
"@coinmasters/tokens": "3.7.20"
"@internal/config": "2.7.21",
"@coinmasters/tokens": "3.7.21",
"@coinmasters/types": "4.7.21"
},

@@ -20,4 +20,4 @@ "eslintConfig": {

"peerDependencies": {
"@coinmasters/types": "4.7.20",
"@coinmasters/tokens": "3.7.20"
"@coinmasters/types": "4.7.21",
"@coinmasters/tokens": "3.7.21"
},

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

"types": "./dist/index.d.ts",
"version": "11.0.20",
"version": "11.0.21",
"scripts": {

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

@@ -90,10 +90,19 @@ import type {

'identifier' in params ? params.identifier : `${params.chain}.${params.symbol}`;
console.log('identifier: ', identifier);
super(
params.value instanceof BigIntArithmetics
? params.value
: { decimal: params.decimal, value: params.value },
);
let value;
if (params.value instanceof BigIntArithmetics) {
value = params.value;
} else {
value = { decimal: params.decimal, value: params.value };
}
console.log('value: ', value);
super(value);
console.log('identifier: ', identifier);
// super(
// params.value instanceof BigIntArithmetics
// ? params.value
// : { decimal: params.decimal, value: params.value },
// );
const assetInfo = getAssetInfo(identifier);

@@ -179,3 +188,2 @@ console.log('assetInfo: ', assetInfo);

static fromStringSync(assetString: string, value: NumberPrimitives = 0) {

@@ -182,0 +190,0 @@ const { isSynthetic, symbol, chain, isGasAsset, ticker, address } = getAssetInfo(assetString);

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