@swapkit/core 1.0.0-rc.35 → 1.0.0-rc.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.es.js +272 -264
- package/package.json +13 -13
- package/src/client/index.ts +21 -6
package/dist/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ var T = (e, t, n) => (Ge(e, typeof t != "symbol" ? t + "" : t, n), n), qe = (e,
|
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var f = (e, t, n) => (qe(e, t, "read from private field"), n ? n.call(e) : t.get(e)),
|
|
7
|
+
var f = (e, t, n) => (qe(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
@@ -624,58 +624,58 @@ const Qe = [
|
|
|
624
624
|
"TC-BEP20"
|
|
625
625
|
/* TC_SUPPORTED_TO_BSC */
|
|
626
626
|
];
|
|
627
|
-
var Se = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(Se || {}), et = /* @__PURE__ */ ((e) => (e.HEALTH_CONTROLLER = "1000", e.LIQUIDITY_CONTROLLER = "1001", e.PROVIDER_CONTROLLER = "1002", e.QUOTE_CONTROLLER = "1003", e.SWAP_CONTROLLER = "1004", e.UTIL_CONTROLLER = "1005", e.AIRDROP_CONTROLLER = "1006", e.PROVIDER = "2000", e.ASSET = "2001", e.TOKEN_LIST = "2002", e.QUOTE = "2100", e.QUOTE_TXN_DETAILS = "2101", e.THORCHAIN_PROVIDER = "3000", e.UNISWAPV2_ETH_PROVIDER = "3001", e.UNISWAPV3_ETH_PROVIDER = "3002", e.SUSHISWAP_ETH_PROVIDER = "3003", e.PANCAKESWAP_BSC_PROVIDER = "3004", e.PANCAKESWAP_ETH_PROVIDER = "3005", e.ONEINCH_ETH_PROVIDER = "3006", e.ONEINCH_BSC_PROVIDER = "3007", e.ONEINCH_AVAX_PROVIDER = "3008", e.ZEROX_ETH_PROVIDER = "3009", e.WOOFI_AVAX_PROVIDER = "3010", e.PANGOLIN_AVAX_PROVIDER = "3011", e.TRADERJOE_AVAX_PROVIDER = "3012", e.KYBER_ETH_PROVIDER = "3013", e.KYBER_AVAX_PROVIDER = "3014", e.WOOFI_BSC_PROVIDER = "3015", e.STARGATE_PROVIDER = "3016", e.PROVIDER_UTIL = "4000", e.TXN_DETAILS = "5000", e.AIRDROP_UTIL = "6000", e))(et || {}),
|
|
627
|
+
var Se = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(Se || {}), et = /* @__PURE__ */ ((e) => (e.HEALTH_CONTROLLER = "1000", e.LIQUIDITY_CONTROLLER = "1001", e.PROVIDER_CONTROLLER = "1002", e.QUOTE_CONTROLLER = "1003", e.SWAP_CONTROLLER = "1004", e.UTIL_CONTROLLER = "1005", e.AIRDROP_CONTROLLER = "1006", e.PROVIDER = "2000", e.ASSET = "2001", e.TOKEN_LIST = "2002", e.QUOTE = "2100", e.QUOTE_TXN_DETAILS = "2101", e.THORCHAIN_PROVIDER = "3000", e.UNISWAPV2_ETH_PROVIDER = "3001", e.UNISWAPV3_ETH_PROVIDER = "3002", e.SUSHISWAP_ETH_PROVIDER = "3003", e.PANCAKESWAP_BSC_PROVIDER = "3004", e.PANCAKESWAP_ETH_PROVIDER = "3005", e.ONEINCH_ETH_PROVIDER = "3006", e.ONEINCH_BSC_PROVIDER = "3007", e.ONEINCH_AVAX_PROVIDER = "3008", e.ZEROX_ETH_PROVIDER = "3009", e.WOOFI_AVAX_PROVIDER = "3010", e.PANGOLIN_AVAX_PROVIDER = "3011", e.TRADERJOE_AVAX_PROVIDER = "3012", e.KYBER_ETH_PROVIDER = "3013", e.KYBER_AVAX_PROVIDER = "3014", e.WOOFI_BSC_PROVIDER = "3015", e.STARGATE_PROVIDER = "3016", e.PROVIDER_UTIL = "4000", e.TXN_DETAILS = "5000", e.AIRDROP_UTIL = "6000", e))(et || {}), y = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(y || {});
|
|
628
628
|
const tt = {
|
|
629
|
-
[
|
|
630
|
-
[
|
|
631
|
-
[
|
|
632
|
-
[
|
|
633
|
-
[
|
|
634
|
-
[
|
|
635
|
-
[
|
|
636
|
-
[
|
|
637
|
-
[
|
|
638
|
-
[
|
|
639
|
-
[
|
|
640
|
-
[
|
|
641
|
-
[
|
|
642
|
-
[
|
|
643
|
-
[
|
|
644
|
-
[
|
|
645
|
-
[
|
|
646
|
-
[
|
|
647
|
-
[
|
|
648
|
-
[
|
|
649
|
-
[
|
|
650
|
-
[
|
|
651
|
-
[
|
|
652
|
-
[
|
|
653
|
-
[
|
|
654
|
-
[
|
|
655
|
-
[
|
|
656
|
-
[
|
|
657
|
-
[
|
|
658
|
-
[
|
|
659
|
-
[
|
|
660
|
-
[
|
|
661
|
-
[
|
|
662
|
-
[
|
|
663
|
-
[
|
|
664
|
-
[
|
|
665
|
-
[
|
|
666
|
-
[
|
|
667
|
-
[
|
|
668
|
-
[
|
|
669
|
-
[
|
|
670
|
-
[
|
|
671
|
-
[
|
|
672
|
-
[
|
|
673
|
-
[
|
|
674
|
-
[
|
|
675
|
-
[
|
|
676
|
-
[
|
|
677
|
-
[
|
|
678
|
-
[
|
|
629
|
+
[y.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
|
+
[y.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
|
+
[y.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
632
|
+
[y.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
|
|
633
|
+
[y.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
|
|
634
|
+
[y.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
|
|
635
|
+
[y.INVALID_TYPE_GENERIC]: "Invalid type",
|
|
636
|
+
[y.INVALID_NUMBER_STRING]: "Invalid number string.",
|
|
637
|
+
[y.INVALID_NUMBER]: "Invalid number.",
|
|
638
|
+
[y.INVALID_BOOLEAN]: "Invalid boolean.",
|
|
639
|
+
[y.INVALID_OBJECT]: "Invalid object.",
|
|
640
|
+
[y.INVALID_ARRAY]: "Invalid array.",
|
|
641
|
+
[y.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
|
|
642
|
+
[y.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
|
|
643
|
+
[y.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
|
|
644
|
+
[y.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
|
|
645
|
+
[y.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
|
|
646
|
+
[y.AFF_BPS_INTEGER_0_100]: "affiliateBasisPoints must be an integer between 0 and 100.",
|
|
647
|
+
[y.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
|
|
648
|
+
[y.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
|
|
649
|
+
[y.PREFERRED_PROFVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
|
|
650
|
+
[y.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
|
|
651
|
+
[y.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
|
|
652
|
+
[y.INVALID_PROVIDER]: "Invalid provider {0}.",
|
|
653
|
+
[y.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
|
|
654
|
+
[y.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
|
|
655
|
+
[y.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
|
|
656
|
+
[y.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
|
|
657
|
+
[y.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
|
|
658
|
+
[y.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
|
|
659
|
+
[y.INVALID_CHAIN]: "Invalid chain {0}.",
|
|
660
|
+
[y.INVALID_ASSET]: "Invalid asset {0}.",
|
|
661
|
+
[y.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
|
|
662
|
+
[y.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
|
|
663
|
+
[y.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
|
|
664
|
+
[y.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
|
|
665
|
+
[y.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
|
|
666
|
+
[y.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
|
|
667
|
+
[y.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
|
|
668
|
+
[y.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
|
|
669
|
+
[y.INVALID_QUOTE_MODE]: "Invalid quote mode.",
|
|
670
|
+
[y.NO_QUOTES]: "No quotes to service this request.",
|
|
671
|
+
[y.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
|
|
672
|
+
[y.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
|
|
673
|
+
[y.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
|
|
674
|
+
[y.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
|
|
675
|
+
[y.NO_PRICE]: "No price for asset {0}.",
|
|
676
|
+
[y.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
|
+
[y.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
|
+
[y.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
679
|
}, ie = (e, t) => {
|
|
680
680
|
let n = tt[e];
|
|
681
681
|
for (let a = 0; a < t.length; a++)
|
|
@@ -690,7 +690,7 @@ class ve extends Error {
|
|
|
690
690
|
code: s,
|
|
691
691
|
message: r,
|
|
692
692
|
type: o,
|
|
693
|
-
options: { shouldLog: p, shouldThrow: d, shouldTrace:
|
|
693
|
+
options: { shouldLog: p, shouldThrow: d, shouldTrace: l } = {
|
|
694
694
|
shouldLog: !0,
|
|
695
695
|
shouldThrow: !0,
|
|
696
696
|
shouldTrace: !0
|
|
@@ -700,7 +700,7 @@ class ve extends Error {
|
|
|
700
700
|
const c = r || ie(s, u || []) || "";
|
|
701
701
|
super(c), S(this, "status"), S(this, "revision"), S(this, "type"), S(this, "module"), S(this, "code"), S(this, "message"), S(this, "display"), S(this, "stack"), S(this, "options"), S(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = ie(s, u || []), this.code = s, this.type = o || Se.UNHANDLED_ERROR, this.options = {
|
|
702
702
|
shouldLog: p || !0,
|
|
703
|
-
shouldTrace:
|
|
703
|
+
shouldTrace: l || !0,
|
|
704
704
|
shouldThrow: d || !1
|
|
705
705
|
}, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
@@ -742,7 +742,7 @@ const _n = {
|
|
|
742
742
|
OP: [44, 60, 0, 0, 0],
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
|
-
var
|
|
745
|
+
var w = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(w || {});
|
|
746
746
|
const st = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
@@ -775,20 +775,20 @@ const st = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var Te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(Te || {}), Ce = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Ce || {}),
|
|
779
|
-
const
|
|
778
|
+
var Te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(Te || {}), Ce = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Ce || {}), k = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(k || {});
|
|
779
|
+
const ne = Object.values(i), it = Object.keys(i), he = ne.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
781
|
const n = it.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
), rt =
|
|
785
|
+
), rt = ne.reduce(
|
|
786
786
|
(e, t) => (e[t] = Te[he[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
), ot =
|
|
788
|
+
), ot = ne.reduce(
|
|
789
789
|
(e, t) => (e[t] = Ce[he[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
), An =
|
|
791
|
+
), An = ne.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
793
|
const n = `${he[t]}Hex`;
|
|
794
794
|
return e[t] = Te[n], e;
|
|
@@ -836,14 +836,14 @@ const ae = Object.values(i), it = Object.keys(i), he = ae.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://viewblock.io/thorchain"
|
|
838
838
|
};
|
|
839
|
-
var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}),
|
|
839
|
+
var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), H = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(H || {}), dt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(dt || {}), ut = Object.defineProperty, lt = (e, t, n) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (lt(e, typeof t != "symbol" ? t + "" : t, n), n), yt = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
|
-
},
|
|
842
|
+
}, j = (e, t, n) => {
|
|
843
843
|
if (t.has(e))
|
|
844
844
|
throw TypeError("Cannot add the same private member more than once");
|
|
845
845
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
846
|
-
},
|
|
846
|
+
}, N = (e, t, n) => (yt(e, t, "access private method"), n);
|
|
847
847
|
const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
849
|
const { result: n } = await fe.post(ot[e], {
|
|
@@ -861,17 +861,17 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
861
861
|
});
|
|
862
862
|
return parseInt(BigInt(n).toString());
|
|
863
863
|
} catch (n) {
|
|
864
|
-
return console.error(n),
|
|
864
|
+
return console.error(n), w[e];
|
|
865
865
|
}
|
|
866
866
|
}, mt = async (e) => {
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
|
-
return
|
|
868
|
+
return w.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
|
-
return t != null && t.startsWith("0x") ? Ne({ chain: i.Ethereum, to: t }) :
|
|
870
|
+
return t != null && t.startsWith("0x") ? Ne({ chain: i.Ethereum, to: t }) : w.ETH;
|
|
871
871
|
}, Tt = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ? Ne({ chain: i.Avalanche, to: t.toLowerCase() }) :
|
|
874
|
-
}, ht = async (e) => (e === i.BinanceSmartChain,
|
|
873
|
+
return t != null && t.startsWith("0x") ? Ne({ chain: i.Avalanche, to: t.toLowerCase() }) : w.AVAX;
|
|
874
|
+
}, ht = async (e) => (e === i.BinanceSmartChain, w.BSC), _t = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
877
|
return mt(t);
|
|
@@ -880,12 +880,12 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
880
880
|
case i.BinanceSmartChain:
|
|
881
881
|
return ht(t);
|
|
882
882
|
default:
|
|
883
|
-
return
|
|
883
|
+
return w[e];
|
|
884
884
|
}
|
|
885
885
|
}, ft = {
|
|
886
|
-
[
|
|
887
|
-
[
|
|
888
|
-
[
|
|
886
|
+
[H.Average]: 1.2,
|
|
887
|
+
[H.Fast]: 1.5,
|
|
888
|
+
[H.Fastest]: 2
|
|
889
889
|
}, xe = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case i.Bitcoin:
|
|
@@ -919,13 +919,13 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
919
919
|
case "ETH.vTHOR":
|
|
920
920
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
921
921
|
case i.Cosmos:
|
|
922
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
922
|
+
return { identifier: "GAIA.ATOM", decimal: w[e] };
|
|
923
923
|
case i.THORChain:
|
|
924
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
924
|
+
return { identifier: "THOR.RUNE", decimal: w[e] };
|
|
925
925
|
case i.BinanceSmartChain:
|
|
926
|
-
return { identifier: "BSC.BNB", decimal:
|
|
926
|
+
return { identifier: "BSC.BNB", decimal: w[e] };
|
|
927
927
|
case i.Maya:
|
|
928
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
928
|
+
return { identifier: "MAYA.CACAO", decimal: w.MAYA };
|
|
929
929
|
case "MAYA.MAYA":
|
|
930
930
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
931
931
|
case i.Kujira:
|
|
@@ -939,7 +939,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
939
939
|
case i.Polygon:
|
|
940
940
|
case i.Bitcoin:
|
|
941
941
|
case i.Ethereum:
|
|
942
|
-
return { identifier: `${e}.${e}`, decimal:
|
|
942
|
+
return { identifier: `${e}.${e}`, decimal: w[e] };
|
|
943
943
|
}
|
|
944
944
|
}, wt = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
@@ -992,14 +992,14 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
992
992
|
poolUnits: t,
|
|
993
993
|
runeDepth: n
|
|
994
994
|
}) => {
|
|
995
|
-
const a = R(e), s = R(t), r = R(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2),
|
|
996
|
-
return o.mul(p.sub(d).add(
|
|
995
|
+
const a = R(e), s = R(t), r = R(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = s.mul(s).mul(s);
|
|
996
|
+
return o.mul(p.sub(d).add(l)).div(u);
|
|
997
997
|
}, gt = ({
|
|
998
998
|
liquidityUnits: e,
|
|
999
999
|
poolUnits: t,
|
|
1000
1000
|
assetDepth: n
|
|
1001
1001
|
}) => {
|
|
1002
|
-
const a = R(e), s = R(t), r = R(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2),
|
|
1002
|
+
const a = R(e), s = R(t), r = R(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = o.mul(p.sub(d).add(l)), c = s.mul(s).mul(s);
|
|
1003
1003
|
return u.div(c);
|
|
1004
1004
|
}, On = ({
|
|
1005
1005
|
percent: e,
|
|
@@ -1011,7 +1011,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1011
1011
|
assetDepth: t,
|
|
1012
1012
|
liquidityUnits: n,
|
|
1013
1013
|
poolUnits: a
|
|
1014
|
-
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), R = (e) =>
|
|
1014
|
+
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), R = (e) => x.fromBigInt(BigInt(e), w.THOR), Ot = ({
|
|
1015
1015
|
liquidityUnits: e,
|
|
1016
1016
|
poolUnits: t,
|
|
1017
1017
|
runeDepth: n,
|
|
@@ -1037,11 +1037,11 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1037
1037
|
runeAmount: s,
|
|
1038
1038
|
assetAmount: r
|
|
1039
1039
|
}) => {
|
|
1040
|
-
const o = new
|
|
1040
|
+
const o = new x({ value: e, decimal: 8 }), p = new x({ value: n, decimal: 8 }), d = new x({ value: t, decimal: 8 }), l = new x({ value: s, decimal: 8 }), u = new x({ value: r, decimal: 8 }), c = l.mul(p), _ = u.mul(o), b = l.mul(u), A = o.mul(p), E = d.mul(c.add(_.add(b.mul(2)))), g = c.add(_.add(A.mul(2))), O = E.div(g), D = R(a).add(O);
|
|
1041
1041
|
if (O.getBaseValue("number") === 0)
|
|
1042
|
-
return
|
|
1043
|
-
const
|
|
1044
|
-
return
|
|
1042
|
+
return D.div(d).getBaseValue("number");
|
|
1043
|
+
const se = d.add(D);
|
|
1044
|
+
return D.div(se).getBaseValue("number");
|
|
1045
1045
|
}, Cn = ({
|
|
1046
1046
|
runeAmount: e,
|
|
1047
1047
|
assetAmount: t,
|
|
@@ -1050,13 +1050,13 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1050
1050
|
}) => {
|
|
1051
1051
|
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1052
1052
|
return 0;
|
|
1053
|
-
const s = R(n), r = R(a), o = R(t), p = R(e), d = o.mul(s).sub(r.mul(p)),
|
|
1054
|
-
return Math.abs(d.div(
|
|
1053
|
+
const s = R(n), r = R(a), o = R(t), p = R(e), d = o.mul(s).sub(r.mul(p)), l = r.mul(p).add(s.mul(r));
|
|
1054
|
+
return Math.abs(d.div(l).getBaseValue("number"));
|
|
1055
1055
|
}, It = ({
|
|
1056
1056
|
symbol: e,
|
|
1057
1057
|
ticker: t,
|
|
1058
1058
|
chain: n
|
|
1059
|
-
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e,
|
|
1059
|
+
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, M = (e, t) => {
|
|
1060
1060
|
switch (e) {
|
|
1061
1061
|
case h.LEAVE:
|
|
1062
1062
|
case h.BOND: {
|
|
@@ -1076,8 +1076,8 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1076
1076
|
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${s || ""}:t:0`;
|
|
1077
1077
|
}
|
|
1078
1078
|
case h.WITHDRAW: {
|
|
1079
|
-
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "",
|
|
1080
|
-
return `${e}:${n}${p ? "/" : "."}${
|
|
1079
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", l = It({ chain: n, symbol: s, ticker: a });
|
|
1080
|
+
return `${e}:${n}${p ? "/" : "."}${l}:${r}${d}`;
|
|
1081
1081
|
}
|
|
1082
1082
|
case h.OPEN_LOAN:
|
|
1083
1083
|
case h.CLOSE_LOAN: {
|
|
@@ -1128,9 +1128,9 @@ class De extends Error {
|
|
|
1128
1128
|
}), this.name = "TimeoutError", this.request = t;
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
|
-
const
|
|
1131
|
+
const Y = (e) => e !== null && typeof e == "object", K = (...e) => {
|
|
1132
1132
|
for (const t of e)
|
|
1133
|
-
if ((!
|
|
1133
|
+
if ((!Y(t) || Array.isArray(t)) && t !== void 0)
|
|
1134
1134
|
throw new TypeError("The `options` argument must be an object");
|
|
1135
1135
|
return _e({}, ...e);
|
|
1136
1136
|
}, Pe = (e = {}, t = {}) => {
|
|
@@ -1143,10 +1143,10 @@ const X = (e) => e !== null && typeof e == "object", Y = (...e) => {
|
|
|
1143
1143
|
for (const a of e)
|
|
1144
1144
|
if (Array.isArray(a))
|
|
1145
1145
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1146
|
-
else if (
|
|
1146
|
+
else if (Y(a)) {
|
|
1147
1147
|
for (let [s, r] of Object.entries(a))
|
|
1148
|
-
|
|
1149
|
-
|
|
1148
|
+
Y(r) && s in t && (r = _e(t[s], r)), t = { ...t, [s]: r };
|
|
1149
|
+
Y(a.headers) && (n = Pe(n, a.headers), t.headers = n);
|
|
1150
1150
|
}
|
|
1151
1151
|
return t;
|
|
1152
1152
|
}, St = (() => {
|
|
@@ -1244,9 +1244,9 @@ const $t = (e, t) => {
|
|
|
1244
1244
|
!(a in Dt) && !(a in xt) && !(a in e) && (n[a] = t[a]);
|
|
1245
1245
|
return n;
|
|
1246
1246
|
};
|
|
1247
|
-
class
|
|
1247
|
+
class z {
|
|
1248
1248
|
static create(t, n) {
|
|
1249
|
-
const a = new
|
|
1249
|
+
const a = new z(t, n), s = async () => {
|
|
1250
1250
|
if (typeof a._options.timeout == "number" && a._options.timeout > re)
|
|
1251
1251
|
throw new RangeError(`The \`timeout\` option cannot be greater than ${re}`);
|
|
1252
1252
|
await Promise.resolve();
|
|
@@ -1418,17 +1418,17 @@ class Z {
|
|
|
1418
1418
|
const o = t.body.getReader();
|
|
1419
1419
|
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1420
1420
|
async function p() {
|
|
1421
|
-
const { done: d, value:
|
|
1421
|
+
const { done: d, value: l } = await o.read();
|
|
1422
1422
|
if (d) {
|
|
1423
1423
|
r.close();
|
|
1424
1424
|
return;
|
|
1425
1425
|
}
|
|
1426
1426
|
if (n) {
|
|
1427
|
-
s +=
|
|
1427
|
+
s += l.byteLength;
|
|
1428
1428
|
const u = a === 0 ? 0 : s / a;
|
|
1429
|
-
n({ percent: u, transferredBytes: s, totalBytes: a },
|
|
1429
|
+
n({ percent: u, transferredBytes: s, totalBytes: a }, l);
|
|
1430
1430
|
}
|
|
1431
|
-
r.enqueue(
|
|
1431
|
+
r.enqueue(l), await p();
|
|
1432
1432
|
}
|
|
1433
1433
|
await p();
|
|
1434
1434
|
}
|
|
@@ -1441,10 +1441,10 @@ class Z {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
/*! MIT License © Sindre Sorhus */
|
|
1443
1443
|
const pe = (e) => {
|
|
1444
|
-
const t = (n, a) =>
|
|
1444
|
+
const t = (n, a) => z.create(n, K(e, a));
|
|
1445
1445
|
for (const n of Be)
|
|
1446
|
-
t[n] = (a, s) =>
|
|
1447
|
-
return t.create = (n) => pe(
|
|
1446
|
+
t[n] = (a, s) => z.create(a, K(e, s, { method: n }));
|
|
1447
|
+
return t.create = (n) => pe(K(n)), t.extend = (n) => pe(K(e, n)), t.stop = Le, t;
|
|
1448
1448
|
}, kt = pe(), Ft = kt, Gt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Ae = Ft.create({ headers: Gt }), fe = {
|
|
1449
1449
|
get: (e, t) => Ae.get(e, t).json(),
|
|
1450
1450
|
post: (e, t) => Ae.post(e, t).json()
|
|
@@ -1458,11 +1458,11 @@ const pe = (e) => {
|
|
|
1458
1458
|
throw new Error(
|
|
1459
1459
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1460
1460
|
);
|
|
1461
|
-
},
|
|
1462
|
-
function
|
|
1461
|
+
}, F = 8, V = (e) => 10n ** BigInt(e), $ = (e) => Math.log10(parseFloat(e.toString()));
|
|
1462
|
+
function ae({
|
|
1463
1463
|
value: e,
|
|
1464
|
-
bigIntDecimal: t =
|
|
1465
|
-
decimal: n =
|
|
1464
|
+
bigIntDecimal: t = F,
|
|
1465
|
+
decimal: n = F
|
|
1466
1466
|
}) {
|
|
1467
1467
|
const a = e < 0n;
|
|
1468
1468
|
let s = e.toString().substring(a ? 1 : 0);
|
|
@@ -1475,19 +1475,19 @@ function se({
|
|
|
1475
1475
|
""
|
|
1476
1476
|
);
|
|
1477
1477
|
}
|
|
1478
|
-
var
|
|
1478
|
+
var L, U, X, de, ue, Re, Z, le;
|
|
1479
1479
|
const Wt = class Ue {
|
|
1480
1480
|
constructor(t) {
|
|
1481
|
-
|
|
1482
|
-
const n =
|
|
1483
|
-
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier =
|
|
1484
|
-
Math.max(He(
|
|
1485
|
-
),
|
|
1481
|
+
j(this, L), j(this, X), j(this, ue), j(this, Z), v(this, "decimalMultiplier", 10n ** 8n), v(this, "bigIntValue", 0n), v(this, "decimal");
|
|
1482
|
+
const n = J(t);
|
|
1483
|
+
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = V(
|
|
1484
|
+
Math.max(He(ee(n)), this.decimal || 0)
|
|
1485
|
+
), N(this, X, de).call(this, n);
|
|
1486
1486
|
}
|
|
1487
1487
|
static fromBigInt(t, n) {
|
|
1488
1488
|
return new Ue({
|
|
1489
1489
|
decimal: n,
|
|
1490
|
-
value:
|
|
1490
|
+
value: ae({ value: t, bigIntDecimal: n, decimal: n })
|
|
1491
1491
|
});
|
|
1492
1492
|
}
|
|
1493
1493
|
static shiftDecimals({
|
|
@@ -1496,24 +1496,24 @@ const Wt = class Ue {
|
|
|
1496
1496
|
to: a
|
|
1497
1497
|
}) {
|
|
1498
1498
|
return this.fromBigInt(
|
|
1499
|
-
t.getBaseValue("bigint") *
|
|
1499
|
+
t.getBaseValue("bigint") * V(a) / V(n),
|
|
1500
1500
|
a
|
|
1501
1501
|
);
|
|
1502
1502
|
}
|
|
1503
1503
|
set(t) {
|
|
1504
|
-
return
|
|
1504
|
+
return N(this, X, de).call(this, J(t)), this;
|
|
1505
1505
|
}
|
|
1506
1506
|
add(...t) {
|
|
1507
|
-
return
|
|
1507
|
+
return N(this, L, U).call(this, "add", ...t);
|
|
1508
1508
|
}
|
|
1509
1509
|
sub(...t) {
|
|
1510
|
-
return
|
|
1510
|
+
return N(this, L, U).call(this, "sub", ...t);
|
|
1511
1511
|
}
|
|
1512
1512
|
mul(...t) {
|
|
1513
|
-
return
|
|
1513
|
+
return N(this, L, U).call(this, "mul", ...t);
|
|
1514
1514
|
}
|
|
1515
1515
|
div(...t) {
|
|
1516
|
-
return
|
|
1516
|
+
return N(this, L, U).call(this, "div", ...t);
|
|
1517
1517
|
}
|
|
1518
1518
|
gt(t) {
|
|
1519
1519
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1533,7 +1533,7 @@ const Wt = class Ue {
|
|
|
1533
1533
|
getValue(t) {
|
|
1534
1534
|
const n = this.formatBigIntToSafeValue(
|
|
1535
1535
|
this.bigIntValue,
|
|
1536
|
-
this.decimal ||
|
|
1536
|
+
this.decimal || $(this.decimalMultiplier)
|
|
1537
1537
|
);
|
|
1538
1538
|
switch (t) {
|
|
1539
1539
|
case "number":
|
|
@@ -1545,7 +1545,7 @@ const Wt = class Ue {
|
|
|
1545
1545
|
}
|
|
1546
1546
|
}
|
|
1547
1547
|
getBaseValue(t) {
|
|
1548
|
-
const n = this.decimalMultiplier /
|
|
1548
|
+
const n = this.decimalMultiplier / V(this.decimal || w.THOR), a = this.bigIntValue / n;
|
|
1549
1549
|
switch (t) {
|
|
1550
1550
|
case "number":
|
|
1551
1551
|
return Number(a);
|
|
@@ -1558,18 +1558,18 @@ const Wt = class Ue {
|
|
|
1558
1558
|
getBigIntValue(t, n) {
|
|
1559
1559
|
if (!n && typeof t == "object")
|
|
1560
1560
|
return t.bigIntValue;
|
|
1561
|
-
const a =
|
|
1562
|
-
return s === "0" || s === "undefined" ? 0n :
|
|
1561
|
+
const a = J(t), s = ee(a);
|
|
1562
|
+
return s === "0" || s === "undefined" ? 0n : N(this, Z, le).call(this, s, n);
|
|
1563
1563
|
}
|
|
1564
1564
|
formatBigIntToSafeValue(t, n) {
|
|
1565
|
-
const a = n || this.decimal ||
|
|
1565
|
+
const a = n || this.decimal || F, s = Math.max(
|
|
1566
1566
|
a,
|
|
1567
|
-
|
|
1568
|
-
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o,
|
|
1567
|
+
$(this.decimalMultiplier)
|
|
1568
|
+
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, l = d.length - s;
|
|
1569
1569
|
let u = d.slice(-s);
|
|
1570
1570
|
return parseInt(u[a]) >= 5 ? u = `${u.substring(0, a - 1)}${(parseInt(u[a - 1]) + 1).toString()}` : u = u.substring(0, a), `${r ? "-" : ""}${d.slice(
|
|
1571
1571
|
0,
|
|
1572
|
-
|
|
1572
|
+
l
|
|
1573
1573
|
)}.${u}`.replace(/\.?0*$/, "");
|
|
1574
1574
|
}
|
|
1575
1575
|
toSignificant(t = 6) {
|
|
@@ -1612,12 +1612,12 @@ const Wt = class Ue {
|
|
|
1612
1612
|
decimalSeparator: s = ".",
|
|
1613
1613
|
thousandSeparator: r = ","
|
|
1614
1614
|
} = {}) {
|
|
1615
|
-
const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."),
|
|
1615
|
+
const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."), l = p.replace(/\B(?=(\d{3})+(?!\d))/g, r), u = !p && !d ? "0.00" : p === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${l}${parseInt(d) ? `${s}${d.slice(0, a)}` : ""}`;
|
|
1616
1616
|
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1617
1617
|
}
|
|
1618
1618
|
};
|
|
1619
|
-
|
|
1620
|
-
const n =
|
|
1619
|
+
L = /* @__PURE__ */ new WeakSet(), U = function(e, ...t) {
|
|
1620
|
+
const n = N(this, ue, Re).call(this, this, ...t), a = V(n), s = t.reduce(
|
|
1621
1621
|
(o, p) => {
|
|
1622
1622
|
const d = this.getBigIntValue(p, n);
|
|
1623
1623
|
switch (e) {
|
|
@@ -1638,22 +1638,22 @@ V = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
|
|
|
1638
1638
|
},
|
|
1639
1639
|
//normalize is to precision multiplier base
|
|
1640
1640
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1641
|
-
), r =
|
|
1641
|
+
), r = ae({
|
|
1642
1642
|
bigIntDecimal: n,
|
|
1643
|
-
decimal: Math.max(n,
|
|
1643
|
+
decimal: Math.max(n, $(this.decimalMultiplier)),
|
|
1644
1644
|
value: s
|
|
1645
1645
|
});
|
|
1646
1646
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1647
|
-
},
|
|
1648
|
-
const t =
|
|
1649
|
-
this.bigIntValue =
|
|
1647
|
+
}, X = /* @__PURE__ */ new WeakSet(), de = function(e) {
|
|
1648
|
+
const t = ee(e) || "0";
|
|
1649
|
+
this.bigIntValue = N(this, Z, le).call(this, t);
|
|
1650
1650
|
}, ue = /* @__PURE__ */ new WeakSet(), Re = function(...e) {
|
|
1651
1651
|
const t = e.map(
|
|
1652
|
-
(n) => typeof n == "object" ? n.decimal ||
|
|
1652
|
+
(n) => typeof n == "object" ? n.decimal || $(n.decimalMultiplier) : He(ee(n))
|
|
1653
1653
|
).filter(Boolean);
|
|
1654
|
-
return Math.max(...t,
|
|
1655
|
-
},
|
|
1656
|
-
const n = t ?
|
|
1654
|
+
return Math.max(...t, F);
|
|
1655
|
+
}, Z = /* @__PURE__ */ new WeakSet(), le = function(e, t) {
|
|
1656
|
+
const n = t ? V(t) : this.decimalMultiplier, a = $(n), [s = "", r = ""] = e.split(".");
|
|
1657
1657
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1658
1658
|
};
|
|
1659
1659
|
let ye = Wt;
|
|
@@ -1661,30 +1661,30 @@ const jt = Intl.NumberFormat("fullwide", {
|
|
|
1661
1661
|
useGrouping: !1,
|
|
1662
1662
|
maximumFractionDigits: 20
|
|
1663
1663
|
});
|
|
1664
|
-
function
|
|
1665
|
-
const t = `${typeof e == "number" ? jt.format(e) :
|
|
1664
|
+
function ee(e) {
|
|
1665
|
+
const t = `${typeof e == "number" ? jt.format(e) : J(e)}`.replaceAll(",", ".").split(".");
|
|
1666
1666
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1667
1667
|
}
|
|
1668
1668
|
function He(e) {
|
|
1669
1669
|
var t;
|
|
1670
1670
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1671
|
-
return Math.max(n,
|
|
1671
|
+
return Math.max(n, F);
|
|
1672
1672
|
}
|
|
1673
|
-
function
|
|
1673
|
+
function J(e) {
|
|
1674
1674
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1675
1675
|
}
|
|
1676
|
-
const
|
|
1676
|
+
const Q = (e, t) => typeof e == "bigint" ? ae({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1677
1677
|
let ce;
|
|
1678
1678
|
const ge = (e) => {
|
|
1679
1679
|
if (!ce)
|
|
1680
1680
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1681
|
-
return ce.get(e.toUpperCase()) || { decimal:
|
|
1681
|
+
return ce.get(e.toUpperCase()) || { decimal: w.THOR, identifier: "" };
|
|
1682
1682
|
}, Oe = async (e, t = 0) => {
|
|
1683
1683
|
qt(e);
|
|
1684
|
-
const n = await _t(me(e)), a =
|
|
1685
|
-
return new
|
|
1684
|
+
const n = await _t(me(e)), a = Q(t, n);
|
|
1685
|
+
return new C({ decimal: n, value: a, identifier: e });
|
|
1686
1686
|
};
|
|
1687
|
-
class
|
|
1687
|
+
class C extends ye {
|
|
1688
1688
|
constructor(t) {
|
|
1689
1689
|
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`;
|
|
1690
1690
|
super(
|
|
@@ -1709,19 +1709,19 @@ class M extends ye {
|
|
|
1709
1709
|
static fromStringSync(t, n = 0) {
|
|
1710
1710
|
const { isSynthetic: a } = me(t), { decimal: s, identifier: r } = ge(
|
|
1711
1711
|
t
|
|
1712
|
-
), o =
|
|
1713
|
-
return r ? new
|
|
1712
|
+
), o = Q(n, s);
|
|
1713
|
+
return r ? new C({ decimal: s, identifier: r, value: o }) : a ? new C({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1714
1714
|
}
|
|
1715
1715
|
static async fromIdentifier(t, n = 0) {
|
|
1716
1716
|
return Oe(t, n);
|
|
1717
1717
|
}
|
|
1718
1718
|
static fromIdentifierSync(t, n = 0) {
|
|
1719
|
-
const { decimal: a, identifier: s } = ge(t), r =
|
|
1720
|
-
return new
|
|
1719
|
+
const { decimal: a, identifier: s } = ge(t), r = Q(n, a);
|
|
1720
|
+
return new C({ decimal: a, identifier: s, value: r });
|
|
1721
1721
|
}
|
|
1722
1722
|
static fromChainOrSignature(t, n = 0) {
|
|
1723
|
-
const { decimal: a, identifier: s } = bt(t), r =
|
|
1724
|
-
return new
|
|
1723
|
+
const { decimal: a, identifier: s } = bt(t), r = Q(n, a);
|
|
1724
|
+
return new C({ value: r, decimal: a, identifier: s });
|
|
1725
1725
|
}
|
|
1726
1726
|
static async loadStaticAssets() {
|
|
1727
1727
|
return new Promise(
|
|
@@ -1735,8 +1735,8 @@ class M extends ye {
|
|
|
1735
1735
|
...r
|
|
1736
1736
|
} = await import("@swapkit/tokens");
|
|
1737
1737
|
ce = [s, ...Object.values(r)].reduce(
|
|
1738
|
-
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain:
|
|
1739
|
-
const c = "decimals" in u ? u.decimals :
|
|
1738
|
+
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: l, ...u }) => {
|
|
1739
|
+
const c = "decimals" in u ? u.decimals : w[l];
|
|
1740
1740
|
o.set(d, { identifier: d, decimal: c });
|
|
1741
1741
|
}), o),
|
|
1742
1742
|
/* @__PURE__ */ new Map()
|
|
@@ -1753,7 +1753,7 @@ class M extends ye {
|
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
1755
|
const oe = (e) => {
|
|
1756
|
-
const t =
|
|
1756
|
+
const t = C.fromChainOrSignature(e);
|
|
1757
1757
|
switch (e) {
|
|
1758
1758
|
case i.Bitcoin:
|
|
1759
1759
|
case i.Litecoin:
|
|
@@ -1842,14 +1842,14 @@ class m extends Error {
|
|
|
1842
1842
|
console.error(n), super(t, { cause: { code: Kt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1843
1843
|
}
|
|
1844
1844
|
}
|
|
1845
|
-
class
|
|
1845
|
+
class x extends ye {
|
|
1846
1846
|
eq(t) {
|
|
1847
1847
|
return this.eqValue(t);
|
|
1848
1848
|
}
|
|
1849
1849
|
static fromBigInt(t, n) {
|
|
1850
|
-
return new
|
|
1850
|
+
return new x({
|
|
1851
1851
|
decimal: n,
|
|
1852
|
-
value:
|
|
1852
|
+
value: ae({ value: t, bigIntDecimal: n, decimal: n })
|
|
1853
1853
|
});
|
|
1854
1854
|
}
|
|
1855
1855
|
}
|
|
@@ -3570,36 +3570,36 @@ const Yt = [
|
|
|
3570
3570
|
data: o = "",
|
|
3571
3571
|
deadline: p,
|
|
3572
3572
|
memo: d,
|
|
3573
|
-
router:
|
|
3573
|
+
router: l,
|
|
3574
3574
|
memoStreamingSwap: u,
|
|
3575
3575
|
tcMemo: c,
|
|
3576
3576
|
tcRouter: _,
|
|
3577
3577
|
tcVault: b,
|
|
3578
|
-
vault:
|
|
3578
|
+
vault: A,
|
|
3579
3579
|
token: E
|
|
3580
3580
|
}
|
|
3581
3581
|
}) => {
|
|
3582
3582
|
const g = !!$e[t.toLowerCase()];
|
|
3583
|
-
if (g && !
|
|
3583
|
+
if (g && !l)
|
|
3584
3584
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3585
|
-
const O = c || d,
|
|
3586
|
-
if (!b && !
|
|
3585
|
+
const O = c || d, D = e && u || O;
|
|
3586
|
+
if (!b && !A)
|
|
3587
3587
|
throw new Error("TC Vault is required on calldata");
|
|
3588
|
-
if (!_ && !
|
|
3588
|
+
if (!_ && !l)
|
|
3589
3589
|
throw new Error("TC Router is required on calldata");
|
|
3590
|
-
if (!
|
|
3590
|
+
if (!D)
|
|
3591
3591
|
throw new Error("TC Memo is required on calldata");
|
|
3592
3592
|
if (!E)
|
|
3593
3593
|
throw new Error("Token is required on calldata");
|
|
3594
|
-
const
|
|
3594
|
+
const se = [
|
|
3595
3595
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3596
|
-
a(_ ||
|
|
3597
|
-
a(b ||
|
|
3598
|
-
|
|
3596
|
+
a(_ || l),
|
|
3597
|
+
a(b || A),
|
|
3598
|
+
D.replace("{recipientAddress}", n),
|
|
3599
3599
|
a(E),
|
|
3600
3600
|
s
|
|
3601
|
-
], ke = g ? [a(
|
|
3602
|
-
return [...
|
|
3601
|
+
], ke = g ? [a(l), o, p] : [r, p];
|
|
3602
|
+
return [...se, ...ke];
|
|
3603
3603
|
}, ln = ({ chain: e, txHash: t }) => {
|
|
3604
3604
|
const n = Me[e];
|
|
3605
3605
|
switch (e) {
|
|
@@ -3651,16 +3651,16 @@ const Yt = [
|
|
|
3651
3651
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3652
3652
|
}
|
|
3653
3653
|
}, cn = (e) => {
|
|
3654
|
-
const t = e ?
|
|
3654
|
+
const t = e ? k.ThornodeStagenet : k.ThornodeMainnet;
|
|
3655
3655
|
return fe.get(`${t}/thorchain/inbound_addresses`);
|
|
3656
3656
|
}, mn = (e) => {
|
|
3657
|
-
const t = e ?
|
|
3657
|
+
const t = e ? k.ThornodeStagenet : k.ThornodeMainnet;
|
|
3658
3658
|
return fe.get(`${t}/thorchain/mimir`);
|
|
3659
3659
|
}, Ie = () => Object.values(i).reduce(
|
|
3660
3660
|
(e, t) => (e[t] = null, e),
|
|
3661
3661
|
{}
|
|
3662
3662
|
);
|
|
3663
|
-
var
|
|
3663
|
+
var B, te, G, I, q, W;
|
|
3664
3664
|
class Dn {
|
|
3665
3665
|
constructor({ stagenet: t } = {}) {
|
|
3666
3666
|
T(this, "connectedChains", Ie());
|
|
@@ -3684,30 +3684,30 @@ class Dn {
|
|
|
3684
3684
|
throw new m("core_swap_route_not_complete");
|
|
3685
3685
|
try {
|
|
3686
3686
|
if (Qe.includes(r)) {
|
|
3687
|
-
const
|
|
3688
|
-
if (!(
|
|
3687
|
+
const l = this.connectedWallets[o];
|
|
3688
|
+
if (!(l != null && l.sendTransaction))
|
|
3689
3689
|
throw new m("core_wallet_connection_not_found");
|
|
3690
3690
|
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3691
3691
|
throw new m("core_swap_route_transaction_not_found");
|
|
3692
|
-
const { data: c, from: _, to: b, value:
|
|
3692
|
+
const { data: c, from: _, to: b, value: A } = a.transaction, E = {
|
|
3693
3693
|
data: c,
|
|
3694
3694
|
from: _,
|
|
3695
3695
|
to: b.toLowerCase(),
|
|
3696
3696
|
chainId: BigInt(rt[o]),
|
|
3697
|
-
value:
|
|
3697
|
+
value: A ? BigInt(A) : 0n
|
|
3698
3698
|
};
|
|
3699
|
-
return
|
|
3699
|
+
return l.sendTransaction(E, s);
|
|
3700
3700
|
}
|
|
3701
3701
|
if (Ze.includes(r)) {
|
|
3702
3702
|
if (!a.calldata.fromAsset)
|
|
3703
3703
|
throw new m("core_swap_asset_not_recognized");
|
|
3704
|
-
const
|
|
3705
|
-
if (!
|
|
3704
|
+
const l = await C.fromString(a.calldata.fromAsset);
|
|
3705
|
+
if (!l)
|
|
3706
3706
|
throw new m("core_swap_asset_not_recognized");
|
|
3707
|
-
const { address: u } = await f(this,
|
|
3707
|
+
const { address: u } = await f(this, B).call(this, l.chain), {
|
|
3708
3708
|
contract: c,
|
|
3709
|
-
calldata: { expiration: _, amountIn: b, memo:
|
|
3710
|
-
} = a, g =
|
|
3709
|
+
calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
|
|
3710
|
+
} = a, g = l.add(x.fromBigInt(BigInt(b), l.decimal)), O = t && E || A;
|
|
3711
3711
|
return this.deposit({
|
|
3712
3712
|
expiration: _,
|
|
3713
3713
|
assetValue: g,
|
|
@@ -3718,30 +3718,30 @@ class Dn {
|
|
|
3718
3718
|
});
|
|
3719
3719
|
}
|
|
3720
3720
|
if (ze.includes(r)) {
|
|
3721
|
-
const { calldata:
|
|
3721
|
+
const { calldata: l, contract: u } = a;
|
|
3722
3722
|
if (!u)
|
|
3723
3723
|
throw new m("core_swap_contract_not_found");
|
|
3724
3724
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3725
3725
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3726
3726
|
throw new m("core_wallet_connection_not_found");
|
|
3727
|
-
const { getProvider: b, toChecksumAddress:
|
|
3727
|
+
const { getProvider: b, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = b(o), g = dn[u.toLowerCase()];
|
|
3728
3728
|
if (!g)
|
|
3729
3729
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3730
|
-
const
|
|
3730
|
+
const D = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, g, E))).getFunction("swapIn").populateTransaction(
|
|
3731
3731
|
...un({
|
|
3732
3732
|
streamSwap: t,
|
|
3733
|
-
toChecksumAddress:
|
|
3733
|
+
toChecksumAddress: A,
|
|
3734
3734
|
contractAddress: u,
|
|
3735
3735
|
recipient: n,
|
|
3736
|
-
calldata:
|
|
3736
|
+
calldata: l
|
|
3737
3737
|
}),
|
|
3738
3738
|
{ from: _ }
|
|
3739
3739
|
);
|
|
3740
|
-
return c.sendTransaction(
|
|
3740
|
+
return c.sendTransaction(D, s);
|
|
3741
3741
|
}
|
|
3742
3742
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3743
|
-
} catch (
|
|
3744
|
-
throw new m("core_swap_transaction_error",
|
|
3743
|
+
} catch (l) {
|
|
3744
|
+
throw new m("core_swap_transaction_error", l);
|
|
3745
3745
|
}
|
|
3746
3746
|
});
|
|
3747
3747
|
T(this, "getWalletByChain", async (t, n) => {
|
|
@@ -3749,7 +3749,7 @@ class Dn {
|
|
|
3749
3749
|
const a = this.getAddress(t);
|
|
3750
3750
|
if (!a)
|
|
3751
3751
|
return null;
|
|
3752
|
-
const s = [
|
|
3752
|
+
const s = [C.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3753
3753
|
try {
|
|
3754
3754
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3755
3755
|
return this.connectedChains[t] = {
|
|
@@ -3761,8 +3761,8 @@ class Dn {
|
|
|
3761
3761
|
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3762
3762
|
}
|
|
3763
3763
|
});
|
|
3764
|
-
T(this, "approveAssetValue", (t, n) => f(this,
|
|
3765
|
-
T(this, "isAssetValueApproved", (t, n) => f(this,
|
|
3764
|
+
T(this, "approveAssetValue", (t, n) => f(this, G).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3765
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, G).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3766
3766
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3767
3767
|
var a, s;
|
|
3768
3768
|
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
@@ -3772,7 +3772,7 @@ class Dn {
|
|
|
3772
3772
|
if (!n)
|
|
3773
3773
|
throw new m("core_wallet_connection_not_found");
|
|
3774
3774
|
try {
|
|
3775
|
-
return await n.transfer(f(this,
|
|
3775
|
+
return await n.transfer(f(this, W).call(this, t));
|
|
3776
3776
|
} catch (a) {
|
|
3777
3777
|
throw new m("core_swap_transaction_error", a);
|
|
3778
3778
|
}
|
|
@@ -3786,12 +3786,12 @@ class Dn {
|
|
|
3786
3786
|
const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
|
|
3787
3787
|
if (!d)
|
|
3788
3788
|
throw new m("core_wallet_connection_not_found");
|
|
3789
|
-
const
|
|
3789
|
+
const l = f(this, W).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3790
3790
|
try {
|
|
3791
3791
|
switch (r) {
|
|
3792
3792
|
case i.THORChain: {
|
|
3793
3793
|
const u = d;
|
|
3794
|
-
return await (n === "" ? u.deposit(
|
|
3794
|
+
return await (n === "" ? u.deposit(l) : u.transfer(l));
|
|
3795
3795
|
}
|
|
3796
3796
|
case i.Ethereum:
|
|
3797
3797
|
case i.BinanceSmartChain:
|
|
@@ -3799,26 +3799,26 @@ class Dn {
|
|
|
3799
3799
|
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Ye : r === i.BinanceSmartChain ? Xe : Ke;
|
|
3800
3800
|
return await d.call({
|
|
3801
3801
|
abi: c,
|
|
3802
|
-
contractAddress: a || (await f(this,
|
|
3802
|
+
contractAddress: a || (await f(this, B).call(this, r)).router,
|
|
3803
3803
|
funcName: "depositWithExpiry",
|
|
3804
3804
|
funcParams: [
|
|
3805
3805
|
n,
|
|
3806
3806
|
u({ chain: r, symbol: o, ticker: p }, r),
|
|
3807
3807
|
t.getBaseValue("string"),
|
|
3808
|
-
|
|
3808
|
+
l.memo,
|
|
3809
3809
|
s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
3810
3810
|
],
|
|
3811
3811
|
txOverrides: {
|
|
3812
|
-
from:
|
|
3812
|
+
from: l.from,
|
|
3813
3813
|
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
3814
3814
|
}
|
|
3815
3815
|
});
|
|
3816
3816
|
}
|
|
3817
3817
|
default:
|
|
3818
|
-
return await d.transfer(
|
|
3818
|
+
return await d.transfer(l);
|
|
3819
3819
|
}
|
|
3820
3820
|
} catch (u) {
|
|
3821
|
-
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"),
|
|
3821
|
+
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), A = c == null ? void 0 : c.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : A ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3822
3822
|
throw new m(E, u);
|
|
3823
3823
|
}
|
|
3824
3824
|
});
|
|
@@ -3833,9 +3833,9 @@ class Dn {
|
|
|
3833
3833
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3834
3834
|
let a = "", s = "";
|
|
3835
3835
|
try {
|
|
3836
|
-
a = await f(this,
|
|
3836
|
+
a = await f(this, I).call(this, {
|
|
3837
3837
|
assetValue: t,
|
|
3838
|
-
memo:
|
|
3838
|
+
memo: M(h.DEPOSIT, {
|
|
3839
3839
|
...n,
|
|
3840
3840
|
address: this.getAddress(n.chain)
|
|
3841
3841
|
})
|
|
@@ -3844,9 +3844,9 @@ class Dn {
|
|
|
3844
3844
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3845
3845
|
}
|
|
3846
3846
|
try {
|
|
3847
|
-
s = await f(this,
|
|
3847
|
+
s = await f(this, I).call(this, {
|
|
3848
3848
|
assetValue: n,
|
|
3849
|
-
memo:
|
|
3849
|
+
memo: M(h.DEPOSIT, {
|
|
3850
3850
|
...n,
|
|
3851
3851
|
address: this.getAddress(i.THORChain)
|
|
3852
3852
|
})
|
|
@@ -3857,40 +3857,48 @@ class Dn {
|
|
|
3857
3857
|
return { runeTx: a, assetTx: s };
|
|
3858
3858
|
});
|
|
3859
3859
|
T(this, "addLiquidity", async ({
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
mode: p = "sym"
|
|
3860
|
+
runeAssetValue: t,
|
|
3861
|
+
assetValue: n,
|
|
3862
|
+
runeAddr: a,
|
|
3863
|
+
assetAddr: s,
|
|
3864
|
+
isPendingSymmAsset: r,
|
|
3865
|
+
mode: o = "sym"
|
|
3867
3866
|
}) => {
|
|
3868
|
-
const
|
|
3869
|
-
if (!
|
|
3867
|
+
const { chain: p, symbol: d } = n, l = o === "sym", u = (t == null ? void 0 : t.gt(0)) && (l || o === "rune"), c = (n == null ? void 0 : n.gt(0)) && (l || o === "asset"), _ = r || u, b = _ ? a || this.getAddress(i.THORChain) : "", A = l || o === "asset" ? s || this.getAddress(p) : "";
|
|
3868
|
+
if (!u && !c)
|
|
3870
3869
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3871
|
-
if (
|
|
3870
|
+
if (_ && !b)
|
|
3872
3871
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3873
|
-
let
|
|
3874
|
-
|
|
3875
|
-
if (c && n)
|
|
3872
|
+
let E, g;
|
|
3873
|
+
if (u && t)
|
|
3876
3874
|
try {
|
|
3877
|
-
|
|
3878
|
-
assetValue:
|
|
3879
|
-
memo:
|
|
3875
|
+
E = await f(this, I).call(this, {
|
|
3876
|
+
assetValue: t,
|
|
3877
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: A })
|
|
3880
3878
|
});
|
|
3881
|
-
} catch (
|
|
3882
|
-
throw new m("core_transaction_add_liquidity_rune_error",
|
|
3879
|
+
} catch (O) {
|
|
3880
|
+
throw new m("core_transaction_add_liquidity_rune_error", O);
|
|
3883
3881
|
}
|
|
3884
|
-
if (
|
|
3882
|
+
if (c && n)
|
|
3885
3883
|
try {
|
|
3886
|
-
|
|
3887
|
-
assetValue:
|
|
3888
|
-
memo:
|
|
3884
|
+
g = await f(this, I).call(this, {
|
|
3885
|
+
assetValue: n,
|
|
3886
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: b })
|
|
3889
3887
|
});
|
|
3890
|
-
} catch (
|
|
3891
|
-
throw new m("core_transaction_add_liquidity_asset_error",
|
|
3888
|
+
} catch (O) {
|
|
3889
|
+
throw new m("core_transaction_add_liquidity_asset_error", O);
|
|
3892
3890
|
}
|
|
3893
|
-
return { runeTx:
|
|
3891
|
+
return { runeTx: E, assetTx: g };
|
|
3892
|
+
});
|
|
3893
|
+
T(this, "addLiquidityPart", ({
|
|
3894
|
+
assetValue: t,
|
|
3895
|
+
poolAddress: n,
|
|
3896
|
+
address: a,
|
|
3897
|
+
symmetric: s
|
|
3898
|
+
}) => {
|
|
3899
|
+
if (s && !a)
|
|
3900
|
+
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3901
|
+
return f(this, I).call(this, { assetValue: t, memo: `+:${n}:${a || ""}:t:0` });
|
|
3894
3902
|
});
|
|
3895
3903
|
T(this, "withdraw", async ({
|
|
3896
3904
|
memo: t,
|
|
@@ -3899,7 +3907,7 @@ class Dn {
|
|
|
3899
3907
|
from: s,
|
|
3900
3908
|
to: r
|
|
3901
3909
|
}) => {
|
|
3902
|
-
const o = r === "rune" ?
|
|
3910
|
+
const o = r === "rune" ? C.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = oe(s === "asset" ? n.chain : i.THORChain), d = t || M(h.WITHDRAW, {
|
|
3903
3911
|
symbol: n.symbol,
|
|
3904
3912
|
chain: n.chain,
|
|
3905
3913
|
ticker: n.ticker,
|
|
@@ -3907,7 +3915,7 @@ class Dn {
|
|
|
3907
3915
|
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3908
3916
|
singleSide: !1
|
|
3909
3917
|
});
|
|
3910
|
-
return f(this,
|
|
3918
|
+
return f(this, I).call(this, { assetValue: p, memo: d });
|
|
3911
3919
|
});
|
|
3912
3920
|
T(this, "savings", async ({
|
|
3913
3921
|
assetValue: t,
|
|
@@ -3915,23 +3923,23 @@ class Dn {
|
|
|
3915
3923
|
percent: a,
|
|
3916
3924
|
type: s
|
|
3917
3925
|
}) => {
|
|
3918
|
-
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n ||
|
|
3926
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || M(r, {
|
|
3919
3927
|
ticker: t.ticker,
|
|
3920
3928
|
symbol: t.symbol,
|
|
3921
3929
|
chain: t.chain,
|
|
3922
3930
|
singleSide: !0,
|
|
3923
3931
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3924
3932
|
}), p = r === h.DEPOSIT ? t : oe(t.chain);
|
|
3925
|
-
return f(this,
|
|
3933
|
+
return f(this, I).call(this, { memo: o, assetValue: p });
|
|
3926
3934
|
});
|
|
3927
3935
|
T(this, "loan", ({
|
|
3928
3936
|
assetValue: t,
|
|
3929
3937
|
memo: n,
|
|
3930
3938
|
minAmount: a,
|
|
3931
3939
|
type: s
|
|
3932
|
-
}) => f(this,
|
|
3940
|
+
}) => f(this, I).call(this, {
|
|
3933
3941
|
assetValue: t,
|
|
3934
|
-
memo: n ||
|
|
3942
|
+
memo: n || M(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3935
3943
|
asset: t.toString(),
|
|
3936
3944
|
minAmount: a.toString(),
|
|
3937
3945
|
address: this.getAddress(t.chain)
|
|
@@ -3942,11 +3950,11 @@ class Dn {
|
|
|
3942
3950
|
assetValue: n,
|
|
3943
3951
|
address: a
|
|
3944
3952
|
}) => {
|
|
3945
|
-
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r =
|
|
3953
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = M(s, {
|
|
3946
3954
|
address: a,
|
|
3947
3955
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
3948
3956
|
});
|
|
3949
|
-
return f(this,
|
|
3957
|
+
return f(this, q).call(this, {
|
|
3950
3958
|
memo: r,
|
|
3951
3959
|
assetValue: t === "bond" ? n : oe(i.THORChain)
|
|
3952
3960
|
});
|
|
@@ -3954,12 +3962,12 @@ class Dn {
|
|
|
3954
3962
|
T(this, "registerThorname", ({
|
|
3955
3963
|
assetValue: t,
|
|
3956
3964
|
...n
|
|
3957
|
-
}) => f(this,
|
|
3965
|
+
}) => f(this, q).call(this, { assetValue: t, memo: M(h.THORNAME_REGISTER, n) }));
|
|
3958
3966
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3959
3967
|
try {
|
|
3960
3968
|
t.forEach((r) => {
|
|
3961
3969
|
this[r.connectMethodName] = r.connect({
|
|
3962
|
-
addChain: f(this,
|
|
3970
|
+
addChain: f(this, te),
|
|
3963
3971
|
config: n || {},
|
|
3964
3972
|
apis: a,
|
|
3965
3973
|
rpcUrls: s
|
|
@@ -4035,7 +4043,7 @@ class Dn {
|
|
|
4035
4043
|
T(this, "disconnectChain", (t) => {
|
|
4036
4044
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
4037
4045
|
});
|
|
4038
|
-
|
|
4046
|
+
P(this, B, async (t) => {
|
|
4039
4047
|
if (t === i.THORChain)
|
|
4040
4048
|
return {
|
|
4041
4049
|
gas_rate: "0",
|
|
@@ -4051,10 +4059,10 @@ class Dn {
|
|
|
4051
4059
|
throw new m("core_chain_halted");
|
|
4052
4060
|
return a;
|
|
4053
4061
|
});
|
|
4054
|
-
|
|
4062
|
+
P(this, te, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4055
4063
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4056
4064
|
});
|
|
4057
|
-
|
|
4065
|
+
P(this, G, async ({
|
|
4058
4066
|
assetValue: t,
|
|
4059
4067
|
type: n = "checkOnly",
|
|
4060
4068
|
contractAddress: a
|
|
@@ -4068,7 +4076,7 @@ class Dn {
|
|
|
4068
4076
|
const _ = this.getAddress(r);
|
|
4069
4077
|
if (!s || !_)
|
|
4070
4078
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
4071
|
-
const b = a || (await f(this,
|
|
4079
|
+
const b = a || (await f(this, B).call(this, r)).router;
|
|
4072
4080
|
return c({
|
|
4073
4081
|
amount: t.getBaseValue("bigint"),
|
|
4074
4082
|
assetAddress: s,
|
|
@@ -4076,16 +4084,16 @@ class Dn {
|
|
|
4076
4084
|
spenderAddress: b
|
|
4077
4085
|
});
|
|
4078
4086
|
});
|
|
4079
|
-
|
|
4087
|
+
P(this, I, async ({
|
|
4080
4088
|
assetValue: t,
|
|
4081
4089
|
memo: n,
|
|
4082
|
-
feeOptionKey: a =
|
|
4090
|
+
feeOptionKey: a = H.Fast
|
|
4083
4091
|
}) => {
|
|
4084
4092
|
const {
|
|
4085
4093
|
gas_rate: s,
|
|
4086
4094
|
router: r,
|
|
4087
4095
|
address: o
|
|
4088
|
-
} = await f(this,
|
|
4096
|
+
} = await f(this, B).call(this, t.chain), p = (parseInt(s) || 0) * ft[a];
|
|
4089
4097
|
return this.deposit({
|
|
4090
4098
|
assetValue: t,
|
|
4091
4099
|
recipient: o,
|
|
@@ -4094,13 +4102,13 @@ class Dn {
|
|
|
4094
4102
|
feeRate: p
|
|
4095
4103
|
});
|
|
4096
4104
|
});
|
|
4097
|
-
|
|
4105
|
+
P(this, q, async ({ memo: t, assetValue: n }) => {
|
|
4098
4106
|
const a = await mn(this.stagenet);
|
|
4099
4107
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4100
4108
|
throw new m("core_chain_halted");
|
|
4101
4109
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
4102
4110
|
});
|
|
4103
|
-
|
|
4111
|
+
P(this, W, ({ assetValue: t, ...n }) => ({
|
|
4104
4112
|
...n,
|
|
4105
4113
|
memo: n.memo || "",
|
|
4106
4114
|
from: this.getAddress(t.chain),
|
|
@@ -4109,13 +4117,13 @@ class Dn {
|
|
|
4109
4117
|
this.stagenet = !!t;
|
|
4110
4118
|
}
|
|
4111
4119
|
}
|
|
4112
|
-
|
|
4120
|
+
B = new WeakMap(), te = new WeakMap(), G = new WeakMap(), I = new WeakMap(), q = new WeakMap(), W = new WeakMap();
|
|
4113
4121
|
export {
|
|
4114
4122
|
Qe as AGG_SWAP,
|
|
4115
4123
|
ve as ApiError,
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4124
|
+
k as ApiUrl,
|
|
4125
|
+
C as AssetValue,
|
|
4126
|
+
w as BaseDecimal,
|
|
4119
4127
|
ye as BigIntArithmetics,
|
|
4120
4128
|
i as Chain,
|
|
4121
4129
|
Te as ChainId,
|
|
@@ -4127,12 +4135,12 @@ export {
|
|
|
4127
4135
|
nt as ContractAddress,
|
|
4128
4136
|
bn as CosmosChainList,
|
|
4129
4137
|
at as DerivationPath,
|
|
4130
|
-
|
|
4138
|
+
y as ERROR_CODE,
|
|
4131
4139
|
et as ERROR_MODULE,
|
|
4132
4140
|
Se as ERROR_TYPE,
|
|
4133
4141
|
st as EVMChainList,
|
|
4134
4142
|
pt as ErrorCode,
|
|
4135
|
-
|
|
4143
|
+
H as FeeOption,
|
|
4136
4144
|
h as MemoType,
|
|
4137
4145
|
_n as NetworkDerivationPath,
|
|
4138
4146
|
Je as QuoteMode,
|
|
@@ -4142,7 +4150,7 @@ export {
|
|
|
4142
4150
|
Ze as SWAP_OUT,
|
|
4143
4151
|
Dn as SwapKitCore,
|
|
4144
4152
|
m as SwapKitError,
|
|
4145
|
-
|
|
4153
|
+
x as SwapKitNumber,
|
|
4146
4154
|
Ye as TCAvalancheDepositABI,
|
|
4147
4155
|
Xe as TCBscDepositABI,
|
|
4148
4156
|
Ke as TCEthereumVaultAbi,
|
|
@@ -4153,7 +4161,7 @@ export {
|
|
|
4153
4161
|
xn as derivationPathToString,
|
|
4154
4162
|
hn as erc20ABI,
|
|
4155
4163
|
gn as filterAssets,
|
|
4156
|
-
|
|
4164
|
+
ae as formatBigIntToSafeValue,
|
|
4157
4165
|
ft as gasFeeMultiplier,
|
|
4158
4166
|
wt as getAssetType,
|
|
4159
4167
|
gt as getAsymmetricAssetShare,
|
|
@@ -4164,7 +4172,7 @@ export {
|
|
|
4164
4172
|
_t as getDecimal,
|
|
4165
4173
|
vn as getEstimatedPoolShare,
|
|
4166
4174
|
Cn as getLiquiditySlippage,
|
|
4167
|
-
|
|
4175
|
+
M as getMemoFor,
|
|
4168
4176
|
oe as getMinAmountByChain,
|
|
4169
4177
|
Ot as getSymmetricPoolShare,
|
|
4170
4178
|
Sn as getSymmetricWithdraw,
|