@coinmasters/swapkit-entities
Advanced tools
Comparing version 3.7.7 to 3.7.8
@@ -5,4 +5,4 @@ var H = Object.defineProperty; | ||
import { BigNumber as E } from "bignumber.js"; | ||
var r = /* @__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))(r || {}); | ||
r.INVALID_INPUT_PARAMETERS + "", r.UNKNOWN_PROVIDERS + "", r.CANNOT_FIND_INBOUND_ADDRESS + "", r.NO_INBOUND_ADDRESSES + "", r.CHAIN_HALTED_OR_UNSUPPORTED + "", r.MISSING_INPUT_PARAMETER + "", r.INVALID_TYPE_GENERIC + "", r.INVALID_NUMBER_STRING + "", r.INVALID_NUMBER + "", r.INVALID_BOOLEAN + "", r.INVALID_OBJECT + "", r.INVALID_ARRAY + "", r.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", r.SELL_BUY_ASSETS_ARE_THE_SAME + "", r.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", r.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", r.AFF_ADDRESS_TOO_LONG + "", r.AFF_BPS_INTEGER_0_100 + "", r.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", r.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", r.PREFERRED_PROFVIDER_NOT_SUPPORTED + "", r.DESTINATION_ADDRESS_SMART_CONTRACT + "", r.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", r.INVALID_PROVIDER + "", r.MISSING_CROSS_CHAIN_PROVIDER + "", r.MISSING_AVAX_PROVIDER + "", r.MISSING_BSC_PROVIDER + "", r.MISSING_ETH_PROVIDER + "", r.MISSING_ARB_PROVIDER + "", r.INVALID_PROVIDER_FOR_SWAP_OUT + "", r.INVALID_CHAIN + "", r.INVALID_ASSET + "", r.UNSUPPORTED_CHAIN + "", r.UNSUPPORTED_ASSET + "", r.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", r.THORNODE_QUOTE_GENERIC_ERROR + "", r.INVALID_SOURCE_ADDRESS + "", r.INVALID_DESTINATION_ADDRESS + "", r.NOT_ENOUGH_SYNTH_BALANCE + "", r.SYNTH_MINTING_CAP_REACHED + "", r.INVALID_QUOTE_MODE + "", r.NO_QUOTES + "", r.SERVICE_UNAVAILABLE_GENERIC + "", r.MISSING_GAS_DATA_GENERIC + "", r.MISSING_TOKEN_INFO_GENERIC + "", r.CANT_FIND_TOKEN_LIST + "", r.NO_PRICE + "", r.PRICE_IS_STALE + "", r.ADDRESS_NOT_WHITELISTED + "", r.ADDRESS_ALREADY_CLAIMED + ""; | ||
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 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 || {}); | ||
@@ -35,3 +35,3 @@ const w = { | ||
w[e[t]], e[t]; | ||
var _ = /* @__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))(_ || {}); | ||
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 d = [ | ||
@@ -88,15 +88,4 @@ "ETH" | ||
]; | ||
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, // Chain.Arbitrum, | ||
// Chain.Avalanche, | ||
e.Base, // Chain.Binance, | ||
// Chain.BinanceSmartChain, | ||
e.Bitcoin, // Chain.BitcoinCash, | ||
// Chain.Cosmos, | ||
// Chain.Osmosis, | ||
// Chain.Ripple, | ||
// Chain.Dogecoin, | ||
// Chain.Dash, | ||
// Chain.Mayachain, | ||
e.Ethereum, 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 || {}), u = /* @__PURE__ */ ((t) => (t[t.BASE_AMOUNT = 0] = "BASE_AMOUNT", t[t.ASSET_AMOUNT = 1] = "ASSET_AMOUNT", t))(u || {}); | ||
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 = { | ||
@@ -109,3 +98,3 @@ 0: E.ROUND_DOWN, | ||
decimalSeparator: "." | ||
}, N = { | ||
}, I = { | ||
prefix: "", | ||
@@ -120,3 +109,3 @@ decimalSeparator: ".", | ||
}; | ||
class a { | ||
class r { | ||
constructor(s, i = 0, n) { | ||
@@ -131,12 +120,12 @@ c(this, "assetAmount"); | ||
static fromMidgard(s) { | ||
return new a(s || 0, 0, _.THOR); | ||
return new r(s || 0, 0, u.THOR); | ||
} | ||
static fromBaseAmount(s, i) { | ||
return new a(s, 0, i); | ||
return new r(s, 0, i); | ||
} | ||
static fromAssetAmount(s, i) { | ||
return new a(s, 1, i); | ||
return new r(s, 1, i); | ||
} | ||
static fromNormalAmount(s) { | ||
return new a(s || 0, 1, 1); | ||
return new r(s || 0, 1, 1); | ||
} | ||
@@ -149,3 +138,3 @@ static sorter(s, i) { | ||
add(s) { | ||
return new a( | ||
return new r( | ||
this.assetAmount.plus(s.assetAmount), | ||
@@ -157,3 +146,3 @@ 1, | ||
sub(s) { | ||
return new a( | ||
return new r( | ||
this.assetAmount.minus(s.assetAmount), | ||
@@ -165,31 +154,31 @@ 1, | ||
mul(s) { | ||
return s instanceof a ? new a( | ||
return s instanceof r ? new r( | ||
this.assetAmount.multipliedBy(s.assetAmount), | ||
1, | ||
this.decimal | ||
) : new a(this.assetAmount.multipliedBy(s), 1, this.decimal); | ||
) : new r(this.assetAmount.multipliedBy(s), 1, this.decimal); | ||
} | ||
div(s) { | ||
return s instanceof a ? new a( | ||
return s instanceof r ? new r( | ||
this.assetAmount.dividedBy(s.assetAmount), | ||
1, | ||
this.decimal | ||
) : new a(this.assetAmount.dividedBy(s), 1, this.decimal); | ||
) : new r(this.assetAmount.dividedBy(s), 1, this.decimal); | ||
} | ||
gte(s) { | ||
return s instanceof a ? this.assetAmount.isGreaterThanOrEqualTo(s.assetAmount) : this.assetAmount.isGreaterThanOrEqualTo(s); | ||
return s instanceof r ? this.assetAmount.isGreaterThanOrEqualTo(s.assetAmount) : this.assetAmount.isGreaterThanOrEqualTo(s); | ||
} | ||
gt(s) { | ||
return s instanceof a ? this.assetAmount.isGreaterThan(s.assetAmount) : this.assetAmount.isGreaterThan(s); | ||
return s instanceof r ? this.assetAmount.isGreaterThan(s.assetAmount) : this.assetAmount.isGreaterThan(s); | ||
} | ||
lte(s) { | ||
return s instanceof a ? this.assetAmount.isLessThanOrEqualTo(s.assetAmount) : this.assetAmount.isLessThanOrEqualTo(s); | ||
return s instanceof r ? this.assetAmount.isLessThanOrEqualTo(s.assetAmount) : this.assetAmount.isLessThanOrEqualTo(s); | ||
} | ||
lt(s) { | ||
return s instanceof a ? this.assetAmount.isLessThan(s.assetAmount) : this.assetAmount.isLessThan(s); | ||
return s instanceof r ? this.assetAmount.isLessThan(s.assetAmount) : this.assetAmount.isLessThan(s); | ||
} | ||
eq(s) { | ||
return s instanceof a ? this.assetAmount.isEqualTo(s.assetAmount) : this.assetAmount.isEqualTo(s); | ||
return s instanceof r ? this.assetAmount.isEqualTo(s.assetAmount) : this.assetAmount.isEqualTo(s); | ||
} | ||
toSignificant(s = 8, i = 8, n = N, o = 0) { | ||
toSignificant(s = 8, i = 8, n = I, o = 0) { | ||
return this.toSignificantBigNumber(s, n, o).decimalPlaces(i).toFormat(); | ||
@@ -204,3 +193,3 @@ } | ||
} | ||
toFixed(s = 8, i = N, n = 0) { | ||
toFixed(s = 8, i = I, n = 0) { | ||
return this.toFixedDecimal(s, i, n); | ||
@@ -217,11 +206,11 @@ } | ||
toMidgard() { | ||
return new a( | ||
return new r( | ||
new E( | ||
this.baseAmount.dividedBy(10 ** this.decimal).multipliedBy(10 ** _.THOR).toFixed() | ||
this.baseAmount.dividedBy(10 ** this.decimal).multipliedBy(10 ** u.THOR).toFixed() | ||
), | ||
0, | ||
_.THOR | ||
u.THOR | ||
); | ||
} | ||
toSignificantBigNumber(s = 8, i = N, n = 0) { | ||
toSignificantBigNumber(s = 8, i = I, n = 0) { | ||
if (!Number.isInteger(s)) | ||
@@ -234,3 +223,3 @@ throw new Error(`${s} is not an integer.`); | ||
} | ||
const k = (t, s = 8, i = 0) => (E.config({ FORMAT: N }), new E(t.toFixed(s, C[i])).toFormat()), T = class T { | ||
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) { | ||
@@ -247,5 +236,5 @@ c(this, "chain"); | ||
c(this, "setDecimal", (s) => { | ||
this.decimal = s || _[this.chain] || _.THOR; | ||
this.decimal = s || u[this.chain] || u.THOR; | ||
}); | ||
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 ? _.THOR : _[s], this.isSynth = n, this.L1Chain = n ? e.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; | ||
} | ||
@@ -360,3 +349,3 @@ static fromAssetString(s) { | ||
}, Y = (t) => t.eq(f(t.chain)), D = (t, s) => s.find((i) => t.shallowEq(i.asset)); | ||
class g extends a { | ||
class g extends r { | ||
constructor({ | ||
@@ -369,7 +358,7 @@ baseAsset: i, | ||
}) { | ||
const I = a.fromAssetAmount( | ||
const O = r.fromAssetAmount( | ||
m ? m.assetAmount : 1, | ||
i.decimal | ||
); | ||
super(I.assetAmount, u.ASSET_AMOUNT, i.decimal); | ||
super(O.assetAmount, _.ASSET_AMOUNT, i.decimal); | ||
c(this, "baseAsset"); | ||
@@ -380,4 +369,4 @@ c(this, "quoteAsset"); | ||
c(this, "amount"); | ||
if (this.amount = I, this.baseAsset = i, this.quoteAsset = n, o !== void 0) | ||
this.unitPrice = o, this.price = I.assetAmount.multipliedBy(o); | ||
if (this.amount = O, this.baseAsset = i, this.quoteAsset = n, o !== void 0) | ||
this.unitPrice = o, this.price = O.assetAmount.multipliedBy(o); | ||
else { | ||
@@ -407,3 +396,3 @@ if (!A) | ||
} | ||
this.price = this.unitPrice.multipliedBy(I.assetAmount); | ||
this.price = this.unitPrice.multipliedBy(O.assetAmount); | ||
} | ||
@@ -423,17 +412,17 @@ } | ||
toAbbreviateRaw(i = 2) { | ||
return a.fromAssetAmount(this.price, 8).toAbbreviate(i); | ||
return r.fromAssetAmount(this.price, 8).toAbbreviate(i); | ||
} | ||
toFixedRaw(i = 8, n = N, o = l.ROUND_DOWN) { | ||
return a.fromAssetAmount(this.price, 8).toFixed(i, n, o); | ||
toFixedRaw(i = 8, n = I, o = l.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.price, 8).toFixed(i, n, o); | ||
} | ||
toFixedInverted(i = 8, n = N, o = l.ROUND_DOWN) { | ||
return a.fromAssetAmount(this.invert(), 8).toFixed(i, n, o); | ||
toFixedInverted(i = 8, n = I, o = l.ROUND_DOWN) { | ||
return r.fromAssetAmount(this.invert(), 8).toFixed(i, n, o); | ||
} | ||
} | ||
class O extends a { | ||
class N extends r { | ||
constructor(i, n) { | ||
super(n.assetAmount, u.ASSET_AMOUNT, n.decimal); | ||
super(n.assetAmount, _.ASSET_AMOUNT, n.decimal); | ||
c(this, "asset"); | ||
c(this, "amount"); | ||
this.asset = i, this.amount = new a(n.assetAmount, u.ASSET_AMOUNT, n.decimal); | ||
this.asset = i, this.amount = new r(n.assetAmount, _.ASSET_AMOUNT, n.decimal); | ||
} | ||
@@ -443,3 +432,3 @@ add(i) { | ||
throw new Error("asset must be same"); | ||
return new O(this.asset, this.amount.add(i.amount)); | ||
return new N(this.asset, this.amount.add(i.amount)); | ||
} | ||
@@ -449,23 +438,23 @@ sub(i) { | ||
throw new Error("asset must be same"); | ||
return new O(this.asset, this.amount.sub(i.amount)); | ||
return new N(this.asset, this.amount.sub(i.amount)); | ||
} | ||
mul(i) { | ||
let n; | ||
return i instanceof a ? n = new a( | ||
return i instanceof r ? n = new r( | ||
this.assetAmount.multipliedBy(i.assetAmount), | ||
u.ASSET_AMOUNT, | ||
_.ASSET_AMOUNT, | ||
this.decimal | ||
) : n = new a( | ||
) : n = new r( | ||
this.assetAmount.multipliedBy(i), | ||
u.ASSET_AMOUNT, | ||
_.ASSET_AMOUNT, | ||
this.decimal | ||
), new O(this.asset, n); | ||
), new N(this.asset, n); | ||
} | ||
div(i) { | ||
let n; | ||
return i instanceof a ? n = new a( | ||
return i instanceof r ? n = new r( | ||
this.assetAmount.dividedBy(i.assetAmount), | ||
u.ASSET_AMOUNT, | ||
_.ASSET_AMOUNT, | ||
this.decimal | ||
) : n = new a(this.assetAmount.dividedBy(i), u.ASSET_AMOUNT, this.decimal), new O(this.asset, n); | ||
) : n = new r(this.assetAmount.dividedBy(i), _.ASSET_AMOUNT, this.decimal), new N(this.asset, n); | ||
} | ||
@@ -478,3 +467,3 @@ toCurrencyFormat({ | ||
significantDigits: 6, | ||
format: N, | ||
format: I, | ||
rounding: l.ROUND_DOWN | ||
@@ -490,3 +479,3 @@ }, A = !1) { | ||
pools: n, | ||
priceAmount: a.fromAssetAmount(this.assetAmount, this.decimal) | ||
priceAmount: r.fromAssetAmount(this.assetAmount, this.decimal) | ||
}); | ||
@@ -509,3 +498,3 @@ } | ||
) : 1; | ||
return new O(s, a.fromBaseAmount(i, s.decimal)); | ||
return new N(s, r.fromBaseAmount(i, s.decimal)); | ||
}; | ||
@@ -519,3 +508,3 @@ class M { | ||
c(this, "detail"); | ||
this.asset = s, this.runeDepth = i, this.assetDepth = n, this.detail = o, this.assetUSDPrice = a.fromAssetAmount(o.assetPriceUSD, _.THOR); | ||
this.asset = s, this.runeDepth = i, this.assetDepth = n, this.detail = o, this.assetUSDPrice = r.fromAssetAmount(o.assetPriceUSD, u.THOR); | ||
} | ||
@@ -525,4 +514,4 @@ static fromPoolData(s) { | ||
if (A && n && o) { | ||
const m = a.fromBaseAmount(n, _.THOR), I = a.fromBaseAmount(o, _.THOR); | ||
return new M(A, m, I, s); | ||
const m = r.fromBaseAmount(n, u.THOR), O = r.fromBaseAmount(o, u.THOR); | ||
return new M(A, m, O, s); | ||
} | ||
@@ -539,7 +528,7 @@ return null; | ||
export { | ||
a as Amount, | ||
u as AmountType, | ||
O as AssetAmount, | ||
r as Amount, | ||
_ as AmountType, | ||
N as AssetAmount, | ||
S as AssetEntity, | ||
N as BN_FORMAT, | ||
I as BN_FORMAT, | ||
y as EMPTY_FORMAT, | ||
@@ -546,0 +535,0 @@ M as Pool, |
@@ -5,3 +5,3 @@ { | ||
"tiny-invariant": "1.3.1", | ||
"@coinmasters/types": "4.7.7" | ||
"@coinmasters/types": "4.7.8" | ||
}, | ||
@@ -14,3 +14,3 @@ "description": "SwapKit Lib swapkit-entities", | ||
"vitest": "0.34.6", | ||
"@internal/config": "2.7.7" | ||
"@internal/config": "2.7.8" | ||
}, | ||
@@ -46,3 +46,3 @@ "eslintConfig": { | ||
"types": "./dist/index.d.ts", | ||
"version": "3.7.7", | ||
"version": "3.7.8", | ||
"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
123372
1484
+ Added@coinmasters/types@4.7.8(transitive)
- Removed@coinmasters/types@4.7.7(transitive)
Updated@coinmasters/types@4.7.8