@swapkit/helpers
Advanced tools
Comparing version 1.0.0-rc.1 to 1.0.0-rc.2
@@ -173,3 +173,3 @@ import { Chain } from '@swapkit/types'; | ||
symbol: string; | ||
}) => "Synth" | "Native" | "GAIA" | "BEP2" | "BEP20" | "ERC20" | "AVAX" | "POLYGON" | "ARBITRUM" | "OPTIMISM"; | ||
}) => "KUJI" | "Synth" | "Native" | "GAIA" | "BEP2" | "BEP20" | "ERC20" | "AVAX" | "POLYGON" | "ARBITRUM" | "OPTIMISM"; | ||
@@ -176,0 +176,0 @@ export declare const getAsymmetricAssetShare: ({ liquidityUnits, poolUnits, assetDepth, }: ShareParams<{ |
@@ -23,3 +23,3 @@ var rt = Object.defineProperty; | ||
return !!n.match(t); | ||
}, yt = ([n, t, e, r, s]) => `${n}'/${t}'/${e}'/${r}${typeof s != "number" ? "" : `/${s}`}`, Tt = async (n, t) => { | ||
}, Tt = ([n, t, e, r, s]) => `${n}'/${t}'/${e}'/${r}${typeof s != "number" ? "" : `/${s}`}`, Bt = async (n, t) => { | ||
const e = Object.entries(t || {}).reduce( | ||
@@ -41,3 +41,3 @@ (s, [a, c]) => (c && (s[a] = c), s), | ||
return r ? s.text() : s.json(); | ||
}, ot = "0x313ce567", z = async ({ chain: n, to: t }) => { | ||
}, ot = "0x313ce567", K = async ({ chain: n, to: t }) => { | ||
try { | ||
@@ -63,7 +63,7 @@ const e = await ct( | ||
const [, t] = n.split("-"); | ||
return t != null && t.startsWith("0x") ? z({ chain: i.Ethereum, to: t }) : h.ETH; | ||
return t != null && t.startsWith("0x") ? K({ chain: i.Ethereum, to: t }) : h.ETH; | ||
}, lt = async (n) => { | ||
const [, t] = n.split("-"); | ||
return t != null && t.startsWith("0x") ? z({ chain: i.Avalanche, to: t.toLowerCase() }) : h.AVAX; | ||
}, dt = async (n) => n === i.BinanceSmartChain ? h.BSC : h.BSC, X = async ({ chain: n, symbol: t }) => { | ||
return t != null && t.startsWith("0x") ? K({ chain: i.Avalanche, to: t.toLowerCase() }) : h.AVAX; | ||
}, dt = async (n) => n === i.BinanceSmartChain ? h.BSC : h.BSC, J = async ({ chain: n, symbol: t }) => { | ||
switch (n) { | ||
@@ -79,3 +79,3 @@ case i.Ethereum: | ||
} | ||
}, Bt = { | ||
}, yt = { | ||
[x.Average]: 1.2, | ||
@@ -99,2 +99,4 @@ [x.Fast]: 1.5, | ||
return t === "CACAO"; | ||
case i.Kujira: | ||
return t === "KUJI"; | ||
case i.Cosmos: | ||
@@ -125,2 +127,3 @@ return t === "ATOM"; | ||
return { identifier: "MAYA.MAYA", decimal: 4 }; | ||
case i.Kujira: | ||
case i.Arbitrum: | ||
@@ -151,2 +154,4 @@ case i.Optimism: | ||
return t === "ATOM" ? "Native" : "GAIA"; | ||
case i.Kujira: | ||
return t === "KUJI" ? "Native" : "KUJI"; | ||
case i.Binance: | ||
@@ -221,4 +226,4 @@ return t === i.Binance ? "Native" : "BEP2"; | ||
}) => { | ||
const c = m(n), o = m(e), l = m(t), u = m(s), g = m(a), $ = u.mul(o), v = g.mul(c), D = u.mul(g), K = c.mul(o), tt = l.mul($.add(v.add(D.mul(2)))), et = $.add(v.add(K.mul(2))), G = tt.div(et), H = m(r).add(G); | ||
if (G.baseValueNumber === 0) | ||
const c = m(n), o = m(e), l = m(t), u = m(s), g = m(a), $ = u.mul(o), v = g.mul(c), D = u.mul(g), Z = c.mul(o), tt = l.mul($.add(v.add(D.mul(2)))), et = $.add(v.add(Z.mul(2))), U = tt.div(et), H = m(r).add(U); | ||
if (U.baseValueNumber === 0) | ||
return H.div(l).baseValueNumber; | ||
@@ -270,6 +275,6 @@ const nt = l.add(H); | ||
} | ||
}, B = 8, U = ({ | ||
}, y = 8, G = ({ | ||
value: n, | ||
bigIntDecimal: t = B, | ||
decimal: e = B | ||
bigIntDecimal: t = y, | ||
decimal: e = y | ||
}) => { | ||
@@ -296,4 +301,4 @@ const r = n < 0n; | ||
); | ||
}, S = (n) => 10n ** BigInt(n), C = (n) => Math.log10(parseFloat(n.toString())); | ||
var w, y, R, J, k, Q, O, L, b, T, V, j, I, N; | ||
}, I = (n) => 10n ** BigInt(n), C = (n) => Math.log10(parseFloat(n.toString())); | ||
var w, T, R, z, k, X, O, L, b, B, V, j, S, N; | ||
const M = class M { | ||
@@ -307,3 +312,3 @@ constructor(t) { | ||
p(this, V); | ||
p(this, I); | ||
p(this, S); | ||
_(this, "decimalMultiplier", 10n ** 8n); | ||
@@ -313,5 +318,5 @@ _(this, "bigIntValue", 0n); | ||
const e = typeof t == "object", r = e ? t.value : t; | ||
this.decimal = e ? t.decimal : void 0, this.decimalMultiplier = S( | ||
Math.max(d(this, V, j).call(this, d(this, b, T).call(this, r)), this.decimal || 0) | ||
), d(this, R, J).call(this, r); | ||
this.decimal = e ? t.decimal : void 0, this.decimalMultiplier = I( | ||
Math.max(d(this, V, j).call(this, d(this, b, B).call(this, r)), this.decimal || 0) | ||
), d(this, R, z).call(this, r); | ||
} | ||
@@ -321,3 +326,3 @@ static fromBigInt(t, e) { | ||
decimal: e, | ||
value: U({ value: t, bigIntDecimal: e, decimal: e }) | ||
value: G({ value: t, bigIntDecimal: e, decimal: e }) | ||
}); | ||
@@ -331,3 +336,3 @@ } | ||
return M.fromBigInt( | ||
new M(t).bigIntValue * S(r) / S(e), | ||
new M(t).bigIntValue * I(r) / I(e), | ||
r | ||
@@ -340,9 +345,9 @@ ); | ||
get baseValue() { | ||
return d(this, I, N).call(this, "string"); | ||
return d(this, S, N).call(this, "string"); | ||
} | ||
get baseValueNumber() { | ||
return d(this, I, N).call(this, "number"); | ||
return d(this, S, N).call(this, "number"); | ||
} | ||
get baseValueBigInt() { | ||
return d(this, I, N).call(this, "number"); | ||
return d(this, S, N).call(this, "number"); | ||
} | ||
@@ -356,12 +361,12 @@ get value() { | ||
add(...t) { | ||
return d(this, w, y).call(this, "add", ...t); | ||
return d(this, w, T).call(this, "add", ...t); | ||
} | ||
sub(...t) { | ||
return d(this, w, y).call(this, "sub", ...t); | ||
return d(this, w, T).call(this, "sub", ...t); | ||
} | ||
mul(...t) { | ||
return d(this, w, y).call(this, "mul", ...t); | ||
return d(this, w, T).call(this, "mul", ...t); | ||
} | ||
div(...t) { | ||
return d(this, w, y).call(this, "div", ...t); | ||
return d(this, w, T).call(this, "div", ...t); | ||
} | ||
@@ -384,6 +389,6 @@ gt(t) { | ||
getBigIntValue(t, e) { | ||
return !e && typeof t == "object" ? t.bigIntValue : (t = typeof t == "object" ? t.value : t, d(this, O, L).call(this, d(this, b, T).call(this, t), e)); | ||
return !e && typeof t == "object" ? t.bigIntValue : (t = typeof t == "object" ? t.value : t, d(this, O, L).call(this, d(this, b, B).call(this, t), e)); | ||
} | ||
formatBigIntToSafeValue(t, e) { | ||
const r = e || this.decimal || B, s = Math.max( | ||
const r = e || this.decimal || y, s = Math.max( | ||
r, | ||
@@ -410,4 +415,4 @@ C(this.decimalMultiplier) | ||
}; | ||
w = new WeakSet(), y = function(t, ...e) { | ||
const r = d(this, k, Q).call(this, this, ...e), s = S(r), a = e.reduce( | ||
w = new WeakSet(), T = function(t, ...e) { | ||
const r = d(this, k, X).call(this, this, ...e), s = I(r), a = e.reduce( | ||
(o, l) => { | ||
@@ -421,3 +426,3 @@ const u = this.getBigIntValue(l, r); | ||
this.bigIntValue * s / this.decimalMultiplier | ||
), c = U({ | ||
), c = G({ | ||
bigIntDecimal: r, | ||
@@ -428,14 +433,14 @@ decimal: Math.max(r, C(this.decimalMultiplier)), | ||
return new this.constructor({ decimal: this.decimal, value: c, identifier: this.toString() }); | ||
}, R = new WeakSet(), J = function(t, e) { | ||
const r = d(this, b, T).call(this, t) || "0"; | ||
}, R = new WeakSet(), z = function(t, e) { | ||
const r = d(this, b, B).call(this, t) || "0"; | ||
this.bigIntValue = e || d(this, O, L).call(this, r); | ||
}, k = new WeakSet(), Q = function(...t) { | ||
}, k = new WeakSet(), X = function(...t) { | ||
const e = t.map( | ||
(r) => typeof r == "object" ? r.decimal || C(r.decimalMultiplier) : d(this, V, j).call(this, d(this, b, T).call(this, r)) | ||
(r) => typeof r == "object" ? r.decimal || C(r.decimalMultiplier) : d(this, V, j).call(this, d(this, b, B).call(this, r)) | ||
).filter(Boolean); | ||
return Math.max(...e, B); | ||
return Math.max(...e, y); | ||
}, O = new WeakSet(), L = function(t, e) { | ||
const r = e ? S(e) : this.decimalMultiplier, s = C(r), [a, c = ""] = t.split("."); | ||
const r = e ? I(e) : this.decimalMultiplier, s = C(r), [a, c = ""] = t.split("."); | ||
return BigInt(`${a}${c.padEnd(s, "0")}`); | ||
}, b = new WeakSet(), T = function(t) { | ||
}, b = new WeakSet(), B = function(t) { | ||
const r = `${typeof t == "number" ? Number(t).toLocaleString("fullwide", { | ||
@@ -449,5 +454,5 @@ useGrouping: !1, | ||
const e = ((r = t.split(".")[1]) == null ? void 0 : r.length) || 0; | ||
return Math.max(e, B); | ||
}, I = new WeakSet(), N = function(t) { | ||
const e = this.decimalMultiplier / S(this.decimal || 0), r = this.bigIntValue / e; | ||
return Math.max(e, y); | ||
}, S = new WeakSet(), N = function(t) { | ||
const e = this.decimalMultiplier / I(this.decimal || 0), r = this.bigIntValue / e; | ||
switch (t) { | ||
@@ -469,3 +474,3 @@ case "number": | ||
$t(n); | ||
const e = await X(F(n)); | ||
const e = await J(F(n)); | ||
return new A({ decimal: e, value: t, identifier: n }); | ||
@@ -509,3 +514,3 @@ }; | ||
static async fromTCQuote(e, r = 0) { | ||
const s = await X(F(e)), a = this.shiftDecimals({ value: r, from: h.THOR, to: s }); | ||
const s = await J(F(e)), a = this.shiftDecimals({ value: r, from: h.THOR, to: s }); | ||
return new A({ value: a, identifier: e, decimal: s }); | ||
@@ -644,5 +649,5 @@ } | ||
}; | ||
class Z extends Error { | ||
class Q extends Error { | ||
constructor(t, e) { | ||
console.error(e), super(t, { cause: { code: wt[t], message: t } }), Object.setPrototypeOf(this, Z.prototype); | ||
console.error(e), super(t, { cause: { code: wt[t], message: t } }), Object.setPrototypeOf(this, Q.prototype); | ||
} | ||
@@ -660,9 +665,9 @@ } | ||
A as AssetValue, | ||
B as DEFAULT_DECIMAL, | ||
Z as SwapKitError, | ||
y as DEFAULT_DECIMAL, | ||
Q as SwapKitError, | ||
bt as SwapKitNumber, | ||
Mt as assetFromString, | ||
yt as derivationPathToString, | ||
U as formatBigIntToSafeValue, | ||
Bt as gasFeeMultiplier, | ||
Tt as derivationPathToString, | ||
G as formatBigIntToSafeValue, | ||
yt as gasFeeMultiplier, | ||
_t as getAssetType, | ||
@@ -674,3 +679,3 @@ pt as getAsymmetricAssetShare, | ||
ht as getCommonAssetInfo, | ||
X as getDecimal, | ||
J as getDecimal, | ||
Nt as getEstimatedPoolShare, | ||
@@ -680,3 +685,3 @@ Rt as getLiquiditySlippage, | ||
Dt as getMinAmountByChain, | ||
Tt as getRequest, | ||
Bt as getRequest, | ||
ft as getSymmetricPoolShare, | ||
@@ -683,0 +688,0 @@ Vt as getSymmetricWithdraw, |
@@ -9,4 +9,4 @@ { | ||
"@internal/config": "0.0.0-internal.0", | ||
"@swapkit/tokens": "1.0.0-rc.0", | ||
"@swapkit/types": "1.0.0-rc.0" | ||
"@swapkit/tokens": "1.0.0-rc.1", | ||
"@swapkit/types": "1.0.0-rc.1" | ||
}, | ||
@@ -17,4 +17,4 @@ "eslintConfig": { | ||
"peerDependencies": { | ||
"@swapkit/tokens": "1.0.0-rc.0", | ||
"@swapkit/types": "1.0.0-rc.0" | ||
"@swapkit/tokens": "1.0.0-rc.1", | ||
"@swapkit/types": "1.0.0-rc.1" | ||
}, | ||
@@ -44,3 +44,3 @@ "exports": { | ||
"types": "./dist/index.d.ts", | ||
"version": "1.0.0-rc.1", | ||
"version": "1.0.0-rc.2", | ||
"scripts": { | ||
@@ -47,0 +47,0 @@ "build": "vite build", |
@@ -93,2 +93,5 @@ import type { EVMChain } from '@swapkit/types'; | ||
case Chain.Kujira: | ||
return symbol === 'KUJI'; | ||
case Chain.Cosmos: | ||
@@ -125,2 +128,3 @@ return symbol === 'ATOM'; | ||
case Chain.Kujira: | ||
case Chain.Arbitrum: | ||
@@ -154,2 +158,4 @@ case Chain.Optimism: | ||
return symbol === 'ATOM' ? 'Native' : 'GAIA'; | ||
case Chain.Kujira: | ||
return symbol === 'KUJI' ? 'Native' : 'KUJI'; | ||
case Chain.Binance: | ||
@@ -156,0 +162,0 @@ return symbol === Chain.Binance ? 'Native' : 'BEP2'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
145881
2847
6