@swapkit/core 1.0.0-rc.70 → 1.0.0-rc.71
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 +383 -371
- package/dist/index.es.js.map +1 -1
- package/package.json +13 -13
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (e, t, n) => (
|
|
1
|
+
var qe = Object.defineProperty;
|
|
2
|
+
var We = (e, t, n) => t in e ? qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var T = (e, t, n) => (We(e, typeof t != "symbol" ? t + "" : t, n), n), je = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var f = (e, t, n) => (
|
|
7
|
+
var f = (e, t, n) => (je(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
const
|
|
12
|
+
var Ke = Object.defineProperty, Xe = (e, t, n) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (Xe(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
+
const fn = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -108,7 +108,7 @@ const _n = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Ye = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const _n = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Je = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const _n = [
|
|
|
447
447
|
stateMutability: "view",
|
|
448
448
|
type: "function"
|
|
449
449
|
}
|
|
450
|
-
],
|
|
450
|
+
], Qe = [
|
|
451
451
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
452
452
|
{
|
|
453
453
|
anonymous: !1,
|
|
@@ -600,13 +600,13 @@ const _n = [
|
|
|
600
600
|
type: "function"
|
|
601
601
|
}
|
|
602
602
|
];
|
|
603
|
-
var
|
|
604
|
-
const
|
|
603
|
+
var ze = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(ze || {});
|
|
604
|
+
const Ze = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], et = [
|
|
610
610
|
"ERC20-TC",
|
|
611
611
|
"ERC20-ARC20",
|
|
612
612
|
"ERC20-BEP20",
|
|
@@ -617,15 +617,15 @@ const ze = [
|
|
|
617
617
|
"BEP20-ERC20",
|
|
618
618
|
"BEP20-ARC20"
|
|
619
619
|
/* BSC_TO_AVAX */
|
|
620
|
-
],
|
|
620
|
+
], tt = [
|
|
621
621
|
"TC-TC",
|
|
622
622
|
"TC-ERC20",
|
|
623
623
|
"TC-ARC20",
|
|
624
624
|
"TC-BEP20"
|
|
625
625
|
/* TC_SUPPORTED_TO_BSC */
|
|
626
626
|
];
|
|
627
|
-
var Ie = /* @__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))(Ie || {}),
|
|
628
|
-
const
|
|
627
|
+
var Ie = /* @__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))(Ie || {}), nt = /* @__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))(nt || {}), y = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_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))(y || {});
|
|
628
|
+
const at = {
|
|
629
629
|
[y.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
630
|
[y.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
631
|
[y.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
@@ -676,13 +676,13 @@ const nt = {
|
|
|
676
676
|
[y.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
677
|
[y.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
678
|
[y.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
|
-
},
|
|
680
|
-
let n =
|
|
679
|
+
}, pe = (e, t) => {
|
|
680
|
+
let n = at[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
|
-
class
|
|
685
|
+
let bn = class ve extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -697,15 +697,15 @@ class Se extends Error {
|
|
|
697
697
|
},
|
|
698
698
|
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
|
-
const m = r ||
|
|
701
|
-
super(m), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = m, this.display =
|
|
700
|
+
const m = r || pe(s, u || []) || "";
|
|
701
|
+
super(m), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = m, this.display = pe(s, u || []), this.code = s, this.type = o || Ie.UNHANDLED_ERROR, this.options = {
|
|
702
702
|
shouldLog: p || !0,
|
|
703
703
|
shouldTrace: l || !0,
|
|
704
704
|
shouldThrow: d || !1
|
|
705
705
|
}, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new ve(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ class Se extends Error {
|
|
|
714
714
|
return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
|
|
715
715
|
}
|
|
716
716
|
get displayMessage() {
|
|
717
|
-
return
|
|
717
|
+
return pe(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -723,9 +723,9 @@ class Se extends Error {
|
|
|
723
723
|
throw Error(t, { cause: this.stack });
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
|
-
}
|
|
727
|
-
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}),
|
|
728
|
-
const
|
|
726
|
+
};
|
|
727
|
+
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), st = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(st || {}), it = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(it || {});
|
|
728
|
+
const wn = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
731
731
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -742,8 +742,8 @@ const fn = {
|
|
|
742
742
|
OP: [44, 60, 0, 0, 0],
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
|
-
var
|
|
746
|
-
const
|
|
745
|
+
var b = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(b || {});
|
|
746
|
+
const rt = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
749
749
|
"BSC",
|
|
@@ -751,18 +751,18 @@ const it = [
|
|
|
751
751
|
"OP",
|
|
752
752
|
"MATIC"
|
|
753
753
|
/* Polygon */
|
|
754
|
-
],
|
|
754
|
+
], An = [
|
|
755
755
|
"BTC",
|
|
756
756
|
"BCH",
|
|
757
757
|
"DOGE",
|
|
758
758
|
"LTC"
|
|
759
759
|
/* Litecoin */
|
|
760
|
-
],
|
|
760
|
+
], En = [
|
|
761
761
|
"GAIA",
|
|
762
762
|
"THOR",
|
|
763
763
|
"BNB"
|
|
764
764
|
/* Binance */
|
|
765
|
-
],
|
|
765
|
+
], Rn = [
|
|
766
766
|
"AVAX",
|
|
767
767
|
"BNB",
|
|
768
768
|
"BSC",
|
|
@@ -775,26 +775,26 @@ const it = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var _e = /* @__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))(_e || {}),
|
|
779
|
-
const
|
|
778
|
+
var _e = /* @__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))(_e || {}), Ce = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Ce || {}), j = /* @__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))(j || {});
|
|
779
|
+
const ie = Object.values(i), ot = Object.keys(i), fe = ie.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
|
-
const n =
|
|
781
|
+
const n = ot.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
785
|
+
), pt = ie.reduce(
|
|
786
786
|
(e, t) => (e[t] = _e[fe[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), dt = ie.reduce(
|
|
789
|
+
(e, t) => (e[t] = Ce[fe[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
),
|
|
791
|
+
), gn = ie.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
793
|
const n = `${fe[t]}Hex`;
|
|
794
794
|
return e[t] = _e[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
|
-
),
|
|
797
|
+
), On = {
|
|
798
798
|
"0xa4b1": "ARB",
|
|
799
799
|
42161: "ARB",
|
|
800
800
|
"0xa86a": "AVAX",
|
|
@@ -819,7 +819,7 @@ const se = Object.values(i), rt = Object.keys(i), fe = se.reduce(
|
|
|
819
819
|
"thorchain-stagenet-v2": "THOR",
|
|
820
820
|
"thorchain-mainnet-v1": "THOR"
|
|
821
821
|
/* THORChain */
|
|
822
|
-
},
|
|
822
|
+
}, Me = {
|
|
823
823
|
ARB: "https://arbiscan.io",
|
|
824
824
|
AVAX: "https://snowtrace.io",
|
|
825
825
|
BSC: "https://bscscan.com",
|
|
@@ -836,17 +836,17 @@ const se = Object.values(i), rt = Object.keys(i), fe = se.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://runescan.io"
|
|
838
838
|
};
|
|
839
|
-
var
|
|
839
|
+
var ut = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(ut || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), lt = /* @__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))(lt || {}), yt = Object.defineProperty, ct = (e, t, n) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, I = (e, t, n) => (ct(e, typeof t != "symbol" ? t + "" : t, n), n), mt = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
|
-
},
|
|
842
|
+
}, H = (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
|
-
}, R = (e, t, n) => (
|
|
847
|
-
const
|
|
846
|
+
}, R = (e, t, n) => (mt(e, t, "access private method"), n);
|
|
847
|
+
const Tt = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await we.post(
|
|
849
|
+
const { result: n } = await we.post(dt[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -856,37 +856,37 @@ const mt = "0x313ce567", Me = 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: Tt }, "latest"]
|
|
860
860
|
})
|
|
861
861
|
});
|
|
862
862
|
return parseInt(BigInt(n).toString());
|
|
863
863
|
} catch (n) {
|
|
864
|
-
return console.error(n),
|
|
864
|
+
return console.error(n), b[e];
|
|
865
865
|
}
|
|
866
|
-
},
|
|
866
|
+
}, ht = async (e) => {
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
|
-
return
|
|
868
|
+
return b.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
|
-
return t != null && t.startsWith("0x") ?
|
|
871
|
-
},
|
|
870
|
+
return t != null && t.startsWith("0x") ? Ne({ chain: i.Ethereum, to: t }) : b.ETH;
|
|
871
|
+
}, _t = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ?
|
|
874
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? Ne({ chain: i.Avalanche, to: t.toLowerCase() }) : b.AVAX;
|
|
874
|
+
}, ft = async (e) => (e === i.BinanceSmartChain, b.BSC), bt = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
|
-
return Tt(t);
|
|
878
|
-
case i.Avalanche:
|
|
879
877
|
return ht(t);
|
|
880
|
-
case i.
|
|
878
|
+
case i.Avalanche:
|
|
881
879
|
return _t(t);
|
|
880
|
+
case i.BinanceSmartChain:
|
|
881
|
+
return ft(t);
|
|
882
882
|
default:
|
|
883
|
-
return
|
|
883
|
+
return b[e];
|
|
884
884
|
}
|
|
885
|
-
},
|
|
885
|
+
}, wt = {
|
|
886
886
|
[F.Average]: 1.2,
|
|
887
887
|
[F.Fast]: 1.5,
|
|
888
888
|
[F.Fastest]: 2
|
|
889
|
-
},
|
|
889
|
+
}, xe = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case i.Bitcoin:
|
|
892
892
|
case i.BitcoinCash:
|
|
@@ -912,20 +912,20 @@ const mt = "0x313ce567", Me = async ({ chain: e, to: t }) => {
|
|
|
912
912
|
case i.THORChain:
|
|
913
913
|
return t === "RUNE";
|
|
914
914
|
}
|
|
915
|
-
},
|
|
915
|
+
}, At = (e) => {
|
|
916
916
|
switch (e) {
|
|
917
917
|
case "ETH.THOR":
|
|
918
918
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
919
919
|
case "ETH.vTHOR":
|
|
920
920
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
921
921
|
case i.Cosmos:
|
|
922
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
922
|
+
return { identifier: "GAIA.ATOM", decimal: b[e] };
|
|
923
923
|
case i.THORChain:
|
|
924
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
924
|
+
return { identifier: "THOR.RUNE", decimal: b[e] };
|
|
925
925
|
case i.BinanceSmartChain:
|
|
926
|
-
return { identifier: "BSC.BNB", decimal:
|
|
926
|
+
return { identifier: "BSC.BNB", decimal: b[e] };
|
|
927
927
|
case i.Maya:
|
|
928
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
928
|
+
return { identifier: "MAYA.CACAO", decimal: b.MAYA };
|
|
929
929
|
case "MAYA.MAYA":
|
|
930
930
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
931
931
|
case i.Kujira:
|
|
@@ -939,9 +939,9 @@ const mt = "0x313ce567", Me = async ({ chain: e, to: t }) => {
|
|
|
939
939
|
case i.Polygon:
|
|
940
940
|
case i.Bitcoin:
|
|
941
941
|
case i.Ethereum:
|
|
942
|
-
return { identifier: `${e}.${e}`, decimal:
|
|
942
|
+
return { identifier: `${e}.${e}`, decimal: b[e] };
|
|
943
943
|
}
|
|
944
|
-
},
|
|
944
|
+
}, Et = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
946
946
|
return "Synth";
|
|
947
947
|
switch (e) {
|
|
@@ -971,24 +971,24 @@ const mt = "0x313ce567", Me = async ({ chain: e, to: t }) => {
|
|
|
971
971
|
case i.Optimism:
|
|
972
972
|
return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
973
973
|
}
|
|
974
|
-
},
|
|
974
|
+
}, Sn = (e) => {
|
|
975
975
|
var t;
|
|
976
976
|
const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."), o = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
977
977
|
return { chain: n, symbol: r, ticker: o, synth: s };
|
|
978
|
-
},
|
|
978
|
+
}, Rt = new RegExp(
|
|
979
979
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
980
|
"gmi"
|
|
981
|
-
),
|
|
981
|
+
), gt = (e) => {
|
|
982
982
|
const [t, n] = e.split(".");
|
|
983
|
-
if (!
|
|
983
|
+
if (!rt.includes(t))
|
|
984
984
|
return !0;
|
|
985
985
|
const [, a] = n.split("-");
|
|
986
|
-
return
|
|
987
|
-
},
|
|
986
|
+
return xe({ chain: t, symbol: n }) || !!a;
|
|
987
|
+
}, In = (e) => e.filter((t) => {
|
|
988
988
|
const n = `${t.chain}.${t.symbol}`;
|
|
989
|
-
return !
|
|
989
|
+
return !Rt.test(n) && gt(n) && t.value !== "0";
|
|
990
990
|
});
|
|
991
|
-
function
|
|
991
|
+
function Ot({
|
|
992
992
|
liquidityUnits: e,
|
|
993
993
|
poolUnits: t,
|
|
994
994
|
runeDepth: n
|
|
@@ -996,7 +996,7 @@ function gt({
|
|
|
996
996
|
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = s.mul(s).mul(s);
|
|
997
997
|
return o.mul(p.sub(d).add(l)).div(u);
|
|
998
998
|
}
|
|
999
|
-
function
|
|
999
|
+
function St({
|
|
1000
1000
|
liquidityUnits: e,
|
|
1001
1001
|
poolUnits: t,
|
|
1002
1002
|
assetDepth: n
|
|
@@ -1004,24 +1004,24 @@ function Ot({
|
|
|
1004
1004
|
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = o.mul(p.sub(d).add(l)), m = s.mul(s).mul(s);
|
|
1005
1005
|
return u.div(m);
|
|
1006
1006
|
}
|
|
1007
|
-
function
|
|
1007
|
+
function vn({
|
|
1008
1008
|
percent: e,
|
|
1009
1009
|
runeDepth: t,
|
|
1010
1010
|
liquidityUnits: n,
|
|
1011
1011
|
poolUnits: a
|
|
1012
1012
|
}) {
|
|
1013
|
-
return
|
|
1013
|
+
return Ot({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1014
1014
|
}
|
|
1015
|
-
function
|
|
1015
|
+
function Cn({
|
|
1016
1016
|
percent: e,
|
|
1017
1017
|
assetDepth: t,
|
|
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
1023
|
function g(e) {
|
|
1024
|
-
return
|
|
1024
|
+
return x.fromBigInt(BigInt(e), b.THOR);
|
|
1025
1025
|
}
|
|
1026
1026
|
function It({
|
|
1027
1027
|
liquidityUnits: e,
|
|
@@ -1034,7 +1034,7 @@ function It({
|
|
|
1034
1034
|
runeAmount: g(n).mul(e).div(t)
|
|
1035
1035
|
};
|
|
1036
1036
|
}
|
|
1037
|
-
function
|
|
1037
|
+
function Mn({
|
|
1038
1038
|
liquidityUnits: e,
|
|
1039
1039
|
poolUnits: t,
|
|
1040
1040
|
runeDepth: n,
|
|
@@ -1047,7 +1047,7 @@ function vn({
|
|
|
1047
1047
|
)
|
|
1048
1048
|
);
|
|
1049
1049
|
}
|
|
1050
|
-
function
|
|
1050
|
+
function Nn({
|
|
1051
1051
|
runeDepth: e,
|
|
1052
1052
|
poolUnits: t,
|
|
1053
1053
|
assetDepth: n,
|
|
@@ -1055,13 +1055,13 @@ function Cn({
|
|
|
1055
1055
|
runeAmount: s,
|
|
1056
1056
|
assetAmount: r
|
|
1057
1057
|
}) {
|
|
1058
|
-
const o = new
|
|
1059
|
-
if (
|
|
1058
|
+
const o = new x({ value: e, decimal: 8 }), p = new x({ value: n, decimal: 8 }), d = new x({ value: t, decimal: 8 }), l = new x({ value: s, decimal: 8 }), u = new x({ value: r, decimal: 8 }), m = l.mul(p), _ = u.mul(o), w = l.mul(u), A = o.mul(p), E = d.mul(m.add(_.add(w.mul(2)))), O = m.add(_.add(A.mul(2))), S = E.div(O), D = g(a).add(S);
|
|
1059
|
+
if (S.getBaseValue("number") === 0)
|
|
1060
1060
|
return D.div(d).getBaseValue("number");
|
|
1061
|
-
const
|
|
1062
|
-
return D.div(
|
|
1061
|
+
const oe = d.add(D);
|
|
1062
|
+
return D.div(oe).getBaseValue("number");
|
|
1063
1063
|
}
|
|
1064
|
-
function
|
|
1064
|
+
function xn({
|
|
1065
1065
|
runeAmount: e,
|
|
1066
1066
|
assetAmount: t,
|
|
1067
1067
|
runeDepth: n,
|
|
@@ -1115,18 +1115,18 @@ const M = (e, t) => {
|
|
|
1115
1115
|
return "";
|
|
1116
1116
|
}
|
|
1117
1117
|
};
|
|
1118
|
-
function
|
|
1118
|
+
function Dn(e) {
|
|
1119
1119
|
if (e < 0)
|
|
1120
1120
|
throw new Error("Invalid number of year");
|
|
1121
1121
|
return 10 + e;
|
|
1122
1122
|
}
|
|
1123
|
-
function
|
|
1123
|
+
function Pn(e) {
|
|
1124
1124
|
if (e.length > 30)
|
|
1125
1125
|
return !1;
|
|
1126
1126
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1127
1127
|
return !!e.match(t);
|
|
1128
1128
|
}
|
|
1129
|
-
function
|
|
1129
|
+
function Bn([e, t, n, a, s]) {
|
|
1130
1130
|
return `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1131
1131
|
}
|
|
1132
1132
|
class Ae extends Error {
|
|
@@ -1150,7 +1150,7 @@ class Ae extends Error {
|
|
|
1150
1150
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
|
-
class
|
|
1153
|
+
class De extends Error {
|
|
1154
1154
|
constructor(t) {
|
|
1155
1155
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1156
1156
|
enumerable: !0,
|
|
@@ -1160,12 +1160,12 @@ class xe 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", Q = (...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
1167
|
return be({}, ...e);
|
|
1168
|
-
},
|
|
1168
|
+
}, Pe = (e = {}, t = {}) => {
|
|
1169
1169
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1170
1170
|
for (const [r, o] of s.entries())
|
|
1171
1171
|
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
@@ -1175,13 +1175,13 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
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 [s, r] of Object.entries(a))
|
|
1180
|
-
|
|
1181
|
-
|
|
1180
|
+
z(r) && s in t && (r = be(t[s], r)), t = { ...t, [s]: r };
|
|
1181
|
+
z(a.headers) && (n = Pe(n, a.headers), t.headers = n);
|
|
1182
1182
|
}
|
|
1183
1183
|
return t;
|
|
1184
|
-
},
|
|
1184
|
+
}, vt = (() => {
|
|
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 Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1192
1192
|
return e = !0, "half";
|
|
1193
1193
|
}
|
|
1194
1194
|
}).headers.has("Content-Type")), e && !t;
|
|
1195
|
-
})(),
|
|
1195
|
+
})(), Ct = typeof globalThis.AbortController == "function", Mt = typeof globalThis.ReadableStream == "function", Nt = typeof globalThis.FormData == "function", Be = ["get", "post", "put", "patch", "head", "delete"], xt = {
|
|
1196
1196
|
json: "application/json",
|
|
1197
1197
|
text: "text/*",
|
|
1198
1198
|
formData: "multipart/form-data",
|
|
1199
1199
|
arrayBuffer: "*/*",
|
|
1200
1200
|
blob: "*/*"
|
|
1201
|
-
},
|
|
1201
|
+
}, de = 2147483647, Le = Symbol("stop"), Dt = {
|
|
1202
1202
|
json: !0,
|
|
1203
1203
|
parseJson: !0,
|
|
1204
1204
|
searchParams: !0,
|
|
@@ -1209,7 +1209,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1209
1209
|
throwHttpErrors: !0,
|
|
1210
1210
|
onDownloadProgress: !0,
|
|
1211
1211
|
fetch: !0
|
|
1212
|
-
},
|
|
1212
|
+
}, Pt = {
|
|
1213
1213
|
method: !0,
|
|
1214
1214
|
headers: !0,
|
|
1215
1215
|
body: !0,
|
|
@@ -1225,15 +1225,15 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1225
1225
|
window: !0,
|
|
1226
1226
|
dispatcher: !0,
|
|
1227
1227
|
duplex: !0
|
|
1228
|
-
},
|
|
1228
|
+
}, Bt = (e) => Be.includes(e) ? e.toUpperCase() : e, Lt = ["get", "put", "head", "delete", "options", "trace"], Vt = [408, 413, 429, 500, 502, 503, 504], Ve = [413, 429, 503], Ee = {
|
|
1229
1229
|
limit: 2,
|
|
1230
|
-
methods:
|
|
1231
|
-
statusCodes:
|
|
1232
|
-
afterStatusCodes:
|
|
1230
|
+
methods: Lt,
|
|
1231
|
+
statusCodes: Vt,
|
|
1232
|
+
afterStatusCodes: Ve,
|
|
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
|
...Ee,
|
|
@@ -1246,13 +1246,13 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1246
1246
|
return {
|
|
1247
1247
|
...Ee,
|
|
1248
1248
|
...e,
|
|
1249
|
-
afterStatusCodes:
|
|
1249
|
+
afterStatusCodes: Ve
|
|
1250
1250
|
};
|
|
1251
1251
|
};
|
|
1252
|
-
async function
|
|
1252
|
+
async function $t(e, t, n, a) {
|
|
1253
1253
|
return new Promise((s, r) => {
|
|
1254
1254
|
const o = setTimeout(() => {
|
|
1255
|
-
n && n.abort(), r(new
|
|
1255
|
+
n && n.abort(), r(new De(e));
|
|
1256
1256
|
}, a.timeout);
|
|
1257
1257
|
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1258
1258
|
clearTimeout(o);
|
|
@@ -1270,17 +1270,17 @@ async function Ht(e, { signal: t }) {
|
|
|
1270
1270
|
}, e);
|
|
1271
1271
|
});
|
|
1272
1272
|
}
|
|
1273
|
-
const
|
|
1273
|
+
const kt = (e, t) => {
|
|
1274
1274
|
const n = {};
|
|
1275
1275
|
for (const a in t)
|
|
1276
|
-
!(a in
|
|
1276
|
+
!(a in Pt) && !(a in Dt) && !(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
|
|
1282
|
-
if (typeof a._options.timeout == "number" && a._options.timeout >
|
|
1283
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
1281
|
+
const a = new te(t, n), s = async () => {
|
|
1282
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > de)
|
|
1283
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${de}`);
|
|
1284
1284
|
await Promise.resolve();
|
|
1285
1285
|
let o = await a._fetch();
|
|
1286
1286
|
for (const p of a._options.hooks.afterResponse) {
|
|
@@ -1296,13 +1296,13 @@ class ee {
|
|
|
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 (!Mt)
|
|
1300
1300
|
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1301
1301
|
return a._stream(o.clone(), a._options.onDownloadProgress);
|
|
1302
1302
|
}
|
|
1303
1303
|
return o;
|
|
1304
1304
|
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
|
|
1305
|
-
for (const [o, p] of Object.entries(
|
|
1305
|
+
for (const [o, p] of Object.entries(xt))
|
|
1306
1306
|
r[o] = async () => {
|
|
1307
1307
|
a.request.headers.set("accept", a.request.headers.get("accept") || p);
|
|
1308
1308
|
const d = (await r).clone();
|
|
@@ -1347,17 +1347,17 @@ class ee {
|
|
|
1347
1347
|
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1348
1348
|
credentials: this._input.credentials || "same-origin",
|
|
1349
1349
|
...n,
|
|
1350
|
-
headers:
|
|
1350
|
+
headers: Pe(this._input.headers, n.headers),
|
|
1351
1351
|
hooks: be({
|
|
1352
1352
|
beforeRequest: [],
|
|
1353
1353
|
beforeRetry: [],
|
|
1354
1354
|
beforeError: [],
|
|
1355
1355
|
afterResponse: []
|
|
1356
1356
|
}, n.hooks),
|
|
1357
|
-
method:
|
|
1357
|
+
method: Bt(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 ee {
|
|
|
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 (Ct) {
|
|
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,14 +1377,14 @@ class ee {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
this._options.signal = this.abortController.signal;
|
|
1379
1379
|
}
|
|
1380
|
-
if (
|
|
1380
|
+
if (vt && (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()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1382
|
-
(
|
|
1382
|
+
(Nt && 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(s, { ...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
|
}
|
|
1386
1386
|
_calculateRetryDelay(t) {
|
|
1387
|
-
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof
|
|
1387
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof De)) {
|
|
1388
1388
|
if (t instanceof Ae) {
|
|
1389
1389
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1390
1390
|
return 0;
|
|
@@ -1408,7 +1408,7 @@ class ee {
|
|
|
1408
1408
|
try {
|
|
1409
1409
|
return await t();
|
|
1410
1410
|
} catch (n) {
|
|
1411
|
-
const a = Math.min(this._calculateRetryDelay(n),
|
|
1411
|
+
const a = Math.min(this._calculateRetryDelay(n), de);
|
|
1412
1412
|
if (a !== 0 && this._retryCount > 0) {
|
|
1413
1413
|
await Ht(a, { signal: this._options.signal });
|
|
1414
1414
|
for (const s of this._options.hooks.beforeRetry)
|
|
@@ -1417,7 +1417,7 @@ class ee {
|
|
|
1417
1417
|
options: this._options,
|
|
1418
1418
|
error: n,
|
|
1419
1419
|
retryCount: this._retryCount
|
|
1420
|
-
}) ===
|
|
1420
|
+
}) === Le)
|
|
1421
1421
|
return;
|
|
1422
1422
|
return this._retry(t);
|
|
1423
1423
|
}
|
|
@@ -1434,8 +1434,8 @@ class ee {
|
|
|
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 = kt(this.request, this._options);
|
|
1438
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : $t(this.request.clone(), t, this.abortController, this._options);
|
|
1439
1439
|
}
|
|
1440
1440
|
/* istanbul ignore next */
|
|
1441
1441
|
_stream(t, n) {
|
|
@@ -1472,16 +1472,16 @@ class ee {
|
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
1474
|
/*! MIT License © Sindre Sorhus */
|
|
1475
|
-
const
|
|
1476
|
-
const t = (n, a) =>
|
|
1477
|
-
for (const n of
|
|
1478
|
-
t[n] = (a, s) =>
|
|
1479
|
-
return t.create = (n) =>
|
|
1480
|
-
},
|
|
1475
|
+
const ce = (e) => {
|
|
1476
|
+
const t = (n, a) => te.create(n, Q(e, a));
|
|
1477
|
+
for (const n of Be)
|
|
1478
|
+
t[n] = (a, s) => te.create(a, Q(e, s, { method: n }));
|
|
1479
|
+
return t.create = (n) => ce(Q(n)), t.extend = (n) => ce(Q(e, n)), t.stop = Le, t;
|
|
1480
|
+
}, Ft = ce(), Gt = Ft, qt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Re = Gt.create({ headers: qt }), we = {
|
|
1481
1481
|
get: (e, t) => Re.get(e, t).json(),
|
|
1482
1482
|
post: (e, t) => Re.post(e, t).json()
|
|
1483
1483
|
}, ge = [...Object.values(i), "TERRA"];
|
|
1484
|
-
function
|
|
1484
|
+
function Wt(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 qt(e = "") {
|
|
|
1492
1492
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1493
1493
|
);
|
|
1494
1494
|
}
|
|
1495
|
-
const
|
|
1496
|
-
function
|
|
1495
|
+
const K = 8, L = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1496
|
+
function re({
|
|
1497
1497
|
value: e,
|
|
1498
|
-
bigIntDecimal: t =
|
|
1499
|
-
decimal: n =
|
|
1498
|
+
bigIntDecimal: t = K,
|
|
1499
|
+
decimal: n = K
|
|
1500
1500
|
}) {
|
|
1501
1501
|
if (n === 0)
|
|
1502
1502
|
return e.toString();
|
|
@@ -1511,17 +1511,17 @@ function ie({
|
|
|
1511
1511
|
""
|
|
1512
1512
|
);
|
|
1513
1513
|
}
|
|
1514
|
-
var U, k, B,
|
|
1515
|
-
const
|
|
1514
|
+
var U, k, B, $, me, Ue, Z, ue, ne, Te;
|
|
1515
|
+
const jt = class $e {
|
|
1516
1516
|
constructor(t) {
|
|
1517
|
-
|
|
1518
|
-
const n =
|
|
1519
|
-
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(
|
|
1517
|
+
H(this, U), H(this, B), H(this, me), H(this, Z), H(this, ne), I(this, "decimalMultiplier", 10n ** 8n), I(this, "bigIntValue", 0n), I(this, "decimal");
|
|
1518
|
+
const n = he(t), a = typeof t == "object";
|
|
1519
|
+
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(ke(ae(n)), this.decimal || 0)), R(this, me, Ue).call(this, n);
|
|
1520
1520
|
}
|
|
1521
1521
|
static fromBigInt(t, n) {
|
|
1522
|
-
return new
|
|
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({
|
|
@@ -1550,19 +1550,19 @@ const Wt = class Ue {
|
|
|
1550
1550
|
return R(this, U, k).call(this, "div", ...t);
|
|
1551
1551
|
}
|
|
1552
1552
|
gt(t) {
|
|
1553
|
-
return R(this, B,
|
|
1553
|
+
return R(this, B, $).call(this, "gt", t);
|
|
1554
1554
|
}
|
|
1555
1555
|
gte(t) {
|
|
1556
|
-
return R(this, B,
|
|
1556
|
+
return R(this, B, $).call(this, "gte", t);
|
|
1557
1557
|
}
|
|
1558
1558
|
lt(t) {
|
|
1559
|
-
return R(this, B,
|
|
1559
|
+
return R(this, B, $).call(this, "lt", t);
|
|
1560
1560
|
}
|
|
1561
1561
|
lte(t) {
|
|
1562
|
-
return R(this, B,
|
|
1562
|
+
return R(this, B, $).call(this, "lte", t);
|
|
1563
1563
|
}
|
|
1564
1564
|
eqValue(t) {
|
|
1565
|
-
return R(this, B,
|
|
1565
|
+
return R(this, B, $).call(this, "eqValue", t);
|
|
1566
1566
|
}
|
|
1567
1567
|
// @ts-expect-error False positive
|
|
1568
1568
|
getValue(t) {
|
|
@@ -1581,7 +1581,7 @@ const Wt = class Ue {
|
|
|
1581
1581
|
}
|
|
1582
1582
|
// @ts-expect-error
|
|
1583
1583
|
getBaseValue(t) {
|
|
1584
|
-
const n = this.decimalMultiplier / L(this.decimal ||
|
|
1584
|
+
const n = this.decimalMultiplier / L(this.decimal || b.THOR), a = this.bigIntValue / n;
|
|
1585
1585
|
switch (t) {
|
|
1586
1586
|
case "number":
|
|
1587
1587
|
return Number(a);
|
|
@@ -1594,8 +1594,8 @@ const Wt = class Ue {
|
|
|
1594
1594
|
getBigIntValue(t, n) {
|
|
1595
1595
|
if (!n && typeof t == "object")
|
|
1596
1596
|
return t.bigIntValue;
|
|
1597
|
-
const a =
|
|
1598
|
-
return s === "0" || s === "undefined" ? 0n : R(this,
|
|
1597
|
+
const a = he(t), s = ae(a);
|
|
1598
|
+
return s === "0" || s === "undefined" ? 0n : R(this, ne, Te).call(this, s, n);
|
|
1599
1599
|
}
|
|
1600
1600
|
toSignificant(t = 6) {
|
|
1601
1601
|
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
@@ -1641,7 +1641,7 @@ const Wt = class Ue {
|
|
|
1641
1641
|
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1642
1642
|
}
|
|
1643
1643
|
formatBigIntToSafeValue(t, n) {
|
|
1644
|
-
const a = n || this.decimal ||
|
|
1644
|
+
const a = n || this.decimal || K, s = Math.max(
|
|
1645
1645
|
a,
|
|
1646
1646
|
G(this.decimalMultiplier)
|
|
1647
1647
|
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, l = d.length - s;
|
|
@@ -1653,7 +1653,7 @@ const Wt = class Ue {
|
|
|
1653
1653
|
}
|
|
1654
1654
|
};
|
|
1655
1655
|
U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1656
|
-
const n = R(this,
|
|
1656
|
+
const n = R(this, Z, ue).call(this, this, ...t), a = Math.max(n, G(this.decimalMultiplier)), s = L(a), r = t.reduce(
|
|
1657
1657
|
(p, d) => {
|
|
1658
1658
|
const l = this.getBigIntValue(d, a);
|
|
1659
1659
|
switch (e) {
|
|
@@ -1674,7 +1674,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1674
1674
|
},
|
|
1675
1675
|
//normalize is to precision multiplier base
|
|
1676
1676
|
this.bigIntValue * s / this.decimalMultiplier
|
|
1677
|
-
), o =
|
|
1677
|
+
), o = re({
|
|
1678
1678
|
bigIntDecimal: a,
|
|
1679
1679
|
decimal: a,
|
|
1680
1680
|
value: r
|
|
@@ -1685,8 +1685,8 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1685
1685
|
value: o,
|
|
1686
1686
|
identifier: this.toString()
|
|
1687
1687
|
});
|
|
1688
|
-
}, B = /* @__PURE__ */ new WeakSet(),
|
|
1689
|
-
const n = R(this,
|
|
1688
|
+
}, B = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
1689
|
+
const n = R(this, Z, ue).call(this, this, ...t), a = this.getBigIntValue(t[0], n), s = this.getBigIntValue(this, n);
|
|
1690
1690
|
switch (e) {
|
|
1691
1691
|
case "gt":
|
|
1692
1692
|
return s > a;
|
|
@@ -1699,35 +1699,35 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1699
1699
|
case "eqValue":
|
|
1700
1700
|
return s === a;
|
|
1701
1701
|
}
|
|
1702
|
-
},
|
|
1703
|
-
const t =
|
|
1704
|
-
this.bigIntValue = R(this,
|
|
1705
|
-
},
|
|
1706
|
-
const t = e.map((n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) :
|
|
1707
|
-
return Math.max(...t,
|
|
1708
|
-
},
|
|
1702
|
+
}, me = /* @__PURE__ */ new WeakSet(), Ue = function(e) {
|
|
1703
|
+
const t = ae(e) || "0";
|
|
1704
|
+
this.bigIntValue = R(this, ne, Te).call(this, t);
|
|
1705
|
+
}, Z = /* @__PURE__ */ new WeakSet(), ue = function(...e) {
|
|
1706
|
+
const t = e.map((n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : ke(ae(n))).filter(Boolean);
|
|
1707
|
+
return Math.max(...t, K);
|
|
1708
|
+
}, ne = /* @__PURE__ */ new WeakSet(), Te = function(e, t) {
|
|
1709
1709
|
const n = t ? L(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
|
|
1710
1710
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1711
1711
|
};
|
|
1712
|
-
let He =
|
|
1713
|
-
const
|
|
1712
|
+
let He = jt;
|
|
1713
|
+
const Kt = 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" ? Kt.format(e) : he(e)}`.replaceAll(",", ".").split(".");
|
|
1719
1719
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1720
1720
|
}
|
|
1721
|
-
function
|
|
1721
|
+
function ke(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, K);
|
|
1725
1725
|
}
|
|
1726
|
-
function
|
|
1726
|
+
function he(e) {
|
|
1727
1727
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1728
1728
|
}
|
|
1729
1729
|
const q = /* @__PURE__ */ new Map();
|
|
1730
|
-
class
|
|
1730
|
+
class N extends He {
|
|
1731
1731
|
constructor({
|
|
1732
1732
|
value: t,
|
|
1733
1733
|
decimal: n,
|
|
@@ -1736,9 +1736,9 @@ class x extends He {
|
|
|
1736
1736
|
symbol: r,
|
|
1737
1737
|
identifier: o
|
|
1738
1738
|
}) {
|
|
1739
|
-
super(typeof t == "object" ? t : { decimal: n, value: t }),
|
|
1740
|
-
const p =
|
|
1741
|
-
this.type =
|
|
1739
|
+
super(typeof t == "object" ? t : { decimal: n, value: t }), I(this, "address"), I(this, "chain"), I(this, "isGasAsset", !1), I(this, "isSynthetic", !1), I(this, "symbol"), I(this, "tax"), I(this, "ticker"), I(this, "type");
|
|
1740
|
+
const p = ee(o || `${s}.${r}`);
|
|
1741
|
+
this.type = Et(p), this.tax = a, this.chain = p.chain, this.ticker = p.ticker, this.symbol = p.symbol, this.address = p.address, this.isSynthetic = p.isSynthetic, this.isGasAsset = p.isGasAsset;
|
|
1742
1742
|
}
|
|
1743
1743
|
toString() {
|
|
1744
1744
|
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
@@ -1757,44 +1757,48 @@ class x extends He {
|
|
|
1757
1757
|
if (!a || !s)
|
|
1758
1758
|
throw new Error("Invalid asset url");
|
|
1759
1759
|
const o = a === i.THORChain && r ? `${a}.${s}/${r}` : t;
|
|
1760
|
-
return
|
|
1760
|
+
return ye(o, n);
|
|
1761
1761
|
}
|
|
1762
1762
|
static fromString(t, n = 0) {
|
|
1763
|
-
return
|
|
1763
|
+
return ye(t, n);
|
|
1764
1764
|
}
|
|
1765
1765
|
static fromIdentifier(t, n = 0) {
|
|
1766
|
-
return
|
|
1766
|
+
return ye(t, n);
|
|
1767
1767
|
}
|
|
1768
1768
|
static fromStringSync(t, n = 0) {
|
|
1769
|
-
const {
|
|
1770
|
-
if (
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
)
|
|
1774
|
-
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1769
|
+
const { chain: a, isSynthetic: s } = ee(t), r = q.get(t.toUpperCase());
|
|
1770
|
+
if (s)
|
|
1771
|
+
return Oe(t, n);
|
|
1772
|
+
r || console.error(
|
|
1773
|
+
`Asset ${t} is not loaded. Use AssetValue.loadStaticAssets() to load it`
|
|
1774
|
+
);
|
|
1775
|
+
const { tax: o, decimal: p, identifier: d } = r || {
|
|
1776
|
+
decimal: b[a],
|
|
1777
|
+
identifier: t
|
|
1778
|
+
};
|
|
1779
|
+
return new N({
|
|
1780
|
+
tax: o,
|
|
1781
|
+
value: W(n, p),
|
|
1782
|
+
identifier: s ? t : d,
|
|
1783
|
+
decimal: s ? 8 : p
|
|
1782
1784
|
});
|
|
1783
1785
|
}
|
|
1784
1786
|
static fromIdentifierSync(t, n = 0) {
|
|
1785
|
-
const a = q.get(t);
|
|
1786
|
-
if (
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
)
|
|
1790
|
-
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1787
|
+
const { chain: a, isSynthetic: s } = ee(t), r = q.get(t);
|
|
1788
|
+
if (s)
|
|
1789
|
+
return Oe(t, n);
|
|
1790
|
+
r || console.error(
|
|
1791
|
+
`Asset ${t} is not loaded. - Loading with base Chain. Use AssetValue.loadStaticAssets() to load it`
|
|
1792
|
+
);
|
|
1793
|
+
const { tax: o, decimal: p, identifier: d } = r || {
|
|
1794
|
+
decimal: b[a],
|
|
1795
|
+
identifier: t
|
|
1796
|
+
};
|
|
1797
|
+
return new N({ tax: o, decimal: p, identifier: d, value: W(n, p) });
|
|
1794
1798
|
}
|
|
1795
1799
|
static fromChainOrSignature(t, n = 0) {
|
|
1796
|
-
const { decimal: a, identifier: s } =
|
|
1797
|
-
return new
|
|
1800
|
+
const { decimal: a, identifier: s } = At(t);
|
|
1801
|
+
return new N({ value: W(n, a), decimal: a, identifier: s });
|
|
1798
1802
|
}
|
|
1799
1803
|
static loadStaticAssets() {
|
|
1800
1804
|
return new Promise(
|
|
@@ -1806,7 +1810,7 @@ class x extends He {
|
|
|
1806
1810
|
(r = s == null ? void 0 : s.tokens) == null || r.forEach(({ identifier: o, chain: p, ...d }) => {
|
|
1807
1811
|
q.set(o.toUpperCase(), {
|
|
1808
1812
|
identifier: o,
|
|
1809
|
-
decimal: "decimals" in d ? d.decimals :
|
|
1813
|
+
decimal: "decimals" in d ? d.decimals : b[p]
|
|
1810
1814
|
});
|
|
1811
1815
|
});
|
|
1812
1816
|
}), t({ ok: !0 });
|
|
@@ -1821,8 +1825,8 @@ class x extends He {
|
|
|
1821
1825
|
);
|
|
1822
1826
|
}
|
|
1823
1827
|
}
|
|
1824
|
-
function
|
|
1825
|
-
const t =
|
|
1828
|
+
function le(e) {
|
|
1829
|
+
const t = N.fromChainOrSignature(e);
|
|
1826
1830
|
switch (e) {
|
|
1827
1831
|
case i.Bitcoin:
|
|
1828
1832
|
case i.Litecoin:
|
|
@@ -1840,26 +1844,34 @@ function ue(e) {
|
|
|
1840
1844
|
return t.set(1e-8);
|
|
1841
1845
|
}
|
|
1842
1846
|
}
|
|
1843
|
-
async function
|
|
1844
|
-
|
|
1845
|
-
const n = q.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await
|
|
1846
|
-
return n || q.set(e.toUpperCase(), { identifier: e, decimal: a }), new
|
|
1847
|
+
async function ye(e, t = 0) {
|
|
1848
|
+
Wt(e);
|
|
1849
|
+
const n = q.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await bt(ee(e));
|
|
1850
|
+
return n || q.set(e.toUpperCase(), { identifier: e, decimal: a }), new N({ decimal: a, value: W(t, a), identifier: e });
|
|
1851
|
+
}
|
|
1852
|
+
function Oe(e, t = 0) {
|
|
1853
|
+
const [n, a] = e.split("/");
|
|
1854
|
+
return new N({
|
|
1855
|
+
decimal: 8,
|
|
1856
|
+
value: W(t, 8),
|
|
1857
|
+
identifier: `${i.THORChain}.${n}/${a}`
|
|
1858
|
+
});
|
|
1847
1859
|
}
|
|
1848
|
-
function
|
|
1849
|
-
return typeof e == "bigint" ?
|
|
1860
|
+
function W(e, t) {
|
|
1861
|
+
return typeof e == "bigint" ? re({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1850
1862
|
}
|
|
1851
|
-
function
|
|
1863
|
+
function ee(e) {
|
|
1852
1864
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".").pop().split("/"), s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
|
|
1853
1865
|
return {
|
|
1854
1866
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1855
1867
|
chain: r,
|
|
1856
|
-
isGasAsset:
|
|
1868
|
+
isGasAsset: xe({ chain: r, symbol: o }),
|
|
1857
1869
|
isSynthetic: t,
|
|
1858
1870
|
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1859
1871
|
ticker: p
|
|
1860
1872
|
};
|
|
1861
1873
|
}
|
|
1862
|
-
const
|
|
1874
|
+
const Xt = {
|
|
1863
1875
|
/**
|
|
1864
1876
|
* Core
|
|
1865
1877
|
*/
|
|
@@ -1919,21 +1931,21 @@ const Kt = {
|
|
|
1919
1931
|
};
|
|
1920
1932
|
class c extends Error {
|
|
1921
1933
|
constructor(t, n) {
|
|
1922
|
-
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code:
|
|
1934
|
+
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Xt[t], message: t } }), Object.setPrototypeOf(this, c.prototype);
|
|
1923
1935
|
}
|
|
1924
1936
|
}
|
|
1925
|
-
class
|
|
1937
|
+
class x extends He {
|
|
1926
1938
|
eq(t) {
|
|
1927
1939
|
return this.eqValue(t);
|
|
1928
1940
|
}
|
|
1929
1941
|
static fromBigInt(t, n) {
|
|
1930
|
-
return new
|
|
1942
|
+
return new x({
|
|
1931
1943
|
decimal: n,
|
|
1932
|
-
value:
|
|
1944
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1933
1945
|
});
|
|
1934
1946
|
}
|
|
1935
1947
|
}
|
|
1936
|
-
const
|
|
1948
|
+
const Yt = [
|
|
1937
1949
|
{
|
|
1938
1950
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1939
1951
|
stateMutability: "nonpayable",
|
|
@@ -2024,7 +2036,7 @@ const Xt = [
|
|
|
2024
2036
|
type: "function"
|
|
2025
2037
|
},
|
|
2026
2038
|
{ stateMutability: "payable", type: "receive" }
|
|
2027
|
-
],
|
|
2039
|
+
], Jt = [
|
|
2028
2040
|
{
|
|
2029
2041
|
inputs: [
|
|
2030
2042
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2168,7 +2180,7 @@ const Xt = [
|
|
|
2168
2180
|
type: "function"
|
|
2169
2181
|
},
|
|
2170
2182
|
{ stateMutability: "payable", type: "receive" }
|
|
2171
|
-
],
|
|
2183
|
+
], Qt = [
|
|
2172
2184
|
{
|
|
2173
2185
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2174
2186
|
stateMutability: "nonpayable",
|
|
@@ -2273,7 +2285,7 @@ const Xt = [
|
|
|
2273
2285
|
type: "function"
|
|
2274
2286
|
},
|
|
2275
2287
|
{ stateMutability: "payable", type: "receive" }
|
|
2276
|
-
],
|
|
2288
|
+
], zt = [
|
|
2277
2289
|
{
|
|
2278
2290
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2279
2291
|
stateMutability: "nonpayable",
|
|
@@ -2364,7 +2376,7 @@ const Xt = [
|
|
|
2364
2376
|
type: "function"
|
|
2365
2377
|
},
|
|
2366
2378
|
{ stateMutability: "payable", type: "receive" }
|
|
2367
|
-
],
|
|
2379
|
+
], Zt = [
|
|
2368
2380
|
{
|
|
2369
2381
|
inputs: [
|
|
2370
2382
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2508,7 +2520,7 @@ const Xt = [
|
|
|
2508
2520
|
type: "function"
|
|
2509
2521
|
},
|
|
2510
2522
|
{ stateMutability: "payable", type: "receive" }
|
|
2511
|
-
],
|
|
2523
|
+
], en = [
|
|
2512
2524
|
{
|
|
2513
2525
|
inputs: [
|
|
2514
2526
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2627,7 +2639,7 @@ const Xt = [
|
|
|
2627
2639
|
type: "function"
|
|
2628
2640
|
},
|
|
2629
2641
|
{ stateMutability: "payable", type: "receive" }
|
|
2630
|
-
],
|
|
2642
|
+
], tn = [
|
|
2631
2643
|
{
|
|
2632
2644
|
inputs: [
|
|
2633
2645
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2746,7 +2758,7 @@ const Xt = [
|
|
|
2746
2758
|
type: "function"
|
|
2747
2759
|
},
|
|
2748
2760
|
{ stateMutability: "payable", type: "receive" }
|
|
2749
|
-
],
|
|
2761
|
+
], nn = [
|
|
2750
2762
|
{
|
|
2751
2763
|
inputs: [
|
|
2752
2764
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2865,7 +2877,7 @@ const Xt = [
|
|
|
2865
2877
|
type: "function"
|
|
2866
2878
|
},
|
|
2867
2879
|
{ stateMutability: "payable", type: "receive" }
|
|
2868
|
-
],
|
|
2880
|
+
], an = [
|
|
2869
2881
|
{
|
|
2870
2882
|
inputs: [
|
|
2871
2883
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2984,7 +2996,7 @@ const Xt = [
|
|
|
2984
2996
|
type: "function"
|
|
2985
2997
|
},
|
|
2986
2998
|
{ stateMutability: "payable", type: "receive" }
|
|
2987
|
-
],
|
|
2999
|
+
], sn = [
|
|
2988
3000
|
{
|
|
2989
3001
|
inputs: [
|
|
2990
3002
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3111,7 +3123,7 @@ const Xt = [
|
|
|
3111
3123
|
type: "function"
|
|
3112
3124
|
},
|
|
3113
3125
|
{ stateMutability: "payable", type: "receive" }
|
|
3114
|
-
],
|
|
3126
|
+
], rn = [
|
|
3115
3127
|
{
|
|
3116
3128
|
inputs: [
|
|
3117
3129
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3238,7 +3250,7 @@ const Xt = [
|
|
|
3238
3250
|
type: "function"
|
|
3239
3251
|
},
|
|
3240
3252
|
{ stateMutability: "payable", type: "receive" }
|
|
3241
|
-
],
|
|
3253
|
+
], on = [
|
|
3242
3254
|
{
|
|
3243
3255
|
inputs: [
|
|
3244
3256
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3365,7 +3377,7 @@ const Xt = [
|
|
|
3365
3377
|
type: "function"
|
|
3366
3378
|
},
|
|
3367
3379
|
{ stateMutability: "payable", type: "receive" }
|
|
3368
|
-
],
|
|
3380
|
+
], pn = [
|
|
3369
3381
|
{
|
|
3370
3382
|
inputs: [
|
|
3371
3383
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3492,7 +3504,7 @@ const Xt = [
|
|
|
3492
3504
|
type: "function"
|
|
3493
3505
|
},
|
|
3494
3506
|
{ stateMutability: "payable", type: "receive" }
|
|
3495
|
-
],
|
|
3507
|
+
], dn = [
|
|
3496
3508
|
{
|
|
3497
3509
|
inputs: [
|
|
3498
3510
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3619,27 +3631,27 @@ const Xt = [
|
|
|
3619
3631
|
type: "function"
|
|
3620
3632
|
},
|
|
3621
3633
|
{ stateMutability: "payable", type: "receive" }
|
|
3622
|
-
],
|
|
3623
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3624
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3625
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3626
|
-
},
|
|
3627
|
-
...
|
|
3634
|
+
], Fe = {
|
|
3635
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Yt,
|
|
3636
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Qt,
|
|
3637
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: zt
|
|
3638
|
+
}, un = {
|
|
3639
|
+
...Fe,
|
|
3628
3640
|
// AVAX
|
|
3629
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3630
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3631
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3641
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: en,
|
|
3642
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Jt,
|
|
3643
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: nn,
|
|
3632
3644
|
// BSC
|
|
3633
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3645
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: Zt,
|
|
3634
3646
|
// ETH
|
|
3635
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3636
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3637
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3638
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3639
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3640
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3641
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3642
|
-
},
|
|
3647
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: tn,
|
|
3648
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: an,
|
|
3649
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: sn,
|
|
3650
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: rn,
|
|
3651
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: on,
|
|
3652
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: pn,
|
|
3653
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: dn
|
|
3654
|
+
}, ln = ({
|
|
3643
3655
|
streamSwap: e,
|
|
3644
3656
|
contractAddress: t,
|
|
3645
3657
|
recipient: n,
|
|
@@ -3654,16 +3666,16 @@ const Xt = [
|
|
|
3654
3666
|
memoStreamingSwap: u,
|
|
3655
3667
|
tcMemo: m,
|
|
3656
3668
|
tcRouter: _,
|
|
3657
|
-
tcVault:
|
|
3658
|
-
vault:
|
|
3669
|
+
tcVault: w,
|
|
3670
|
+
vault: A,
|
|
3659
3671
|
token: E
|
|
3660
3672
|
}
|
|
3661
3673
|
}) => {
|
|
3662
|
-
const O = !!
|
|
3674
|
+
const O = !!Fe[t.toLowerCase()];
|
|
3663
3675
|
if (O && !l)
|
|
3664
3676
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3665
|
-
const
|
|
3666
|
-
if (!
|
|
3677
|
+
const S = m || d, D = e && u || S;
|
|
3678
|
+
if (!w && !A)
|
|
3667
3679
|
throw new Error("TC Vault is required on calldata");
|
|
3668
3680
|
if (!_ && !l)
|
|
3669
3681
|
throw new Error("TC Router is required on calldata");
|
|
@@ -3671,17 +3683,17 @@ const Xt = [
|
|
|
3671
3683
|
throw new Error("TC Memo is required on calldata");
|
|
3672
3684
|
if (!E)
|
|
3673
3685
|
throw new Error("Token is required on calldata");
|
|
3674
|
-
const
|
|
3686
|
+
const oe = [
|
|
3675
3687
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3676
3688
|
a(_ || l),
|
|
3677
|
-
a(
|
|
3689
|
+
a(w || A),
|
|
3678
3690
|
D.replace("{recipientAddress}", n),
|
|
3679
3691
|
a(E),
|
|
3680
3692
|
s
|
|
3681
|
-
],
|
|
3682
|
-
return [...
|
|
3683
|
-
},
|
|
3684
|
-
const n =
|
|
3693
|
+
], Ge = O ? [a(l), o, p] : [r, p];
|
|
3694
|
+
return [...oe, ...Ge];
|
|
3695
|
+
}, yn = ({ chain: e, txHash: t }) => {
|
|
3696
|
+
const n = Me[e];
|
|
3685
3697
|
switch (e) {
|
|
3686
3698
|
case i.Binance:
|
|
3687
3699
|
case i.Maya:
|
|
@@ -3705,8 +3717,8 @@ const Xt = [
|
|
|
3705
3717
|
default:
|
|
3706
3718
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3707
3719
|
}
|
|
3708
|
-
},
|
|
3709
|
-
const n =
|
|
3720
|
+
}, cn = ({ chain: e, address: t }) => {
|
|
3721
|
+
const n = Me[e];
|
|
3710
3722
|
switch (e) {
|
|
3711
3723
|
case i.Arbitrum:
|
|
3712
3724
|
case i.Avalanche:
|
|
@@ -3728,16 +3740,16 @@ const Xt = [
|
|
|
3728
3740
|
default:
|
|
3729
3741
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3730
3742
|
}
|
|
3731
|
-
}, cn = (e) => {
|
|
3732
|
-
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3733
|
-
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3734
3743
|
}, mn = (e) => {
|
|
3735
|
-
const t = e ?
|
|
3744
|
+
const t = e ? j.ThornodeStagenet : j.ThornodeMainnet;
|
|
3745
|
+
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3746
|
+
}, Tn = (e) => {
|
|
3747
|
+
const t = e ? j.ThornodeStagenet : j.ThornodeMainnet;
|
|
3736
3748
|
return we.get(`${t}/thorchain/mimir`);
|
|
3737
|
-
},
|
|
3749
|
+
}, Se = () => Object.values(i).reduce(
|
|
3738
3750
|
(e, t) => (e[t] = null, e),
|
|
3739
3751
|
{}
|
|
3740
|
-
),
|
|
3752
|
+
), hn = async ({ chain: e, address: t }) => {
|
|
3741
3753
|
if (!t)
|
|
3742
3754
|
return !1;
|
|
3743
3755
|
switch (e) {
|
|
@@ -3747,19 +3759,19 @@ const Xt = [
|
|
|
3747
3759
|
return !0;
|
|
3748
3760
|
}
|
|
3749
3761
|
};
|
|
3750
|
-
var V,
|
|
3751
|
-
class
|
|
3762
|
+
var V, se, X, v, Y, J;
|
|
3763
|
+
class Ln {
|
|
3752
3764
|
constructor({ stagenet: t } = {}) {
|
|
3753
|
-
T(this, "connectedChains",
|
|
3754
|
-
T(this, "connectedWallets",
|
|
3765
|
+
T(this, "connectedChains", Se());
|
|
3766
|
+
T(this, "connectedWallets", Se());
|
|
3755
3767
|
T(this, "stagenet", !1);
|
|
3756
3768
|
T(this, "getAddress", (t) => {
|
|
3757
3769
|
var n;
|
|
3758
3770
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3759
3771
|
});
|
|
3760
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3772
|
+
T(this, "getExplorerTxUrl", (t, n) => yn({ chain: t, txHash: n }));
|
|
3761
3773
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3762
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3774
|
+
T(this, "getExplorerAddressUrl", (t, n) => cn({ chain: t, address: n }));
|
|
3763
3775
|
T(this, "getBalance", async (t, n) => {
|
|
3764
3776
|
const a = await this.getWalletByChain(t, n);
|
|
3765
3777
|
return (a == null ? void 0 : a.balance) || [];
|
|
@@ -3770,54 +3782,54 @@ class Pn {
|
|
|
3770
3782
|
if (!a.complete)
|
|
3771
3783
|
throw new c("core_swap_route_not_complete");
|
|
3772
3784
|
try {
|
|
3773
|
-
if (
|
|
3785
|
+
if (Ze.includes(r)) {
|
|
3774
3786
|
const l = this.connectedWallets[o];
|
|
3775
3787
|
if (!(l != null && l.sendTransaction))
|
|
3776
3788
|
throw new c("core_wallet_connection_not_found");
|
|
3777
3789
|
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3778
3790
|
throw new c("core_swap_route_transaction_not_found");
|
|
3779
|
-
const { data: m, from: _, to:
|
|
3791
|
+
const { data: m, from: _, to: w, value: A } = a.transaction, E = {
|
|
3780
3792
|
data: m,
|
|
3781
3793
|
from: _,
|
|
3782
|
-
to:
|
|
3783
|
-
chainId: BigInt(
|
|
3784
|
-
value:
|
|
3794
|
+
to: w.toLowerCase(),
|
|
3795
|
+
chainId: BigInt(pt[o]),
|
|
3796
|
+
value: A ? BigInt(A) : 0n
|
|
3785
3797
|
};
|
|
3786
3798
|
return l.sendTransaction(E, s);
|
|
3787
3799
|
}
|
|
3788
|
-
if (
|
|
3800
|
+
if (tt.includes(r)) {
|
|
3789
3801
|
if (!a.calldata.fromAsset)
|
|
3790
3802
|
throw new c("core_swap_asset_not_recognized");
|
|
3791
|
-
const l = await
|
|
3803
|
+
const l = await N.fromString(a.calldata.fromAsset);
|
|
3792
3804
|
if (!l)
|
|
3793
3805
|
throw new c("core_swap_asset_not_recognized");
|
|
3794
3806
|
const { address: u } = await f(this, V).call(this, l.chain), {
|
|
3795
3807
|
contract: m,
|
|
3796
|
-
calldata: { expiration: _, amountIn:
|
|
3797
|
-
} = a, O = l.add(
|
|
3808
|
+
calldata: { expiration: _, amountIn: w, memo: A, memoStreamingSwap: E }
|
|
3809
|
+
} = a, O = l.add(x.fromBigInt(BigInt(w), l.decimal)), S = t && E || A;
|
|
3798
3810
|
return this.deposit({
|
|
3799
3811
|
expiration: _,
|
|
3800
3812
|
assetValue: O,
|
|
3801
|
-
memo:
|
|
3813
|
+
memo: S,
|
|
3802
3814
|
feeOptionKey: s,
|
|
3803
3815
|
router: m,
|
|
3804
3816
|
recipient: u
|
|
3805
3817
|
});
|
|
3806
3818
|
}
|
|
3807
|
-
if (
|
|
3819
|
+
if (et.includes(r)) {
|
|
3808
3820
|
const { calldata: l, contract: u } = a;
|
|
3809
3821
|
if (!u)
|
|
3810
3822
|
throw new c("core_swap_contract_not_found");
|
|
3811
3823
|
const m = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3812
3824
|
if (!(m != null && m.sendTransaction) || !_)
|
|
3813
3825
|
throw new c("core_wallet_connection_not_found");
|
|
3814
|
-
const { getProvider:
|
|
3826
|
+
const { getProvider: w, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = w(o), O = un[u.toLowerCase()];
|
|
3815
3827
|
if (!O)
|
|
3816
3828
|
throw new c("core_swap_contract_not_supported", { contractAddress: u });
|
|
3817
3829
|
const D = await (await ((d = m.createContract) == null ? void 0 : d.call(m, u, O, E))).getFunction("swapIn").populateTransaction(
|
|
3818
|
-
...
|
|
3830
|
+
...ln({
|
|
3819
3831
|
streamSwap: t,
|
|
3820
|
-
toChecksumAddress:
|
|
3832
|
+
toChecksumAddress: A,
|
|
3821
3833
|
contractAddress: u,
|
|
3822
3834
|
recipient: n,
|
|
3823
3835
|
calldata: l
|
|
@@ -3836,7 +3848,7 @@ class Pn {
|
|
|
3836
3848
|
const a = this.getAddress(t);
|
|
3837
3849
|
if (!a)
|
|
3838
3850
|
return null;
|
|
3839
|
-
const s = [
|
|
3851
|
+
const s = [N.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3840
3852
|
try {
|
|
3841
3853
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3842
3854
|
return this.connectedChains[t] = {
|
|
@@ -3848,8 +3860,8 @@ class Pn {
|
|
|
3848
3860
|
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3849
3861
|
}
|
|
3850
3862
|
});
|
|
3851
|
-
T(this, "approveAssetValue", (t, n) => f(this,
|
|
3852
|
-
T(this, "isAssetValueApproved", (t, n) => f(this,
|
|
3863
|
+
T(this, "approveAssetValue", (t, n) => f(this, X).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3864
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, X).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3853
3865
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3854
3866
|
var a, s;
|
|
3855
3867
|
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
@@ -3859,7 +3871,7 @@ class Pn {
|
|
|
3859
3871
|
if (!n)
|
|
3860
3872
|
throw new c("core_wallet_connection_not_found");
|
|
3861
3873
|
try {
|
|
3862
|
-
return await n.transfer(f(this,
|
|
3874
|
+
return await n.transfer(f(this, J).call(this, t));
|
|
3863
3875
|
} catch (a) {
|
|
3864
3876
|
throw new c("core_swap_transaction_error", a);
|
|
3865
3877
|
}
|
|
@@ -3871,11 +3883,11 @@ class Pn {
|
|
|
3871
3883
|
...s
|
|
3872
3884
|
}) => {
|
|
3873
3885
|
const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
|
|
3874
|
-
if (!await
|
|
3886
|
+
if (!await hn({ address: await (d == null ? void 0 : d.getAddress()), chain: r }))
|
|
3875
3887
|
throw new c("core_transaction_invalid_sender_address");
|
|
3876
3888
|
if (!d)
|
|
3877
3889
|
throw new c("core_wallet_connection_not_found");
|
|
3878
|
-
const l = f(this,
|
|
3890
|
+
const l = f(this, J).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3879
3891
|
try {
|
|
3880
3892
|
switch (r) {
|
|
3881
3893
|
case i.THORChain: {
|
|
@@ -3885,7 +3897,7 @@ class Pn {
|
|
|
3885
3897
|
case i.Ethereum:
|
|
3886
3898
|
case i.BinanceSmartChain:
|
|
3887
3899
|
case i.Avalanche: {
|
|
3888
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ?
|
|
3900
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ? Je : r === i.BinanceSmartChain ? Qe : Ye;
|
|
3889
3901
|
return await d.call({
|
|
3890
3902
|
abi: m,
|
|
3891
3903
|
contractAddress: a || (await f(this, V).call(this, r)).router,
|
|
@@ -3907,7 +3919,7 @@ class Pn {
|
|
|
3907
3919
|
return await d.transfer(l);
|
|
3908
3920
|
}
|
|
3909
3921
|
} catch (u) {
|
|
3910
|
-
const m = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = m == null ? void 0 : m.includes("insufficient funds"),
|
|
3922
|
+
const m = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = m == null ? void 0 : m.includes("insufficient funds"), w = m == null ? void 0 : m.includes("gas"), A = m == null ? void 0 : m.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : w ? "core_transaction_deposit_gas_error" : A ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3911
3923
|
throw new c(E, u);
|
|
3912
3924
|
}
|
|
3913
3925
|
});
|
|
@@ -3953,29 +3965,29 @@ class Pn {
|
|
|
3953
3965
|
isPendingSymmAsset: r,
|
|
3954
3966
|
mode: o = "sym"
|
|
3955
3967
|
}) => {
|
|
3956
|
-
const { chain: p, symbol: d } = n, l = o === "sym", u = (t == null ? void 0 : t.gt(0)) && (l || o === "rune"), m = (n == null ? void 0 : n.gt(0)) && (l || o === "asset"), _ = r || u,
|
|
3968
|
+
const { chain: p, symbol: d } = n, l = o === "sym", u = (t == null ? void 0 : t.gt(0)) && (l || o === "rune"), m = (n == null ? void 0 : n.gt(0)) && (l || o === "asset"), _ = r || u, w = _ ? a || this.getAddress(i.THORChain) : "", A = l || o === "asset" ? s || this.getAddress(p) : "";
|
|
3957
3969
|
if (!u && !m)
|
|
3958
3970
|
throw new c("core_transaction_add_liquidity_invalid_params");
|
|
3959
|
-
if (_ && !
|
|
3971
|
+
if (_ && !w)
|
|
3960
3972
|
throw new c("core_transaction_add_liquidity_no_rune_address");
|
|
3961
3973
|
let E, O;
|
|
3962
3974
|
if (u && t)
|
|
3963
3975
|
try {
|
|
3964
3976
|
E = await f(this, v).call(this, {
|
|
3965
3977
|
assetValue: t,
|
|
3966
|
-
memo: M(h.DEPOSIT, { chain: p, symbol: d, address:
|
|
3978
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: A })
|
|
3967
3979
|
});
|
|
3968
|
-
} catch (
|
|
3969
|
-
throw new c("core_transaction_add_liquidity_rune_error",
|
|
3980
|
+
} catch (S) {
|
|
3981
|
+
throw new c("core_transaction_add_liquidity_rune_error", S);
|
|
3970
3982
|
}
|
|
3971
3983
|
if (m && n)
|
|
3972
3984
|
try {
|
|
3973
3985
|
O = await f(this, v).call(this, {
|
|
3974
3986
|
assetValue: n,
|
|
3975
|
-
memo: M(h.DEPOSIT, { chain: p, symbol: d, address:
|
|
3987
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: w })
|
|
3976
3988
|
});
|
|
3977
|
-
} catch (
|
|
3978
|
-
throw new c("core_transaction_add_liquidity_asset_error",
|
|
3989
|
+
} catch (S) {
|
|
3990
|
+
throw new c("core_transaction_add_liquidity_asset_error", S);
|
|
3979
3991
|
}
|
|
3980
3992
|
return { runeTx: E, assetTx: O };
|
|
3981
3993
|
});
|
|
@@ -4001,7 +4013,7 @@ class Pn {
|
|
|
4001
4013
|
from: s,
|
|
4002
4014
|
to: r
|
|
4003
4015
|
}) => {
|
|
4004
|
-
const o = r === "rune" ?
|
|
4016
|
+
const o = r === "rune" ? N.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = le(s === "asset" ? n.chain : i.THORChain), d = t || M(h.WITHDRAW, {
|
|
4005
4017
|
symbol: n.symbol,
|
|
4006
4018
|
chain: n.chain,
|
|
4007
4019
|
ticker: n.ticker,
|
|
@@ -4023,7 +4035,7 @@ class Pn {
|
|
|
4023
4035
|
chain: t.chain,
|
|
4024
4036
|
singleSide: !0,
|
|
4025
4037
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
4026
|
-
}), p = r === h.DEPOSIT ? t :
|
|
4038
|
+
}), p = r === h.DEPOSIT ? t : le(t.chain);
|
|
4027
4039
|
return f(this, v).call(this, { memo: o, assetValue: p });
|
|
4028
4040
|
});
|
|
4029
4041
|
T(this, "loan", ({
|
|
@@ -4048,20 +4060,20 @@ class Pn {
|
|
|
4048
4060
|
address: a,
|
|
4049
4061
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
4050
4062
|
});
|
|
4051
|
-
return f(this,
|
|
4063
|
+
return f(this, Y).call(this, {
|
|
4052
4064
|
memo: r,
|
|
4053
|
-
assetValue: t === "bond" ? n :
|
|
4065
|
+
assetValue: t === "bond" ? n : le(i.THORChain)
|
|
4054
4066
|
});
|
|
4055
4067
|
});
|
|
4056
4068
|
T(this, "registerThorname", ({
|
|
4057
4069
|
assetValue: t,
|
|
4058
4070
|
...n
|
|
4059
|
-
}) => f(this,
|
|
4071
|
+
}) => f(this, Y).call(this, { assetValue: t, memo: M(h.THORNAME_REGISTER, n) }));
|
|
4060
4072
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
4061
4073
|
try {
|
|
4062
4074
|
t.forEach((r) => {
|
|
4063
4075
|
this[r.connectMethodName] = r.connect({
|
|
4064
|
-
addChain: f(this,
|
|
4076
|
+
addChain: f(this, se),
|
|
4065
4077
|
config: n || {},
|
|
4066
4078
|
apis: a,
|
|
4067
4079
|
rpcUrls: s
|
|
@@ -4146,17 +4158,17 @@ class Pn {
|
|
|
4146
4158
|
halted: !1,
|
|
4147
4159
|
chain: i.THORChain
|
|
4148
4160
|
};
|
|
4149
|
-
const a = (await
|
|
4161
|
+
const a = (await mn(this.stagenet)).find((s) => s.chain === t);
|
|
4150
4162
|
if (!a)
|
|
4151
4163
|
throw new c("core_inbound_data_not_found");
|
|
4152
4164
|
if (a != null && a.halted)
|
|
4153
4165
|
throw new c("core_chain_halted");
|
|
4154
4166
|
return a;
|
|
4155
4167
|
});
|
|
4156
|
-
P(this,
|
|
4168
|
+
P(this, se, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4157
4169
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4158
4170
|
});
|
|
4159
|
-
P(this,
|
|
4171
|
+
P(this, X, async ({
|
|
4160
4172
|
assetValue: t,
|
|
4161
4173
|
type: n = "checkOnly",
|
|
4162
4174
|
contractAddress: a
|
|
@@ -4170,12 +4182,12 @@ class Pn {
|
|
|
4170
4182
|
const _ = this.getAddress(r);
|
|
4171
4183
|
if (!s || !_)
|
|
4172
4184
|
throw new c("core_approve_asset_address_or_from_not_found");
|
|
4173
|
-
const
|
|
4185
|
+
const w = a || (await f(this, V).call(this, r)).router;
|
|
4174
4186
|
return m({
|
|
4175
4187
|
amount: t.getBaseValue("bigint"),
|
|
4176
4188
|
assetAddress: s,
|
|
4177
4189
|
from: _,
|
|
4178
|
-
spenderAddress:
|
|
4190
|
+
spenderAddress: w
|
|
4179
4191
|
});
|
|
4180
4192
|
});
|
|
4181
4193
|
P(this, v, async ({
|
|
@@ -4187,7 +4199,7 @@ class Pn {
|
|
|
4187
4199
|
gas_rate: s,
|
|
4188
4200
|
router: r,
|
|
4189
4201
|
address: o
|
|
4190
|
-
} = await f(this, V).call(this, t.chain), p = (parseInt(s) || 0) *
|
|
4202
|
+
} = await f(this, V).call(this, t.chain), p = (parseInt(s) || 0) * wt[a];
|
|
4191
4203
|
return this.deposit({
|
|
4192
4204
|
assetValue: t,
|
|
4193
4205
|
recipient: o,
|
|
@@ -4196,13 +4208,13 @@ class Pn {
|
|
|
4196
4208
|
feeRate: p
|
|
4197
4209
|
});
|
|
4198
4210
|
});
|
|
4199
|
-
P(this,
|
|
4200
|
-
const a = await
|
|
4211
|
+
P(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
4212
|
+
const a = await Tn(this.stagenet);
|
|
4201
4213
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4202
4214
|
throw new c("core_chain_halted");
|
|
4203
4215
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
4204
4216
|
});
|
|
4205
|
-
P(this,
|
|
4217
|
+
P(this, J, ({ assetValue: t, ...n }) => ({
|
|
4206
4218
|
...n,
|
|
4207
4219
|
memo: n.memo || "",
|
|
4208
4220
|
from: this.getAddress(t.chain),
|
|
@@ -4211,67 +4223,67 @@ class Pn {
|
|
|
4211
4223
|
this.stagenet = !!t;
|
|
4212
4224
|
}
|
|
4213
4225
|
}
|
|
4214
|
-
V = new WeakMap(),
|
|
4226
|
+
V = new WeakMap(), se = new WeakMap(), X = new WeakMap(), v = new WeakMap(), Y = new WeakMap(), J = new WeakMap();
|
|
4215
4227
|
export {
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4228
|
+
Ze as AGG_SWAP,
|
|
4229
|
+
bn as ApiError,
|
|
4230
|
+
j as ApiUrl,
|
|
4231
|
+
N as AssetValue,
|
|
4232
|
+
b as BaseDecimal,
|
|
4221
4233
|
He as BigIntArithmetics,
|
|
4222
4234
|
i as Chain,
|
|
4223
4235
|
_e as ChainId,
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4236
|
+
On as ChainIdToChain,
|
|
4237
|
+
pt as ChainToChainId,
|
|
4238
|
+
Me as ChainToExplorerUrl,
|
|
4239
|
+
gn as ChainToHexChainId,
|
|
4240
|
+
dt as ChainToRPC,
|
|
4241
|
+
st as ContractAddress,
|
|
4242
|
+
En as CosmosChainList,
|
|
4243
|
+
it as DerivationPath,
|
|
4232
4244
|
y as ERROR_CODE,
|
|
4233
|
-
|
|
4245
|
+
nt as ERROR_MODULE,
|
|
4234
4246
|
Ie as ERROR_TYPE,
|
|
4235
|
-
|
|
4236
|
-
|
|
4247
|
+
rt as EVMChainList,
|
|
4248
|
+
ut as ErrorCode,
|
|
4237
4249
|
F as FeeOption,
|
|
4238
4250
|
h as MemoType,
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4251
|
+
wn as NetworkDerivationPath,
|
|
4252
|
+
ze as QuoteMode,
|
|
4253
|
+
Ce as RPCUrl,
|
|
4242
4254
|
we as RequestClient,
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4255
|
+
et as SWAP_IN,
|
|
4256
|
+
tt as SWAP_OUT,
|
|
4257
|
+
Ln as SwapKitCore,
|
|
4246
4258
|
c as SwapKitError,
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4259
|
+
x as SwapKitNumber,
|
|
4260
|
+
Je as TCAvalancheDepositABI,
|
|
4261
|
+
Qe as TCBscDepositABI,
|
|
4262
|
+
Ye as TCEthereumVaultAbi,
|
|
4263
|
+
Rn as TCSupportedChainList,
|
|
4264
|
+
An as UTXOChainList,
|
|
4265
|
+
lt as WalletOption,
|
|
4266
|
+
Sn as assetFromString,
|
|
4267
|
+
Bn as derivationPathToString,
|
|
4268
|
+
fn as erc20ABI,
|
|
4269
|
+
In as filterAssets,
|
|
4270
|
+
re as formatBigIntToSafeValue,
|
|
4271
|
+
wt as gasFeeMultiplier,
|
|
4272
|
+
Et as getAssetType,
|
|
4273
|
+
St as getAsymmetricAssetShare,
|
|
4274
|
+
Cn as getAsymmetricAssetWithdrawAmount,
|
|
4275
|
+
Ot as getAsymmetricRuneShare,
|
|
4276
|
+
vn as getAsymmetricRuneWithdrawAmount,
|
|
4277
|
+
At as getCommonAssetInfo,
|
|
4278
|
+
bt as getDecimal,
|
|
4279
|
+
Nn as getEstimatedPoolShare,
|
|
4280
|
+
xn as getLiquiditySlippage,
|
|
4269
4281
|
M as getMemoFor,
|
|
4270
|
-
|
|
4282
|
+
le as getMinAmountByChain,
|
|
4271
4283
|
It as getSymmetricPoolShare,
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4284
|
+
Mn as getSymmetricWithdraw,
|
|
4285
|
+
Dn as getTHORNameCost,
|
|
4286
|
+
xe as isGasAsset,
|
|
4287
|
+
Pn as validateTHORName
|
|
4276
4288
|
};
|
|
4277
4289
|
//# sourceMappingURL=index.es.js.map
|