@swapkit/core 1.0.0-rc.80 → 1.0.0-rc.82
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.cjs.map +1 -1
- package/dist/index.es.js +470 -481
- package/dist/index.es.js.map +1 -1
- package/package.json +8 -8
- package/src/client/index.ts +23 -22
package/dist/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ var c = (e, t, n) => (Ye(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
|
|
7
|
+
var h = (e, t, n) => (Qe(e, t, "read from private field"), n ? n.call(e) : t.get(e)), B = (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,73 +624,73 @@ const at = [
|
|
|
624
624
|
"TC-BEP20"
|
|
625
625
|
/* TC_SUPPORTED_TO_BSC */
|
|
626
626
|
];
|
|
627
|
-
var
|
|
627
|
+
var Ce = /* @__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))(Ce || {}), rt = /* @__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))(rt || {}), l = /* @__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_MAX_500 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROVIDER_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))(l || {});
|
|
628
628
|
const pt = {
|
|
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
|
+
[l.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
|
+
[l.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
|
+
[l.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
632
|
+
[l.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
|
|
633
|
+
[l.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
|
|
634
|
+
[l.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
|
|
635
|
+
[l.INVALID_TYPE_GENERIC]: "Invalid type",
|
|
636
|
+
[l.INVALID_NUMBER_STRING]: "Invalid number string.",
|
|
637
|
+
[l.INVALID_NUMBER]: "Invalid number.",
|
|
638
|
+
[l.INVALID_BOOLEAN]: "Invalid boolean.",
|
|
639
|
+
[l.INVALID_OBJECT]: "Invalid object.",
|
|
640
|
+
[l.INVALID_ARRAY]: "Invalid array.",
|
|
641
|
+
[l.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
|
|
642
|
+
[l.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
|
|
643
|
+
[l.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
|
|
644
|
+
[l.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
|
|
645
|
+
[l.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
|
|
646
|
+
[l.AFF_BPS_INTEGER_MAX_500]: "affiliateBasisPoints must be an integer between 0 and 100.",
|
|
647
|
+
[l.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
|
|
648
|
+
[l.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
|
|
649
|
+
[l.PREFERRED_PROVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
|
|
650
|
+
[l.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
|
|
651
|
+
[l.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
|
|
652
|
+
[l.INVALID_PROVIDER]: "Invalid provider {0}.",
|
|
653
|
+
[l.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
|
|
654
|
+
[l.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
|
|
655
|
+
[l.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
|
|
656
|
+
[l.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
|
|
657
|
+
[l.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
|
|
658
|
+
[l.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
|
|
659
|
+
[l.INVALID_CHAIN]: "Invalid chain {0}.",
|
|
660
|
+
[l.INVALID_ASSET]: "Invalid asset {0}.",
|
|
661
|
+
[l.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
|
|
662
|
+
[l.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
|
|
663
|
+
[l.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
|
|
664
|
+
[l.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
|
|
665
|
+
[l.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
|
|
666
|
+
[l.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
|
|
667
|
+
[l.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
|
|
668
|
+
[l.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
|
|
669
|
+
[l.INVALID_QUOTE_MODE]: "Invalid quote mode.",
|
|
670
|
+
[l.NO_QUOTES]: "No quotes to service this request.",
|
|
671
|
+
[l.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
|
|
672
|
+
[l.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
|
|
673
|
+
[l.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
|
|
674
|
+
[l.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
|
|
675
|
+
[l.NO_PRICE]: "No price for asset {0}.",
|
|
676
|
+
[l.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
|
+
[l.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
|
+
[l.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
679
|
}, ue = (e, t) => {
|
|
680
680
|
let n = pt[e];
|
|
681
681
|
for (let a = 0; a < t.length; a++)
|
|
682
682
|
n = n.replace(`{${a}}`, t[a]);
|
|
683
683
|
return t.length === 0 ? n.replace("{0}", "") : n;
|
|
684
684
|
};
|
|
685
|
-
let Sn = class
|
|
685
|
+
let Sn = class xe extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
689
689
|
module: a,
|
|
690
690
|
code: i,
|
|
691
691
|
message: r,
|
|
692
|
-
type:
|
|
693
|
-
options: { shouldLog:
|
|
692
|
+
type: p,
|
|
693
|
+
options: { shouldLog: u, shouldThrow: y, shouldTrace: d } = {
|
|
694
694
|
shouldLog: !0,
|
|
695
695
|
shouldThrow: !0,
|
|
696
696
|
shouldTrace: !0
|
|
@@ -698,14 +698,14 @@ let Sn = class ke extends Error {
|
|
|
698
698
|
displayMessageParams: o
|
|
699
699
|
}) {
|
|
700
700
|
const T = r || ue(i, o || []) || "";
|
|
701
|
-
super(T), 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 = T, this.display = ue(i, o || []), this.code = i, this.type =
|
|
702
|
-
shouldLog:
|
|
703
|
-
shouldTrace:
|
|
701
|
+
super(T), 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 = T, this.display = ue(i, o || []), this.code = i, this.type = p || Ce.UNHANDLED_ERROR, this.options = {
|
|
702
|
+
shouldLog: u || !0,
|
|
703
|
+
shouldTrace: d || !0,
|
|
704
704
|
shouldThrow: y || !1
|
|
705
705
|
}, this.displayMessageParams = o || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new xe(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -775,20 +775,20 @@ const ot = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var fe = /* @__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))(fe || {}),
|
|
779
|
-
const
|
|
778
|
+
var fe = /* @__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))(fe || {}), ke = /* @__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))(ke || {}), X = /* @__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.net", e.ThorswapStatic = "https://static.thorswap.net", e))(X || {});
|
|
779
|
+
const se = Object.values(s), dt = Object.keys(s), he = se.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
781
|
const n = dt.find((a) => s[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
785
|
+
), De = se.reduce(
|
|
786
786
|
(e, t) => (e[t] = fe[he[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), lt = se.reduce(
|
|
789
|
+
(e, t) => (e[t] = ke[he[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
), Bn =
|
|
791
|
+
), Bn = se.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
793
|
const n = `${he[t]}Hex`;
|
|
794
794
|
return e[t] = fe[n], e;
|
|
@@ -836,17 +836,17 @@ const re = Object.values(s), dt = Object.keys(s), he = re.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://runescan.io"
|
|
838
838
|
};
|
|
839
|
-
var
|
|
839
|
+
var mt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(mt || {}), b = /* @__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))(b || {}), q = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(q || {}), Tt = /* @__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.OKX_MOBILE = "OKX_MOBILE", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(Tt || {}), ct = Object.defineProperty, bt = (e, t, n) => t in e ? ct(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (bt(e, typeof t != "symbol" ? t + "" : t, n), n), ft = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
|
-
},
|
|
842
|
+
}, F = (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
|
-
},
|
|
847
|
-
const
|
|
846
|
+
}, E = (e, t, n) => (ft(e, t, "access private method"), n);
|
|
847
|
+
const ht = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await
|
|
849
|
+
const { result: n } = await _e.post(lt[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -856,7 +856,7 @@ const _t = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
856
856
|
id: 44,
|
|
857
857
|
jsonrpc: "2.0",
|
|
858
858
|
method: "eth_call",
|
|
859
|
-
params: [{ to: t.toLowerCase(), data:
|
|
859
|
+
params: [{ to: t.toLowerCase(), data: ht }, "latest"]
|
|
860
860
|
})
|
|
861
861
|
});
|
|
862
862
|
return parseInt(BigInt(n).toString());
|
|
@@ -868,24 +868,24 @@ const _t = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
868
868
|
return A.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
870
|
return t != null && t.startsWith("0x") ? Ne({ chain: s.Ethereum, to: t }) : A.ETH;
|
|
871
|
-
},
|
|
871
|
+
}, _t = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
873
|
return t != null && t.startsWith("0x") ? Ne({ chain: s.Avalanche, to: t.toLowerCase() }) : A.AVAX;
|
|
874
|
-
},
|
|
874
|
+
}, wt = async (e) => (e === s.BinanceSmartChain, A.BSC), Mt = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case s.Ethereum:
|
|
877
877
|
return At(t);
|
|
878
878
|
case s.Avalanche:
|
|
879
|
-
return
|
|
879
|
+
return _t(t);
|
|
880
880
|
case s.BinanceSmartChain:
|
|
881
|
-
return
|
|
881
|
+
return wt(t);
|
|
882
882
|
default:
|
|
883
883
|
return A[e];
|
|
884
884
|
}
|
|
885
|
-
},
|
|
886
|
-
[
|
|
887
|
-
[
|
|
888
|
-
[
|
|
885
|
+
}, Et = {
|
|
886
|
+
[q.Average]: 1.2,
|
|
887
|
+
[q.Fast]: 1.5,
|
|
888
|
+
[q.Fastest]: 2
|
|
889
889
|
}, Pe = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case s.Bitcoin:
|
|
@@ -912,7 +912,7 @@ const _t = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
912
912
|
case s.THORChain:
|
|
913
913
|
return t === "RUNE";
|
|
914
914
|
}
|
|
915
|
-
},
|
|
915
|
+
}, gt = (e) => {
|
|
916
916
|
switch (e) {
|
|
917
917
|
case "ETH.THOR":
|
|
918
918
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
@@ -941,7 +941,7 @@ const _t = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
941
941
|
case s.Ethereum:
|
|
942
942
|
return { identifier: `${e}.${e}`, decimal: A[e] };
|
|
943
943
|
}
|
|
944
|
-
},
|
|
944
|
+
}, Rt = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
946
946
|
return "Synth";
|
|
947
947
|
switch (e) {
|
|
@@ -973,12 +973,12 @@ const _t = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
973
973
|
}
|
|
974
974
|
}, Pn = (e) => {
|
|
975
975
|
var t;
|
|
976
|
-
const [n, ...a] = e.split("."), i = e.includes("/"), r = a.join("."),
|
|
977
|
-
return { chain: n, symbol: r, ticker:
|
|
978
|
-
},
|
|
976
|
+
const [n, ...a] = e.split("."), i = e.includes("/"), r = a.join("."), p = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
977
|
+
return { chain: n, symbol: r, ticker: p, synth: i };
|
|
978
|
+
}, Ot = new RegExp(
|
|
979
979
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
980
|
"gmi"
|
|
981
|
-
),
|
|
981
|
+
), vt = (e) => {
|
|
982
982
|
const [t, n] = e.split(".");
|
|
983
983
|
if (!ot.includes(t))
|
|
984
984
|
return !0;
|
|
@@ -986,22 +986,22 @@ const _t = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
986
986
|
return Pe({ chain: t, symbol: n }) || !!a;
|
|
987
987
|
}, Ln = (e) => e.filter((t) => {
|
|
988
988
|
const n = `${t.chain}.${t.symbol}`;
|
|
989
|
-
return !
|
|
989
|
+
return !Ot.test(n) && vt(n) && t.value !== "0";
|
|
990
990
|
});
|
|
991
|
-
function
|
|
991
|
+
function It({
|
|
992
992
|
liquidityUnits: e,
|
|
993
993
|
poolUnits: t,
|
|
994
994
|
runeDepth: n
|
|
995
995
|
}) {
|
|
996
|
-
const a =
|
|
997
|
-
return
|
|
996
|
+
const a = g(e), i = g(t), r = g(n), p = a.mul(r), u = i.mul(i).mul(2), y = i.mul(a).mul(2), d = a.mul(a), o = i.mul(i).mul(i);
|
|
997
|
+
return p.mul(u.sub(y).add(d)).div(o);
|
|
998
998
|
}
|
|
999
|
-
function
|
|
999
|
+
function St({
|
|
1000
1000
|
liquidityUnits: e,
|
|
1001
1001
|
poolUnits: t,
|
|
1002
1002
|
assetDepth: n
|
|
1003
1003
|
}) {
|
|
1004
|
-
const a =
|
|
1004
|
+
const a = g(e), i = g(t), r = g(n), p = a.mul(r), u = i.mul(i).mul(2), y = i.mul(a).mul(2), d = a.mul(a), o = p.mul(u.sub(y).add(d)), T = i.mul(i).mul(i);
|
|
1005
1005
|
return o.div(T);
|
|
1006
1006
|
}
|
|
1007
1007
|
function Hn({
|
|
@@ -1010,7 +1010,7 @@ function Hn({
|
|
|
1010
1010
|
liquidityUnits: n,
|
|
1011
1011
|
poolUnits: a
|
|
1012
1012
|
}) {
|
|
1013
|
-
return
|
|
1013
|
+
return It({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1014
1014
|
}
|
|
1015
1015
|
function Vn({
|
|
1016
1016
|
percent: e,
|
|
@@ -1018,20 +1018,20 @@ function Vn({
|
|
|
1018
1018
|
liquidityUnits: n,
|
|
1019
1019
|
poolUnits: a
|
|
1020
1020
|
}) {
|
|
1021
|
-
return
|
|
1021
|
+
return St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1022
1022
|
}
|
|
1023
|
-
function
|
|
1024
|
-
return
|
|
1023
|
+
function g(e) {
|
|
1024
|
+
return k.fromBigInt(BigInt(e), A.THOR);
|
|
1025
1025
|
}
|
|
1026
|
-
function
|
|
1026
|
+
function Ct({
|
|
1027
1027
|
liquidityUnits: e,
|
|
1028
1028
|
poolUnits: t,
|
|
1029
1029
|
runeDepth: n,
|
|
1030
1030
|
assetDepth: a
|
|
1031
1031
|
}) {
|
|
1032
1032
|
return {
|
|
1033
|
-
assetAmount:
|
|
1034
|
-
runeAmount:
|
|
1033
|
+
assetAmount: g(a).mul(e).div(t),
|
|
1034
|
+
runeAmount: g(n).mul(e).div(t)
|
|
1035
1035
|
};
|
|
1036
1036
|
}
|
|
1037
1037
|
function Fn({
|
|
@@ -1042,8 +1042,8 @@ function Fn({
|
|
|
1042
1042
|
percent: i
|
|
1043
1043
|
}) {
|
|
1044
1044
|
return Object.fromEntries(
|
|
1045
|
-
Object.entries(
|
|
1046
|
-
([r,
|
|
1045
|
+
Object.entries(Ct({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1046
|
+
([r, p]) => [r, p.mul(i)]
|
|
1047
1047
|
)
|
|
1048
1048
|
);
|
|
1049
1049
|
}
|
|
@@ -1055,11 +1055,11 @@ function Un({
|
|
|
1055
1055
|
runeAmount: i,
|
|
1056
1056
|
assetAmount: r
|
|
1057
1057
|
}) {
|
|
1058
|
-
const
|
|
1059
|
-
if (
|
|
1060
|
-
return
|
|
1061
|
-
const
|
|
1062
|
-
return
|
|
1058
|
+
const p = new k({ value: e, decimal: 8 }), u = new k({ value: n, decimal: 8 }), y = new k({ value: t, decimal: 8 }), d = new k({ value: i, decimal: 8 }), o = new k({ value: r, decimal: 8 }), T = d.mul(u), f = o.mul(p), _ = d.mul(o), w = p.mul(u), M = y.mul(T.add(f.add(_.mul(2)))), R = T.add(f.add(w.mul(2))), O = M.div(R), D = g(a).add(O);
|
|
1059
|
+
if (O.getBaseValue("number") === 0)
|
|
1060
|
+
return D.div(y).getBaseValue("number");
|
|
1061
|
+
const pe = y.add(D);
|
|
1062
|
+
return D.div(pe).getBaseValue("number");
|
|
1063
1063
|
}
|
|
1064
1064
|
function qn({
|
|
1065
1065
|
runeAmount: e,
|
|
@@ -1069,28 +1069,28 @@ function qn({
|
|
|
1069
1069
|
}) {
|
|
1070
1070
|
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1071
1071
|
return 0;
|
|
1072
|
-
const i =
|
|
1073
|
-
return Math.abs(y.div(
|
|
1072
|
+
const i = g(n), r = g(a), p = g(t), u = g(e), y = p.mul(i).sub(r.mul(u)), d = r.mul(u).add(i.mul(r));
|
|
1073
|
+
return Math.abs(y.div(d).getBaseValue("number"));
|
|
1074
1074
|
}
|
|
1075
1075
|
const C = (e, t) => {
|
|
1076
1076
|
switch (e) {
|
|
1077
|
-
case
|
|
1078
|
-
case
|
|
1077
|
+
case b.LEAVE:
|
|
1078
|
+
case b.BOND: {
|
|
1079
1079
|
const { address: n } = t;
|
|
1080
1080
|
return `${e}:${n}`;
|
|
1081
1081
|
}
|
|
1082
|
-
case
|
|
1082
|
+
case b.UNBOND: {
|
|
1083
1083
|
const { address: n, unbondAmount: a } = t;
|
|
1084
1084
|
return `${e}:${n}:${a}`;
|
|
1085
1085
|
}
|
|
1086
|
-
case
|
|
1086
|
+
case b.THORNAME_REGISTER: {
|
|
1087
1087
|
const { name: n, chain: a, address: i, owner: r } = t;
|
|
1088
1088
|
return `${e}:${n}:${a}:${i}${r ? `:${r}` : ""}`;
|
|
1089
1089
|
}
|
|
1090
|
-
case
|
|
1090
|
+
case b.DEPOSIT: {
|
|
1091
1091
|
const { chain: n, symbol: a, address: i, singleSide: r } = t;
|
|
1092
|
-
return r ? `${e}:${n}/${a}::t:0` : `${e}:${((
|
|
1093
|
-
switch (
|
|
1092
|
+
return r ? `${e}:${n}/${a}::t:0` : `${e}:${((p, u) => {
|
|
1093
|
+
switch (p) {
|
|
1094
1094
|
case s.Litecoin:
|
|
1095
1095
|
return "l";
|
|
1096
1096
|
case s.Dogecoin:
|
|
@@ -1098,16 +1098,16 @@ const C = (e, t) => {
|
|
|
1098
1098
|
case s.BitcoinCash:
|
|
1099
1099
|
return "c";
|
|
1100
1100
|
default:
|
|
1101
|
-
return `${
|
|
1101
|
+
return `${p}.${u}`;
|
|
1102
1102
|
}
|
|
1103
1103
|
})(n, a)}:${i || ""}:t:0`;
|
|
1104
1104
|
}
|
|
1105
|
-
case
|
|
1106
|
-
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString:
|
|
1107
|
-
return `${e}:${n}${
|
|
1105
|
+
case b.WITHDRAW: {
|
|
1106
|
+
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: u } = t, y = n === "ETH" && a !== "ETH" ? `${a}-${i.slice(-3)}` : i, d = !u && p ? `:${p}` : "";
|
|
1107
|
+
return `${e}:${n}${u ? "/" : "."}${y}:${r}${d}`;
|
|
1108
1108
|
}
|
|
1109
|
-
case
|
|
1110
|
-
case
|
|
1109
|
+
case b.OPEN_LOAN:
|
|
1110
|
+
case b.CLOSE_LOAN: {
|
|
1111
1111
|
const { asset: n, address: a } = t;
|
|
1112
1112
|
return `${e}:${n}:${a}`;
|
|
1113
1113
|
}
|
|
@@ -1131,8 +1131,8 @@ function Gn([e, t, n, a, i]) {
|
|
|
1131
1131
|
}
|
|
1132
1132
|
class we extends Error {
|
|
1133
1133
|
constructor(t, n, a) {
|
|
1134
|
-
const i = t.status || t.status === 0 ? t.status : "", r = t.statusText || "",
|
|
1135
|
-
super(`Request failed with ${
|
|
1134
|
+
const i = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", p = `${i} ${r}`.trim(), u = p ? `status code ${p}` : "an unknown error";
|
|
1135
|
+
super(`Request failed with ${u}`), Object.defineProperty(this, "response", {
|
|
1136
1136
|
enumerable: !0,
|
|
1137
1137
|
configurable: !0,
|
|
1138
1138
|
writable: !0,
|
|
@@ -1160,28 +1160,28 @@ class Le extends Error {
|
|
|
1160
1160
|
}), this.name = "TimeoutError", this.request = t;
|
|
1161
1161
|
}
|
|
1162
1162
|
}
|
|
1163
|
-
const
|
|
1163
|
+
const Z = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
1164
1164
|
for (const t of e)
|
|
1165
|
-
if ((!
|
|
1165
|
+
if ((!Z(t) || Array.isArray(t)) && t !== void 0)
|
|
1166
1166
|
throw new TypeError("The `options` argument must be an object");
|
|
1167
|
-
return
|
|
1167
|
+
return Ae({}, ...e);
|
|
1168
1168
|
}, He = (e = {}, t = {}) => {
|
|
1169
1169
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, i = new globalThis.Headers(t);
|
|
1170
|
-
for (const [r,
|
|
1171
|
-
a &&
|
|
1170
|
+
for (const [r, p] of i.entries())
|
|
1171
|
+
a && p === "undefined" || p === void 0 ? n.delete(r) : n.set(r, p);
|
|
1172
1172
|
return n;
|
|
1173
|
-
},
|
|
1173
|
+
}, Ae = (...e) => {
|
|
1174
1174
|
let t = {}, n = {};
|
|
1175
1175
|
for (const a of e)
|
|
1176
1176
|
if (Array.isArray(a))
|
|
1177
1177
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1178
|
-
else if (
|
|
1178
|
+
else if (Z(a)) {
|
|
1179
1179
|
for (let [i, r] of Object.entries(a))
|
|
1180
|
-
|
|
1181
|
-
|
|
1180
|
+
Z(r) && i in t && (r = Ae(t[i], r)), t = { ...t, [i]: r };
|
|
1181
|
+
Z(a.headers) && (n = He(n, a.headers), t.headers = n);
|
|
1182
1182
|
}
|
|
1183
1183
|
return t;
|
|
1184
|
-
},
|
|
1184
|
+
}, xt = (() => {
|
|
1185
1185
|
let e = !1, t = !1;
|
|
1186
1186
|
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1187
1187
|
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
@@ -1192,13 +1192,13 @@ const z = (e) => e !== null && typeof e == "object", Z = (...e) => {
|
|
|
1192
1192
|
return e = !0, "half";
|
|
1193
1193
|
}
|
|
1194
1194
|
}).headers.has("Content-Type")), e && !t;
|
|
1195
|
-
})(),
|
|
1195
|
+
})(), kt = typeof globalThis.AbortController == "function", Dt = typeof globalThis.ReadableStream == "function", Bt = typeof globalThis.FormData == "function", Ve = ["get", "post", "put", "patch", "head", "delete"], Nt = {
|
|
1196
1196
|
json: "application/json",
|
|
1197
1197
|
text: "text/*",
|
|
1198
1198
|
formData: "multipart/form-data",
|
|
1199
1199
|
arrayBuffer: "*/*",
|
|
1200
1200
|
blob: "*/*"
|
|
1201
|
-
}, ye = 2147483647, Fe = Symbol("stop"),
|
|
1201
|
+
}, ye = 2147483647, Fe = Symbol("stop"), Pt = {
|
|
1202
1202
|
json: !0,
|
|
1203
1203
|
parseJson: !0,
|
|
1204
1204
|
searchParams: !0,
|
|
@@ -1209,7 +1209,7 @@ const z = (e) => e !== null && typeof e == "object", Z = (...e) => {
|
|
|
1209
1209
|
throwHttpErrors: !0,
|
|
1210
1210
|
onDownloadProgress: !0,
|
|
1211
1211
|
fetch: !0
|
|
1212
|
-
},
|
|
1212
|
+
}, Lt = {
|
|
1213
1213
|
method: !0,
|
|
1214
1214
|
headers: !0,
|
|
1215
1215
|
body: !0,
|
|
@@ -1225,15 +1225,15 @@ const z = (e) => e !== null && typeof e == "object", Z = (...e) => {
|
|
|
1225
1225
|
window: !0,
|
|
1226
1226
|
dispatcher: !0,
|
|
1227
1227
|
duplex: !0
|
|
1228
|
-
},
|
|
1228
|
+
}, Ht = (e) => Ve.includes(e) ? e.toUpperCase() : e, Vt = ["get", "put", "head", "delete", "options", "trace"], Ft = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], Me = {
|
|
1229
1229
|
limit: 2,
|
|
1230
|
-
methods:
|
|
1231
|
-
statusCodes:
|
|
1230
|
+
methods: Vt,
|
|
1231
|
+
statusCodes: Ft,
|
|
1232
1232
|
afterStatusCodes: Ue,
|
|
1233
1233
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1234
1234
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1235
1235
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1236
|
-
},
|
|
1236
|
+
}, Ut = (e = {}) => {
|
|
1237
1237
|
if (typeof e == "number")
|
|
1238
1238
|
return {
|
|
1239
1239
|
...Me,
|
|
@@ -1249,17 +1249,17 @@ const z = (e) => e !== null && typeof e == "object", Z = (...e) => {
|
|
|
1249
1249
|
afterStatusCodes: Ue
|
|
1250
1250
|
};
|
|
1251
1251
|
};
|
|
1252
|
-
async function
|
|
1252
|
+
async function qt(e, t, n, a) {
|
|
1253
1253
|
return new Promise((i, r) => {
|
|
1254
|
-
const
|
|
1254
|
+
const p = setTimeout(() => {
|
|
1255
1255
|
n && n.abort(), r(new Le(e));
|
|
1256
1256
|
}, a.timeout);
|
|
1257
1257
|
a.fetch(e, t).then(i).catch(r).then(() => {
|
|
1258
|
-
clearTimeout(
|
|
1258
|
+
clearTimeout(p);
|
|
1259
1259
|
});
|
|
1260
1260
|
});
|
|
1261
1261
|
}
|
|
1262
|
-
async function
|
|
1262
|
+
async function $t(e, { signal: t }) {
|
|
1263
1263
|
return new Promise((n, a) => {
|
|
1264
1264
|
t && (t.throwIfAborted(), t.addEventListener("abort", i, { once: !0 }));
|
|
1265
1265
|
function i() {
|
|
@@ -1270,49 +1270,49 @@ async function Wt(e, { signal: t }) {
|
|
|
1270
1270
|
}, e);
|
|
1271
1271
|
});
|
|
1272
1272
|
}
|
|
1273
|
-
const
|
|
1273
|
+
const Wt = (e, t) => {
|
|
1274
1274
|
const n = {};
|
|
1275
1275
|
for (const a in t)
|
|
1276
|
-
!(a in
|
|
1276
|
+
!(a in Lt) && !(a in Pt) && !(a in e) && (n[a] = t[a]);
|
|
1277
1277
|
return n;
|
|
1278
1278
|
};
|
|
1279
|
-
class
|
|
1279
|
+
class te {
|
|
1280
1280
|
static create(t, n) {
|
|
1281
|
-
const a = new
|
|
1281
|
+
const a = new te(t, n), i = async () => {
|
|
1282
1282
|
if (typeof a._options.timeout == "number" && a._options.timeout > ye)
|
|
1283
1283
|
throw new RangeError(`The \`timeout\` option cannot be greater than ${ye}`);
|
|
1284
1284
|
await Promise.resolve();
|
|
1285
|
-
let
|
|
1286
|
-
for (const
|
|
1287
|
-
const y = await
|
|
1288
|
-
y instanceof globalThis.Response && (
|
|
1285
|
+
let p = await a._fetch();
|
|
1286
|
+
for (const u of a._options.hooks.afterResponse) {
|
|
1287
|
+
const y = await u(a.request, a._options, a._decorateResponse(p.clone()));
|
|
1288
|
+
y instanceof globalThis.Response && (p = y);
|
|
1289
1289
|
}
|
|
1290
|
-
if (a._decorateResponse(
|
|
1291
|
-
let
|
|
1290
|
+
if (a._decorateResponse(p), !p.ok && a._options.throwHttpErrors) {
|
|
1291
|
+
let u = new we(p, a.request, a._options);
|
|
1292
1292
|
for (const y of a._options.hooks.beforeError)
|
|
1293
|
-
|
|
1294
|
-
throw
|
|
1293
|
+
u = await y(u);
|
|
1294
|
+
throw u;
|
|
1295
1295
|
}
|
|
1296
1296
|
if (a._options.onDownloadProgress) {
|
|
1297
1297
|
if (typeof a._options.onDownloadProgress != "function")
|
|
1298
1298
|
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
1299
|
-
if (!
|
|
1299
|
+
if (!Dt)
|
|
1300
1300
|
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1301
|
-
return a._stream(
|
|
1301
|
+
return a._stream(p.clone(), a._options.onDownloadProgress);
|
|
1302
1302
|
}
|
|
1303
|
-
return
|
|
1303
|
+
return p;
|
|
1304
1304
|
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(i) : i();
|
|
1305
|
-
for (const [
|
|
1306
|
-
r[
|
|
1307
|
-
a.request.headers.set("accept", a.request.headers.get("accept") ||
|
|
1305
|
+
for (const [p, u] of Object.entries(Nt))
|
|
1306
|
+
r[p] = async () => {
|
|
1307
|
+
a.request.headers.set("accept", a.request.headers.get("accept") || u);
|
|
1308
1308
|
const y = (await r).clone();
|
|
1309
|
-
if (
|
|
1309
|
+
if (p === "json") {
|
|
1310
1310
|
if (y.status === 204 || (await y.clone().arrayBuffer()).byteLength === 0)
|
|
1311
1311
|
return "";
|
|
1312
1312
|
if (n.parseJson)
|
|
1313
1313
|
return n.parseJson(await y.text());
|
|
1314
1314
|
}
|
|
1315
|
-
return y[
|
|
1315
|
+
return y[p]();
|
|
1316
1316
|
};
|
|
1317
1317
|
return r;
|
|
1318
1318
|
}
|
|
@@ -1348,16 +1348,16 @@ class ne {
|
|
|
1348
1348
|
credentials: this._input.credentials || "same-origin",
|
|
1349
1349
|
...n,
|
|
1350
1350
|
headers: He(this._input.headers, n.headers),
|
|
1351
|
-
hooks:
|
|
1351
|
+
hooks: Ae({
|
|
1352
1352
|
beforeRequest: [],
|
|
1353
1353
|
beforeRetry: [],
|
|
1354
1354
|
beforeError: [],
|
|
1355
1355
|
afterResponse: []
|
|
1356
1356
|
}, n.hooks),
|
|
1357
|
-
method:
|
|
1357
|
+
method: Ht(n.method ?? this._input.method),
|
|
1358
1358
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1359
1359
|
prefixUrl: String(n.prefixUrl || ""),
|
|
1360
|
-
retry:
|
|
1360
|
+
retry: Ut(n.retry),
|
|
1361
1361
|
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1362
1362
|
timeout: n.timeout ?? 1e4,
|
|
1363
1363
|
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
@@ -1368,7 +1368,7 @@ class ne {
|
|
|
1368
1368
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1369
1369
|
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1370
1370
|
}
|
|
1371
|
-
if (
|
|
1371
|
+
if (kt) {
|
|
1372
1372
|
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1373
1373
|
const a = this._options.signal;
|
|
1374
1374
|
this._options.signal.addEventListener("abort", () => {
|
|
@@ -1377,9 +1377,9 @@ class ne {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
this._options.signal = this.abortController.signal;
|
|
1379
1379
|
}
|
|
1380
|
-
if (
|
|
1380
|
+
if (xt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1381
1381
|
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1382
|
-
(
|
|
1382
|
+
(Bt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(i, { ...this.request }), this._options);
|
|
1383
1383
|
}
|
|
1384
1384
|
this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
|
|
1385
1385
|
}
|
|
@@ -1410,7 +1410,7 @@ class ne {
|
|
|
1410
1410
|
} catch (n) {
|
|
1411
1411
|
const a = Math.min(this._calculateRetryDelay(n), ye);
|
|
1412
1412
|
if (a !== 0 && this._retryCount > 0) {
|
|
1413
|
-
await
|
|
1413
|
+
await $t(a, { signal: this._options.signal });
|
|
1414
1414
|
for (const i of this._options.hooks.beforeRetry)
|
|
1415
1415
|
if (await i({
|
|
1416
1416
|
request: this.request,
|
|
@@ -1434,8 +1434,8 @@ class ne {
|
|
|
1434
1434
|
if (a instanceof Response)
|
|
1435
1435
|
return a;
|
|
1436
1436
|
}
|
|
1437
|
-
const t =
|
|
1438
|
-
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) :
|
|
1437
|
+
const t = Wt(this.request, this._options);
|
|
1438
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : qt(this.request.clone(), t, this.abortController, this._options);
|
|
1439
1439
|
}
|
|
1440
1440
|
/* istanbul ignore next */
|
|
1441
1441
|
_stream(t, n) {
|
|
@@ -1447,22 +1447,22 @@ class ne {
|
|
|
1447
1447
|
headers: t.headers
|
|
1448
1448
|
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
1449
1449
|
async start(r) {
|
|
1450
|
-
const
|
|
1450
|
+
const p = t.body.getReader();
|
|
1451
1451
|
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1452
|
-
async function
|
|
1453
|
-
const { done: y, value:
|
|
1452
|
+
async function u() {
|
|
1453
|
+
const { done: y, value: d } = await p.read();
|
|
1454
1454
|
if (y) {
|
|
1455
1455
|
r.close();
|
|
1456
1456
|
return;
|
|
1457
1457
|
}
|
|
1458
1458
|
if (n) {
|
|
1459
|
-
i +=
|
|
1459
|
+
i += d.byteLength;
|
|
1460
1460
|
const o = a === 0 ? 0 : i / a;
|
|
1461
|
-
n({ percent: o, transferredBytes: i, totalBytes: a },
|
|
1461
|
+
n({ percent: o, transferredBytes: i, totalBytes: a }, d);
|
|
1462
1462
|
}
|
|
1463
|
-
r.enqueue(
|
|
1463
|
+
r.enqueue(d), await u();
|
|
1464
1464
|
}
|
|
1465
|
-
await
|
|
1465
|
+
await u();
|
|
1466
1466
|
}
|
|
1467
1467
|
}), {
|
|
1468
1468
|
status: t.status,
|
|
@@ -1473,15 +1473,15 @@ class ne {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
/*! MIT License © Sindre Sorhus */
|
|
1475
1475
|
const me = (e) => {
|
|
1476
|
-
const t = (n, a) =>
|
|
1476
|
+
const t = (n, a) => te.create(n, J(e, a));
|
|
1477
1477
|
for (const n of Ve)
|
|
1478
|
-
t[n] = (a, i) =>
|
|
1479
|
-
return t.create = (n) => me(
|
|
1480
|
-
},
|
|
1478
|
+
t[n] = (a, i) => te.create(a, J(e, i, { method: n }));
|
|
1479
|
+
return t.create = (n) => me(J(n)), t.extend = (n) => me(J(e, n)), t.stop = Fe, t;
|
|
1480
|
+
}, Gt = me(), Xt = Gt, jt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Ee = Xt.create({ headers: jt }), _e = {
|
|
1481
1481
|
get: (e, t) => Ee.get(e, t).json(),
|
|
1482
1482
|
post: (e, t) => Ee.post(e, t).json()
|
|
1483
1483
|
}, ge = [...Object.values(s), "TERRA"];
|
|
1484
|
-
function
|
|
1484
|
+
function Kt(e = "") {
|
|
1485
1485
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1486
1486
|
if (ge.includes(n))
|
|
1487
1487
|
return !0;
|
|
@@ -1492,11 +1492,11 @@ function Yt(e = "") {
|
|
|
1492
1492
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1493
1493
|
);
|
|
1494
1494
|
}
|
|
1495
|
-
const
|
|
1496
|
-
function
|
|
1495
|
+
const j = 8, P = (e) => 10n ** BigInt(e), $ = (e) => Math.log10(parseFloat(e.toString()));
|
|
1496
|
+
function re({
|
|
1497
1497
|
value: e,
|
|
1498
|
-
bigIntDecimal: t =
|
|
1499
|
-
decimal: n =
|
|
1498
|
+
bigIntDecimal: t = j,
|
|
1499
|
+
decimal: n = j
|
|
1500
1500
|
}) {
|
|
1501
1501
|
if (n === 0)
|
|
1502
1502
|
return e.toString();
|
|
@@ -1504,24 +1504,24 @@ function pe({
|
|
|
1504
1504
|
let i = e.toString().substring(a ? 1 : 0);
|
|
1505
1505
|
const r = n - (i.length - 1);
|
|
1506
1506
|
r > 0 && (i = "0".repeat(r) + i);
|
|
1507
|
-
const
|
|
1508
|
-
let
|
|
1509
|
-
return parseInt(
|
|
1507
|
+
const p = i.length - n;
|
|
1508
|
+
let u = i.slice(-n);
|
|
1509
|
+
return parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${u}`.replace(
|
|
1510
1510
|
/\.?0*$/,
|
|
1511
1511
|
""
|
|
1512
1512
|
);
|
|
1513
1513
|
}
|
|
1514
|
-
var H,
|
|
1515
|
-
const
|
|
1514
|
+
var H, U, N, V, Te, qe, z, oe, ne, ce;
|
|
1515
|
+
const Yt = class $e {
|
|
1516
1516
|
constructor(t) {
|
|
1517
|
-
|
|
1517
|
+
F(this, H), F(this, N), F(this, Te), F(this, z), F(this, ne), v(this, "decimalMultiplier", 10n ** 8n), v(this, "bigIntValue", 0n), v(this, "decimal");
|
|
1518
1518
|
const n = be(t), a = typeof t == "object";
|
|
1519
|
-
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : P(Math.max(Ge(
|
|
1519
|
+
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : P(Math.max(Ge(ae(n)), this.decimal || 0)), E(this, Te, qe).call(this, n);
|
|
1520
1520
|
}
|
|
1521
1521
|
static fromBigInt(t, n) {
|
|
1522
1522
|
return new $e({
|
|
1523
1523
|
decimal: n,
|
|
1524
|
-
value:
|
|
1524
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1525
1525
|
});
|
|
1526
1526
|
}
|
|
1527
1527
|
static shiftDecimals({
|
|
@@ -1538,37 +1538,37 @@ const Qt = class $e {
|
|
|
1538
1538
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1539
1539
|
}
|
|
1540
1540
|
add(...t) {
|
|
1541
|
-
return
|
|
1541
|
+
return E(this, H, U).call(this, "add", ...t);
|
|
1542
1542
|
}
|
|
1543
1543
|
sub(...t) {
|
|
1544
|
-
return
|
|
1544
|
+
return E(this, H, U).call(this, "sub", ...t);
|
|
1545
1545
|
}
|
|
1546
1546
|
mul(...t) {
|
|
1547
|
-
return
|
|
1547
|
+
return E(this, H, U).call(this, "mul", ...t);
|
|
1548
1548
|
}
|
|
1549
1549
|
div(...t) {
|
|
1550
|
-
return
|
|
1550
|
+
return E(this, H, U).call(this, "div", ...t);
|
|
1551
1551
|
}
|
|
1552
1552
|
gt(t) {
|
|
1553
|
-
return
|
|
1553
|
+
return E(this, N, V).call(this, "gt", t);
|
|
1554
1554
|
}
|
|
1555
1555
|
gte(t) {
|
|
1556
|
-
return
|
|
1556
|
+
return E(this, N, V).call(this, "gte", t);
|
|
1557
1557
|
}
|
|
1558
1558
|
lt(t) {
|
|
1559
|
-
return
|
|
1559
|
+
return E(this, N, V).call(this, "lt", t);
|
|
1560
1560
|
}
|
|
1561
1561
|
lte(t) {
|
|
1562
|
-
return
|
|
1562
|
+
return E(this, N, V).call(this, "lte", t);
|
|
1563
1563
|
}
|
|
1564
1564
|
eqValue(t) {
|
|
1565
|
-
return
|
|
1565
|
+
return E(this, N, V).call(this, "eqValue", t);
|
|
1566
1566
|
}
|
|
1567
1567
|
// @ts-expect-error False positive
|
|
1568
1568
|
getValue(t) {
|
|
1569
1569
|
const n = this.formatBigIntToSafeValue(
|
|
1570
1570
|
this.bigIntValue,
|
|
1571
|
-
this.decimal ||
|
|
1571
|
+
this.decimal || $(this.decimalMultiplier)
|
|
1572
1572
|
);
|
|
1573
1573
|
switch (t) {
|
|
1574
1574
|
case "number":
|
|
@@ -1594,8 +1594,8 @@ const Qt = class $e {
|
|
|
1594
1594
|
getBigIntValue(t, n) {
|
|
1595
1595
|
if (!n && typeof t == "object")
|
|
1596
1596
|
return t.bigIntValue;
|
|
1597
|
-
const a = be(t), i =
|
|
1598
|
-
return i === "0" || i === "undefined" ? 0n :
|
|
1597
|
+
const a = be(t), i = ae(a);
|
|
1598
|
+
return i === "0" || i === "undefined" ? 0n : E(this, ne, ce).call(this, i, n);
|
|
1599
1599
|
}
|
|
1600
1600
|
toSignificant(t = 6) {
|
|
1601
1601
|
const [n, a] = this.getValue("string").split("."), i = n || "", r = a || "";
|
|
@@ -1608,9 +1608,9 @@ const Qt = class $e {
|
|
|
1608
1608
|
t - i.length,
|
|
1609
1609
|
"0"
|
|
1610
1610
|
);
|
|
1611
|
-
const
|
|
1612
|
-
return `0.${
|
|
1613
|
-
r.length - `${
|
|
1611
|
+
const p = parseInt(r), u = `${p}`.slice(0, t);
|
|
1612
|
+
return `0.${u.padStart(
|
|
1613
|
+
r.length - `${p}`.length + u.length,
|
|
1614
1614
|
"0"
|
|
1615
1615
|
)}`;
|
|
1616
1616
|
}
|
|
@@ -1618,9 +1618,9 @@ const Qt = class $e {
|
|
|
1618
1618
|
const [n, a] = this.getValue("string").split("."), i = n || "", r = a || "";
|
|
1619
1619
|
if (parseInt(i))
|
|
1620
1620
|
return `${i}.${r.slice(0, t)}`.padEnd(t, "0");
|
|
1621
|
-
const
|
|
1622
|
-
return `0.${
|
|
1623
|
-
r.length - `${
|
|
1621
|
+
const p = parseInt(r), u = `${p}`.slice(0, t);
|
|
1622
|
+
return `0.${u.padStart(
|
|
1623
|
+
r.length - `${p}`.length + u.length,
|
|
1624
1624
|
"0"
|
|
1625
1625
|
)}`;
|
|
1626
1626
|
}
|
|
@@ -1628,8 +1628,8 @@ const Qt = class $e {
|
|
|
1628
1628
|
const n = this.getValue("number"), a = ["", "K", "M", "B", "T", "Q", "Qi", "S"], i = Math.floor(Math.log10(Math.abs(n)) / 3), r = a[i];
|
|
1629
1629
|
if (!r)
|
|
1630
1630
|
return this.getValue("string");
|
|
1631
|
-
const
|
|
1632
|
-
return `${(n /
|
|
1631
|
+
const p = 10 ** (i * 3);
|
|
1632
|
+
return `${(n / p).toFixed(t)}${r}`;
|
|
1633
1633
|
}
|
|
1634
1634
|
toCurrency(t = "$", {
|
|
1635
1635
|
currencyPosition: n = "start",
|
|
@@ -1637,44 +1637,44 @@ const Qt = class $e {
|
|
|
1637
1637
|
decimalSeparator: i = ".",
|
|
1638
1638
|
thousandSeparator: r = ","
|
|
1639
1639
|
} = {}) {
|
|
1640
|
-
const
|
|
1640
|
+
const p = this.getValue("number"), [u, y = ""] = p.toFixed(6).split("."), d = u.replace(/\B(?=(\d{3})+(?!\d))/g, r), o = !u && !y ? "0.00" : u === "0" ? `${parseFloat(`0.${y}`)}`.replace(".", i) : `${d}${parseInt(y) ? `${i}${y.slice(0, a)}` : ""}`;
|
|
1641
1641
|
return `${n === "start" ? t : ""}${o}${n === "end" ? t : ""}`;
|
|
1642
1642
|
}
|
|
1643
1643
|
formatBigIntToSafeValue(t, n) {
|
|
1644
|
-
const a = n || this.decimal ||
|
|
1644
|
+
const a = n || this.decimal || j, i = Math.max(
|
|
1645
1645
|
a,
|
|
1646
|
-
|
|
1647
|
-
), r = t < 0n,
|
|
1646
|
+
$(this.decimalMultiplier)
|
|
1647
|
+
), r = t < 0n, p = t.toString().substring(r ? 1 : 0), u = i - (p.length - 1), y = u > 0 ? "0".repeat(u) + p : p, d = y.length - i;
|
|
1648
1648
|
let o = y.slice(-i);
|
|
1649
1649
|
return parseInt(o[a]) >= 5 ? o = `${o.substring(0, a - 1)}${(parseInt(o[a - 1]) + 1).toString()}` : o = o.substring(0, a), `${r ? "-" : ""}${y.slice(
|
|
1650
1650
|
0,
|
|
1651
|
-
|
|
1651
|
+
d
|
|
1652
1652
|
)}.${o}`.replace(/\.?0*$/, "");
|
|
1653
1653
|
}
|
|
1654
1654
|
};
|
|
1655
|
-
H = /* @__PURE__ */ new WeakSet(),
|
|
1656
|
-
const n =
|
|
1657
|
-
(
|
|
1658
|
-
const
|
|
1655
|
+
H = /* @__PURE__ */ new WeakSet(), U = function(e, ...t) {
|
|
1656
|
+
const n = E(this, z, oe).call(this, this, ...t), a = Math.max(n, $(this.decimalMultiplier)), i = P(a), r = t.reduce(
|
|
1657
|
+
(u, y) => {
|
|
1658
|
+
const d = this.getBigIntValue(y, a);
|
|
1659
1659
|
switch (e) {
|
|
1660
1660
|
case "add":
|
|
1661
|
-
return
|
|
1661
|
+
return u + d;
|
|
1662
1662
|
case "sub":
|
|
1663
|
-
return
|
|
1663
|
+
return u - d;
|
|
1664
1664
|
case "mul":
|
|
1665
|
-
return
|
|
1665
|
+
return u * d / i;
|
|
1666
1666
|
case "div": {
|
|
1667
|
-
if (
|
|
1667
|
+
if (d === 0n)
|
|
1668
1668
|
throw new RangeError("Division by zero");
|
|
1669
|
-
return
|
|
1669
|
+
return u * i / d;
|
|
1670
1670
|
}
|
|
1671
1671
|
default:
|
|
1672
|
-
return
|
|
1672
|
+
return u;
|
|
1673
1673
|
}
|
|
1674
1674
|
},
|
|
1675
1675
|
//normalize is to precision multiplier base
|
|
1676
1676
|
this.bigIntValue * i / this.decimalMultiplier
|
|
1677
|
-
),
|
|
1677
|
+
), p = re({
|
|
1678
1678
|
bigIntDecimal: a,
|
|
1679
1679
|
decimal: a,
|
|
1680
1680
|
value: r
|
|
@@ -1682,11 +1682,11 @@ H = /* @__PURE__ */ new WeakSet(), q = function(e, ...t) {
|
|
|
1682
1682
|
return new this.constructor({
|
|
1683
1683
|
decimalMultiplier: P(a),
|
|
1684
1684
|
decimal: this.decimal,
|
|
1685
|
-
value:
|
|
1685
|
+
value: p,
|
|
1686
1686
|
identifier: this.toString()
|
|
1687
1687
|
});
|
|
1688
1688
|
}, N = /* @__PURE__ */ new WeakSet(), V = function(e, ...t) {
|
|
1689
|
-
const n =
|
|
1689
|
+
const n = E(this, z, oe).call(this, this, ...t), a = this.getBigIntValue(t[0], n), i = this.getBigIntValue(this, n);
|
|
1690
1690
|
switch (e) {
|
|
1691
1691
|
case "gt":
|
|
1692
1692
|
return i > a;
|
|
@@ -1700,33 +1700,33 @@ H = /* @__PURE__ */ new WeakSet(), q = function(e, ...t) {
|
|
|
1700
1700
|
return i === a;
|
|
1701
1701
|
}
|
|
1702
1702
|
}, Te = /* @__PURE__ */ new WeakSet(), qe = function(e) {
|
|
1703
|
-
const t =
|
|
1704
|
-
this.bigIntValue =
|
|
1705
|
-
},
|
|
1706
|
-
const t = e.map((n) => typeof n == "object" ? n.decimal ||
|
|
1707
|
-
return Math.max(...t,
|
|
1708
|
-
},
|
|
1709
|
-
const n = t ? P(t) : this.decimalMultiplier, a =
|
|
1703
|
+
const t = ae(e) || "0";
|
|
1704
|
+
this.bigIntValue = E(this, ne, ce).call(this, t);
|
|
1705
|
+
}, z = /* @__PURE__ */ new WeakSet(), oe = function(...e) {
|
|
1706
|
+
const t = e.map((n) => typeof n == "object" ? n.decimal || $(n.decimalMultiplier) : Ge(ae(n))).filter(Boolean);
|
|
1707
|
+
return Math.max(...t, j);
|
|
1708
|
+
}, ne = /* @__PURE__ */ new WeakSet(), ce = function(e, t) {
|
|
1709
|
+
const n = t ? P(t) : this.decimalMultiplier, a = $(n), [i = "", r = ""] = e.split(".");
|
|
1710
1710
|
return BigInt(`${i}${r.padEnd(a, "0")}`);
|
|
1711
1711
|
};
|
|
1712
|
-
let We =
|
|
1713
|
-
const
|
|
1712
|
+
let We = Yt;
|
|
1713
|
+
const Qt = Intl.NumberFormat("fullwide", {
|
|
1714
1714
|
useGrouping: !1,
|
|
1715
1715
|
maximumFractionDigits: 20
|
|
1716
1716
|
});
|
|
1717
|
-
function
|
|
1718
|
-
const t = `${typeof e == "number" ?
|
|
1717
|
+
function ae(e) {
|
|
1718
|
+
const t = `${typeof e == "number" ? Qt.format(e) : be(e)}`.replaceAll(",", ".").split(".");
|
|
1719
1719
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1720
1720
|
}
|
|
1721
1721
|
function Ge(e) {
|
|
1722
1722
|
var t;
|
|
1723
1723
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1724
|
-
return Math.max(n,
|
|
1724
|
+
return Math.max(n, j);
|
|
1725
1725
|
}
|
|
1726
1726
|
function be(e) {
|
|
1727
1727
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1728
1728
|
}
|
|
1729
|
-
const
|
|
1729
|
+
const W = /* @__PURE__ */ new Map();
|
|
1730
1730
|
class x extends We {
|
|
1731
1731
|
constructor({
|
|
1732
1732
|
value: t,
|
|
@@ -1734,11 +1734,11 @@ class x extends We {
|
|
|
1734
1734
|
tax: a,
|
|
1735
1735
|
chain: i,
|
|
1736
1736
|
symbol: r,
|
|
1737
|
-
identifier:
|
|
1737
|
+
identifier: p
|
|
1738
1738
|
}) {
|
|
1739
1739
|
super(typeof t == "object" ? t : { decimal: n, value: t }), v(this, "address"), v(this, "chain"), v(this, "isGasAsset", !1), v(this, "isSynthetic", !1), v(this, "symbol"), v(this, "tax"), v(this, "ticker"), v(this, "type");
|
|
1740
|
-
const
|
|
1741
|
-
this.type =
|
|
1740
|
+
const u = ee(p || `${i}.${r}`);
|
|
1741
|
+
this.type = Rt(u), this.tax = a, this.chain = u.chain, this.ticker = u.ticker, this.symbol = u.symbol, this.address = u.address, this.isSynthetic = u.isSynthetic, this.isGasAsset = u.isGasAsset;
|
|
1742
1742
|
}
|
|
1743
1743
|
toString() {
|
|
1744
1744
|
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
@@ -1749,6 +1749,9 @@ class x extends We {
|
|
|
1749
1749
|
eq({ chain: t, symbol: n }) {
|
|
1750
1750
|
return this.chain === t && this.symbol === n;
|
|
1751
1751
|
}
|
|
1752
|
+
chainId() {
|
|
1753
|
+
return De[this.chain];
|
|
1754
|
+
}
|
|
1752
1755
|
// THOR.RUNE
|
|
1753
1756
|
// THOR.ETH.ETH
|
|
1754
1757
|
// ETH.THOR-0x1234567890
|
|
@@ -1756,8 +1759,8 @@ class x extends We {
|
|
|
1756
1759
|
const [a, i, r] = t.split(".");
|
|
1757
1760
|
if (!a || !i)
|
|
1758
1761
|
throw new Error("Invalid asset url");
|
|
1759
|
-
const
|
|
1760
|
-
return le(
|
|
1762
|
+
const p = a === s.THORChain && r ? `${a}.${i}/${r}` : t;
|
|
1763
|
+
return le(p, n);
|
|
1761
1764
|
}
|
|
1762
1765
|
static fromString(t, n = 0) {
|
|
1763
1766
|
return le(t, n);
|
|
@@ -1766,33 +1769,33 @@ class x extends We {
|
|
|
1766
1769
|
return le(t, n);
|
|
1767
1770
|
}
|
|
1768
1771
|
static fromStringSync(t, n = 0) {
|
|
1769
|
-
const { chain: a, isSynthetic: i } =
|
|
1772
|
+
const { chain: a, isSynthetic: i } = ee(t), r = W.get(t.toUpperCase());
|
|
1770
1773
|
if (i)
|
|
1771
1774
|
return Re(t, n);
|
|
1772
|
-
const { tax:
|
|
1775
|
+
const { tax: p, decimal: u, identifier: y } = r || {
|
|
1773
1776
|
decimal: A[a],
|
|
1774
1777
|
identifier: t
|
|
1775
1778
|
};
|
|
1776
1779
|
return new x({
|
|
1777
|
-
tax:
|
|
1778
|
-
value:
|
|
1780
|
+
tax: p,
|
|
1781
|
+
value: G(n, u),
|
|
1779
1782
|
identifier: i ? t : y,
|
|
1780
|
-
decimal: i ? 8 :
|
|
1783
|
+
decimal: i ? 8 : u
|
|
1781
1784
|
});
|
|
1782
1785
|
}
|
|
1783
1786
|
static fromIdentifierSync(t, n = 0) {
|
|
1784
|
-
const { chain: a, isSynthetic: i } =
|
|
1787
|
+
const { chain: a, isSynthetic: i } = ee(t), r = W.get(t);
|
|
1785
1788
|
if (i)
|
|
1786
1789
|
return Re(t, n);
|
|
1787
|
-
const { tax:
|
|
1790
|
+
const { tax: p, decimal: u, identifier: y } = r || {
|
|
1788
1791
|
decimal: A[a],
|
|
1789
1792
|
identifier: t
|
|
1790
1793
|
};
|
|
1791
|
-
return new x({ tax:
|
|
1794
|
+
return new x({ tax: p, decimal: u, identifier: y, value: G(n, u) });
|
|
1792
1795
|
}
|
|
1793
1796
|
static fromChainOrSignature(t, n = 0) {
|
|
1794
|
-
const { decimal: a, identifier: i } =
|
|
1795
|
-
return new x({ value:
|
|
1797
|
+
const { decimal: a, identifier: i } = gt(t);
|
|
1798
|
+
return new x({ value: G(n, a), decimal: a, identifier: i });
|
|
1796
1799
|
}
|
|
1797
1800
|
static loadStaticAssets() {
|
|
1798
1801
|
return new Promise(
|
|
@@ -1801,10 +1804,10 @@ class x extends We {
|
|
|
1801
1804
|
const a = await import("@swapkit/tokens");
|
|
1802
1805
|
Object.values(a).forEach((i) => {
|
|
1803
1806
|
var r;
|
|
1804
|
-
(r = i == null ? void 0 : i.tokens) == null || r.forEach(({ identifier:
|
|
1805
|
-
|
|
1806
|
-
identifier:
|
|
1807
|
-
decimal: "decimals" in y ? y.decimals : A[
|
|
1807
|
+
(r = i == null ? void 0 : i.tokens) == null || r.forEach(({ identifier: p, chain: u, ...y }) => {
|
|
1808
|
+
W.set(p.toUpperCase(), {
|
|
1809
|
+
identifier: p,
|
|
1810
|
+
decimal: "decimals" in y ? y.decimals : A[u]
|
|
1808
1811
|
});
|
|
1809
1812
|
});
|
|
1810
1813
|
}), t({ ok: !0 });
|
|
@@ -1841,9 +1844,9 @@ function de(e) {
|
|
|
1841
1844
|
}
|
|
1842
1845
|
}
|
|
1843
1846
|
async function le(e, t = 0) {
|
|
1844
|
-
|
|
1845
|
-
const n =
|
|
1846
|
-
return n ||
|
|
1847
|
+
Kt(e);
|
|
1848
|
+
const n = W.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await Mt(ee(e));
|
|
1849
|
+
return n || W.set(e.toUpperCase(), { identifier: e, decimal: a }), new x({ decimal: a, value: G(t, a), identifier: e });
|
|
1847
1850
|
}
|
|
1848
1851
|
function Re(e, t = 0) {
|
|
1849
1852
|
const [n, a] = e.split(".")[0].toUpperCase() === s.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
@@ -1851,28 +1854,28 @@ function Re(e, t = 0) {
|
|
|
1851
1854
|
throw new Error("Invalid asset identifier");
|
|
1852
1855
|
return new x({
|
|
1853
1856
|
decimal: 8,
|
|
1854
|
-
value:
|
|
1857
|
+
value: G(t, 8),
|
|
1855
1858
|
identifier: `${s.THORChain}.${n}/${a}`
|
|
1856
1859
|
});
|
|
1857
1860
|
}
|
|
1858
|
-
function
|
|
1859
|
-
return typeof e == "bigint" ?
|
|
1861
|
+
function G(e, t) {
|
|
1862
|
+
return typeof e == "bigint" ? re({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1860
1863
|
}
|
|
1861
|
-
function
|
|
1864
|
+
function ee(e) {
|
|
1862
1865
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".")[0].toUpperCase() === s.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1863
1866
|
if (t && (!n || !a))
|
|
1864
1867
|
throw new Error("Invalid asset identifier");
|
|
1865
|
-
const i = e.includes(".") && !t ? e : `${s.THORChain}.${a}`, [r,
|
|
1868
|
+
const i = e.includes(".") && !t ? e : `${s.THORChain}.${a}`, [r, p] = i.split("."), [u, y] = (t ? a : p).split("-");
|
|
1866
1869
|
return {
|
|
1867
1870
|
address: y == null ? void 0 : y.toLowerCase(),
|
|
1868
1871
|
chain: r,
|
|
1869
|
-
isGasAsset: Pe({ chain: r, symbol:
|
|
1872
|
+
isGasAsset: Pe({ chain: r, symbol: p }),
|
|
1870
1873
|
isSynthetic: t,
|
|
1871
|
-
symbol: (t ? `${n}/` : "") + (y ? `${
|
|
1872
|
-
ticker:
|
|
1874
|
+
symbol: (t ? `${n}/` : "") + (y ? `${u}-${(y == null ? void 0 : y.toLowerCase()) ?? ""}` : p),
|
|
1875
|
+
ticker: u
|
|
1873
1876
|
};
|
|
1874
1877
|
}
|
|
1875
|
-
const
|
|
1878
|
+
const Jt = {
|
|
1876
1879
|
/**
|
|
1877
1880
|
* Core
|
|
1878
1881
|
*/
|
|
@@ -1932,21 +1935,21 @@ const Zt = {
|
|
|
1932
1935
|
};
|
|
1933
1936
|
class m extends Error {
|
|
1934
1937
|
constructor(t, n) {
|
|
1935
|
-
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code:
|
|
1938
|
+
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Jt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1936
1939
|
}
|
|
1937
1940
|
}
|
|
1938
|
-
class
|
|
1941
|
+
class k extends We {
|
|
1939
1942
|
eq(t) {
|
|
1940
1943
|
return this.eqValue(t);
|
|
1941
1944
|
}
|
|
1942
1945
|
static fromBigInt(t, n) {
|
|
1943
|
-
return new
|
|
1946
|
+
return new k({
|
|
1944
1947
|
decimal: n,
|
|
1945
|
-
value:
|
|
1948
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1946
1949
|
});
|
|
1947
1950
|
}
|
|
1948
1951
|
}
|
|
1949
|
-
const
|
|
1952
|
+
const Zt = [
|
|
1950
1953
|
{
|
|
1951
1954
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1952
1955
|
stateMutability: "nonpayable",
|
|
@@ -2037,7 +2040,7 @@ const zt = [
|
|
|
2037
2040
|
type: "function"
|
|
2038
2041
|
},
|
|
2039
2042
|
{ stateMutability: "payable", type: "receive" }
|
|
2040
|
-
],
|
|
2043
|
+
], zt = [
|
|
2041
2044
|
{
|
|
2042
2045
|
inputs: [
|
|
2043
2046
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2181,7 +2184,7 @@ const zt = [
|
|
|
2181
2184
|
type: "function"
|
|
2182
2185
|
},
|
|
2183
2186
|
{ stateMutability: "payable", type: "receive" }
|
|
2184
|
-
],
|
|
2187
|
+
], en = [
|
|
2185
2188
|
{
|
|
2186
2189
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2187
2190
|
stateMutability: "nonpayable",
|
|
@@ -2286,7 +2289,7 @@ const zt = [
|
|
|
2286
2289
|
type: "function"
|
|
2287
2290
|
},
|
|
2288
2291
|
{ stateMutability: "payable", type: "receive" }
|
|
2289
|
-
],
|
|
2292
|
+
], tn = [
|
|
2290
2293
|
{
|
|
2291
2294
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2292
2295
|
stateMutability: "nonpayable",
|
|
@@ -2377,7 +2380,7 @@ const zt = [
|
|
|
2377
2380
|
type: "function"
|
|
2378
2381
|
},
|
|
2379
2382
|
{ stateMutability: "payable", type: "receive" }
|
|
2380
|
-
],
|
|
2383
|
+
], nn = [
|
|
2381
2384
|
{
|
|
2382
2385
|
inputs: [
|
|
2383
2386
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2521,7 +2524,7 @@ const zt = [
|
|
|
2521
2524
|
type: "function"
|
|
2522
2525
|
},
|
|
2523
2526
|
{ stateMutability: "payable", type: "receive" }
|
|
2524
|
-
],
|
|
2527
|
+
], an = [
|
|
2525
2528
|
{
|
|
2526
2529
|
inputs: [
|
|
2527
2530
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -5567,7 +5570,7 @@ const zt = [
|
|
|
5567
5570
|
type: "function"
|
|
5568
5571
|
},
|
|
5569
5572
|
{ stateMutability: "payable", type: "receive" }
|
|
5570
|
-
],
|
|
5573
|
+
], sn = [
|
|
5571
5574
|
{
|
|
5572
5575
|
inputs: [
|
|
5573
5576
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -5906,7 +5909,7 @@ const zt = [
|
|
|
5906
5909
|
type: "function"
|
|
5907
5910
|
},
|
|
5908
5911
|
{ stateMutability: "payable", type: "receive" }
|
|
5909
|
-
],
|
|
5912
|
+
], rn = [
|
|
5910
5913
|
{
|
|
5911
5914
|
inputs: [
|
|
5912
5915
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6245,7 +6248,7 @@ const zt = [
|
|
|
6245
6248
|
type: "function"
|
|
6246
6249
|
},
|
|
6247
6250
|
{ stateMutability: "payable", type: "receive" }
|
|
6248
|
-
],
|
|
6251
|
+
], pn = [
|
|
6249
6252
|
{
|
|
6250
6253
|
inputs: [
|
|
6251
6254
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6584,7 +6587,7 @@ const zt = [
|
|
|
6584
6587
|
type: "function"
|
|
6585
6588
|
},
|
|
6586
6589
|
{ stateMutability: "payable", type: "receive" }
|
|
6587
|
-
],
|
|
6590
|
+
], un = [
|
|
6588
6591
|
{
|
|
6589
6592
|
inputs: [
|
|
6590
6593
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6923,7 +6926,7 @@ const zt = [
|
|
|
6923
6926
|
type: "function"
|
|
6924
6927
|
},
|
|
6925
6928
|
{ stateMutability: "payable", type: "receive" }
|
|
6926
|
-
],
|
|
6929
|
+
], yn = [
|
|
6927
6930
|
{
|
|
6928
6931
|
inputs: [
|
|
6929
6932
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -7176,7 +7179,7 @@ const zt = [
|
|
|
7176
7179
|
type: "function"
|
|
7177
7180
|
},
|
|
7178
7181
|
{ stateMutability: "payable", type: "receive" }
|
|
7179
|
-
],
|
|
7182
|
+
], on = [
|
|
7180
7183
|
{
|
|
7181
7184
|
inputs: [
|
|
7182
7185
|
{ internalType: "address", name: "_weth", type: "address" },
|
|
@@ -7346,23 +7349,23 @@ const zt = [
|
|
|
7346
7349
|
type: "function"
|
|
7347
7350
|
},
|
|
7348
7351
|
{ stateMutability: "payable", type: "receive" }
|
|
7349
|
-
],
|
|
7352
|
+
], dn = {
|
|
7350
7353
|
// AVAX
|
|
7351
|
-
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]:
|
|
7352
|
-
["0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9".toLowerCase()]:
|
|
7353
|
-
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]:
|
|
7354
|
+
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]: sn,
|
|
7355
|
+
["0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9".toLowerCase()]: on,
|
|
7356
|
+
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]: pn,
|
|
7354
7357
|
["0x1111111254fb6c44bAC0beD2854e76F90643097d".toLowerCase()]: ve,
|
|
7355
7358
|
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: Oe,
|
|
7356
7359
|
// BSC
|
|
7357
7360
|
["0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase()]: Ie,
|
|
7358
7361
|
// ETH
|
|
7359
7362
|
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: Oe,
|
|
7360
|
-
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]:
|
|
7363
|
+
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]: rn,
|
|
7361
7364
|
["0xEfF92A263d31888d860bD50809A8D171709b7b1c".toLowerCase()]: Ie,
|
|
7362
|
-
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]:
|
|
7363
|
-
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]:
|
|
7365
|
+
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]: un,
|
|
7366
|
+
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]: yn,
|
|
7364
7367
|
["0x1111111254fb6c44bac0bed2854e76f90643097d".toLowerCase()]: ve
|
|
7365
|
-
},
|
|
7368
|
+
}, ln = [
|
|
7366
7369
|
{
|
|
7367
7370
|
inputs: [
|
|
7368
7371
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7481,7 +7484,7 @@ const zt = [
|
|
|
7481
7484
|
type: "function"
|
|
7482
7485
|
},
|
|
7483
7486
|
{ stateMutability: "payable", type: "receive" }
|
|
7484
|
-
],
|
|
7487
|
+
], mn = [
|
|
7485
7488
|
{
|
|
7486
7489
|
inputs: [
|
|
7487
7490
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7600,7 +7603,7 @@ const zt = [
|
|
|
7600
7603
|
type: "function"
|
|
7601
7604
|
},
|
|
7602
7605
|
{ stateMutability: "payable", type: "receive" }
|
|
7603
|
-
],
|
|
7606
|
+
], Tn = [
|
|
7604
7607
|
{
|
|
7605
7608
|
inputs: [
|
|
7606
7609
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7719,7 +7722,7 @@ const zt = [
|
|
|
7719
7722
|
type: "function"
|
|
7720
7723
|
},
|
|
7721
7724
|
{ stateMutability: "payable", type: "receive" }
|
|
7722
|
-
],
|
|
7725
|
+
], cn = [
|
|
7723
7726
|
{
|
|
7724
7727
|
inputs: [
|
|
7725
7728
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7846,7 +7849,7 @@ const zt = [
|
|
|
7846
7849
|
type: "function"
|
|
7847
7850
|
},
|
|
7848
7851
|
{ stateMutability: "payable", type: "receive" }
|
|
7849
|
-
],
|
|
7852
|
+
], bn = [
|
|
7850
7853
|
{
|
|
7851
7854
|
inputs: [
|
|
7852
7855
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7973,7 +7976,7 @@ const zt = [
|
|
|
7973
7976
|
type: "function"
|
|
7974
7977
|
},
|
|
7975
7978
|
{ stateMutability: "payable", type: "receive" }
|
|
7976
|
-
],
|
|
7979
|
+
], fn = [
|
|
7977
7980
|
{
|
|
7978
7981
|
inputs: [
|
|
7979
7982
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8100,7 +8103,7 @@ const zt = [
|
|
|
8100
8103
|
type: "function"
|
|
8101
8104
|
},
|
|
8102
8105
|
{ stateMutability: "payable", type: "receive" }
|
|
8103
|
-
],
|
|
8106
|
+
], hn = [
|
|
8104
8107
|
{
|
|
8105
8108
|
inputs: [
|
|
8106
8109
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8355,25 +8358,25 @@ const zt = [
|
|
|
8355
8358
|
},
|
|
8356
8359
|
{ stateMutability: "payable", type: "receive" }
|
|
8357
8360
|
], Xe = {
|
|
8358
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
8359
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
8360
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
8361
|
-
},
|
|
8362
|
-
...
|
|
8361
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Zt,
|
|
8362
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: en,
|
|
8363
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: tn
|
|
8364
|
+
}, _n = {
|
|
8365
|
+
...dn,
|
|
8363
8366
|
...Xe,
|
|
8364
8367
|
// AVAX
|
|
8365
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
8366
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
8367
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
8368
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: an,
|
|
8369
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: zt,
|
|
8370
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: mn,
|
|
8368
8371
|
// BSC
|
|
8369
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
8372
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: nn,
|
|
8370
8373
|
// ETH
|
|
8371
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
8372
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
8373
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
8374
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
8375
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
8376
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
8374
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: ln,
|
|
8375
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Tn,
|
|
8376
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: cn,
|
|
8377
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: bn,
|
|
8378
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: fn,
|
|
8379
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: hn,
|
|
8377
8380
|
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: An
|
|
8378
8381
|
}, wn = ({
|
|
8379
8382
|
streamSwap: e,
|
|
@@ -8383,39 +8386,39 @@ const zt = [
|
|
|
8383
8386
|
calldata: {
|
|
8384
8387
|
amount: i,
|
|
8385
8388
|
amountOutMin: r = "",
|
|
8386
|
-
data:
|
|
8387
|
-
deadline:
|
|
8389
|
+
data: p = "",
|
|
8390
|
+
deadline: u,
|
|
8388
8391
|
memo: y,
|
|
8389
|
-
router:
|
|
8392
|
+
router: d,
|
|
8390
8393
|
memoStreamingSwap: o,
|
|
8391
8394
|
tcMemo: T,
|
|
8392
|
-
tcRouter:
|
|
8393
|
-
tcVault:
|
|
8395
|
+
tcRouter: f,
|
|
8396
|
+
tcVault: _,
|
|
8394
8397
|
vault: w,
|
|
8395
8398
|
token: M
|
|
8396
8399
|
}
|
|
8397
8400
|
}) => {
|
|
8398
8401
|
const R = !!Xe[t.toLowerCase()];
|
|
8399
|
-
if (R && !
|
|
8402
|
+
if (R && !d)
|
|
8400
8403
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
8401
|
-
const
|
|
8402
|
-
if (!
|
|
8404
|
+
const O = T || y, D = e && o || O;
|
|
8405
|
+
if (!_ && !w)
|
|
8403
8406
|
throw new Error("TC Vault is required on calldata");
|
|
8404
|
-
if (!
|
|
8407
|
+
if (!f && !d)
|
|
8405
8408
|
throw new Error("TC Router is required on calldata");
|
|
8406
|
-
if (!
|
|
8409
|
+
if (!D)
|
|
8407
8410
|
throw new Error("TC Memo is required on calldata");
|
|
8408
8411
|
if (!M)
|
|
8409
8412
|
throw new Error("Token is required on calldata");
|
|
8410
|
-
const
|
|
8413
|
+
const pe = [
|
|
8411
8414
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
8412
|
-
a(
|
|
8413
|
-
a(
|
|
8414
|
-
|
|
8415
|
+
a(f || d),
|
|
8416
|
+
a(_ || w),
|
|
8417
|
+
D.replace("{recipientAddress}", n),
|
|
8415
8418
|
a(M),
|
|
8416
8419
|
i
|
|
8417
|
-
], je = R ? [a(
|
|
8418
|
-
return [...
|
|
8420
|
+
], je = R ? [a(d), p, u] : [r, u];
|
|
8421
|
+
return [...pe, ...je];
|
|
8419
8422
|
}, Mn = ({ chain: e, txHash: t }) => {
|
|
8420
8423
|
const n = Be[e];
|
|
8421
8424
|
switch (e) {
|
|
@@ -8465,12 +8468,12 @@ const zt = [
|
|
|
8465
8468
|
throw new Error(`Unsupported chain: ${e}`);
|
|
8466
8469
|
}
|
|
8467
8470
|
}, gn = (e) => {
|
|
8468
|
-
const t = e ?
|
|
8469
|
-
return
|
|
8471
|
+
const t = e ? X.ThornodeStagenet : X.ThornodeMainnet;
|
|
8472
|
+
return _e.get(`${t}/thorchain/inbound_addresses`);
|
|
8470
8473
|
}, Rn = (e) => {
|
|
8471
|
-
const t = e ?
|
|
8472
|
-
return
|
|
8473
|
-
},
|
|
8474
|
+
const t = e ? X.ThornodeStagenet : X.ThornodeMainnet;
|
|
8475
|
+
return _e.get(`${t}/thorchain/mimir`);
|
|
8476
|
+
}, Se = () => Object.values(s).reduce(
|
|
8474
8477
|
(e, t) => (e[t] = null, e),
|
|
8475
8478
|
{}
|
|
8476
8479
|
), On = async ({ chain: e, address: t }) => {
|
|
@@ -8483,11 +8486,11 @@ const zt = [
|
|
|
8483
8486
|
return !0;
|
|
8484
8487
|
}
|
|
8485
8488
|
};
|
|
8486
|
-
var L,
|
|
8489
|
+
var L, ie, K, I, Y, Q;
|
|
8487
8490
|
class Xn {
|
|
8488
8491
|
constructor({ stagenet: t } = {}) {
|
|
8489
|
-
c(this, "connectedChains",
|
|
8490
|
-
c(this, "connectedWallets",
|
|
8492
|
+
c(this, "connectedChains", Se());
|
|
8493
|
+
c(this, "connectedWallets", Se());
|
|
8491
8494
|
c(this, "stagenet", !1);
|
|
8492
8495
|
c(this, "getAddress", (t) => {
|
|
8493
8496
|
var n;
|
|
@@ -8501,97 +8504,83 @@ class Xn {
|
|
|
8501
8504
|
return (a == null ? void 0 : a.balance) || [];
|
|
8502
8505
|
});
|
|
8503
8506
|
c(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: i }) => {
|
|
8504
|
-
var
|
|
8507
|
+
var u, y;
|
|
8505
8508
|
const {
|
|
8506
|
-
meta: { quoteMode: r }
|
|
8507
|
-
evmTransactionDetails:
|
|
8509
|
+
meta: { quoteMode: r }
|
|
8510
|
+
// evmTransactionDetails: contractCallParams,
|
|
8508
8511
|
} = a, p = r.startsWith("ERC20-") ? s.Ethereum : r.startsWith("ARC20-") ? s.Avalanche : r.startsWith("BEP20-") ? s.BinanceSmartChain : void 0;
|
|
8509
8512
|
if (!a.complete)
|
|
8510
8513
|
throw new m("core_swap_route_not_complete");
|
|
8511
8514
|
try {
|
|
8512
|
-
if (u && p) {
|
|
8513
|
-
const o = this.connectedWallets[p];
|
|
8514
|
-
if (!(o != null && o.call))
|
|
8515
|
-
throw new m("core_wallet_connection_not_found");
|
|
8516
|
-
const { contractAddress: T, contractMethod: b, contractParams: h, contractParamsStreaming: w } = u;
|
|
8517
|
-
if (!(t ? w : h))
|
|
8518
|
-
throw new m("core_swap_route_transaction_not_found");
|
|
8519
|
-
return await o.call({
|
|
8520
|
-
contractAddress: T,
|
|
8521
|
-
abi: Se[T.toLowerCase()],
|
|
8522
|
-
funcName: b,
|
|
8523
|
-
funcParams: t ? w : h
|
|
8524
|
-
});
|
|
8525
|
-
}
|
|
8526
8515
|
if (at.includes(r) && p) {
|
|
8527
|
-
const
|
|
8528
|
-
if (!(
|
|
8516
|
+
const d = this.connectedWallets[p];
|
|
8517
|
+
if (!(d != null && d.sendTransaction))
|
|
8529
8518
|
throw new m("core_wallet_connection_not_found");
|
|
8530
|
-
if (!(t ? (
|
|
8519
|
+
if (!(t ? (u = a == null ? void 0 : a.streamingSwap) == null ? void 0 : u.transaction : a == null ? void 0 : a.transaction))
|
|
8531
8520
|
throw new m("core_swap_route_transaction_not_found");
|
|
8532
|
-
const { data:
|
|
8533
|
-
data:
|
|
8534
|
-
from:
|
|
8535
|
-
to:
|
|
8536
|
-
chainId: BigInt(
|
|
8537
|
-
value:
|
|
8521
|
+
const { data: T, from: f, to: _, value: w } = a.transaction, M = {
|
|
8522
|
+
data: T,
|
|
8523
|
+
from: f,
|
|
8524
|
+
to: _.toLowerCase(),
|
|
8525
|
+
chainId: BigInt(De[p]),
|
|
8526
|
+
value: w ? BigInt(w) : 0n
|
|
8538
8527
|
};
|
|
8539
|
-
return
|
|
8528
|
+
return d.sendTransaction(M, i);
|
|
8540
8529
|
}
|
|
8541
8530
|
if (st.includes(r)) {
|
|
8542
8531
|
if (!a.calldata.fromAsset)
|
|
8543
8532
|
throw new m("core_swap_asset_not_recognized");
|
|
8544
|
-
const
|
|
8545
|
-
if (!
|
|
8533
|
+
const d = await x.fromString(a.calldata.fromAsset);
|
|
8534
|
+
if (!d)
|
|
8546
8535
|
throw new m("core_swap_asset_not_recognized");
|
|
8547
|
-
const { address:
|
|
8548
|
-
contract:
|
|
8549
|
-
calldata: { expiration:
|
|
8550
|
-
} = a,
|
|
8536
|
+
const { address: o } = await h(this, L).call(this, d.chain), {
|
|
8537
|
+
contract: T,
|
|
8538
|
+
calldata: { expiration: f, amountIn: _, memo: w, memoStreamingSwap: M }
|
|
8539
|
+
} = a, R = d.add(k.fromBigInt(BigInt(_), d.decimal)), O = t && M || w;
|
|
8551
8540
|
return this.deposit({
|
|
8552
|
-
expiration:
|
|
8553
|
-
assetValue:
|
|
8554
|
-
memo:
|
|
8541
|
+
expiration: f,
|
|
8542
|
+
assetValue: R,
|
|
8543
|
+
memo: O,
|
|
8555
8544
|
feeOptionKey: i,
|
|
8556
|
-
router:
|
|
8557
|
-
recipient:
|
|
8545
|
+
router: T,
|
|
8546
|
+
recipient: o
|
|
8558
8547
|
});
|
|
8559
8548
|
}
|
|
8560
8549
|
if (it.includes(r) && p) {
|
|
8561
|
-
const { calldata:
|
|
8562
|
-
if (!
|
|
8550
|
+
const { calldata: d, contract: o } = a;
|
|
8551
|
+
if (!o)
|
|
8563
8552
|
throw new m("core_swap_contract_not_found");
|
|
8564
|
-
const
|
|
8565
|
-
if (!(
|
|
8553
|
+
const T = this.connectedWallets[p], f = this.getAddress(p);
|
|
8554
|
+
if (!(T != null && T.sendTransaction) || !f)
|
|
8566
8555
|
throw new m("core_wallet_connection_not_found");
|
|
8567
|
-
const { getProvider:
|
|
8568
|
-
if (!
|
|
8569
|
-
throw new m("core_swap_contract_not_supported", { contractAddress:
|
|
8570
|
-
const
|
|
8556
|
+
const { getProvider: _, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), M = _(p), R = _n[o.toLowerCase()];
|
|
8557
|
+
if (!R)
|
|
8558
|
+
throw new m("core_swap_contract_not_supported", { contractAddress: o });
|
|
8559
|
+
const D = await (await ((y = T.createContract) == null ? void 0 : y.call(T, o, R, M))).getFunction("swapIn").populateTransaction(
|
|
8571
8560
|
...wn({
|
|
8572
8561
|
streamSwap: t,
|
|
8573
|
-
toChecksumAddress:
|
|
8574
|
-
contractAddress:
|
|
8562
|
+
toChecksumAddress: w,
|
|
8563
|
+
contractAddress: o,
|
|
8575
8564
|
recipient: n,
|
|
8576
|
-
calldata:
|
|
8565
|
+
calldata: d
|
|
8577
8566
|
}),
|
|
8578
|
-
{ from:
|
|
8567
|
+
{ from: f }
|
|
8579
8568
|
);
|
|
8580
|
-
return
|
|
8569
|
+
return T.sendTransaction(D, i);
|
|
8581
8570
|
}
|
|
8582
8571
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
8583
|
-
} catch (
|
|
8584
|
-
throw new m("core_swap_transaction_error",
|
|
8572
|
+
} catch (d) {
|
|
8573
|
+
throw new m("core_swap_transaction_error", d);
|
|
8585
8574
|
}
|
|
8586
8575
|
});
|
|
8587
8576
|
c(this, "getWalletByChain", async (t, n) => {
|
|
8588
|
-
var
|
|
8577
|
+
var p, u;
|
|
8589
8578
|
const a = this.getAddress(t);
|
|
8590
8579
|
if (!a)
|
|
8591
8580
|
return null;
|
|
8592
|
-
const i = [x.fromChainOrSignature(t)], r = (
|
|
8581
|
+
const i = [x.fromChainOrSignature(t)], r = (p = this.connectedChains[t]) == null ? void 0 : p.walletType;
|
|
8593
8582
|
try {
|
|
8594
|
-
const y = await ((
|
|
8583
|
+
const y = await ((u = this.getWallet(t)) == null ? void 0 : u.getBalance(a, n));
|
|
8595
8584
|
return this.connectedChains[t] = {
|
|
8596
8585
|
address: a,
|
|
8597
8586
|
balance: y != null && y.length ? y : i,
|
|
@@ -8601,8 +8590,8 @@ class Xn {
|
|
|
8601
8590
|
return console.error(y), { address: a, balance: i, walletType: r };
|
|
8602
8591
|
}
|
|
8603
8592
|
});
|
|
8604
|
-
c(this, "approveAssetValue", (t, n) =>
|
|
8605
|
-
c(this, "isAssetValueApproved", (t, n) =>
|
|
8593
|
+
c(this, "approveAssetValue", (t, n) => h(this, K).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
8594
|
+
c(this, "isAssetValueApproved", (t, n) => h(this, K).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
8606
8595
|
c(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
8607
8596
|
var a, i;
|
|
8608
8597
|
return (i = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : i.call(a, t);
|
|
@@ -8612,7 +8601,7 @@ class Xn {
|
|
|
8612
8601
|
if (!n)
|
|
8613
8602
|
throw new m("core_wallet_connection_not_found");
|
|
8614
8603
|
try {
|
|
8615
|
-
return await n.transfer(
|
|
8604
|
+
return await n.transfer(h(this, Q).call(this, t));
|
|
8616
8605
|
} catch (a) {
|
|
8617
8606
|
throw new m("core_swap_transaction_error", a);
|
|
8618
8607
|
}
|
|
@@ -8623,17 +8612,17 @@ class Xn {
|
|
|
8623
8612
|
router: a,
|
|
8624
8613
|
...i
|
|
8625
8614
|
}) => {
|
|
8626
|
-
const { chain: r, symbol:
|
|
8615
|
+
const { chain: r, symbol: p, ticker: u } = t, y = this.connectedWallets[r];
|
|
8627
8616
|
if (!await On({ address: await (y == null ? void 0 : y.getAddress()), chain: r }))
|
|
8628
8617
|
throw new m("core_transaction_invalid_sender_address");
|
|
8629
8618
|
if (!y)
|
|
8630
8619
|
throw new m("core_wallet_connection_not_found");
|
|
8631
|
-
const
|
|
8620
|
+
const d = h(this, Q).call(this, { assetValue: t, recipient: n, router: a, ...i });
|
|
8632
8621
|
try {
|
|
8633
8622
|
switch (r) {
|
|
8634
8623
|
case s.THORChain: {
|
|
8635
8624
|
const o = y;
|
|
8636
|
-
return await (n === "" ? o.deposit(
|
|
8625
|
+
return await (n === "" ? o.deposit(d) : o.transfer(d));
|
|
8637
8626
|
}
|
|
8638
8627
|
case s.Ethereum:
|
|
8639
8628
|
case s.BinanceSmartChain:
|
|
@@ -8641,26 +8630,26 @@ class Xn {
|
|
|
8641
8630
|
const { getChecksumAddressFromAsset: o } = await import("@swapkit/toolbox-evm"), T = r === s.Avalanche ? et : r === s.BinanceSmartChain ? tt : ze;
|
|
8642
8631
|
return await y.call({
|
|
8643
8632
|
abi: T,
|
|
8644
|
-
contractAddress: a || (await
|
|
8633
|
+
contractAddress: a || (await h(this, L).call(this, r)).router,
|
|
8645
8634
|
funcName: "depositWithExpiry",
|
|
8646
8635
|
funcParams: [
|
|
8647
8636
|
n,
|
|
8648
|
-
o({ chain: r, symbol:
|
|
8637
|
+
o({ chain: r, symbol: p, ticker: u }, r),
|
|
8649
8638
|
t.getBaseValue("string"),
|
|
8650
|
-
|
|
8639
|
+
d.memo,
|
|
8651
8640
|
i.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
8652
8641
|
],
|
|
8653
8642
|
txOverrides: {
|
|
8654
|
-
from:
|
|
8643
|
+
from: d.from,
|
|
8655
8644
|
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
8656
8645
|
}
|
|
8657
8646
|
});
|
|
8658
8647
|
}
|
|
8659
8648
|
default:
|
|
8660
|
-
return await y.transfer(
|
|
8649
|
+
return await y.transfer(d);
|
|
8661
8650
|
}
|
|
8662
8651
|
} catch (o) {
|
|
8663
|
-
const T = ((o == null ? void 0 : o.message) || (o == null ? void 0 : o.toString())).toLowerCase(),
|
|
8652
|
+
const T = ((o == null ? void 0 : o.message) || (o == null ? void 0 : o.toString())).toLowerCase(), f = T == null ? void 0 : T.includes("insufficient funds"), _ = T == null ? void 0 : T.includes("gas"), w = T == null ? void 0 : T.includes("server"), M = f ? "core_transaction_deposit_insufficient_funds_error" : _ ? "core_transaction_deposit_gas_error" : w ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
8664
8653
|
throw new m(M, o);
|
|
8665
8654
|
}
|
|
8666
8655
|
});
|
|
@@ -8675,9 +8664,9 @@ class Xn {
|
|
|
8675
8664
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
8676
8665
|
let a = "", i = "";
|
|
8677
8666
|
try {
|
|
8678
|
-
a = await
|
|
8667
|
+
a = await h(this, I).call(this, {
|
|
8679
8668
|
assetValue: t,
|
|
8680
|
-
memo: C(
|
|
8669
|
+
memo: C(b.DEPOSIT, {
|
|
8681
8670
|
...n,
|
|
8682
8671
|
address: this.getAddress(n.chain)
|
|
8683
8672
|
})
|
|
@@ -8686,9 +8675,9 @@ class Xn {
|
|
|
8686
8675
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
8687
8676
|
}
|
|
8688
8677
|
try {
|
|
8689
|
-
i = await
|
|
8678
|
+
i = await h(this, I).call(this, {
|
|
8690
8679
|
assetValue: n,
|
|
8691
|
-
memo: C(
|
|
8680
|
+
memo: C(b.DEPOSIT, {
|
|
8692
8681
|
...n,
|
|
8693
8682
|
address: this.getAddress(s.THORChain)
|
|
8694
8683
|
})
|
|
@@ -8704,31 +8693,31 @@ class Xn {
|
|
|
8704
8693
|
runeAddr: a,
|
|
8705
8694
|
assetAddr: i,
|
|
8706
8695
|
isPendingSymmAsset: r,
|
|
8707
|
-
mode:
|
|
8696
|
+
mode: p = "sym"
|
|
8708
8697
|
}) => {
|
|
8709
|
-
const { chain:
|
|
8698
|
+
const { chain: u, symbol: y } = n, d = p === "sym", o = (t == null ? void 0 : t.gt(0)) && (d || p === "rune"), T = (n == null ? void 0 : n.gt(0)) && (d || p === "asset"), f = r || o, _ = f ? a || this.getAddress(s.THORChain) : "", w = d || p === "asset" ? i || this.getAddress(u) : "";
|
|
8710
8699
|
if (!o && !T)
|
|
8711
8700
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
8712
|
-
if (
|
|
8701
|
+
if (f && !_)
|
|
8713
8702
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
8714
8703
|
let M, R;
|
|
8715
8704
|
if (o && t)
|
|
8716
8705
|
try {
|
|
8717
|
-
M = await
|
|
8706
|
+
M = await h(this, I).call(this, {
|
|
8718
8707
|
assetValue: t,
|
|
8719
|
-
memo: C(
|
|
8708
|
+
memo: C(b.DEPOSIT, { chain: u, symbol: y, address: w })
|
|
8720
8709
|
});
|
|
8721
|
-
} catch (
|
|
8722
|
-
throw new m("core_transaction_add_liquidity_rune_error",
|
|
8710
|
+
} catch (O) {
|
|
8711
|
+
throw new m("core_transaction_add_liquidity_rune_error", O);
|
|
8723
8712
|
}
|
|
8724
8713
|
if (T && n)
|
|
8725
8714
|
try {
|
|
8726
|
-
R = await
|
|
8715
|
+
R = await h(this, I).call(this, {
|
|
8727
8716
|
assetValue: n,
|
|
8728
|
-
memo: C(
|
|
8717
|
+
memo: C(b.DEPOSIT, { chain: u, symbol: y, address: _ })
|
|
8729
8718
|
});
|
|
8730
|
-
} catch (
|
|
8731
|
-
throw new m("core_transaction_add_liquidity_asset_error",
|
|
8719
|
+
} catch (O) {
|
|
8720
|
+
throw new m("core_transaction_add_liquidity_asset_error", O);
|
|
8732
8721
|
}
|
|
8733
8722
|
return { runeTx: M, assetTx: R };
|
|
8734
8723
|
});
|
|
@@ -8740,12 +8729,12 @@ class Xn {
|
|
|
8740
8729
|
}) => {
|
|
8741
8730
|
if (i && !a)
|
|
8742
8731
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
8743
|
-
const r = C(
|
|
8732
|
+
const r = C(b.DEPOSIT, {
|
|
8744
8733
|
chain: n.split(".")[0],
|
|
8745
8734
|
symbol: n.split(".")[1],
|
|
8746
8735
|
address: i ? a : ""
|
|
8747
8736
|
});
|
|
8748
|
-
return
|
|
8737
|
+
return h(this, I).call(this, { assetValue: t, memo: r });
|
|
8749
8738
|
});
|
|
8750
8739
|
c(this, "withdraw", async ({
|
|
8751
8740
|
memo: t,
|
|
@@ -8754,15 +8743,15 @@ class Xn {
|
|
|
8754
8743
|
from: i,
|
|
8755
8744
|
to: r
|
|
8756
8745
|
}) => {
|
|
8757
|
-
const
|
|
8746
|
+
const p = r === "rune" && i !== "rune" ? x.fromChainOrSignature(s.THORChain) : i === "sym" && r === "sym" || i === "rune" || i === "asset" ? void 0 : n, u = de(i === "asset" ? n.chain : s.THORChain), y = t || C(b.WITHDRAW, {
|
|
8758
8747
|
symbol: n.symbol,
|
|
8759
8748
|
chain: n.chain,
|
|
8760
8749
|
ticker: n.ticker,
|
|
8761
8750
|
basisPoints: Math.min(1e4, Math.round(a * 100)),
|
|
8762
|
-
targetAssetString:
|
|
8751
|
+
targetAssetString: p == null ? void 0 : p.toString(),
|
|
8763
8752
|
singleSide: !1
|
|
8764
8753
|
});
|
|
8765
|
-
return
|
|
8754
|
+
return h(this, I).call(this, { assetValue: u, memo: y });
|
|
8766
8755
|
});
|
|
8767
8756
|
c(this, "savings", async ({
|
|
8768
8757
|
assetValue: t,
|
|
@@ -8770,23 +8759,23 @@ class Xn {
|
|
|
8770
8759
|
percent: a,
|
|
8771
8760
|
type: i
|
|
8772
8761
|
}) => {
|
|
8773
|
-
const r = i === "add" ?
|
|
8762
|
+
const r = i === "add" ? b.DEPOSIT : b.WITHDRAW, p = n || C(r, {
|
|
8774
8763
|
ticker: t.ticker,
|
|
8775
8764
|
symbol: t.symbol,
|
|
8776
8765
|
chain: t.chain,
|
|
8777
8766
|
singleSide: !0,
|
|
8778
8767
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
8779
|
-
}),
|
|
8780
|
-
return
|
|
8768
|
+
}), u = r === b.DEPOSIT ? t : de(t.chain);
|
|
8769
|
+
return h(this, I).call(this, { memo: p, assetValue: u });
|
|
8781
8770
|
});
|
|
8782
8771
|
c(this, "loan", ({
|
|
8783
8772
|
assetValue: t,
|
|
8784
8773
|
memo: n,
|
|
8785
8774
|
minAmount: a,
|
|
8786
8775
|
type: i
|
|
8787
|
-
}) =>
|
|
8776
|
+
}) => h(this, I).call(this, {
|
|
8788
8777
|
assetValue: t,
|
|
8789
|
-
memo: n || C(i === "open" ?
|
|
8778
|
+
memo: n || C(i === "open" ? b.OPEN_LOAN : b.CLOSE_LOAN, {
|
|
8790
8779
|
asset: t.toString(),
|
|
8791
8780
|
minAmount: a.toString(),
|
|
8792
8781
|
address: this.getAddress(t.chain)
|
|
@@ -8797,11 +8786,11 @@ class Xn {
|
|
|
8797
8786
|
assetValue: n,
|
|
8798
8787
|
address: a
|
|
8799
8788
|
}) => {
|
|
8800
|
-
const i = t === "bond" ?
|
|
8789
|
+
const i = t === "bond" ? b.BOND : t === "unbond" ? b.UNBOND : b.LEAVE, r = C(i, {
|
|
8801
8790
|
address: a,
|
|
8802
8791
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
8803
8792
|
});
|
|
8804
|
-
return
|
|
8793
|
+
return h(this, Y).call(this, {
|
|
8805
8794
|
memo: r,
|
|
8806
8795
|
assetValue: t === "bond" ? n : de(s.THORChain)
|
|
8807
8796
|
});
|
|
@@ -8809,12 +8798,12 @@ class Xn {
|
|
|
8809
8798
|
c(this, "registerThorname", ({
|
|
8810
8799
|
assetValue: t,
|
|
8811
8800
|
...n
|
|
8812
|
-
}) =>
|
|
8801
|
+
}) => h(this, Y).call(this, { assetValue: t, memo: C(b.THORNAME_REGISTER, n) }));
|
|
8813
8802
|
c(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: i = {} }) => {
|
|
8814
8803
|
try {
|
|
8815
8804
|
t.forEach((r) => {
|
|
8816
8805
|
this[r.connectMethodName] = r.connect({
|
|
8817
|
-
addChain:
|
|
8806
|
+
addChain: h(this, ie),
|
|
8818
8807
|
config: n || {},
|
|
8819
8808
|
apis: a,
|
|
8820
8809
|
rpcUrls: i
|
|
@@ -8906,56 +8895,56 @@ class Xn {
|
|
|
8906
8895
|
throw new m("core_chain_halted");
|
|
8907
8896
|
return a;
|
|
8908
8897
|
});
|
|
8909
|
-
B(this,
|
|
8898
|
+
B(this, ie, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
8910
8899
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
8911
8900
|
});
|
|
8912
|
-
B(this,
|
|
8901
|
+
B(this, K, async ({
|
|
8913
8902
|
assetValue: t,
|
|
8914
8903
|
type: n = "checkOnly",
|
|
8915
8904
|
contractAddress: a
|
|
8916
8905
|
}) => {
|
|
8917
|
-
const { address: i, chain: r, isGasAsset:
|
|
8918
|
-
if (y &&
|
|
8906
|
+
const { address: i, chain: r, isGasAsset: p, isSynthetic: u } = t, y = [s.Ethereum, s.Avalanche, s.BinanceSmartChain].includes(r);
|
|
8907
|
+
if (y && p || !y || u)
|
|
8919
8908
|
return !0;
|
|
8920
8909
|
const o = this.connectedWallets[r], T = n === "checkOnly" ? o == null ? void 0 : o.isApproved : o == null ? void 0 : o.approve;
|
|
8921
8910
|
if (!T)
|
|
8922
8911
|
throw new m("core_wallet_connection_not_found");
|
|
8923
|
-
const
|
|
8924
|
-
if (!i || !
|
|
8912
|
+
const f = this.getAddress(r);
|
|
8913
|
+
if (!i || !f)
|
|
8925
8914
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
8926
|
-
const
|
|
8915
|
+
const _ = a || (await h(this, L).call(this, r)).router;
|
|
8927
8916
|
return T({
|
|
8928
8917
|
amount: t.getBaseValue("bigint"),
|
|
8929
8918
|
assetAddress: i,
|
|
8930
|
-
from:
|
|
8931
|
-
spenderAddress:
|
|
8919
|
+
from: f,
|
|
8920
|
+
spenderAddress: _
|
|
8932
8921
|
});
|
|
8933
8922
|
});
|
|
8934
8923
|
B(this, I, async ({
|
|
8935
8924
|
assetValue: t,
|
|
8936
8925
|
memo: n,
|
|
8937
|
-
feeOptionKey: a =
|
|
8926
|
+
feeOptionKey: a = q.Fast
|
|
8938
8927
|
}) => {
|
|
8939
8928
|
const {
|
|
8940
8929
|
gas_rate: i,
|
|
8941
8930
|
router: r,
|
|
8942
|
-
address:
|
|
8943
|
-
} = await
|
|
8931
|
+
address: p
|
|
8932
|
+
} = await h(this, L).call(this, t.chain), u = (parseInt(i) || 0) * Et[a];
|
|
8944
8933
|
return this.deposit({
|
|
8945
8934
|
assetValue: t,
|
|
8946
|
-
recipient:
|
|
8935
|
+
recipient: p,
|
|
8947
8936
|
memo: n,
|
|
8948
8937
|
router: r,
|
|
8949
|
-
feeRate:
|
|
8938
|
+
feeRate: u
|
|
8950
8939
|
});
|
|
8951
8940
|
});
|
|
8952
|
-
B(this,
|
|
8941
|
+
B(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
8953
8942
|
const a = await Rn(this.stagenet);
|
|
8954
8943
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
8955
8944
|
throw new m("core_chain_halted");
|
|
8956
8945
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
8957
8946
|
});
|
|
8958
|
-
B(this,
|
|
8947
|
+
B(this, Q, ({ assetValue: t, ...n }) => ({
|
|
8959
8948
|
...n,
|
|
8960
8949
|
memo: n.memo || "",
|
|
8961
8950
|
from: this.getAddress(t.chain),
|
|
@@ -8964,64 +8953,64 @@ class Xn {
|
|
|
8964
8953
|
this.stagenet = !!t;
|
|
8965
8954
|
}
|
|
8966
8955
|
}
|
|
8967
|
-
L = new WeakMap(),
|
|
8956
|
+
L = new WeakMap(), ie = new WeakMap(), K = new WeakMap(), I = new WeakMap(), Y = new WeakMap(), Q = new WeakMap();
|
|
8968
8957
|
export {
|
|
8969
8958
|
at as AGG_SWAP,
|
|
8970
8959
|
Sn as ApiError,
|
|
8971
|
-
|
|
8960
|
+
X as ApiUrl,
|
|
8972
8961
|
x as AssetValue,
|
|
8973
8962
|
A as BaseDecimal,
|
|
8974
8963
|
We as BigIntArithmetics,
|
|
8975
8964
|
s as Chain,
|
|
8976
8965
|
fe as ChainId,
|
|
8977
8966
|
Nn as ChainIdToChain,
|
|
8978
|
-
|
|
8967
|
+
De as ChainToChainId,
|
|
8979
8968
|
Be as ChainToExplorerUrl,
|
|
8980
8969
|
Bn as ChainToHexChainId,
|
|
8981
|
-
|
|
8970
|
+
lt as ChainToRPC,
|
|
8982
8971
|
ut as ContractAddress,
|
|
8983
8972
|
kn as CosmosChainList,
|
|
8984
8973
|
yt as DerivationPath,
|
|
8985
|
-
|
|
8974
|
+
l as ERROR_CODE,
|
|
8986
8975
|
rt as ERROR_MODULE,
|
|
8987
|
-
|
|
8976
|
+
Ce as ERROR_TYPE,
|
|
8988
8977
|
ot as EVMChainList,
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8978
|
+
mt as ErrorCode,
|
|
8979
|
+
q as FeeOption,
|
|
8980
|
+
b as MemoType,
|
|
8992
8981
|
Cn as NetworkDerivationPath,
|
|
8993
8982
|
nt as QuoteMode,
|
|
8994
|
-
|
|
8995
|
-
|
|
8983
|
+
ke as RPCUrl,
|
|
8984
|
+
_e as RequestClient,
|
|
8996
8985
|
it as SWAP_IN,
|
|
8997
8986
|
st as SWAP_OUT,
|
|
8998
8987
|
Xn as SwapKitCore,
|
|
8999
8988
|
m as SwapKitError,
|
|
9000
|
-
|
|
8989
|
+
k as SwapKitNumber,
|
|
9001
8990
|
et as TCAvalancheDepositABI,
|
|
9002
8991
|
tt as TCBscDepositABI,
|
|
9003
8992
|
ze as TCEthereumVaultAbi,
|
|
9004
8993
|
Dn as TCSupportedChainList,
|
|
9005
8994
|
xn as UTXOChainList,
|
|
9006
|
-
|
|
8995
|
+
Tt as WalletOption,
|
|
9007
8996
|
Pn as assetFromString,
|
|
9008
8997
|
Gn as derivationPathToString,
|
|
9009
8998
|
In as erc20ABI,
|
|
9010
8999
|
Ln as filterAssets,
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9000
|
+
re as formatBigIntToSafeValue,
|
|
9001
|
+
Et as gasFeeMultiplier,
|
|
9002
|
+
Rt as getAssetType,
|
|
9003
|
+
St as getAsymmetricAssetShare,
|
|
9015
9004
|
Vn as getAsymmetricAssetWithdrawAmount,
|
|
9016
|
-
|
|
9005
|
+
It as getAsymmetricRuneShare,
|
|
9017
9006
|
Hn as getAsymmetricRuneWithdrawAmount,
|
|
9018
|
-
|
|
9019
|
-
|
|
9007
|
+
gt as getCommonAssetInfo,
|
|
9008
|
+
Mt as getDecimal,
|
|
9020
9009
|
Un as getEstimatedPoolShare,
|
|
9021
9010
|
qn as getLiquiditySlippage,
|
|
9022
9011
|
C as getMemoFor,
|
|
9023
9012
|
de as getMinAmountByChain,
|
|
9024
|
-
|
|
9013
|
+
Ct as getSymmetricPoolShare,
|
|
9025
9014
|
Fn as getSymmetricWithdraw,
|
|
9026
9015
|
$n as getTHORNameCost,
|
|
9027
9016
|
Pe as isGasAsset,
|