@coinmasters/swapkit-entities
Advanced tools
Comparing version 3.7.3 to 3.7.4
@@ -1,8 +0,8 @@ | ||
var L = Object.defineProperty; | ||
var H = (t, s, e) => s in t ? L(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e; | ||
var c = (t, s, e) => (H(t, typeof s != "symbol" ? s + "" : s, e), e); | ||
var H = Object.defineProperty; | ||
var L = (t, s, i) => s in t ? H(t, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[s] = i; | ||
var c = (t, s, i) => (L(t, typeof s != "symbol" ? s + "" : s, i), i); | ||
import { BigNumber as E } from "bignumber.js"; | ||
var a = /* @__PURE__ */ ((t) => (t.INVALID_INPUT_PARAMETERS = "1000", t.UNKNOWN_PROVIDERS = "1001", t.CANNOT_FIND_INBOUND_ADDRESS = "1002", t.NO_INBOUND_ADDRESSES = "1003", t.CHAIN_HALTED_OR_UNSUPPORTED = "1004", t.MISSING_INPUT_PARAMETER = "1005", t.INVALID_TYPE_GENERIC = "1100", t.INVALID_NUMBER_STRING = "1101", t.INVALID_NUMBER = "1102", t.INVALID_BOOLEAN = "1103", t.INVALID_OBJECT = "1104", t.INVALID_ARRAY = "1105", t.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", t.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", t.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", t.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", t.AFF_ADDRESS_TOO_LONG = "2004", t.AFF_BPS_INTEGER_0_100 = "2005", t.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", t.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", t.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", t.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", t.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", t.SOURCE_ADDRESS_SMART_CONTRACT = "2011", t.INVALID_PROVIDER = "2100", t.MISSING_CROSS_CHAIN_PROVIDER = "2101", t.MISSING_AVAX_PROVIDER = "2102", t.MISSING_BSC_PROVIDER = "2103", t.MISSING_ETH_PROVIDER = "2104", t.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", t.MISSING_ARB_PROVIDER = "2106", t.INVALID_CHAIN = "2200", t.INVALID_ASSET = "2201", t.INVALID_ASSET_IDENTIFIER = "2202", t.UNSUPPORTED_CHAIN = "2204", t.UNSUPPORTED_ASSET = "2203", t.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", t.INVALID_SOURCE_ADDRESS = "2300", t.INVALID_DESTINATION_ADDRESS = "2301", t.THORNODE_QUOTE_GENERIC_ERROR = "3000", t.NOT_ENOUGH_SYNTH_BALANCE = "3001", t.SYNTH_MINTING_CAP_REACHED = "3002", t.INVALID_QUOTE_MODE = "4000", t.NO_QUOTES = "4001", t.SERVICE_UNAVAILABLE_GENERIC = "5000", t.MISSING_GAS_DATA_GENERIC = "5100", t.MISSING_TOKEN_INFO_GENERIC = "5200", t.CANT_FIND_TOKEN_LIST = "5201", t.NO_PRICE = "5202", t.PRICE_IS_STALE = "5203", t.ADDRESS_NOT_WHITELISTED = "6000", t.ADDRESS_ALREADY_CLAIMED = "6001", t.TEMPORARY_ERROR = "9999", t))(a || {}); | ||
a.INVALID_INPUT_PARAMETERS + "", a.UNKNOWN_PROVIDERS + "", a.CANNOT_FIND_INBOUND_ADDRESS + "", a.NO_INBOUND_ADDRESSES + "", a.CHAIN_HALTED_OR_UNSUPPORTED + "", a.MISSING_INPUT_PARAMETER + "", a.INVALID_TYPE_GENERIC + "", a.INVALID_NUMBER_STRING + "", a.INVALID_NUMBER + "", a.INVALID_BOOLEAN + "", a.INVALID_OBJECT + "", a.INVALID_ARRAY + "", a.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", a.SELL_BUY_ASSETS_ARE_THE_SAME + "", a.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", a.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", a.AFF_ADDRESS_TOO_LONG + "", a.AFF_BPS_INTEGER_0_100 + "", a.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", a.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", a.PREFERRED_PROFVIDER_NOT_SUPPORTED + "", a.DESTINATION_ADDRESS_SMART_CONTRACT + "", a.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", a.INVALID_PROVIDER + "", a.MISSING_CROSS_CHAIN_PROVIDER + "", a.MISSING_AVAX_PROVIDER + "", a.MISSING_BSC_PROVIDER + "", a.MISSING_ETH_PROVIDER + "", a.MISSING_ARB_PROVIDER + "", a.INVALID_PROVIDER_FOR_SWAP_OUT + "", a.INVALID_CHAIN + "", a.INVALID_ASSET + "", a.UNSUPPORTED_CHAIN + "", a.UNSUPPORTED_ASSET + "", a.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", a.THORNODE_QUOTE_GENERIC_ERROR + "", a.INVALID_SOURCE_ADDRESS + "", a.INVALID_DESTINATION_ADDRESS + "", a.NOT_ENOUGH_SYNTH_BALANCE + "", a.SYNTH_MINTING_CAP_REACHED + "", a.INVALID_QUOTE_MODE + "", a.NO_QUOTES + "", a.SERVICE_UNAVAILABLE_GENERIC + "", a.MISSING_GAS_DATA_GENERIC + "", a.MISSING_TOKEN_INFO_GENERIC + "", a.CANT_FIND_TOKEN_LIST + "", a.NO_PRICE + "", a.PRICE_IS_STALE + "", a.ADDRESS_NOT_WHITELISTED + "", a.ADDRESS_ALREADY_CLAIMED + ""; | ||
var i = /* @__PURE__ */ ((t) => (t.Arbitrum = "ARB", t.Avalanche = "AVAX", t.Base = "BASE", t.Binance = "BNB", t.BinanceSmartChain = "BSC", t.Bitcoin = "BTC", t.BitcoinCash = "BCH", t.Cosmos = "GAIA", t.Dash = "DASH", t.Digibyte = "DGB", t.Dogecoin = "DOGE", t.EOS = "EOS", t.Ethereum = "ETH", t.Kujira = "KUJI", t.Litecoin = "LTC", t.Mayachain = "MAYA", t.Optimism = "OP", t.Osmosis = "OSMO", t.Polygon = "MATIC", t.Ripple = "XRP", t.THORChain = "THOR", t.Zcash = "ZEC", t))(i || {}); | ||
var e = /* @__PURE__ */ ((t) => (t.Arbitrum = "ARB", t.Avalanche = "AVAX", t.Base = "BASE", t.Binance = "BNB", t.BinanceSmartChain = "BSC", t.Bitcoin = "BTC", t.BitcoinCash = "BCH", t.Cosmos = "GAIA", t.Dash = "DASH", t.Digibyte = "DGB", t.Dogecoin = "DOGE", t.EOS = "EOS", t.Ethereum = "ETH", t.Kujira = "KUJI", t.Litecoin = "LTC", t.Mayachain = "MAYA", t.Optimism = "OP", t.Osmosis = "OSMO", t.Polygon = "MATIC", t.Ripple = "XRP", t.THORChain = "THOR", t.Zcash = "ZEC", t))(e || {}); | ||
const w = { | ||
@@ -32,6 +32,6 @@ ARB: "eip155:42161", | ||
}; | ||
for (const t in i) | ||
w[i[t]], i[t]; | ||
for (const t in e) | ||
w[e[t]], e[t]; | ||
var u = /* @__PURE__ */ ((t) => (t[t.ARB = 18] = "ARB", t[t.AVAX = 18] = "AVAX", t[t.BCH = 8] = "BCH", t[t.BNB = 8] = "BNB", t[t.BSC = 18] = "BSC", t[t.BTC = 8] = "BTC", t[t.DASH = 8] = "DASH", t[t.DGB = 8] = "DGB", t[t.DOGE = 8] = "DOGE", t[t.ETH = 18] = "ETH", t[t.BASE = 18] = "BASE", t[t.EOS = 6] = "EOS", t[t.GAIA = 6] = "GAIA", t[t.KUJI = 6] = "KUJI", t[t.LTC = 8] = "LTC", t[t.MATIC = 18] = "MATIC", t[t.MAYA = 10] = "MAYA", t[t.OP = 18] = "OP", t[t.OSMO = 6] = "OSMO", t[t.XRP = 6] = "XRP", t[t.THOR = 8] = "THOR", t[t.ZEC = 8] = "ZEC", t))(u || {}); | ||
const p = [ | ||
const d = [ | ||
"ETH", | ||
@@ -41,3 +41,3 @@ "AVAX", | ||
"ARB", | ||
// Chain.Base, | ||
"BASE", | ||
"OP", | ||
@@ -48,21 +48,21 @@ "MATIC" | ||
var B = /* @__PURE__ */ ((t) => (t.Arbitrum = "42161", t.ArbitrumHex = "0xa4b1", t.Avalanche = "43114", t.AvalancheHex = "0xa86a", t.Base = "8453", t.Binance = "Binance-Chain-Tigris", t.BinanceSmartChain = "56", t.BinanceSmartChainHex = "0x38", t.Bitcoin = "bitcoin", t.BitcoinCash = "bitcoincash", t.Cosmos = "cosmoshub-4", t.Dash = "dash", t.Dogecoin = "dogecoin", t.Kujira = "kaiyo-1", t.Ethereum = "1", t.EthereumHex = "0x1", t.Litecoin = "litecoin", t.Mayachain = "mayachain-mainnet-v1", t.MayaStagenet = "mayachain-stagenet-v1", t.Optimism = "10", t.OptimismHex = "0xa", t.Osmosis = "osmosis-1", t.Polygon = "137", t.PolygonHex = "0x89", t.THORChain = "thorchain-mainnet-v1", t.THORChainStagenet = "thorchain-stagenet-v2", t))(B || {}), b = /* @__PURE__ */ ((t) => (t.Arbitrum = "https://arb1.arbitrum.io/rpc", t.Avalanche = "https://daemon.avalanche.shapeshift.com/ext/bc/C/rpc", t.Binance = "https://base.llamarpc.com", t.BinanceSmartChain = "https://daemon.bnbsmartchain.shapeshift.com", t.Base = "https://developer-access-mainnet.base.org", t.Bitcoin = "https://node-router.thorswap.net/bitcoin", t.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", t.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", t.Kujira = "https://rpc-kujira.synergynodes.com/", t.Dash = "https://dash.nownodes.io", t.Dogecoin = "https://node-router.thorswap.net/dogecoin", t.Ethereum = "https://daemon.ethereum.shapeshift.com", t.Litecoin = "https://node-router.thorswap.net/litecoin", t.Mayachain = "https://mayanode.mayachain.info", t.MayaStagenet = "https://stagenet.tendermint.mayachain.info", t.Optimism = "https://mainnet.optimism.io", t.Osmosis = "https://lcd-osmosis.keplr.app", t.Polygon = "https://polygon-rpc.com", t.Ripple = "https://xrplcluster.com", t.THORChain = "https://thornode.ninerealms.com", t.THORChainStagenet = "https://thornode.ninerealms.com", t))(b || {}); | ||
const l = Object.values(i), v = Object.keys(i), U = l.reduce( | ||
const p = Object.values(e), v = Object.keys(e), U = p.reduce( | ||
(t, s) => { | ||
const e = v.find((n) => i[n] === s); | ||
return e && (t[s] = e), t; | ||
const i = v.find((n) => e[n] === s); | ||
return i && (t[s] = i), t; | ||
}, | ||
{} | ||
); | ||
l.reduce( | ||
p.reduce( | ||
(t, s) => (t[s] = B[U[s]], t), | ||
{} | ||
); | ||
l.reduce( | ||
p.reduce( | ||
(t, s) => (t[s] = b[U[s]], t), | ||
{} | ||
); | ||
l.reduce( | ||
p.reduce( | ||
(t, s) => { | ||
const e = `${U[s]}Hex`; | ||
return t[s] = B[e], t; | ||
const i = `${U[s]}Hex`; | ||
return t[s] = B[i], t; | ||
}, | ||
@@ -72,21 +72,21 @@ {} | ||
const V = [ | ||
i.Arbitrum, | ||
i.Avalanche, | ||
i.Binance, | ||
i.BinanceSmartChain, | ||
i.Bitcoin, | ||
i.BitcoinCash, | ||
i.Cosmos, | ||
i.Osmosis, | ||
i.Ripple, | ||
i.Dogecoin, | ||
i.Dash, | ||
i.Ethereum, | ||
i.Litecoin, | ||
i.Optimism, | ||
i.Polygon, | ||
i.THORChain | ||
e.Arbitrum, | ||
e.Avalanche, | ||
e.Binance, | ||
e.BinanceSmartChain, | ||
e.Bitcoin, | ||
e.BitcoinCash, | ||
e.Cosmos, | ||
e.Osmosis, | ||
e.Ripple, | ||
e.Dogecoin, | ||
e.Dash, | ||
e.Ethereum, | ||
e.Litecoin, | ||
e.Optimism, | ||
e.Polygon, | ||
e.THORChain | ||
]; | ||
i.Cosmos, i.Arbitrum, i.Base, i.Avalanche, i.Binance, i.BinanceSmartChain, i.Bitcoin, i.BitcoinCash, i.Cosmos, i.Dogecoin, i.Ethereum, i.Litecoin, i.Optimism, i.Polygon, i.THORChain, i.Bitcoin, i.BitcoinCash, i.Litecoin, i.Dogecoin, i.Ethereum, i.Arbitrum, i.Avalanche, i.Base, i.Binance, i.BinanceSmartChain, i.Bitcoin, i.BitcoinCash, i.Cosmos, i.Osmosis, i.Ripple, i.Dogecoin, i.Dash, i.Mayachain, i.Ethereum, i.Litecoin, i.Optimism, i.Polygon, i.THORChain, i.Arbitrum, i.Avalanche, i.BinanceSmartChain, i.Bitcoin, i.BitcoinCash, i.Cosmos, i.Dogecoin, i.Ethereum, i.Litecoin, i.Optimism, i.Polygon, i.THORChain, i.Arbitrum, i.Avalanche, i.Binance, i.BinanceSmartChain, i.Bitcoin, i.BitcoinCash, i.Cosmos, i.Ripple, i.Dogecoin, i.Ethereum, i.Litecoin, i.Optimism, i.Polygon, i.THORChain, i.Ethereum, i.Binance, i.BinanceSmartChain, i.Avalanche, i.THORChain, i.Ethereum, i.Avalanche, i.BinanceSmartChain, i.Bitcoin, i.Cosmos; | ||
var d = /* @__PURE__ */ ((t) => (t[t.ROUND_DOWN = 0] = "ROUND_DOWN", t[t.ROUND_HALF_UP = 1] = "ROUND_HALF_UP", t[t.ROUND_UP = 2] = "ROUND_UP", t))(d || {}), _ = /* @__PURE__ */ ((t) => (t[t.BASE_AMOUNT = 0] = "BASE_AMOUNT", t[t.ASSET_AMOUNT = 1] = "ASSET_AMOUNT", t))(_ || {}); | ||
e.Cosmos, e.Arbitrum, e.Base, e.Avalanche, e.Binance, e.BinanceSmartChain, e.Bitcoin, e.BitcoinCash, e.Cosmos, e.Dogecoin, e.Ethereum, e.Litecoin, e.Optimism, e.Polygon, e.THORChain, e.Bitcoin, e.BitcoinCash, e.Litecoin, e.Dogecoin, e.Ethereum, e.Arbitrum, e.Avalanche, e.Base, e.Binance, e.BinanceSmartChain, e.Bitcoin, e.BitcoinCash, e.Cosmos, e.Osmosis, e.Ripple, e.Dogecoin, e.Dash, e.Mayachain, e.Ethereum, e.Litecoin, e.Optimism, e.Polygon, e.THORChain, e.Arbitrum, e.Avalanche, e.BinanceSmartChain, e.Bitcoin, e.BitcoinCash, e.Cosmos, e.Dogecoin, e.Ethereum, e.Litecoin, e.Optimism, e.Polygon, e.THORChain, e.Arbitrum, e.Avalanche, e.Binance, e.BinanceSmartChain, e.Bitcoin, e.BitcoinCash, e.Cosmos, e.Ripple, e.Dogecoin, e.Ethereum, e.Litecoin, e.Optimism, e.Polygon, e.THORChain, e.Ethereum, e.Ethereum, e.Avalanche, e.BinanceSmartChain, e.Bitcoin, e.Cosmos; | ||
var l = /* @__PURE__ */ ((t) => (t[t.ROUND_DOWN = 0] = "ROUND_DOWN", t[t.ROUND_HALF_UP = 1] = "ROUND_HALF_UP", t[t.ROUND_UP = 2] = "ROUND_UP", t))(l || {}), _ = /* @__PURE__ */ ((t) => (t[t.BASE_AMOUNT = 0] = "BASE_AMOUNT", t[t.ASSET_AMOUNT = 1] = "ASSET_AMOUNT", t))(_ || {}); | ||
const C = { | ||
@@ -110,3 +110,3 @@ 0: E.ROUND_DOWN, | ||
class r { | ||
constructor(s, e = 0, n) { | ||
constructor(s, i = 0, n) { | ||
c(this, "assetAmount"); | ||
@@ -117,3 +117,3 @@ c(this, "baseAmount"); | ||
const o = 10 ** n; | ||
e === 0 ? (this.baseAmount = new E(s), this.assetAmount = this.baseAmount.dividedBy(o)) : (this.assetAmount = new E(s), this.baseAmount = this.assetAmount.multipliedBy(o)), this.baseAmount = new E(this.baseAmount.integerValue(E.ROUND_DOWN)); | ||
i === 0 ? (this.baseAmount = new E(s), this.assetAmount = this.baseAmount.dividedBy(o)) : (this.assetAmount = new E(s), this.baseAmount = this.assetAmount.multipliedBy(o)), this.baseAmount = new E(this.baseAmount.integerValue(E.ROUND_DOWN)); | ||
} | ||
@@ -123,7 +123,7 @@ static fromMidgard(s) { | ||
} | ||
static fromBaseAmount(s, e) { | ||
return new r(s, 0, e); | ||
static fromBaseAmount(s, i) { | ||
return new r(s, 0, i); | ||
} | ||
static fromAssetAmount(s, e) { | ||
return new r(s, 1, e); | ||
static fromAssetAmount(s, i) { | ||
return new r(s, 1, i); | ||
} | ||
@@ -133,6 +133,6 @@ static fromNormalAmount(s) { | ||
} | ||
static sorter(s, e) { | ||
if (s.decimal !== e.decimal) | ||
static sorter(s, i) { | ||
if (s.decimal !== i.decimal) | ||
throw new Error("Decimal must be same"); | ||
return s.assetAmount.minus(e.assetAmount).toNumber(); | ||
return s.assetAmount.minus(i.assetAmount).toNumber(); | ||
} | ||
@@ -182,6 +182,6 @@ add(s) { | ||
} | ||
toSignificant(s = 8, e = 8, n = I, o = 0) { | ||
return this.toSignificantBigNumber(s, n, o).decimalPlaces(e).toFormat(); | ||
toSignificant(s = 8, i = 8, n = I, o = 0) { | ||
return this.toSignificantBigNumber(s, n, o).decimalPlaces(i).toFormat(); | ||
} | ||
toFixedDecimal(s = 8, e = y, n = 0) { | ||
toFixedDecimal(s = 8, i = y, n = 0) { | ||
if (!Number.isInteger(s)) | ||
@@ -191,14 +191,14 @@ throw new Error(`${s} is not an integer.`); | ||
throw new Error(`${s} is not positive.`); | ||
return E.config({ FORMAT: e }), new E(this.assetAmount.toFixed(s, C[n])).toFormat(); | ||
return E.config({ FORMAT: i }), new E(this.assetAmount.toFixed(s, C[n])).toFormat(); | ||
} | ||
toFixed(s = 8, e = I, n = 0) { | ||
return this.toFixedDecimal(s, e, n); | ||
toFixed(s = 8, i = I, n = 0) { | ||
return this.toFixedDecimal(s, i, n); | ||
} | ||
toAbbreviate(s = 2) { | ||
let e = this.assetAmount.toNumber(); | ||
let i = this.assetAmount.toNumber(); | ||
const n = ["", "K", "M", "B", "T", "Q", "Q", "s"]; | ||
let o = 0; | ||
for (; e >= 1e3; ) | ||
e /= 1e3, o++; | ||
return `${e.toFixed(s)}${o > 0 ? ` ${n[o]}` : ""}`; | ||
for (; i >= 1e3; ) | ||
i /= 1e3, o++; | ||
return `${i.toFixed(s)}${o > 0 ? ` ${n[o]}` : ""}`; | ||
} | ||
@@ -214,3 +214,3 @@ toMidgard() { | ||
} | ||
toSignificantBigNumber(s = 8, e = I, n = 0) { | ||
toSignificantBigNumber(s = 8, i = I, n = 0) { | ||
if (!Number.isInteger(s)) | ||
@@ -220,7 +220,7 @@ throw new Error(`${s} is not an integer.`); | ||
throw new Error(`${s} is not positive.`); | ||
return E.config({ FORMAT: e }), new E(this.assetAmount.toPrecision(s, C[n])); | ||
return E.config({ FORMAT: i }), new E(this.assetAmount.toPrecision(s, C[n])); | ||
} | ||
} | ||
const k = (t, s = 8, e = 0) => (E.config({ FORMAT: I }), new E(t.toFixed(s, C[e])).toFormat()), T = class T { | ||
constructor(s, e, n = !1, o) { | ||
const k = (t, s = 8, i = 0) => (E.config({ FORMAT: I }), new E(t.toFixed(s, C[i])).toFormat()), T = class T { | ||
constructor(s, i, n = !1, o) { | ||
c(this, "chain"); | ||
@@ -238,3 +238,3 @@ c(this, "symbol"); | ||
}); | ||
this.chain = s, this.symbol = e.toUpperCase(), this.ticker = o || e.toUpperCase().split("-")[0], this.type = "Broken - MIGRATION", this.name = n ? `Synth ${this.ticker}` : this.ticker, this.network = "Broken - MIGRATION", this.decimal = n ? u.THOR : u[s], this.isSynth = n, this.L1Chain = n ? i.THORChain : s; | ||
this.chain = s, this.symbol = i.toUpperCase(), this.ticker = o || i.toUpperCase().split("-")[0], this.type = "Broken - MIGRATION", this.name = n ? `Synth ${this.ticker}` : this.ticker, this.network = "Broken - MIGRATION", this.decimal = n ? u.THOR : u[s], this.isSynth = n, this.L1Chain = n ? e.THORChain : s; | ||
} | ||
@@ -245,4 +245,4 @@ static fromAssetString(s) { | ||
return null; | ||
const e = s.includes("/"), [n, ...o] = s.split(e ? "/" : "."), A = o.join("."), m = (h = A == null ? void 0 : A.split("-")) == null ? void 0 : h[0]; | ||
return n && A && m ? new T(n, A, e) : null; | ||
const i = s.includes("/"), [n, ...o] = s.split(i ? "/" : "."), A = o.join("."), m = (h = A == null ? void 0 : A.split("-")) == null ? void 0 : h[0]; | ||
return n && A && m ? new T(n, A, i) : null; | ||
} | ||
@@ -253,3 +253,3 @@ getAssetObj() { | ||
return { | ||
chain: i.THORChain, | ||
chain: e.THORChain, | ||
symbol: s, | ||
@@ -280,3 +280,3 @@ ticker: s | ||
isRUNE() { | ||
return this.eq(f(i.THORChain)); | ||
return this.eq(f(e.THORChain)); | ||
} | ||
@@ -287,3 +287,3 @@ identifier() { | ||
toSynth() { | ||
return this.isSynth ? this : new T(i.THORChain, `${this.chain}/${this.symbol}`, !0); | ||
return this.isSynth ? this : new T(e.THORChain, `${this.chain}/${this.symbol}`, !0); | ||
} | ||
@@ -298,4 +298,4 @@ }; | ||
var n, o, A; | ||
let e = s.toUpperCase(); | ||
return e.startsWith("THOR.") && ((n = e.split("THOR.")) == null ? void 0 : n[1]) !== "RUNE" && (e = (A = (o = e.split("THOR.")) == null ? void 0 : o[1]) == null ? void 0 : A.replace(".", "/")), T.fromAssetString(e); | ||
let i = s.toUpperCase(); | ||
return i.startsWith("THOR.") && ((n = i.split("THOR.")) == null ? void 0 : n[1]) !== "RUNE" && (i = (A = (o = i.split("THOR.")) == null ? void 0 : o[1]) == null ? void 0 : A.replace(".", "/")), T.fromAssetString(i); | ||
}); | ||
@@ -307,52 +307,52 @@ let S = T; | ||
switch (t) { | ||
case i.Avalanche: | ||
case i.Binance: | ||
case i.Bitcoin: | ||
case i.BitcoinCash: | ||
case i.Dogecoin: | ||
case i.Ethereum: | ||
case i.Litecoin: { | ||
const e = new S(t, t, s); | ||
return R[t] = e, e; | ||
case e.Avalanche: | ||
case e.Binance: | ||
case e.Bitcoin: | ||
case e.BitcoinCash: | ||
case e.Dogecoin: | ||
case e.Ethereum: | ||
case e.Litecoin: { | ||
const i = new S(t, t, s); | ||
return R[t] = i, i; | ||
} | ||
case i.Optimism: | ||
case i.Arbitrum: { | ||
const e = new S(t, i.Ethereum, s); | ||
return e.setDecimal(18), R[t] = e, e; | ||
case e.Optimism: | ||
case e.Arbitrum: { | ||
const i = new S(t, e.Ethereum, s); | ||
return i.setDecimal(18), R[t] = i, i; | ||
} | ||
case i.BinanceSmartChain: { | ||
const e = new S(t, i.Binance, s); | ||
return e.setDecimal(18), R[t] = e, e; | ||
case e.BinanceSmartChain: { | ||
const i = new S(t, e.Binance, s); | ||
return i.setDecimal(18), R[t] = i, i; | ||
} | ||
case i.Polygon: { | ||
const e = new S(t, t, s); | ||
return e.setDecimal(18), R[t] = e, e; | ||
case e.Polygon: { | ||
const i = new S(t, t, s); | ||
return i.setDecimal(18), R[t] = i, i; | ||
} | ||
case i.Cosmos: { | ||
const e = new S(t, "ATOM", s, "ATOM"); | ||
return R[t] = e, e; | ||
case e.Cosmos: { | ||
const i = new S(t, "ATOM", s, "ATOM"); | ||
return R[t] = i, i; | ||
} | ||
case i.THORChain: { | ||
const e = new S(i.THORChain, "RUNE", s, "RUNE"); | ||
return R[t] = e, e; | ||
case e.THORChain: { | ||
const i = new S(e.THORChain, "RUNE", s, "RUNE"); | ||
return R[t] = i, i; | ||
} | ||
case "USD": { | ||
const e = new S(i.THORChain, "USD-USD", s, "USD-USD"); | ||
return R[t] = e, e; | ||
const i = new S(e.THORChain, "USD-USD", s, "USD-USD"); | ||
return R[t] = i, i; | ||
} | ||
case "ETH_THOR": { | ||
const e = new S(i.Ethereum, F, s); | ||
return e.setDecimal(18), R[t] = e, e; | ||
const i = new S(e.Ethereum, F, s); | ||
return i.setDecimal(18), R[t] = i, i; | ||
} | ||
case "ETH_VTHOR": { | ||
const e = new S(i.Ethereum, G, s); | ||
return e.setDecimal(18), R[t] = e, e; | ||
const i = new S(e.Ethereum, G, s); | ||
return i.setDecimal(18), R[t] = i, i; | ||
} | ||
default: | ||
return new S(i.THORChain, "RUNE", s, "RUNE"); | ||
return new S(e.THORChain, "RUNE", s, "RUNE"); | ||
} | ||
}, Y = (t) => t.eq(f(t.chain)), D = (t, s) => s.find((e) => t.shallowEq(e.asset)); | ||
}, Y = (t) => t.eq(f(t.chain)), D = (t, s) => s.find((i) => t.shallowEq(i.asset)); | ||
class g extends r { | ||
constructor({ | ||
baseAsset: e, | ||
baseAsset: i, | ||
quoteAsset: n, | ||
@@ -365,5 +365,5 @@ unitPrice: o, | ||
m ? m.assetAmount : 1, | ||
e.decimal | ||
i.decimal | ||
); | ||
super(O.assetAmount, _.ASSET_AMOUNT, e.decimal); | ||
super(O.assetAmount, _.ASSET_AMOUNT, i.decimal); | ||
c(this, "baseAsset"); | ||
@@ -374,3 +374,3 @@ c(this, "quoteAsset"); | ||
c(this, "amount"); | ||
if (this.amount = O, this.baseAsset = e, this.quoteAsset = n, o !== void 0) | ||
if (this.amount = O, this.baseAsset = i, this.quoteAsset = n, o !== void 0) | ||
this.unitPrice = o, this.price = O.assetAmount.multipliedBy(o); | ||
@@ -381,10 +381,10 @@ else { | ||
if (this.unitPrice = new E(0), n) | ||
if (e.isRUNE() && !n.isRUNE()) { | ||
if (i.isRUNE() && !n.isRUNE()) { | ||
const h = D(n, A); | ||
h && (this.unitPrice = h.runePriceInAsset.assetAmount); | ||
} else if (!e.isRUNE() && n.isRUNE()) { | ||
const h = D(e, A); | ||
} else if (!i.isRUNE() && n.isRUNE()) { | ||
const h = D(i, A); | ||
h && (this.unitPrice = h.assetPriceInRune.assetAmount); | ||
} else if (!e.isRUNE() && !n.isRUNE()) { | ||
const h = D(e, A), P = D(n, A); | ||
} else if (!i.isRUNE() && !n.isRUNE()) { | ||
const h = D(i, A), P = D(n, A); | ||
h && P && (this.unitPrice = h.assetPriceInRune.div( | ||
@@ -395,7 +395,7 @@ P.assetPriceInRune | ||
this.unitPrice = new E(1); | ||
else if (e.isRUNE()) { | ||
else if (i.isRUNE()) { | ||
const h = A == null ? void 0 : A[0]; | ||
h && (this.unitPrice = h.runePriceInAsset.mul(h.assetUSDPrice).assetAmount); | ||
} else { | ||
const h = D(e, A); | ||
const h = D(i, A); | ||
h && (this.unitPrice = h.assetUSDPrice.assetAmount); | ||
@@ -412,42 +412,42 @@ } | ||
} | ||
toCurrencyFormat(e = 8, n = !0) { | ||
toCurrencyFormat(i = 8, n = !0) { | ||
var m; | ||
const o = n ? this.toAbbreviateRaw(e) : this.toFixedRaw(e); | ||
const o = n ? this.toAbbreviateRaw(i) : this.toFixedRaw(i); | ||
return !this.quoteAsset || this.quoteAsset.ticker === "USD" ? `$${o}` : `${o} ${(m = this.quoteAsset) == null ? void 0 : m.ticker}`; | ||
} | ||
toAbbreviateRaw(e = 2) { | ||
return r.fromAssetAmount(this.price, 8).toAbbreviate(e); | ||
toAbbreviateRaw(i = 2) { | ||
return r.fromAssetAmount(this.price, 8).toAbbreviate(i); | ||
} | ||
toFixedRaw(e = 8, n = I, o = d.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.price, 8).toFixed(e, n, o); | ||
toFixedRaw(i = 8, n = I, o = l.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.price, 8).toFixed(i, n, o); | ||
} | ||
toFixedInverted(e = 8, n = I, o = d.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.invert(), 8).toFixed(e, n, o); | ||
toFixedInverted(i = 8, n = I, o = l.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.invert(), 8).toFixed(i, n, o); | ||
} | ||
} | ||
class N extends r { | ||
constructor(e, n) { | ||
constructor(i, n) { | ||
super(n.assetAmount, _.ASSET_AMOUNT, n.decimal); | ||
c(this, "asset"); | ||
c(this, "amount"); | ||
this.asset = e, this.amount = new r(n.assetAmount, _.ASSET_AMOUNT, n.decimal); | ||
this.asset = i, this.amount = new r(n.assetAmount, _.ASSET_AMOUNT, n.decimal); | ||
} | ||
add(e) { | ||
if (!this.asset.shallowEq(e.asset)) | ||
add(i) { | ||
if (!this.asset.shallowEq(i.asset)) | ||
throw new Error("asset must be same"); | ||
return new N(this.asset, this.amount.add(e.amount)); | ||
return new N(this.asset, this.amount.add(i.amount)); | ||
} | ||
sub(e) { | ||
if (!this.asset.shallowEq(e.asset)) | ||
sub(i) { | ||
if (!this.asset.shallowEq(i.asset)) | ||
throw new Error("asset must be same"); | ||
return new N(this.asset, this.amount.sub(e.amount)); | ||
return new N(this.asset, this.amount.sub(i.amount)); | ||
} | ||
mul(e) { | ||
mul(i) { | ||
let n; | ||
return e instanceof r ? n = new r( | ||
this.assetAmount.multipliedBy(e.assetAmount), | ||
return i instanceof r ? n = new r( | ||
this.assetAmount.multipliedBy(i.assetAmount), | ||
_.ASSET_AMOUNT, | ||
this.decimal | ||
) : n = new r( | ||
this.assetAmount.multipliedBy(e), | ||
this.assetAmount.multipliedBy(i), | ||
_.ASSET_AMOUNT, | ||
@@ -457,12 +457,12 @@ this.decimal | ||
} | ||
div(e) { | ||
div(i) { | ||
let n; | ||
return e instanceof r ? n = new r( | ||
this.assetAmount.dividedBy(e.assetAmount), | ||
return i instanceof r ? n = new r( | ||
this.assetAmount.dividedBy(i.assetAmount), | ||
_.ASSET_AMOUNT, | ||
this.decimal | ||
) : n = new r(this.assetAmount.dividedBy(e), _.ASSET_AMOUNT, this.decimal), new N(this.asset, n); | ||
) : n = new r(this.assetAmount.dividedBy(i), _.ASSET_AMOUNT, this.decimal), new N(this.asset, n); | ||
} | ||
toCurrencyFormat({ | ||
significantDigits: e, | ||
significantDigits: i, | ||
format: n, | ||
@@ -473,11 +473,11 @@ rounding: o | ||
format: I, | ||
rounding: d.ROUND_DOWN | ||
rounding: l.ROUND_DOWN | ||
}, A = !1) { | ||
const m = super.toSignificant(e, 8, n, o); | ||
const m = super.toSignificant(i, 8, n, o); | ||
return A ? `${this.asset.ticker} ${m}` : `${m} ${this.asset.ticker}`; | ||
} | ||
totalPriceIn(e, n) { | ||
totalPriceIn(i, n) { | ||
return new g({ | ||
baseAsset: this.asset, | ||
quoteAsset: e, | ||
quoteAsset: i, | ||
pools: n, | ||
@@ -489,19 +489,19 @@ priceAmount: r.fromAssetAmount(this.assetAmount, this.decimal) | ||
const q = (t) => { | ||
const s = f(t), e = [i.Bitcoin, i.Litecoin, i.BitcoinCash].includes(t) ? ( | ||
const s = f(t), i = [e.Bitcoin, e.Litecoin, e.BitcoinCash].includes(t) ? ( | ||
// 10001 satoshi | ||
10001 | ||
) : [i.Dogecoin].includes(t) ? ( | ||
) : [e.Dogecoin].includes(t) ? ( | ||
// 1 DOGE | ||
100000001 | ||
) : [i.Avalanche, i.Ethereum, i.BinanceSmartChain].includes(t) ? ( | ||
) : [e.Avalanche, e.Ethereum, e.BinanceSmartChain].includes(t) ? ( | ||
// 10 gwei | ||
10 * 10 ** 9 | ||
) : t === i.THORChain ? ( | ||
) : t === e.THORChain ? ( | ||
// 0 RUNE | ||
0 | ||
) : 1; | ||
return new N(s, r.fromBaseAmount(e, s.decimal)); | ||
return new N(s, r.fromBaseAmount(i, s.decimal)); | ||
}; | ||
class M { | ||
constructor(s, e, n, o) { | ||
constructor(s, i, n, o) { | ||
c(this, "asset"); | ||
@@ -512,6 +512,6 @@ c(this, "runeDepth"); | ||
c(this, "detail"); | ||
this.asset = s, this.runeDepth = e, this.assetDepth = n, this.detail = o, this.assetUSDPrice = r.fromAssetAmount(o.assetPriceUSD, u.THOR); | ||
this.asset = s, this.runeDepth = i, this.assetDepth = n, this.detail = o, this.assetUSDPrice = r.fromAssetAmount(o.assetPriceUSD, u.THOR); | ||
} | ||
static fromPoolData(s) { | ||
const { asset: e, runeDepth: n, assetDepth: o } = s, A = S.fromAssetString(e); | ||
const { asset: i, runeDepth: n, assetDepth: o } = s, A = S.fromAssetString(i); | ||
if (A && n && o) { | ||
@@ -539,3 +539,3 @@ const m = r.fromBaseAmount(n, u.THOR), O = r.fromBaseAmount(o, u.THOR); | ||
g as Price, | ||
d as Rounding, | ||
l as Rounding, | ||
k as formatBigNumber, | ||
@@ -542,0 +542,0 @@ q as getMinAmountByChain, |
@@ -5,3 +5,3 @@ { | ||
"tiny-invariant": "1.3.1", | ||
"@coinmasters/types": "4.7.3" | ||
"@coinmasters/types": "4.7.4" | ||
}, | ||
@@ -14,3 +14,3 @@ "description": "SwapKit Lib swapkit-entities", | ||
"vitest": "0.34.6", | ||
"@internal/config": "2.7.3" | ||
"@internal/config": "2.7.4" | ||
}, | ||
@@ -46,3 +46,3 @@ "eslintConfig": { | ||
"types": "./dist/index.d.ts", | ||
"version": "3.7.3", | ||
"version": "3.7.4", | ||
"scripts": { | ||
@@ -49,0 +49,0 @@ "build": "vite build", |
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
99564
+ Added@coinmasters/types@4.7.4(transitive)
- Removed@coinmasters/types@4.7.3(transitive)
Updated@coinmasters/types@4.7.4