@swapkit/core 1.0.0-rc.70 → 1.0.0-rc.72
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 +373 -367
- 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
|
|
628
|
-
const
|
|
627
|
+
var Se = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(Se || {}), 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 || Se.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, S = (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
|
+
}, In = (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
|
+
}, Sn = (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 It({
|
|
1000
1000
|
liquidityUnits: e,
|
|
1001
1001
|
poolUnits: t,
|
|
1002
1002
|
assetDepth: n
|
|
@@ -1004,26 +1004,26 @@ 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 It({ 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
|
-
function
|
|
1026
|
+
function St({
|
|
1027
1027
|
liquidityUnits: e,
|
|
1028
1028
|
poolUnits: t,
|
|
1029
1029
|
runeDepth: n,
|
|
@@ -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,
|
|
@@ -1042,12 +1042,12 @@ function vn({
|
|
|
1042
1042
|
percent: s
|
|
1043
1043
|
}) {
|
|
1044
1044
|
return Object.fromEntries(
|
|
1045
|
-
Object.entries(
|
|
1045
|
+
Object.entries(St({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1046
1046
|
([r, o]) => [r, o.mul(s)]
|
|
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
|
|
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))), I = E.div(O), D = g(a).add(I);
|
|
1059
1059
|
if (I.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), S(this, "decimalMultiplier", 10n ** 8n), S(this, "bigIntValue", 0n), S(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,
|
|
@@ -1737,8 +1737,8 @@ class x extends He {
|
|
|
1737
1737
|
identifier: o
|
|
1738
1738
|
}) {
|
|
1739
1739
|
super(typeof t == "object" ? t : { decimal: n, value: t }), S(this, "address"), S(this, "chain"), S(this, "isGasAsset", !1), S(this, "isSynthetic", !1), S(this, "symbol"), S(this, "tax"), S(this, "ticker"), S(this, "type");
|
|
1740
|
-
const p =
|
|
1741
|
-
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,42 @@ 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
|
-
decimal: a ? 8 : o
|
|
1769
|
+
const { chain: a, isSynthetic: s } = ee(t), r = q.get(t.toUpperCase());
|
|
1770
|
+
if (s)
|
|
1771
|
+
return Oe(t, n);
|
|
1772
|
+
const { tax: o, decimal: p, identifier: d } = r || {
|
|
1773
|
+
decimal: b[a],
|
|
1774
|
+
identifier: t
|
|
1775
|
+
};
|
|
1776
|
+
return new N({
|
|
1777
|
+
tax: o,
|
|
1778
|
+
value: W(n, p),
|
|
1779
|
+
identifier: s ? t : d,
|
|
1780
|
+
decimal: s ? 8 : p
|
|
1782
1781
|
});
|
|
1783
1782
|
}
|
|
1784
1783
|
static fromIdentifierSync(t, n = 0) {
|
|
1785
|
-
const a = q.get(t);
|
|
1786
|
-
if (
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
return new x({ tax: s, decimal: r, identifier: o, value: Z(n, r) });
|
|
1784
|
+
const { chain: a, isSynthetic: s } = ee(t), r = q.get(t);
|
|
1785
|
+
if (s)
|
|
1786
|
+
return Oe(t, n);
|
|
1787
|
+
const { tax: o, decimal: p, identifier: d } = r || {
|
|
1788
|
+
decimal: b[a],
|
|
1789
|
+
identifier: t
|
|
1790
|
+
};
|
|
1791
|
+
return new N({ tax: o, decimal: p, identifier: d, value: W(n, p) });
|
|
1794
1792
|
}
|
|
1795
1793
|
static fromChainOrSignature(t, n = 0) {
|
|
1796
|
-
const { decimal: a, identifier: s } =
|
|
1797
|
-
return new
|
|
1794
|
+
const { decimal: a, identifier: s } = At(t);
|
|
1795
|
+
return new N({ value: W(n, a), decimal: a, identifier: s });
|
|
1798
1796
|
}
|
|
1799
1797
|
static loadStaticAssets() {
|
|
1800
1798
|
return new Promise(
|
|
@@ -1806,7 +1804,7 @@ class x extends He {
|
|
|
1806
1804
|
(r = s == null ? void 0 : s.tokens) == null || r.forEach(({ identifier: o, chain: p, ...d }) => {
|
|
1807
1805
|
q.set(o.toUpperCase(), {
|
|
1808
1806
|
identifier: o,
|
|
1809
|
-
decimal: "decimals" in d ? d.decimals :
|
|
1807
|
+
decimal: "decimals" in d ? d.decimals : b[p]
|
|
1810
1808
|
});
|
|
1811
1809
|
});
|
|
1812
1810
|
}), t({ ok: !0 });
|
|
@@ -1821,8 +1819,8 @@ class x extends He {
|
|
|
1821
1819
|
);
|
|
1822
1820
|
}
|
|
1823
1821
|
}
|
|
1824
|
-
function
|
|
1825
|
-
const t =
|
|
1822
|
+
function le(e) {
|
|
1823
|
+
const t = N.fromChainOrSignature(e);
|
|
1826
1824
|
switch (e) {
|
|
1827
1825
|
case i.Bitcoin:
|
|
1828
1826
|
case i.Litecoin:
|
|
@@ -1840,26 +1838,34 @@ function ue(e) {
|
|
|
1840
1838
|
return t.set(1e-8);
|
|
1841
1839
|
}
|
|
1842
1840
|
}
|
|
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
|
|
1841
|
+
async function ye(e, t = 0) {
|
|
1842
|
+
Wt(e);
|
|
1843
|
+
const n = q.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await bt(ee(e));
|
|
1844
|
+
return n || q.set(e.toUpperCase(), { identifier: e, decimal: a }), new N({ decimal: a, value: W(t, a), identifier: e });
|
|
1845
|
+
}
|
|
1846
|
+
function Oe(e, t = 0) {
|
|
1847
|
+
const [n, a] = e.split("/");
|
|
1848
|
+
return new N({
|
|
1849
|
+
decimal: 8,
|
|
1850
|
+
value: W(t, 8),
|
|
1851
|
+
identifier: `${i.THORChain}.${n}/${a}`
|
|
1852
|
+
});
|
|
1847
1853
|
}
|
|
1848
|
-
function
|
|
1849
|
-
return typeof e == "bigint" ?
|
|
1854
|
+
function W(e, t) {
|
|
1855
|
+
return typeof e == "bigint" ? re({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1850
1856
|
}
|
|
1851
|
-
function
|
|
1857
|
+
function ee(e) {
|
|
1852
1858
|
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
1859
|
return {
|
|
1854
1860
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1855
1861
|
chain: r,
|
|
1856
|
-
isGasAsset:
|
|
1862
|
+
isGasAsset: xe({ chain: r, symbol: o }),
|
|
1857
1863
|
isSynthetic: t,
|
|
1858
1864
|
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1859
1865
|
ticker: p
|
|
1860
1866
|
};
|
|
1861
1867
|
}
|
|
1862
|
-
const
|
|
1868
|
+
const Xt = {
|
|
1863
1869
|
/**
|
|
1864
1870
|
* Core
|
|
1865
1871
|
*/
|
|
@@ -1919,21 +1925,21 @@ const Kt = {
|
|
|
1919
1925
|
};
|
|
1920
1926
|
class c extends Error {
|
|
1921
1927
|
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:
|
|
1928
|
+
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
1929
|
}
|
|
1924
1930
|
}
|
|
1925
|
-
class
|
|
1931
|
+
class x extends He {
|
|
1926
1932
|
eq(t) {
|
|
1927
1933
|
return this.eqValue(t);
|
|
1928
1934
|
}
|
|
1929
1935
|
static fromBigInt(t, n) {
|
|
1930
|
-
return new
|
|
1936
|
+
return new x({
|
|
1931
1937
|
decimal: n,
|
|
1932
|
-
value:
|
|
1938
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1933
1939
|
});
|
|
1934
1940
|
}
|
|
1935
1941
|
}
|
|
1936
|
-
const
|
|
1942
|
+
const Yt = [
|
|
1937
1943
|
{
|
|
1938
1944
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1939
1945
|
stateMutability: "nonpayable",
|
|
@@ -2024,7 +2030,7 @@ const Xt = [
|
|
|
2024
2030
|
type: "function"
|
|
2025
2031
|
},
|
|
2026
2032
|
{ stateMutability: "payable", type: "receive" }
|
|
2027
|
-
],
|
|
2033
|
+
], Jt = [
|
|
2028
2034
|
{
|
|
2029
2035
|
inputs: [
|
|
2030
2036
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2168,7 +2174,7 @@ const Xt = [
|
|
|
2168
2174
|
type: "function"
|
|
2169
2175
|
},
|
|
2170
2176
|
{ stateMutability: "payable", type: "receive" }
|
|
2171
|
-
],
|
|
2177
|
+
], Qt = [
|
|
2172
2178
|
{
|
|
2173
2179
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2174
2180
|
stateMutability: "nonpayable",
|
|
@@ -2273,7 +2279,7 @@ const Xt = [
|
|
|
2273
2279
|
type: "function"
|
|
2274
2280
|
},
|
|
2275
2281
|
{ stateMutability: "payable", type: "receive" }
|
|
2276
|
-
],
|
|
2282
|
+
], zt = [
|
|
2277
2283
|
{
|
|
2278
2284
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2279
2285
|
stateMutability: "nonpayable",
|
|
@@ -2364,7 +2370,7 @@ const Xt = [
|
|
|
2364
2370
|
type: "function"
|
|
2365
2371
|
},
|
|
2366
2372
|
{ stateMutability: "payable", type: "receive" }
|
|
2367
|
-
],
|
|
2373
|
+
], Zt = [
|
|
2368
2374
|
{
|
|
2369
2375
|
inputs: [
|
|
2370
2376
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2508,7 +2514,7 @@ const Xt = [
|
|
|
2508
2514
|
type: "function"
|
|
2509
2515
|
},
|
|
2510
2516
|
{ stateMutability: "payable", type: "receive" }
|
|
2511
|
-
],
|
|
2517
|
+
], en = [
|
|
2512
2518
|
{
|
|
2513
2519
|
inputs: [
|
|
2514
2520
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2627,7 +2633,7 @@ const Xt = [
|
|
|
2627
2633
|
type: "function"
|
|
2628
2634
|
},
|
|
2629
2635
|
{ stateMutability: "payable", type: "receive" }
|
|
2630
|
-
],
|
|
2636
|
+
], tn = [
|
|
2631
2637
|
{
|
|
2632
2638
|
inputs: [
|
|
2633
2639
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2746,7 +2752,7 @@ const Xt = [
|
|
|
2746
2752
|
type: "function"
|
|
2747
2753
|
},
|
|
2748
2754
|
{ stateMutability: "payable", type: "receive" }
|
|
2749
|
-
],
|
|
2755
|
+
], nn = [
|
|
2750
2756
|
{
|
|
2751
2757
|
inputs: [
|
|
2752
2758
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2865,7 +2871,7 @@ const Xt = [
|
|
|
2865
2871
|
type: "function"
|
|
2866
2872
|
},
|
|
2867
2873
|
{ stateMutability: "payable", type: "receive" }
|
|
2868
|
-
],
|
|
2874
|
+
], an = [
|
|
2869
2875
|
{
|
|
2870
2876
|
inputs: [
|
|
2871
2877
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2984,7 +2990,7 @@ const Xt = [
|
|
|
2984
2990
|
type: "function"
|
|
2985
2991
|
},
|
|
2986
2992
|
{ stateMutability: "payable", type: "receive" }
|
|
2987
|
-
],
|
|
2993
|
+
], sn = [
|
|
2988
2994
|
{
|
|
2989
2995
|
inputs: [
|
|
2990
2996
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3111,7 +3117,7 @@ const Xt = [
|
|
|
3111
3117
|
type: "function"
|
|
3112
3118
|
},
|
|
3113
3119
|
{ stateMutability: "payable", type: "receive" }
|
|
3114
|
-
],
|
|
3120
|
+
], rn = [
|
|
3115
3121
|
{
|
|
3116
3122
|
inputs: [
|
|
3117
3123
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3238,7 +3244,7 @@ const Xt = [
|
|
|
3238
3244
|
type: "function"
|
|
3239
3245
|
},
|
|
3240
3246
|
{ stateMutability: "payable", type: "receive" }
|
|
3241
|
-
],
|
|
3247
|
+
], on = [
|
|
3242
3248
|
{
|
|
3243
3249
|
inputs: [
|
|
3244
3250
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3365,7 +3371,7 @@ const Xt = [
|
|
|
3365
3371
|
type: "function"
|
|
3366
3372
|
},
|
|
3367
3373
|
{ stateMutability: "payable", type: "receive" }
|
|
3368
|
-
],
|
|
3374
|
+
], pn = [
|
|
3369
3375
|
{
|
|
3370
3376
|
inputs: [
|
|
3371
3377
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3492,7 +3498,7 @@ const Xt = [
|
|
|
3492
3498
|
type: "function"
|
|
3493
3499
|
},
|
|
3494
3500
|
{ stateMutability: "payable", type: "receive" }
|
|
3495
|
-
],
|
|
3501
|
+
], dn = [
|
|
3496
3502
|
{
|
|
3497
3503
|
inputs: [
|
|
3498
3504
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3619,27 +3625,27 @@ const Xt = [
|
|
|
3619
3625
|
type: "function"
|
|
3620
3626
|
},
|
|
3621
3627
|
{ stateMutability: "payable", type: "receive" }
|
|
3622
|
-
],
|
|
3623
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3624
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3625
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3626
|
-
},
|
|
3627
|
-
...
|
|
3628
|
+
], Fe = {
|
|
3629
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Yt,
|
|
3630
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Qt,
|
|
3631
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: zt
|
|
3632
|
+
}, un = {
|
|
3633
|
+
...Fe,
|
|
3628
3634
|
// AVAX
|
|
3629
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3630
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3631
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3635
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: en,
|
|
3636
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Jt,
|
|
3637
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: nn,
|
|
3632
3638
|
// BSC
|
|
3633
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3639
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: Zt,
|
|
3634
3640
|
// ETH
|
|
3635
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3636
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3637
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3638
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3639
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3640
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3641
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3642
|
-
},
|
|
3641
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: tn,
|
|
3642
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: an,
|
|
3643
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: sn,
|
|
3644
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: rn,
|
|
3645
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: on,
|
|
3646
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: pn,
|
|
3647
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: dn
|
|
3648
|
+
}, ln = ({
|
|
3643
3649
|
streamSwap: e,
|
|
3644
3650
|
contractAddress: t,
|
|
3645
3651
|
recipient: n,
|
|
@@ -3654,16 +3660,16 @@ const Xt = [
|
|
|
3654
3660
|
memoStreamingSwap: u,
|
|
3655
3661
|
tcMemo: m,
|
|
3656
3662
|
tcRouter: _,
|
|
3657
|
-
tcVault:
|
|
3658
|
-
vault:
|
|
3663
|
+
tcVault: w,
|
|
3664
|
+
vault: A,
|
|
3659
3665
|
token: E
|
|
3660
3666
|
}
|
|
3661
3667
|
}) => {
|
|
3662
|
-
const O = !!
|
|
3668
|
+
const O = !!Fe[t.toLowerCase()];
|
|
3663
3669
|
if (O && !l)
|
|
3664
3670
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3665
3671
|
const I = m || d, D = e && u || I;
|
|
3666
|
-
if (!
|
|
3672
|
+
if (!w && !A)
|
|
3667
3673
|
throw new Error("TC Vault is required on calldata");
|
|
3668
3674
|
if (!_ && !l)
|
|
3669
3675
|
throw new Error("TC Router is required on calldata");
|
|
@@ -3671,17 +3677,17 @@ const Xt = [
|
|
|
3671
3677
|
throw new Error("TC Memo is required on calldata");
|
|
3672
3678
|
if (!E)
|
|
3673
3679
|
throw new Error("Token is required on calldata");
|
|
3674
|
-
const
|
|
3680
|
+
const oe = [
|
|
3675
3681
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3676
3682
|
a(_ || l),
|
|
3677
|
-
a(
|
|
3683
|
+
a(w || A),
|
|
3678
3684
|
D.replace("{recipientAddress}", n),
|
|
3679
3685
|
a(E),
|
|
3680
3686
|
s
|
|
3681
|
-
],
|
|
3682
|
-
return [...
|
|
3683
|
-
},
|
|
3684
|
-
const n =
|
|
3687
|
+
], Ge = O ? [a(l), o, p] : [r, p];
|
|
3688
|
+
return [...oe, ...Ge];
|
|
3689
|
+
}, yn = ({ chain: e, txHash: t }) => {
|
|
3690
|
+
const n = Me[e];
|
|
3685
3691
|
switch (e) {
|
|
3686
3692
|
case i.Binance:
|
|
3687
3693
|
case i.Maya:
|
|
@@ -3705,8 +3711,8 @@ const Xt = [
|
|
|
3705
3711
|
default:
|
|
3706
3712
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3707
3713
|
}
|
|
3708
|
-
},
|
|
3709
|
-
const n =
|
|
3714
|
+
}, cn = ({ chain: e, address: t }) => {
|
|
3715
|
+
const n = Me[e];
|
|
3710
3716
|
switch (e) {
|
|
3711
3717
|
case i.Arbitrum:
|
|
3712
3718
|
case i.Avalanche:
|
|
@@ -3728,16 +3734,16 @@ const Xt = [
|
|
|
3728
3734
|
default:
|
|
3729
3735
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3730
3736
|
}
|
|
3731
|
-
}, cn = (e) => {
|
|
3732
|
-
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3733
|
-
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3734
3737
|
}, mn = (e) => {
|
|
3735
|
-
const t = e ?
|
|
3738
|
+
const t = e ? j.ThornodeStagenet : j.ThornodeMainnet;
|
|
3739
|
+
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3740
|
+
}, Tn = (e) => {
|
|
3741
|
+
const t = e ? j.ThornodeStagenet : j.ThornodeMainnet;
|
|
3736
3742
|
return we.get(`${t}/thorchain/mimir`);
|
|
3737
|
-
},
|
|
3743
|
+
}, Ie = () => Object.values(i).reduce(
|
|
3738
3744
|
(e, t) => (e[t] = null, e),
|
|
3739
3745
|
{}
|
|
3740
|
-
),
|
|
3746
|
+
), hn = async ({ chain: e, address: t }) => {
|
|
3741
3747
|
if (!t)
|
|
3742
3748
|
return !1;
|
|
3743
3749
|
switch (e) {
|
|
@@ -3747,19 +3753,19 @@ const Xt = [
|
|
|
3747
3753
|
return !0;
|
|
3748
3754
|
}
|
|
3749
3755
|
};
|
|
3750
|
-
var V,
|
|
3751
|
-
class
|
|
3756
|
+
var V, se, X, v, Y, J;
|
|
3757
|
+
class Ln {
|
|
3752
3758
|
constructor({ stagenet: t } = {}) {
|
|
3753
|
-
T(this, "connectedChains",
|
|
3754
|
-
T(this, "connectedWallets",
|
|
3759
|
+
T(this, "connectedChains", Ie());
|
|
3760
|
+
T(this, "connectedWallets", Ie());
|
|
3755
3761
|
T(this, "stagenet", !1);
|
|
3756
3762
|
T(this, "getAddress", (t) => {
|
|
3757
3763
|
var n;
|
|
3758
3764
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3759
3765
|
});
|
|
3760
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3766
|
+
T(this, "getExplorerTxUrl", (t, n) => yn({ chain: t, txHash: n }));
|
|
3761
3767
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3762
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3768
|
+
T(this, "getExplorerAddressUrl", (t, n) => cn({ chain: t, address: n }));
|
|
3763
3769
|
T(this, "getBalance", async (t, n) => {
|
|
3764
3770
|
const a = await this.getWalletByChain(t, n);
|
|
3765
3771
|
return (a == null ? void 0 : a.balance) || [];
|
|
@@ -3770,31 +3776,31 @@ class Pn {
|
|
|
3770
3776
|
if (!a.complete)
|
|
3771
3777
|
throw new c("core_swap_route_not_complete");
|
|
3772
3778
|
try {
|
|
3773
|
-
if (
|
|
3779
|
+
if (Ze.includes(r)) {
|
|
3774
3780
|
const l = this.connectedWallets[o];
|
|
3775
3781
|
if (!(l != null && l.sendTransaction))
|
|
3776
3782
|
throw new c("core_wallet_connection_not_found");
|
|
3777
3783
|
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3778
3784
|
throw new c("core_swap_route_transaction_not_found");
|
|
3779
|
-
const { data: m, from: _, to:
|
|
3785
|
+
const { data: m, from: _, to: w, value: A } = a.transaction, E = {
|
|
3780
3786
|
data: m,
|
|
3781
3787
|
from: _,
|
|
3782
|
-
to:
|
|
3783
|
-
chainId: BigInt(
|
|
3784
|
-
value:
|
|
3788
|
+
to: w.toLowerCase(),
|
|
3789
|
+
chainId: BigInt(pt[o]),
|
|
3790
|
+
value: A ? BigInt(A) : 0n
|
|
3785
3791
|
};
|
|
3786
3792
|
return l.sendTransaction(E, s);
|
|
3787
3793
|
}
|
|
3788
|
-
if (
|
|
3794
|
+
if (tt.includes(r)) {
|
|
3789
3795
|
if (!a.calldata.fromAsset)
|
|
3790
3796
|
throw new c("core_swap_asset_not_recognized");
|
|
3791
|
-
const l = await
|
|
3797
|
+
const l = await N.fromString(a.calldata.fromAsset);
|
|
3792
3798
|
if (!l)
|
|
3793
3799
|
throw new c("core_swap_asset_not_recognized");
|
|
3794
3800
|
const { address: u } = await f(this, V).call(this, l.chain), {
|
|
3795
3801
|
contract: m,
|
|
3796
|
-
calldata: { expiration: _, amountIn:
|
|
3797
|
-
} = a, O = l.add(
|
|
3802
|
+
calldata: { expiration: _, amountIn: w, memo: A, memoStreamingSwap: E }
|
|
3803
|
+
} = a, O = l.add(x.fromBigInt(BigInt(w), l.decimal)), I = t && E || A;
|
|
3798
3804
|
return this.deposit({
|
|
3799
3805
|
expiration: _,
|
|
3800
3806
|
assetValue: O,
|
|
@@ -3804,20 +3810,20 @@ class Pn {
|
|
|
3804
3810
|
recipient: u
|
|
3805
3811
|
});
|
|
3806
3812
|
}
|
|
3807
|
-
if (
|
|
3813
|
+
if (et.includes(r)) {
|
|
3808
3814
|
const { calldata: l, contract: u } = a;
|
|
3809
3815
|
if (!u)
|
|
3810
3816
|
throw new c("core_swap_contract_not_found");
|
|
3811
3817
|
const m = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3812
3818
|
if (!(m != null && m.sendTransaction) || !_)
|
|
3813
3819
|
throw new c("core_wallet_connection_not_found");
|
|
3814
|
-
const { getProvider:
|
|
3820
|
+
const { getProvider: w, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = w(o), O = un[u.toLowerCase()];
|
|
3815
3821
|
if (!O)
|
|
3816
3822
|
throw new c("core_swap_contract_not_supported", { contractAddress: u });
|
|
3817
3823
|
const D = await (await ((d = m.createContract) == null ? void 0 : d.call(m, u, O, E))).getFunction("swapIn").populateTransaction(
|
|
3818
|
-
...
|
|
3824
|
+
...ln({
|
|
3819
3825
|
streamSwap: t,
|
|
3820
|
-
toChecksumAddress:
|
|
3826
|
+
toChecksumAddress: A,
|
|
3821
3827
|
contractAddress: u,
|
|
3822
3828
|
recipient: n,
|
|
3823
3829
|
calldata: l
|
|
@@ -3836,7 +3842,7 @@ class Pn {
|
|
|
3836
3842
|
const a = this.getAddress(t);
|
|
3837
3843
|
if (!a)
|
|
3838
3844
|
return null;
|
|
3839
|
-
const s = [
|
|
3845
|
+
const s = [N.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3840
3846
|
try {
|
|
3841
3847
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3842
3848
|
return this.connectedChains[t] = {
|
|
@@ -3848,8 +3854,8 @@ class Pn {
|
|
|
3848
3854
|
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3849
3855
|
}
|
|
3850
3856
|
});
|
|
3851
|
-
T(this, "approveAssetValue", (t, n) => f(this,
|
|
3852
|
-
T(this, "isAssetValueApproved", (t, n) => f(this,
|
|
3857
|
+
T(this, "approveAssetValue", (t, n) => f(this, X).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3858
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, X).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3853
3859
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3854
3860
|
var a, s;
|
|
3855
3861
|
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
@@ -3859,7 +3865,7 @@ class Pn {
|
|
|
3859
3865
|
if (!n)
|
|
3860
3866
|
throw new c("core_wallet_connection_not_found");
|
|
3861
3867
|
try {
|
|
3862
|
-
return await n.transfer(f(this,
|
|
3868
|
+
return await n.transfer(f(this, J).call(this, t));
|
|
3863
3869
|
} catch (a) {
|
|
3864
3870
|
throw new c("core_swap_transaction_error", a);
|
|
3865
3871
|
}
|
|
@@ -3871,11 +3877,11 @@ class Pn {
|
|
|
3871
3877
|
...s
|
|
3872
3878
|
}) => {
|
|
3873
3879
|
const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
|
|
3874
|
-
if (!await
|
|
3880
|
+
if (!await hn({ address: await (d == null ? void 0 : d.getAddress()), chain: r }))
|
|
3875
3881
|
throw new c("core_transaction_invalid_sender_address");
|
|
3876
3882
|
if (!d)
|
|
3877
3883
|
throw new c("core_wallet_connection_not_found");
|
|
3878
|
-
const l = f(this,
|
|
3884
|
+
const l = f(this, J).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3879
3885
|
try {
|
|
3880
3886
|
switch (r) {
|
|
3881
3887
|
case i.THORChain: {
|
|
@@ -3885,7 +3891,7 @@ class Pn {
|
|
|
3885
3891
|
case i.Ethereum:
|
|
3886
3892
|
case i.BinanceSmartChain:
|
|
3887
3893
|
case i.Avalanche: {
|
|
3888
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ?
|
|
3894
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ? Je : r === i.BinanceSmartChain ? Qe : Ye;
|
|
3889
3895
|
return await d.call({
|
|
3890
3896
|
abi: m,
|
|
3891
3897
|
contractAddress: a || (await f(this, V).call(this, r)).router,
|
|
@@ -3907,7 +3913,7 @@ class Pn {
|
|
|
3907
3913
|
return await d.transfer(l);
|
|
3908
3914
|
}
|
|
3909
3915
|
} 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"),
|
|
3916
|
+
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
3917
|
throw new c(E, u);
|
|
3912
3918
|
}
|
|
3913
3919
|
});
|
|
@@ -3953,17 +3959,17 @@ class Pn {
|
|
|
3953
3959
|
isPendingSymmAsset: r,
|
|
3954
3960
|
mode: o = "sym"
|
|
3955
3961
|
}) => {
|
|
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,
|
|
3962
|
+
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
3963
|
if (!u && !m)
|
|
3958
3964
|
throw new c("core_transaction_add_liquidity_invalid_params");
|
|
3959
|
-
if (_ && !
|
|
3965
|
+
if (_ && !w)
|
|
3960
3966
|
throw new c("core_transaction_add_liquidity_no_rune_address");
|
|
3961
3967
|
let E, O;
|
|
3962
3968
|
if (u && t)
|
|
3963
3969
|
try {
|
|
3964
3970
|
E = await f(this, v).call(this, {
|
|
3965
3971
|
assetValue: t,
|
|
3966
|
-
memo: M(h.DEPOSIT, { chain: p, symbol: d, address:
|
|
3972
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: A })
|
|
3967
3973
|
});
|
|
3968
3974
|
} catch (I) {
|
|
3969
3975
|
throw new c("core_transaction_add_liquidity_rune_error", I);
|
|
@@ -3972,7 +3978,7 @@ class Pn {
|
|
|
3972
3978
|
try {
|
|
3973
3979
|
O = await f(this, v).call(this, {
|
|
3974
3980
|
assetValue: n,
|
|
3975
|
-
memo: M(h.DEPOSIT, { chain: p, symbol: d, address:
|
|
3981
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: w })
|
|
3976
3982
|
});
|
|
3977
3983
|
} catch (I) {
|
|
3978
3984
|
throw new c("core_transaction_add_liquidity_asset_error", I);
|
|
@@ -4001,7 +4007,7 @@ class Pn {
|
|
|
4001
4007
|
from: s,
|
|
4002
4008
|
to: r
|
|
4003
4009
|
}) => {
|
|
4004
|
-
const o = r === "rune" ?
|
|
4010
|
+
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
4011
|
symbol: n.symbol,
|
|
4006
4012
|
chain: n.chain,
|
|
4007
4013
|
ticker: n.ticker,
|
|
@@ -4023,7 +4029,7 @@ class Pn {
|
|
|
4023
4029
|
chain: t.chain,
|
|
4024
4030
|
singleSide: !0,
|
|
4025
4031
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
4026
|
-
}), p = r === h.DEPOSIT ? t :
|
|
4032
|
+
}), p = r === h.DEPOSIT ? t : le(t.chain);
|
|
4027
4033
|
return f(this, v).call(this, { memo: o, assetValue: p });
|
|
4028
4034
|
});
|
|
4029
4035
|
T(this, "loan", ({
|
|
@@ -4048,20 +4054,20 @@ class Pn {
|
|
|
4048
4054
|
address: a,
|
|
4049
4055
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
4050
4056
|
});
|
|
4051
|
-
return f(this,
|
|
4057
|
+
return f(this, Y).call(this, {
|
|
4052
4058
|
memo: r,
|
|
4053
|
-
assetValue: t === "bond" ? n :
|
|
4059
|
+
assetValue: t === "bond" ? n : le(i.THORChain)
|
|
4054
4060
|
});
|
|
4055
4061
|
});
|
|
4056
4062
|
T(this, "registerThorname", ({
|
|
4057
4063
|
assetValue: t,
|
|
4058
4064
|
...n
|
|
4059
|
-
}) => f(this,
|
|
4065
|
+
}) => f(this, Y).call(this, { assetValue: t, memo: M(h.THORNAME_REGISTER, n) }));
|
|
4060
4066
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
4061
4067
|
try {
|
|
4062
4068
|
t.forEach((r) => {
|
|
4063
4069
|
this[r.connectMethodName] = r.connect({
|
|
4064
|
-
addChain: f(this,
|
|
4070
|
+
addChain: f(this, se),
|
|
4065
4071
|
config: n || {},
|
|
4066
4072
|
apis: a,
|
|
4067
4073
|
rpcUrls: s
|
|
@@ -4146,17 +4152,17 @@ class Pn {
|
|
|
4146
4152
|
halted: !1,
|
|
4147
4153
|
chain: i.THORChain
|
|
4148
4154
|
};
|
|
4149
|
-
const a = (await
|
|
4155
|
+
const a = (await mn(this.stagenet)).find((s) => s.chain === t);
|
|
4150
4156
|
if (!a)
|
|
4151
4157
|
throw new c("core_inbound_data_not_found");
|
|
4152
4158
|
if (a != null && a.halted)
|
|
4153
4159
|
throw new c("core_chain_halted");
|
|
4154
4160
|
return a;
|
|
4155
4161
|
});
|
|
4156
|
-
P(this,
|
|
4162
|
+
P(this, se, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4157
4163
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4158
4164
|
});
|
|
4159
|
-
P(this,
|
|
4165
|
+
P(this, X, async ({
|
|
4160
4166
|
assetValue: t,
|
|
4161
4167
|
type: n = "checkOnly",
|
|
4162
4168
|
contractAddress: a
|
|
@@ -4170,12 +4176,12 @@ class Pn {
|
|
|
4170
4176
|
const _ = this.getAddress(r);
|
|
4171
4177
|
if (!s || !_)
|
|
4172
4178
|
throw new c("core_approve_asset_address_or_from_not_found");
|
|
4173
|
-
const
|
|
4179
|
+
const w = a || (await f(this, V).call(this, r)).router;
|
|
4174
4180
|
return m({
|
|
4175
4181
|
amount: t.getBaseValue("bigint"),
|
|
4176
4182
|
assetAddress: s,
|
|
4177
4183
|
from: _,
|
|
4178
|
-
spenderAddress:
|
|
4184
|
+
spenderAddress: w
|
|
4179
4185
|
});
|
|
4180
4186
|
});
|
|
4181
4187
|
P(this, v, async ({
|
|
@@ -4187,7 +4193,7 @@ class Pn {
|
|
|
4187
4193
|
gas_rate: s,
|
|
4188
4194
|
router: r,
|
|
4189
4195
|
address: o
|
|
4190
|
-
} = await f(this, V).call(this, t.chain), p = (parseInt(s) || 0) *
|
|
4196
|
+
} = await f(this, V).call(this, t.chain), p = (parseInt(s) || 0) * wt[a];
|
|
4191
4197
|
return this.deposit({
|
|
4192
4198
|
assetValue: t,
|
|
4193
4199
|
recipient: o,
|
|
@@ -4196,13 +4202,13 @@ class Pn {
|
|
|
4196
4202
|
feeRate: p
|
|
4197
4203
|
});
|
|
4198
4204
|
});
|
|
4199
|
-
P(this,
|
|
4200
|
-
const a = await
|
|
4205
|
+
P(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
4206
|
+
const a = await Tn(this.stagenet);
|
|
4201
4207
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4202
4208
|
throw new c("core_chain_halted");
|
|
4203
4209
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
4204
4210
|
});
|
|
4205
|
-
P(this,
|
|
4211
|
+
P(this, J, ({ assetValue: t, ...n }) => ({
|
|
4206
4212
|
...n,
|
|
4207
4213
|
memo: n.memo || "",
|
|
4208
4214
|
from: this.getAddress(t.chain),
|
|
@@ -4211,67 +4217,67 @@ class Pn {
|
|
|
4211
4217
|
this.stagenet = !!t;
|
|
4212
4218
|
}
|
|
4213
4219
|
}
|
|
4214
|
-
V = new WeakMap(),
|
|
4220
|
+
V = new WeakMap(), se = new WeakMap(), X = new WeakMap(), v = new WeakMap(), Y = new WeakMap(), J = new WeakMap();
|
|
4215
4221
|
export {
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4222
|
+
Ze as AGG_SWAP,
|
|
4223
|
+
bn as ApiError,
|
|
4224
|
+
j as ApiUrl,
|
|
4225
|
+
N as AssetValue,
|
|
4226
|
+
b as BaseDecimal,
|
|
4221
4227
|
He as BigIntArithmetics,
|
|
4222
4228
|
i as Chain,
|
|
4223
4229
|
_e as ChainId,
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4230
|
+
On as ChainIdToChain,
|
|
4231
|
+
pt as ChainToChainId,
|
|
4232
|
+
Me as ChainToExplorerUrl,
|
|
4233
|
+
gn as ChainToHexChainId,
|
|
4234
|
+
dt as ChainToRPC,
|
|
4235
|
+
st as ContractAddress,
|
|
4236
|
+
En as CosmosChainList,
|
|
4237
|
+
it as DerivationPath,
|
|
4232
4238
|
y as ERROR_CODE,
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4239
|
+
nt as ERROR_MODULE,
|
|
4240
|
+
Se as ERROR_TYPE,
|
|
4241
|
+
rt as EVMChainList,
|
|
4242
|
+
ut as ErrorCode,
|
|
4237
4243
|
F as FeeOption,
|
|
4238
4244
|
h as MemoType,
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4245
|
+
wn as NetworkDerivationPath,
|
|
4246
|
+
ze as QuoteMode,
|
|
4247
|
+
Ce as RPCUrl,
|
|
4242
4248
|
we as RequestClient,
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4249
|
+
et as SWAP_IN,
|
|
4250
|
+
tt as SWAP_OUT,
|
|
4251
|
+
Ln as SwapKitCore,
|
|
4246
4252
|
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
|
-
|
|
4253
|
+
x as SwapKitNumber,
|
|
4254
|
+
Je as TCAvalancheDepositABI,
|
|
4255
|
+
Qe as TCBscDepositABI,
|
|
4256
|
+
Ye as TCEthereumVaultAbi,
|
|
4257
|
+
Rn as TCSupportedChainList,
|
|
4258
|
+
An as UTXOChainList,
|
|
4259
|
+
lt as WalletOption,
|
|
4260
|
+
In as assetFromString,
|
|
4261
|
+
Bn as derivationPathToString,
|
|
4262
|
+
fn as erc20ABI,
|
|
4263
|
+
Sn as filterAssets,
|
|
4264
|
+
re as formatBigIntToSafeValue,
|
|
4265
|
+
wt as gasFeeMultiplier,
|
|
4266
|
+
Et as getAssetType,
|
|
4267
|
+
It as getAsymmetricAssetShare,
|
|
4268
|
+
Cn as getAsymmetricAssetWithdrawAmount,
|
|
4269
|
+
Ot as getAsymmetricRuneShare,
|
|
4270
|
+
vn as getAsymmetricRuneWithdrawAmount,
|
|
4271
|
+
At as getCommonAssetInfo,
|
|
4272
|
+
bt as getDecimal,
|
|
4273
|
+
Nn as getEstimatedPoolShare,
|
|
4274
|
+
xn as getLiquiditySlippage,
|
|
4269
4275
|
M as getMemoFor,
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
+
le as getMinAmountByChain,
|
|
4277
|
+
St as getSymmetricPoolShare,
|
|
4278
|
+
Mn as getSymmetricWithdraw,
|
|
4279
|
+
Dn as getTHORNameCost,
|
|
4280
|
+
xe as isGasAsset,
|
|
4281
|
+
Pn as validateTHORName
|
|
4276
4282
|
};
|
|
4277
4283
|
//# sourceMappingURL=index.es.js.map
|