@coinmasters/swapkit-entities
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -1,11 +0,11 @@ | ||
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 A = (t, s, i) => (L(t, typeof s != "symbol" ? s + "" : s, i), i); | ||
var w = Object.defineProperty; | ||
var H = (t, s, i) => s in t ? w(t, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[s] = i; | ||
var A = (t, s, i) => (H(t, typeof s != "symbol" ? s + "" : s, i), i); | ||
import { BigNumber as S } from "bignumber.js"; | ||
var n = /* @__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))(n || {}); | ||
n.INVALID_INPUT_PARAMETERS + "", n.UNKNOWN_PROVIDERS + "", n.CANNOT_FIND_INBOUND_ADDRESS + "", n.NO_INBOUND_ADDRESSES + "", n.CHAIN_HALTED_OR_UNSUPPORTED + "", n.MISSING_INPUT_PARAMETER + "", n.INVALID_TYPE_GENERIC + "", n.INVALID_NUMBER_STRING + "", n.INVALID_NUMBER + "", n.INVALID_BOOLEAN + "", n.INVALID_OBJECT + "", n.INVALID_ARRAY + "", n.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", n.SELL_BUY_ASSETS_ARE_THE_SAME + "", n.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", n.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", n.AFF_ADDRESS_TOO_LONG + "", n.AFF_BPS_INTEGER_0_100 + "", n.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", n.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", n.PREFERRED_PROFVIDER_NOT_SUPPORTED + "", n.DESTINATION_ADDRESS_SMART_CONTRACT + "", n.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", n.INVALID_PROVIDER + "", n.MISSING_CROSS_CHAIN_PROVIDER + "", n.MISSING_AVAX_PROVIDER + "", n.MISSING_BSC_PROVIDER + "", n.MISSING_ETH_PROVIDER + "", n.MISSING_ARB_PROVIDER + "", n.INVALID_PROVIDER_FOR_SWAP_OUT + "", n.INVALID_CHAIN + "", n.INVALID_ASSET + "", n.UNSUPPORTED_CHAIN + "", n.UNSUPPORTED_ASSET + "", n.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", n.THORNODE_QUOTE_GENERIC_ERROR + "", n.INVALID_SOURCE_ADDRESS + "", n.INVALID_DESTINATION_ADDRESS + "", n.NOT_ENOUGH_SYNTH_BALANCE + "", n.SYNTH_MINTING_CAP_REACHED + "", n.INVALID_QUOTE_MODE + "", n.NO_QUOTES + "", n.SERVICE_UNAVAILABLE_GENERIC + "", n.MISSING_GAS_DATA_GENERIC + "", n.MISSING_TOKEN_INFO_GENERIC + "", n.CANT_FIND_TOKEN_LIST + "", n.NO_PRICE + "", n.PRICE_IS_STALE + "", n.ADDRESS_NOT_WHITELISTED + "", n.ADDRESS_ALREADY_CLAIMED + ""; | ||
var a = /* @__PURE__ */ ((t) => (t.Arbitrum = "ARB", t.Avalanche = "AVAX", t.Binance = "BNB", t.BinanceSmartChain = "BSC", t.Bitcoin = "BTC", t.BitcoinCash = "BCH", t.Cosmos = "GAIA", t.Dash = "DASH", t.Dogecoin = "DOGE", t.Ethereum = "ETH", t.Kujira = "KUJI", t.Litecoin = "LTC", t.Maya = "MAYA", t.Optimism = "OP", t.Polygon = "MATIC", t.THORChain = "THOR", t))(a || {}), 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.DOGE = 8] = "DOGE", t[t.ETH = 18] = "ETH", 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.THOR = 8] = "THOR", t))(u || {}), l = /* @__PURE__ */ ((t) => (t.Arbitrum = "42161", t.ArbitrumHex = "0xa4b1", t.Avalanche = "43114", t.AvalancheHex = "0xa86a", 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.Maya = "mayachain-mainnet-v1", t.MayaStagenet = "mayachain-stagenet-v1", t.Optimism = "10", t.OptimismHex = "0xa", t.Polygon = "137", t.PolygonHex = "0x89", t.THORChain = "thorchain-mainnet-v1", t.THORChainStagenet = "thorchain-stagenet-v2", t))(l || {}), P = /* @__PURE__ */ ((t) => (t.Arbitrum = "https://arb1.arbitrum.io/rpc", t.Avalanche = "https://node-router.thorswap.net/avalanche-c", t.Binance = "", t.BinanceSmartChain = "https://bsc-dataseed.binance.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 = "todo", t.Dogecoin = "https://node-router.thorswap.net/dogecoin", t.Ethereum = "https://node-router.thorswap.net/ethereum", t.Litecoin = "https://node-router.thorswap.net/litecoin", t.Maya = "https://tendermint.mayachain.info", t.MayaStagenet = "https://stagenet.tendermint.mayachain.info", t.Optimism = "https://mainnet.optimism.io", t.Polygon = "https://polygon-rpc.com", t.THORChain = "https://rpc.thorswap.net", t.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", t))(P || {}); | ||
const U = Object.values(a), w = Object.keys(a), p = U.reduce( | ||
var a = /* @__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.Maya = "MAYA", t.Optimism = "OP", t.Polygon = "MATIC", t.Ripple = "XRP", t.THORChain = "THOR", t.Zcash = "ZEC", t))(a || {}), N = /* @__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.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.XRP = 6] = "XRP", t[t.THOR = 8] = "THOR", t[t.ZEC = 8] = "ZEC", t))(N || {}), U = /* @__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.Maya = "mayachain-mainnet-v1", t.MayaStagenet = "mayachain-stagenet-v1", t.Optimism = "10", t.OptimismHex = "0xa", t.Polygon = "137", t.PolygonHex = "0x89", t.THORChain = "thorchain-mainnet-v1", t.THORChainStagenet = "thorchain-stagenet-v2", t))(U || {}), P = /* @__PURE__ */ ((t) => (t.Arbitrum = "https://arb1.arbitrum.io/rpc", t.Avalanche = "https://node-router.thorswap.net/avalanche-c", t.Binance = "https://base.llamarpc.com", t.BinanceSmartChain = "https://bsc-dataseed.binance.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://node-router.thorswap.net/ethereum", t.Litecoin = "https://node-router.thorswap.net/litecoin", t.Maya = "https://tendermint.mayachain.info", t.MayaStagenet = "https://stagenet.tendermint.mayachain.info", t.Optimism = "https://mainnet.optimism.io", t.Polygon = "https://polygon-rpc.com", t.THORChain = "https://rpc.thorswap.net", t.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", t))(P || {}); | ||
const l = Object.values(a), L = Object.keys(a), C = l.reduce( | ||
(t, s) => { | ||
const i = w.find((e) => a[e] === s); | ||
const i = L.find((e) => a[e] === s); | ||
return i && (t[s] = i), t; | ||
@@ -15,20 +15,19 @@ }, | ||
); | ||
U.reduce( | ||
(t, s) => (t[s] = l[p[s]], t), | ||
l.reduce( | ||
(t, s) => (t[s] = U[C[s]], t), | ||
{} | ||
); | ||
U.reduce( | ||
(t, s) => (t[s] = P[p[s]], t), | ||
l.reduce( | ||
(t, s) => (t[s] = P[C[s]], t), | ||
{} | ||
); | ||
U.reduce( | ||
l.reduce( | ||
(t, s) => { | ||
const i = `${p[s]}Hex`; | ||
return t[s] = l[i], t; | ||
const i = `${C[s]}Hex`; | ||
return t[s] = U[i], t; | ||
}, | ||
{} | ||
); | ||
l.Dash + ""; | ||
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 || {}), N = /* @__PURE__ */ ((t) => (t[t.BASE_AMOUNT = 0] = "BASE_AMOUNT", t[t.ASSET_AMOUNT = 1] = "ASSET_AMOUNT", t))(N || {}); | ||
const C = { | ||
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 || {}), I = /* @__PURE__ */ ((t) => (t[t.BASE_AMOUNT = 0] = "BASE_AMOUNT", t[t.ASSET_AMOUNT = 1] = "ASSET_AMOUNT", t))(I || {}); | ||
const p = { | ||
0: S.ROUND_DOWN, | ||
@@ -40,3 +39,3 @@ 1: S.ROUND_HALF_UP, | ||
decimalSeparator: "." | ||
}, T = { | ||
}, O = { | ||
prefix: "", | ||
@@ -61,3 +60,3 @@ decimalSeparator: ".", | ||
static fromMidgard(s) { | ||
return new r(s || 0, 0, u.THOR); | ||
return new r(s || 0, 0, N.THOR); | ||
} | ||
@@ -121,3 +120,3 @@ static fromBaseAmount(s, i) { | ||
} | ||
toSignificant(s = 8, i = 8, e = T, o = 0) { | ||
toSignificant(s = 8, i = 8, e = O, o = 0) { | ||
return this.toSignificantBigNumber(s, e, o).decimalPlaces(i).toFormat(); | ||
@@ -130,5 +129,5 @@ } | ||
throw new Error(`${s} is not positive.`); | ||
return S.config({ FORMAT: i }), new S(this.assetAmount.toFixed(s, C[e])).toFormat(); | ||
return S.config({ FORMAT: i }), new S(this.assetAmount.toFixed(s, p[e])).toFormat(); | ||
} | ||
toFixed(s = 8, i = T, e = 0) { | ||
toFixed(s = 8, i = O, e = 0) { | ||
return this.toFixedDecimal(s, i, e); | ||
@@ -147,9 +146,9 @@ } | ||
new S( | ||
this.baseAmount.dividedBy(10 ** this.decimal).multipliedBy(10 ** u.THOR).toFixed() | ||
this.baseAmount.dividedBy(10 ** this.decimal).multipliedBy(10 ** N.THOR).toFixed() | ||
), | ||
0, | ||
u.THOR | ||
N.THOR | ||
); | ||
} | ||
toSignificantBigNumber(s = 8, i = T, e = 0) { | ||
toSignificantBigNumber(s = 8, i = O, e = 0) { | ||
if (!Number.isInteger(s)) | ||
@@ -159,6 +158,6 @@ throw new Error(`${s} is not an integer.`); | ||
throw new Error(`${s} is not positive.`); | ||
return S.config({ FORMAT: i }), new S(this.assetAmount.toPrecision(s, C[e])); | ||
return S.config({ FORMAT: i }), new S(this.assetAmount.toPrecision(s, p[e])); | ||
} | ||
} | ||
const g = (t, s = 8, i = 0) => (S.config({ FORMAT: T }), new S(t.toFixed(s, C[i])).toFormat()), m = class m { | ||
const g = (t, s = 8, i = 0) => (S.config({ FORMAT: O }), new S(t.toFixed(s, p[i])).toFormat()), T = class T { | ||
constructor(s, i, e = !1, o) { | ||
@@ -175,5 +174,5 @@ A(this, "chain"); | ||
A(this, "setDecimal", (s) => { | ||
this.decimal = s || u[this.chain] || u.THOR; | ||
this.decimal = s || N[this.chain] || N.THOR; | ||
}); | ||
this.chain = s, this.symbol = i.toUpperCase(), this.ticker = o || i.toUpperCase().split("-")[0], this.type = "Broken - MIGRATION", this.name = e ? `Synth ${this.ticker}` : this.ticker, this.network = "Broken - MIGRATION", this.decimal = e ? u.THOR : u[s], this.isSynth = e, this.L1Chain = e ? a.THORChain : s; | ||
this.chain = s, this.symbol = i.toUpperCase(), this.ticker = o || i.toUpperCase().split("-")[0], this.type = "Broken - MIGRATION", this.name = e ? `Synth ${this.ticker}` : this.ticker, this.network = "Broken - MIGRATION", this.decimal = e ? N.THOR : N[s], this.isSynth = e, this.L1Chain = e ? a.THORChain : s; | ||
} | ||
@@ -185,3 +184,3 @@ static fromAssetString(s) { | ||
const i = s.includes("/"), [e, ...o] = s.split(i ? "/" : "."), c = o.join("."), _ = (h = c == null ? void 0 : c.split("-")) == null ? void 0 : h[0]; | ||
return e && c && _ ? new m(e, c, i) : null; | ||
return e && c && _ ? new T(e, c, i) : null; | ||
} | ||
@@ -224,3 +223,3 @@ getAssetObj() { | ||
toSynth() { | ||
return this.isSynth ? this : new m(a.THORChain, `${this.chain}/${this.symbol}`, !0); | ||
return this.isSynth ? this : new T(a.THORChain, `${this.chain}/${this.symbol}`, !0); | ||
} | ||
@@ -233,11 +232,11 @@ }; | ||
*/ | ||
A(m, "decodeFromURL", (s) => { | ||
A(T, "decodeFromURL", (s) => { | ||
var e, o, c; | ||
let i = s.toUpperCase(); | ||
return i.startsWith("THOR.") && ((e = i.split("THOR.")) == null ? void 0 : e[1]) !== "RUNE" && (i = (c = (o = i.split("THOR.")) == null ? void 0 : o[1]) == null ? void 0 : c.replace(".", "/")), m.fromAssetString(i); | ||
return i.startsWith("THOR.") && ((e = i.split("THOR.")) == null ? void 0 : e[1]) !== "RUNE" && (i = (c = (o = i.split("THOR.")) == null ? void 0 : o[1]) == null ? void 0 : c.replace(".", "/")), T.fromAssetString(i); | ||
}); | ||
let E = m; | ||
const V = "THOR-0xa5f2211B9b8170F694421f2046281775E8468044", v = "VTHOR-0x815C23eCA83261b6Ec689b60Cc4a58b54BC24D8D", I = {}, B = (t, s = !1) => { | ||
if (I[t]) | ||
return I[t]; | ||
let E = T; | ||
const V = "THOR-0xa5f2211B9b8170F694421f2046281775E8468044", v = "VTHOR-0x815C23eCA83261b6Ec689b60Cc4a58b54BC24D8D", u = {}, B = (t, s = !1) => { | ||
if (u[t]) | ||
return u[t]; | ||
switch (t) { | ||
@@ -252,3 +251,3 @@ case a.Avalanche: | ||
const i = new E(t, t, s); | ||
return I[t] = i, i; | ||
return u[t] = i, i; | ||
} | ||
@@ -258,31 +257,31 @@ case a.Optimism: | ||
const i = new E(t, a.Ethereum, s); | ||
return i.setDecimal(18), I[t] = i, i; | ||
return i.setDecimal(18), u[t] = i, i; | ||
} | ||
case a.BinanceSmartChain: { | ||
const i = new E(t, a.Binance, s); | ||
return i.setDecimal(18), I[t] = i, i; | ||
return i.setDecimal(18), u[t] = i, i; | ||
} | ||
case a.Polygon: { | ||
const i = new E(t, t, s); | ||
return i.setDecimal(18), I[t] = i, i; | ||
return i.setDecimal(18), u[t] = i, i; | ||
} | ||
case a.Cosmos: { | ||
const i = new E(t, "ATOM", s, "ATOM"); | ||
return I[t] = i, i; | ||
return u[t] = i, i; | ||
} | ||
case a.THORChain: { | ||
const i = new E(a.THORChain, "RUNE", s, "RUNE"); | ||
return I[t] = i, i; | ||
return u[t] = i, i; | ||
} | ||
case "USD": { | ||
const i = new E(a.THORChain, "USD-USD", s, "USD-USD"); | ||
return I[t] = i, i; | ||
return u[t] = i, i; | ||
} | ||
case "ETH_THOR": { | ||
const i = new E(a.Ethereum, V, s); | ||
return i.setDecimal(18), I[t] = i, i; | ||
return i.setDecimal(18), u[t] = i, i; | ||
} | ||
case "ETH_VTHOR": { | ||
const i = new E(a.Ethereum, v, s); | ||
return i.setDecimal(18), I[t] = i, i; | ||
return i.setDecimal(18), u[t] = i, i; | ||
} | ||
@@ -293,3 +292,3 @@ default: | ||
}, x = (t) => t.eq(B(t.chain)), D = (t, s) => s.find((i) => t.shallowEq(i.asset)); | ||
class y extends r { | ||
class G extends r { | ||
constructor({ | ||
@@ -306,3 +305,3 @@ baseAsset: i, | ||
); | ||
super(R.assetAmount, N.ASSET_AMOUNT, i.decimal); | ||
super(R.assetAmount, I.ASSET_AMOUNT, i.decimal); | ||
A(this, "baseAsset"); | ||
@@ -356,15 +355,15 @@ A(this, "quoteAsset"); | ||
} | ||
toFixedRaw(i = 8, e = T, o = d.ROUND_DOWN) { | ||
toFixedRaw(i = 8, e = O, o = d.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.price, 8).toFixed(i, e, o); | ||
} | ||
toFixedInverted(i = 8, e = T, o = d.ROUND_DOWN) { | ||
toFixedInverted(i = 8, e = O, o = d.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.invert(), 8).toFixed(i, e, o); | ||
} | ||
} | ||
class O extends r { | ||
class m extends r { | ||
constructor(i, e) { | ||
super(e.assetAmount, N.ASSET_AMOUNT, e.decimal); | ||
super(e.assetAmount, I.ASSET_AMOUNT, e.decimal); | ||
A(this, "asset"); | ||
A(this, "amount"); | ||
this.asset = i, this.amount = new r(e.assetAmount, N.ASSET_AMOUNT, e.decimal); | ||
this.asset = i, this.amount = new r(e.assetAmount, I.ASSET_AMOUNT, e.decimal); | ||
} | ||
@@ -374,3 +373,3 @@ add(i) { | ||
throw new Error("asset must be same"); | ||
return new O(this.asset, this.amount.add(i.amount)); | ||
return new m(this.asset, this.amount.add(i.amount)); | ||
} | ||
@@ -380,3 +379,3 @@ sub(i) { | ||
throw new Error("asset must be same"); | ||
return new O(this.asset, this.amount.sub(i.amount)); | ||
return new m(this.asset, this.amount.sub(i.amount)); | ||
} | ||
@@ -387,9 +386,9 @@ mul(i) { | ||
this.assetAmount.multipliedBy(i.assetAmount), | ||
N.ASSET_AMOUNT, | ||
I.ASSET_AMOUNT, | ||
this.decimal | ||
) : e = new r( | ||
this.assetAmount.multipliedBy(i), | ||
N.ASSET_AMOUNT, | ||
I.ASSET_AMOUNT, | ||
this.decimal | ||
), new O(this.asset, e); | ||
), new m(this.asset, e); | ||
} | ||
@@ -400,5 +399,5 @@ div(i) { | ||
this.assetAmount.dividedBy(i.assetAmount), | ||
N.ASSET_AMOUNT, | ||
I.ASSET_AMOUNT, | ||
this.decimal | ||
) : e = new r(this.assetAmount.dividedBy(i), N.ASSET_AMOUNT, this.decimal), new O(this.asset, e); | ||
) : e = new r(this.assetAmount.dividedBy(i), I.ASSET_AMOUNT, this.decimal), new m(this.asset, e); | ||
} | ||
@@ -411,3 +410,3 @@ toCurrencyFormat({ | ||
significantDigits: 6, | ||
format: T, | ||
format: O, | ||
rounding: d.ROUND_DOWN | ||
@@ -419,3 +418,3 @@ }, c = !1) { | ||
totalPriceIn(i, e) { | ||
return new y({ | ||
return new G({ | ||
baseAsset: this.asset, | ||
@@ -442,3 +441,3 @@ quoteAsset: i, | ||
) : 1; | ||
return new O(s, r.fromBaseAmount(i, s.decimal)); | ||
return new m(s, r.fromBaseAmount(i, s.decimal)); | ||
}; | ||
@@ -452,3 +451,3 @@ class M { | ||
A(this, "detail"); | ||
this.asset = s, this.runeDepth = i, this.assetDepth = e, this.detail = o, this.assetUSDPrice = r.fromAssetAmount(o.assetPriceUSD, u.THOR); | ||
this.asset = s, this.runeDepth = i, this.assetDepth = e, this.detail = o, this.assetUSDPrice = r.fromAssetAmount(o.assetPriceUSD, N.THOR); | ||
} | ||
@@ -458,3 +457,3 @@ static fromPoolData(s) { | ||
if (c && e && o) { | ||
const _ = r.fromBaseAmount(e, u.THOR), R = r.fromBaseAmount(o, u.THOR); | ||
const _ = r.fromBaseAmount(e, N.THOR), R = r.fromBaseAmount(o, N.THOR); | ||
return new M(c, _, R, s); | ||
@@ -473,9 +472,9 @@ } | ||
r as Amount, | ||
N as AmountType, | ||
O as AssetAmount, | ||
I as AmountType, | ||
m as AssetAmount, | ||
E as AssetEntity, | ||
T as BN_FORMAT, | ||
O as BN_FORMAT, | ||
b as EMPTY_FORMAT, | ||
M as Pool, | ||
y as Price, | ||
G as Price, | ||
d as Rounding, | ||
@@ -482,0 +481,0 @@ g as formatBigNumber, |
@@ -5,3 +5,3 @@ { | ||
"tiny-invariant": "1.3.1", | ||
"@coinmasters/types": "3.0.0" | ||
"@coinmasters/types": "4.0.0" | ||
}, | ||
@@ -45,3 +45,3 @@ "description": "SwapKit Lib swapkit-entities", | ||
"types": "./dist/index.d.ts", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"scripts": { | ||
@@ -48,0 +48,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
93170
+ Added@coinmasters/types@4.0.0(transitive)
- Removed@coinmasters/types@3.0.0(transitive)
Updated@coinmasters/types@4.0.0