Socket
Socket
Sign inDemoInstall

@swapkit/helpers

Package Overview
Dependencies
Maintainers
1
Versions
203
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.6 to 1.0.0-rc.7

2

dist/index.d.ts

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

symbol: string;
}) => "KUJI" | "Synth" | "Native" | "GAIA" | "BEP2" | "BEP20" | "ERC20" | "AVAX" | "POLYGON" | "ARBITRUM" | "OPTIMISM";
}) => Chain.Avalanche | Chain.Cosmos | Chain.Kujira | "Synth" | "Native" | "BEP2" | "BEP20" | "ERC20" | "POLYGON" | "ARBITRUM" | "OPTIMISM";

@@ -183,0 +183,0 @@ export declare const getAsymmetricAssetShare: ({ liquidityUnits, poolUnits, assetDepth, }: ShareParams<{

@@ -155,5 +155,5 @@ var nt = Object.defineProperty;

case i.Cosmos:
return t === "ATOM" ? "Native" : "GAIA";
return t === "ATOM" ? "Native" : i.Cosmos;
case i.Kujira:
return t === "KUJI" ? "Native" : "KUJI";
return t === i.Kujira ? "Native" : i.Kujira;
case i.Binance:

@@ -166,3 +166,3 @@ return t === i.Binance ? "Native" : "BEP2";

case i.Avalanche:
return t === i.Avalanche ? "Native" : "AVAX";
return t === i.Avalanche ? "Native" : i.Avalanche;
case i.Polygon:

@@ -182,3 +182,5 @@ return t === i.Polygon ? "Native" : "POLYGON";

"gmi"
), Et = (n) => n.filter((t) => !gt.test(t.toString())), _t = ({
), Et = (n) => n.filter(
(t) => !gt.test(t.toString()) && !t.toString().includes("undefined")
), _t = ({
liquidityUnits: n,

@@ -233,3 +235,3 @@ poolUnits: t,

}) => {
const c = h(n), o = h(e), u = h(t), l = h(s), d = h(a), A = l.mul(o), S = d.mul(c), R = l.mul(d), Q = c.mul(o), Z = u.mul(A.add(S.add(R.mul(2)))), tt = A.add(S.add(Q.mul(2))), F = Z.div(tt), k = h(r).add(F);
const c = h(n), o = h(e), u = h(t), l = h(s), d = h(a), A = l.mul(o), I = d.mul(c), R = l.mul(d), X = c.mul(o), Z = u.mul(A.add(I.add(R.mul(2)))), tt = A.add(I.add(X.mul(2))), F = Z.div(tt), k = h(r).add(F);
if (F.baseValueNumber === 0)

@@ -282,8 +284,8 @@ return k.div(u).baseValueNumber;

}
}, U = Object.values(i), $t = (n = "") => {
}, G = Object.values(i), $t = (n = "") => {
const t = n.toUpperCase(), [e] = t.split(".");
if (U.includes(e))
if (G.includes(e))
return !0;
const [r] = t.split("/");
if (U.includes(r))
if (G.includes(r))
return !0;

@@ -293,4 +295,4 @@ throw new Error(

);
}, T = 8, I = (n) => 10n ** BigInt(n), v = (n) => Math.log10(parseFloat(n.toString()));
function G({
}, T = 8, S = (n) => 10n ** BigInt(n), v = (n) => Math.log10(parseFloat(n.toString()));
function U({
value: n,

@@ -311,3 +313,3 @@ bigIntDecimal: t = T,

}
var w, V, M, J, N, z, E, D, b, C, O, L;
var w, V, M, z, N, J, E, D, b, C, O, L;
const B = class B {

@@ -325,5 +327,5 @@ constructor(t) {

const e = P(t);
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = I(
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = S(
Math.max(g(this, O, L).call(this, g(this, b, C).call(this, e)), this.decimal || 0)
), g(this, M, J).call(this, e);
), g(this, M, z).call(this, e);
}

@@ -333,3 +335,3 @@ static fromBigInt(t, e) {

decimal: e,
value: G({ value: t, bigIntDecimal: e, decimal: e })
value: U({ value: t, bigIntDecimal: e, decimal: e })
});

@@ -343,3 +345,3 @@ }

return B.fromBigInt(
new B(t).bigIntValue * I(r) / I(e),
new B(t).bigIntValue * S(r) / S(e),
r

@@ -411,3 +413,3 @@ );

getBaseValue(t) {
const e = this.decimalMultiplier / I(this.decimal || 0), r = this.bigIntValue / e;
const e = this.decimalMultiplier / S(this.decimal || 0), r = this.bigIntValue / e;
switch (t) {

@@ -423,3 +425,6 @@ case "number":

getBigIntValue(t, e) {
return !e && typeof t == "object" ? t.bigIntValue : g(this, E, D).call(this, g(this, b, C).call(this, P(t)), e);
if (!e && typeof t == "object")
return t.bigIntValue;
const r = P(t), s = g(this, b, C).call(this, r);
return s === "0" || s === "undefined" ? 0n : g(this, E, D).call(this, s, e);
}

@@ -456,3 +461,3 @@ formatBigIntToSafeValue(t, e) {

w = new WeakSet(), V = function(t, ...e) {
const r = g(this, N, z).call(this, this, ...e), s = I(r), a = e.reduce(
const r = g(this, N, J).call(this, this, ...e), s = S(r), a = e.reduce(
(o, u) => {

@@ -478,3 +483,3 @@ const l = this.getBigIntValue(u, r);

this.bigIntValue * s / this.decimalMultiplier
), c = G({
), c = U({
bigIntDecimal: r,

@@ -485,6 +490,6 @@ decimal: Math.max(r, v(this.decimalMultiplier)),

return new this.constructor({ decimal: this.decimal, value: c, identifier: this.toString() });
}, M = new WeakSet(), J = function(t) {
}, M = new WeakSet(), z = function(t) {
const e = g(this, b, C).call(this, t) || "0";
this.bigIntValue = g(this, E, D).call(this, e);
}, N = new WeakSet(), z = function(...t) {
}, N = new WeakSet(), J = function(...t) {
const e = t.map(

@@ -495,3 +500,3 @@ (r) => typeof r == "object" ? r.decimal || v(r.decimalMultiplier) : g(this, O, L).call(this, g(this, b, C).call(this, r))

}, E = new WeakSet(), D = function(t, e) {
const r = e ? I(e) : this.decimalMultiplier, s = v(r), [a, c = ""] = t.split(".");
const r = e ? S(e) : this.decimalMultiplier, s = v(r), [a = "", c = ""] = t.split(".");
return BigInt(`${a}${c.padEnd(s, "0")}`);

@@ -595,4 +600,4 @@ }, b = new WeakSet(), C = function(t) {

j = [a, ...Object.values(c)].reduce(
(u, { tokens: l }) => (l.forEach(({ identifier: d, chain: A, ...S }) => {
const R = "decimals" in S ? S.decimals : m[A];
(u, { tokens: l }) => (l.forEach(({ identifier: d, chain: A, ...I }) => {
const R = "decimals" in I ? I.decimals : m[A];
u.set(d, { identifier: d, decimal: R });

@@ -698,5 +703,5 @@ }), u),

};
class X extends Error {
class Q extends Error {
constructor(t, e) {
console.error(e), super(t, { cause: { code: wt[t], message: t } }), Object.setPrototypeOf(this, X.prototype);
console.error(e), super(t, { cause: { code: wt[t], message: t } }), Object.setPrototypeOf(this, Q.prototype);
}

@@ -712,3 +717,3 @@ }

y as BigIntArithmetics,
X as SwapKitError,
Q as SwapKitError,
bt as SwapKitNumber,

@@ -718,3 +723,3 @@ yt as assetFromString,

Et as filterAssets,
G as formatBigIntToSafeValue,
U as formatBigIntToSafeValue,
Bt as gasFeeMultiplier,

@@ -721,0 +726,0 @@ mt as getAssetType,

@@ -42,3 +42,3 @@ {

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

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

@@ -157,5 +157,5 @@ import type { EVMChain } from '@swapkit/types';

case Chain.Cosmos:
return symbol === 'ATOM' ? 'Native' : 'GAIA';
return symbol === 'ATOM' ? 'Native' : Chain.Cosmos;
case Chain.Kujira:
return symbol === 'KUJI' ? 'Native' : 'KUJI';
return symbol === Chain.Kujira ? 'Native' : Chain.Kujira;
case Chain.Binance:

@@ -168,3 +168,3 @@ return symbol === Chain.Binance ? 'Native' : 'BEP2';

case Chain.Avalanche:
return symbol === Chain.Avalanche ? 'Native' : 'AVAX';
return symbol === Chain.Avalanche ? 'Native' : Chain.Avalanche;
case Chain.Polygon:

@@ -194,2 +194,5 @@ return symbol === Chain.Polygon ? 'Native' : 'POLYGON';

export const filterAssets = (assets: AssetValue[]) =>
assets.filter((asset) => !potentialScamRegex.test(asset.toString()));
assets.filter(
(asset) =>
!potentialScamRegex.test(asset.toString()) && !asset.toString().includes('undefined'),
);

@@ -183,3 +183,7 @@ import type { SwapKitNumber } from './swapKitNumber.ts';

return this.#toBigInt(this.#toSafeValue(getStringValue(value)), decimal);
const stringValue = getStringValue(value);
const safeValue = this.#toSafeValue(stringValue);
if (safeValue === '0' || safeValue === 'undefined') return 0n;
return this.#toBigInt(safeValue, decimal);
}

@@ -314,3 +318,3 @@

const padDecimal = decimalFromMultiplier(multiplier);
const [integerPart, decimalPart = ''] = value.split('.');
const [integerPart = '', decimalPart = ''] = value.split('.');

@@ -317,0 +321,0 @@ return BigInt(`${integerPart}${decimalPart.padEnd(padDecimal, '0')}`);

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