@swapkit/core 1.0.0-rc.87 → 1.0.0-rc.89
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.d.ts +1 -1
- package/dist/index.es.js +830 -766
- package/dist/index.es.js.map +1 -1
- package/package.json +15 -17
- package/src/aggregator/getSwapParams.ts +1 -1
- package/src/client/types.ts +1 -2
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var st = Object.defineProperty;
|
|
2
|
+
var rt = (e, t, n) => t in e ? st(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var b = (e, t, n) => (rt(e, typeof t != "symbol" ? t + "" : t, n), n), pt = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var A = (e, t, n) => (pt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), V = (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 ut = Object.defineProperty, yt = (e, t, n) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, N = (e, t, n) => (yt(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
+
const Un = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -108,7 +108,7 @@ const In = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], ot = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const In = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], dt = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const In = [
|
|
|
447
447
|
stateMutability: "view",
|
|
448
448
|
type: "function"
|
|
449
449
|
}
|
|
450
|
-
],
|
|
450
|
+
], lt = [
|
|
451
451
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
452
452
|
{
|
|
453
453
|
anonymous: !1,
|
|
@@ -600,13 +600,13 @@ const In = [
|
|
|
600
600
|
type: "function"
|
|
601
601
|
}
|
|
602
602
|
];
|
|
603
|
-
var
|
|
604
|
-
const
|
|
603
|
+
var mt = /* @__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))(mt || {});
|
|
604
|
+
const Tt = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], ct = [
|
|
610
610
|
"ERC20-TC",
|
|
611
611
|
"ERC20-ARC20",
|
|
612
612
|
"ERC20-BEP20",
|
|
@@ -617,15 +617,15 @@ const at = [
|
|
|
617
617
|
"BEP20-ERC20",
|
|
618
618
|
"BEP20-ARC20"
|
|
619
619
|
/* BSC_TO_AVAX */
|
|
620
|
-
],
|
|
620
|
+
], bt = [
|
|
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 Ve = /* @__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))(Ve || {}), _t = /* @__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))(_t || {}), l = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_MAX_500 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(l || {});
|
|
628
|
+
const ft = {
|
|
629
629
|
[l.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
630
|
[l.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
631
|
[l.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
@@ -677,15 +677,15 @@ const pt = {
|
|
|
677
677
|
[l.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
678
678
|
[l.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
679
679
|
[l.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
680
|
-
},
|
|
681
|
-
let n =
|
|
680
|
+
}, ce = (e, t) => {
|
|
681
|
+
let n = ft[e];
|
|
682
682
|
if (!n)
|
|
683
683
|
return "";
|
|
684
684
|
for (let a = 0; a < t.length; a++)
|
|
685
685
|
n = (n == null ? void 0 : n.replace(`{${a}}`, t[a])) ?? "";
|
|
686
686
|
return n;
|
|
687
687
|
};
|
|
688
|
-
let
|
|
688
|
+
let Wn = class He extends Error {
|
|
689
689
|
constructor({
|
|
690
690
|
status: t,
|
|
691
691
|
revision: n,
|
|
@@ -700,15 +700,15 @@ let Sn = class xe extends Error {
|
|
|
700
700
|
},
|
|
701
701
|
displayMessageParams: o
|
|
702
702
|
}) {
|
|
703
|
-
const
|
|
704
|
-
super(
|
|
703
|
+
const c = r || ce(i, o || []) || "";
|
|
704
|
+
super(c), N(this, "status"), N(this, "revision"), N(this, "type"), N(this, "module"), N(this, "code"), N(this, "message"), N(this, "display"), N(this, "stack"), N(this, "options"), N(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = ce(i, o || []), this.code = i, this.type = p || Ve.UNHANDLED_ERROR, this.options = {
|
|
705
705
|
shouldLog: u || !0,
|
|
706
706
|
shouldTrace: d || !0,
|
|
707
707
|
shouldThrow: y || !1
|
|
708
708
|
}, this.displayMessageParams = o || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
709
709
|
}
|
|
710
710
|
static fromErrorInfo(t) {
|
|
711
|
-
return new
|
|
711
|
+
return new He(t);
|
|
712
712
|
}
|
|
713
713
|
toErrorInfo() {
|
|
714
714
|
return { ...this, identifier: this.identifier };
|
|
@@ -717,7 +717,7 @@ let Sn = class xe extends Error {
|
|
|
717
717
|
return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
|
|
718
718
|
}
|
|
719
719
|
get displayMessage() {
|
|
720
|
-
return
|
|
720
|
+
return ce(this.code, this.displayMessageParams || []);
|
|
721
721
|
}
|
|
722
722
|
handle() {
|
|
723
723
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -727,8 +727,8 @@ let Sn = class xe extends Error {
|
|
|
727
727
|
return this.toErrorInfo();
|
|
728
728
|
}
|
|
729
729
|
};
|
|
730
|
-
var s = /* @__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))(s || {}),
|
|
731
|
-
const
|
|
730
|
+
var s = /* @__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))(s || {}), At = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(At || {}), ht = /* @__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))(ht || {});
|
|
731
|
+
const $n = {
|
|
732
732
|
ARB: [44, 60, 0, 0, 0],
|
|
733
733
|
AVAX: [44, 60, 0, 0, 0],
|
|
734
734
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -745,8 +745,8 @@ const Cn = {
|
|
|
745
745
|
OP: [44, 60, 0, 0, 0],
|
|
746
746
|
THOR: [44, 931, 0, 0, 0]
|
|
747
747
|
};
|
|
748
|
-
var
|
|
749
|
-
const
|
|
748
|
+
var h = /* @__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))(h || {});
|
|
749
|
+
const Et = [
|
|
750
750
|
"ETH",
|
|
751
751
|
"AVAX",
|
|
752
752
|
"BSC",
|
|
@@ -754,18 +754,18 @@ const ot = [
|
|
|
754
754
|
"OP",
|
|
755
755
|
"MATIC"
|
|
756
756
|
/* Polygon */
|
|
757
|
-
],
|
|
757
|
+
], qn = [
|
|
758
758
|
"BTC",
|
|
759
759
|
"BCH",
|
|
760
760
|
"DOGE",
|
|
761
761
|
"LTC"
|
|
762
762
|
/* Litecoin */
|
|
763
|
-
],
|
|
763
|
+
], Gn = [
|
|
764
764
|
"GAIA",
|
|
765
765
|
"THOR",
|
|
766
766
|
"BNB"
|
|
767
767
|
/* Binance */
|
|
768
|
-
],
|
|
768
|
+
], Xn = [
|
|
769
769
|
"AVAX",
|
|
770
770
|
"BNB",
|
|
771
771
|
"BSC",
|
|
@@ -778,26 +778,26 @@ const ot = [
|
|
|
778
778
|
"THOR"
|
|
779
779
|
/* THORChain */
|
|
780
780
|
];
|
|
781
|
-
var
|
|
782
|
-
const
|
|
781
|
+
var we = /* @__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))(we || {}), Fe = /* @__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))(Fe || {}), Q = /* @__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))(Q || {});
|
|
782
|
+
const oe = Object.values(s), Rt = Object.keys(s), Oe = oe.reduce(
|
|
783
783
|
(e, t) => {
|
|
784
|
-
const n =
|
|
784
|
+
const n = Rt.find((a) => s[a] === t);
|
|
785
785
|
return n && (e[t] = n), e;
|
|
786
786
|
},
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), Ue = oe.reduce(
|
|
789
|
+
(e, t) => (e[t] = we[Oe[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
),
|
|
792
|
-
(e, t) => (e[t] =
|
|
791
|
+
), St = oe.reduce(
|
|
792
|
+
(e, t) => (e[t] = Fe[Oe[t]], e),
|
|
793
793
|
{}
|
|
794
|
-
),
|
|
794
|
+
), jn = oe.reduce(
|
|
795
795
|
(e, t) => {
|
|
796
|
-
const n = `${
|
|
797
|
-
return e[t] =
|
|
796
|
+
const n = `${Oe[t]}Hex`;
|
|
797
|
+
return e[t] = we[n], e;
|
|
798
798
|
},
|
|
799
799
|
{}
|
|
800
|
-
),
|
|
800
|
+
), Kn = {
|
|
801
801
|
"0xa4b1": "ARB",
|
|
802
802
|
42161: "ARB",
|
|
803
803
|
"0xa86a": "AVAX",
|
|
@@ -822,7 +822,7 @@ const se = Object.values(s), dt = Object.keys(s), he = se.reduce(
|
|
|
822
822
|
"thorchain-stagenet-v2": "THOR",
|
|
823
823
|
"thorchain-mainnet-v1": "THOR"
|
|
824
824
|
/* THORChain */
|
|
825
|
-
},
|
|
825
|
+
}, We = {
|
|
826
826
|
ARB: "https://arbiscan.io",
|
|
827
827
|
AVAX: "https://snowtrace.io",
|
|
828
828
|
BSC: "https://bscscan.com",
|
|
@@ -839,302 +839,39 @@ const se = Object.values(s), dt = Object.keys(s), he = se.reduce(
|
|
|
839
839
|
MATIC: "https://polygonscan.com",
|
|
840
840
|
THOR: "https://runescan.io"
|
|
841
841
|
};
|
|
842
|
-
var
|
|
842
|
+
var wt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(wt || {}), _ = /* @__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))(_ || {}), X = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(X || {}), Ot = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.KEEPKEY = "KEEPKEY", 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))(Ot || {}), Mt = Object.defineProperty, It = (e, t, n) => t in e ? Mt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (It(e, typeof t != "symbol" ? t + "" : t, n), n), gt = (e, t, n) => {
|
|
843
843
|
if (!t.has(e))
|
|
844
844
|
throw TypeError("Cannot " + n);
|
|
845
|
-
},
|
|
845
|
+
}, q = (e, t, n) => {
|
|
846
846
|
if (t.has(e))
|
|
847
847
|
throw TypeError("Cannot add the same private member more than once");
|
|
848
848
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
849
|
-
},
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
const [, t] = e.split("-");
|
|
876
|
-
return t != null && t.startsWith("0x") ? Ne({ chain: s.Avalanche, to: t.toLowerCase() }) : _.AVAX;
|
|
877
|
-
}, wt = async (e) => (e === s.BinanceSmartChain, _.BSC), Mt = async ({ chain: e, symbol: t }) => {
|
|
878
|
-
switch (e) {
|
|
879
|
-
case s.Ethereum:
|
|
880
|
-
return _t(t);
|
|
881
|
-
case s.Avalanche:
|
|
882
|
-
return At(t);
|
|
883
|
-
case s.BinanceSmartChain:
|
|
884
|
-
return wt(t);
|
|
885
|
-
default:
|
|
886
|
-
return _[e];
|
|
887
|
-
}
|
|
888
|
-
}, Et = {
|
|
889
|
-
[q.Average]: 1.2,
|
|
890
|
-
[q.Fast]: 1.5,
|
|
891
|
-
[q.Fastest]: 2
|
|
892
|
-
}, Pe = ({ chain: e, symbol: t }) => {
|
|
893
|
-
switch (e) {
|
|
894
|
-
case s.Bitcoin:
|
|
895
|
-
case s.BitcoinCash:
|
|
896
|
-
case s.Litecoin:
|
|
897
|
-
case s.Dogecoin:
|
|
898
|
-
case s.Binance:
|
|
899
|
-
case s.Ethereum:
|
|
900
|
-
case s.Avalanche:
|
|
901
|
-
return t === e;
|
|
902
|
-
case s.Arbitrum:
|
|
903
|
-
case s.Optimism:
|
|
904
|
-
return t === "ETH";
|
|
905
|
-
case s.Maya:
|
|
906
|
-
return t === "CACAO";
|
|
907
|
-
case s.Kujira:
|
|
908
|
-
return t === "KUJI";
|
|
909
|
-
case s.Cosmos:
|
|
910
|
-
return t === "ATOM";
|
|
911
|
-
case s.Polygon:
|
|
912
|
-
return t === "MATIC";
|
|
913
|
-
case s.BinanceSmartChain:
|
|
914
|
-
return t === "BNB";
|
|
915
|
-
case s.THORChain:
|
|
916
|
-
return t === "RUNE";
|
|
917
|
-
}
|
|
918
|
-
}, gt = (e) => {
|
|
919
|
-
switch (e) {
|
|
920
|
-
case `${s.Ethereum}.THOR`:
|
|
921
|
-
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
922
|
-
case `${s.Ethereum}.vTHOR`:
|
|
923
|
-
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
924
|
-
case s.Cosmos:
|
|
925
|
-
return { identifier: "GAIA.ATOM", decimal: _[e] };
|
|
926
|
-
case s.THORChain:
|
|
927
|
-
return { identifier: "THOR.RUNE", decimal: _[e] };
|
|
928
|
-
case s.BinanceSmartChain:
|
|
929
|
-
return { identifier: "BSC.BNB", decimal: _[e] };
|
|
930
|
-
case s.Maya:
|
|
931
|
-
return { identifier: "MAYA.CACAO", decimal: _.MAYA };
|
|
932
|
-
case `${s.Maya}.MAYA`:
|
|
933
|
-
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
934
|
-
case `${s.Kujira}.USK`:
|
|
935
|
-
return { identifier: `${s.Kujira}.USK`, decimal: 6 };
|
|
936
|
-
case s.Kujira:
|
|
937
|
-
case s.Arbitrum:
|
|
938
|
-
case s.Optimism:
|
|
939
|
-
case s.BitcoinCash:
|
|
940
|
-
case s.Litecoin:
|
|
941
|
-
case s.Dogecoin:
|
|
942
|
-
case s.Binance:
|
|
943
|
-
case s.Avalanche:
|
|
944
|
-
case s.Polygon:
|
|
945
|
-
case s.Bitcoin:
|
|
946
|
-
case s.Ethereum:
|
|
947
|
-
return { identifier: `${e}.${e}`, decimal: _[e] };
|
|
948
|
-
}
|
|
949
|
-
}, Rt = ({ chain: e, symbol: t }) => {
|
|
950
|
-
if (t.includes("/"))
|
|
951
|
-
return "Synth";
|
|
952
|
-
switch (e) {
|
|
953
|
-
case s.Bitcoin:
|
|
954
|
-
case s.BitcoinCash:
|
|
955
|
-
case s.Dogecoin:
|
|
956
|
-
case s.Litecoin:
|
|
957
|
-
case s.Maya:
|
|
958
|
-
case s.THORChain:
|
|
959
|
-
return "Native";
|
|
960
|
-
case s.Cosmos:
|
|
961
|
-
return t === "ATOM" ? "Native" : s.Cosmos;
|
|
962
|
-
case s.Kujira:
|
|
963
|
-
return t === s.Kujira ? "Native" : s.Kujira;
|
|
964
|
-
case s.Binance:
|
|
965
|
-
return t === s.Binance ? "Native" : "BEP2";
|
|
966
|
-
case s.BinanceSmartChain:
|
|
967
|
-
return t === s.Binance ? "Native" : "BEP20";
|
|
968
|
-
case s.Ethereum:
|
|
969
|
-
return t === s.Ethereum ? "Native" : "ERC20";
|
|
970
|
-
case s.Avalanche:
|
|
971
|
-
return t === s.Avalanche ? "Native" : s.Avalanche;
|
|
972
|
-
case s.Polygon:
|
|
973
|
-
return t === s.Polygon ? "Native" : "POLYGON";
|
|
974
|
-
case s.Arbitrum:
|
|
975
|
-
return [s.Ethereum, s.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
976
|
-
case s.Optimism:
|
|
977
|
-
return [s.Ethereum, s.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
978
|
-
}
|
|
979
|
-
}, Pn = (e) => {
|
|
980
|
-
var t;
|
|
981
|
-
const [n, ...a] = e.split("."), i = e.includes("/"), r = a.join("."), p = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
982
|
-
return { chain: n, symbol: r, ticker: p, synth: i };
|
|
983
|
-
}, Ot = new RegExp(
|
|
984
|
-
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
985
|
-
"gmi"
|
|
986
|
-
), vt = (e) => {
|
|
987
|
-
const [t, n] = e.split(".");
|
|
988
|
-
if (!ot.includes(t))
|
|
989
|
-
return !0;
|
|
990
|
-
const [, a] = n.split("-");
|
|
991
|
-
return Pe({ chain: t, symbol: n }) || !!a;
|
|
992
|
-
}, Ln = (e) => e.filter((t) => {
|
|
993
|
-
const n = `${t.chain}.${t.symbol}`;
|
|
994
|
-
return !Ot.test(n) && vt(n) && t.value !== "0";
|
|
995
|
-
});
|
|
996
|
-
function It({
|
|
997
|
-
liquidityUnits: e,
|
|
998
|
-
poolUnits: t,
|
|
999
|
-
runeDepth: n
|
|
1000
|
-
}) {
|
|
1001
|
-
const a = g(e), i = g(t), r = g(n), p = a.mul(r), u = i.mul(i).mul(2), y = i.mul(a).mul(2), d = a.mul(a), o = i.mul(i).mul(i);
|
|
1002
|
-
return p.mul(u.sub(y).add(d)).div(o);
|
|
1003
|
-
}
|
|
1004
|
-
function St({
|
|
1005
|
-
liquidityUnits: e,
|
|
1006
|
-
poolUnits: t,
|
|
1007
|
-
assetDepth: n
|
|
1008
|
-
}) {
|
|
1009
|
-
const a = g(e), i = g(t), r = g(n), p = a.mul(r), u = i.mul(i).mul(2), y = i.mul(a).mul(2), d = a.mul(a), o = p.mul(u.sub(y).add(d)), T = i.mul(i).mul(i);
|
|
1010
|
-
return o.div(T);
|
|
1011
|
-
}
|
|
1012
|
-
function Hn({
|
|
1013
|
-
percent: e,
|
|
1014
|
-
runeDepth: t,
|
|
1015
|
-
liquidityUnits: n,
|
|
1016
|
-
poolUnits: a
|
|
1017
|
-
}) {
|
|
1018
|
-
return It({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1019
|
-
}
|
|
1020
|
-
function Vn({
|
|
1021
|
-
percent: e,
|
|
1022
|
-
assetDepth: t,
|
|
1023
|
-
liquidityUnits: n,
|
|
1024
|
-
poolUnits: a
|
|
1025
|
-
}) {
|
|
1026
|
-
return St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1027
|
-
}
|
|
1028
|
-
function g(e) {
|
|
1029
|
-
return k.fromBigInt(BigInt(e), _.THOR);
|
|
1030
|
-
}
|
|
1031
|
-
function Ct({
|
|
1032
|
-
liquidityUnits: e,
|
|
1033
|
-
poolUnits: t,
|
|
1034
|
-
runeDepth: n,
|
|
1035
|
-
assetDepth: a
|
|
1036
|
-
}) {
|
|
1037
|
-
return {
|
|
1038
|
-
assetAmount: g(a).mul(e).div(t),
|
|
1039
|
-
runeAmount: g(n).mul(e).div(t)
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
function Fn({
|
|
1043
|
-
liquidityUnits: e,
|
|
1044
|
-
poolUnits: t,
|
|
1045
|
-
runeDepth: n,
|
|
1046
|
-
assetDepth: a,
|
|
1047
|
-
percent: i
|
|
1048
|
-
}) {
|
|
1049
|
-
return Object.fromEntries(
|
|
1050
|
-
Object.entries(Ct({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1051
|
-
([r, p]) => [r, p.mul(i)]
|
|
1052
|
-
)
|
|
1053
|
-
);
|
|
1054
|
-
}
|
|
1055
|
-
function Un({
|
|
1056
|
-
runeDepth: e,
|
|
1057
|
-
poolUnits: t,
|
|
1058
|
-
assetDepth: n,
|
|
1059
|
-
liquidityUnits: a,
|
|
1060
|
-
runeAmount: i,
|
|
1061
|
-
assetAmount: r
|
|
1062
|
-
}) {
|
|
1063
|
-
const p = new k({ value: e, decimal: 8 }), u = new k({ value: n, decimal: 8 }), y = new k({ value: t, decimal: 8 }), d = new k({ value: i, decimal: 8 }), o = new k({ value: r, decimal: 8 }), T = d.mul(u), f = o.mul(p), A = d.mul(o), w = p.mul(u), M = y.mul(T.add(f.add(A.mul(2)))), R = T.add(f.add(w.mul(2))), O = M.div(R), D = g(a).add(O);
|
|
1064
|
-
if (O.getBaseValue("number") === 0)
|
|
1065
|
-
return D.div(y).getBaseValue("number");
|
|
1066
|
-
const pe = y.add(D);
|
|
1067
|
-
return D.div(pe).getBaseValue("number");
|
|
1068
|
-
}
|
|
1069
|
-
function qn({
|
|
1070
|
-
runeAmount: e,
|
|
1071
|
-
assetAmount: t,
|
|
1072
|
-
runeDepth: n,
|
|
1073
|
-
assetDepth: a
|
|
1074
|
-
}) {
|
|
1075
|
-
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1076
|
-
return 0;
|
|
1077
|
-
const i = g(n), r = g(a), p = g(t), u = g(e), y = p.mul(i).sub(r.mul(u)), d = r.mul(u).add(i.mul(r));
|
|
1078
|
-
return Math.abs(y.div(d).getBaseValue("number"));
|
|
1079
|
-
}
|
|
1080
|
-
const C = (e, t) => {
|
|
1081
|
-
switch (e) {
|
|
1082
|
-
case b.LEAVE:
|
|
1083
|
-
case b.BOND: {
|
|
1084
|
-
const { address: n } = t;
|
|
1085
|
-
return `${e}:${n}`;
|
|
1086
|
-
}
|
|
1087
|
-
case b.UNBOND: {
|
|
1088
|
-
const { address: n, unbondAmount: a } = t;
|
|
1089
|
-
return `${e}:${n}:${a}`;
|
|
1090
|
-
}
|
|
1091
|
-
case b.THORNAME_REGISTER: {
|
|
1092
|
-
const { name: n, chain: a, address: i, owner: r } = t;
|
|
1093
|
-
return `${e}:${n}:${a}:${i}${r ? `:${r}` : ""}`;
|
|
1094
|
-
}
|
|
1095
|
-
case b.DEPOSIT: {
|
|
1096
|
-
const { chain: n, symbol: a, address: i, singleSide: r } = t;
|
|
1097
|
-
return r ? `${e}:${n}/${a}::t:0` : `${e}:${((p, u) => {
|
|
1098
|
-
switch (p) {
|
|
1099
|
-
case s.Litecoin:
|
|
1100
|
-
return "l";
|
|
1101
|
-
case s.Dogecoin:
|
|
1102
|
-
return "d";
|
|
1103
|
-
case s.BitcoinCash:
|
|
1104
|
-
return "c";
|
|
1105
|
-
default:
|
|
1106
|
-
return `${p}.${u}`;
|
|
1107
|
-
}
|
|
1108
|
-
})(n, a)}:${i || ""}:t:0`;
|
|
1109
|
-
}
|
|
1110
|
-
case b.WITHDRAW: {
|
|
1111
|
-
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: u } = t, y = n === "ETH" && a !== "ETH" ? `${a}-${i.slice(-3)}` : i, d = !u && p ? `:${p}` : "";
|
|
1112
|
-
return `${e}:${n}${u ? "/" : "."}${y}:${r}${d}`;
|
|
1113
|
-
}
|
|
1114
|
-
case b.OPEN_LOAN:
|
|
1115
|
-
case b.CLOSE_LOAN: {
|
|
1116
|
-
const { asset: n, address: a } = t;
|
|
1117
|
-
return `${e}:${n}:${a}`;
|
|
1118
|
-
}
|
|
1119
|
-
default:
|
|
1120
|
-
return "";
|
|
1121
|
-
}
|
|
1122
|
-
};
|
|
1123
|
-
function $n(e) {
|
|
1124
|
-
if (e < 0)
|
|
1125
|
-
throw new Error("Invalid number of year");
|
|
1126
|
-
return 10 + e;
|
|
1127
|
-
}
|
|
1128
|
-
function Wn(e) {
|
|
1129
|
-
if (e.length > 30)
|
|
1130
|
-
return !1;
|
|
1131
|
-
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1132
|
-
return !!e.match(t);
|
|
1133
|
-
}
|
|
1134
|
-
function Gn([e, t, n, a, i]) {
|
|
1135
|
-
return `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`;
|
|
1136
|
-
}
|
|
1137
|
-
class we extends Error {
|
|
849
|
+
}, w = (e, t, n) => (gt(e, t, "access private method"), n), m = /* @__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))(m || {});
|
|
850
|
+
m.INVALID_INPUT_PARAMETERS + "", m.UNKNOWN_PROVIDERS + "", m.CANNOT_FIND_INBOUND_ADDRESS + "", m.NO_INBOUND_ADDRESSES + "", m.CHAIN_HALTED_OR_UNSUPPORTED + "", m.MISSING_INPUT_PARAMETER + "", m.INVALID_TYPE_GENERIC + "", m.INVALID_NUMBER_STRING + "", m.INVALID_NUMBER + "", m.INVALID_BOOLEAN + "", m.INVALID_OBJECT + "", m.INVALID_ARRAY + "", m.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", m.SELL_BUY_ASSETS_ARE_THE_SAME + "", m.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", m.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", m.AFF_ADDRESS_TOO_LONG + "", m.AFF_BPS_INTEGER_MAX_500 + "", m.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", m.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", m.PREFERRED_PROVIDER_NOT_SUPPORTED + "", m.SOURCE_ADDRESS_SMART_CONTRACT + "", m.DESTINATION_ADDRESS_SMART_CONTRACT + "", m.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", m.INVALID_PROVIDER + "", m.MISSING_CROSS_CHAIN_PROVIDER + "", m.MISSING_AVAX_PROVIDER + "", m.MISSING_BSC_PROVIDER + "", m.MISSING_ETH_PROVIDER + "", m.MISSING_ARB_PROVIDER + "", m.INVALID_PROVIDER_FOR_SWAP_OUT + "", m.INVALID_CHAIN + "", m.INVALID_ASSET + "", m.UNSUPPORTED_CHAIN + "", m.UNSUPPORTED_ASSET + "", m.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", m.THORNODE_QUOTE_GENERIC_ERROR + "", m.INVALID_SOURCE_ADDRESS + "", m.INVALID_DESTINATION_ADDRESS + "", m.NOT_ENOUGH_SYNTH_BALANCE + "", m.SYNTH_MINTING_CAP_REACHED + "", m.INVALID_QUOTE_MODE + "", m.NO_QUOTES + "", m.SERVICE_UNAVAILABLE_GENERIC + "", m.MISSING_GAS_DATA_GENERIC + "", m.MISSING_TOKEN_INFO_GENERIC + "", m.CANT_FIND_TOKEN_LIST + "", m.NO_PRICE + "", m.PRICE_IS_STALE + "", m.ADDRESS_NOT_WHITELISTED + "", m.ADDRESS_ALREADY_CLAIMED + "";
|
|
851
|
+
var de = /* @__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))(de || {}), Me = /* @__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))(Me || {}), $e = /* @__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))($e || {}), L = /* @__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))(L || {});
|
|
852
|
+
const le = Object.values(de), Ct = Object.keys(de), Ie = le.reduce(
|
|
853
|
+
(e, t) => {
|
|
854
|
+
const n = Ct.find((a) => de[a] === t);
|
|
855
|
+
return n && (e[t] = n), e;
|
|
856
|
+
},
|
|
857
|
+
{}
|
|
858
|
+
);
|
|
859
|
+
le.reduce(
|
|
860
|
+
(e, t) => (e[t] = Me[Ie[t]], e),
|
|
861
|
+
{}
|
|
862
|
+
);
|
|
863
|
+
le.reduce(
|
|
864
|
+
(e, t) => (e[t] = $e[Ie[t]], e),
|
|
865
|
+
{}
|
|
866
|
+
);
|
|
867
|
+
le.reduce(
|
|
868
|
+
(e, t) => {
|
|
869
|
+
const n = `${Ie[t]}Hex`;
|
|
870
|
+
return e[t] = Me[n], e;
|
|
871
|
+
},
|
|
872
|
+
{}
|
|
873
|
+
);
|
|
874
|
+
class Ce extends Error {
|
|
1138
875
|
constructor(t, n, a) {
|
|
1139
876
|
const i = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", p = `${i} ${r}`.trim(), u = p ? `status code ${p}` : "an unknown error";
|
|
1140
877
|
super(`Request failed with ${u}`), Object.defineProperty(this, "response", {
|
|
@@ -1155,7 +892,7 @@ class we extends Error {
|
|
|
1155
892
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1156
893
|
}
|
|
1157
894
|
}
|
|
1158
|
-
class
|
|
895
|
+
class qe extends Error {
|
|
1159
896
|
constructor(t) {
|
|
1160
897
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1161
898
|
enumerable: !0,
|
|
@@ -1165,28 +902,28 @@ class Le extends Error {
|
|
|
1165
902
|
}), this.name = "TimeoutError", this.request = t;
|
|
1166
903
|
}
|
|
1167
904
|
}
|
|
1168
|
-
const
|
|
905
|
+
const ne = (e) => e !== null && typeof e == "object", te = (...e) => {
|
|
1169
906
|
for (const t of e)
|
|
1170
|
-
if ((!
|
|
907
|
+
if ((!ne(t) || Array.isArray(t)) && t !== void 0)
|
|
1171
908
|
throw new TypeError("The `options` argument must be an object");
|
|
1172
|
-
return
|
|
1173
|
-
},
|
|
909
|
+
return ge({}, ...e);
|
|
910
|
+
}, Ge = (e = {}, t = {}) => {
|
|
1174
911
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, i = new globalThis.Headers(t);
|
|
1175
912
|
for (const [r, p] of i.entries())
|
|
1176
913
|
a && p === "undefined" || p === void 0 ? n.delete(r) : n.set(r, p);
|
|
1177
914
|
return n;
|
|
1178
|
-
},
|
|
915
|
+
}, ge = (...e) => {
|
|
1179
916
|
let t = {}, n = {};
|
|
1180
917
|
for (const a of e)
|
|
1181
918
|
if (Array.isArray(a))
|
|
1182
919
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1183
|
-
else if (
|
|
920
|
+
else if (ne(a)) {
|
|
1184
921
|
for (let [i, r] of Object.entries(a))
|
|
1185
|
-
|
|
1186
|
-
|
|
922
|
+
ne(r) && i in t && (r = ge(t[i], r)), t = { ...t, [i]: r };
|
|
923
|
+
ne(a.headers) && (n = Ge(n, a.headers), t.headers = n);
|
|
1187
924
|
}
|
|
1188
925
|
return t;
|
|
1189
|
-
},
|
|
926
|
+
}, vt = (() => {
|
|
1190
927
|
let e = !1, t = !1;
|
|
1191
928
|
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1192
929
|
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
@@ -1197,13 +934,13 @@ const Z = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1197
934
|
return e = !0, "half";
|
|
1198
935
|
}
|
|
1199
936
|
}).headers.has("Content-Type")), e && !t;
|
|
1200
|
-
})(),
|
|
937
|
+
})(), Nt = typeof globalThis.AbortController == "function", Dt = typeof globalThis.ReadableStream == "function", xt = typeof globalThis.FormData == "function", Xe = ["get", "post", "put", "patch", "head", "delete"], Pt = {
|
|
1201
938
|
json: "application/json",
|
|
1202
939
|
text: "text/*",
|
|
1203
940
|
formData: "multipart/form-data",
|
|
1204
941
|
arrayBuffer: "*/*",
|
|
1205
942
|
blob: "*/*"
|
|
1206
|
-
},
|
|
943
|
+
}, be = 2147483647, je = Symbol("stop"), kt = {
|
|
1207
944
|
json: !0,
|
|
1208
945
|
parseJson: !0,
|
|
1209
946
|
searchParams: !0,
|
|
@@ -1214,7 +951,7 @@ const Z = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1214
951
|
throwHttpErrors: !0,
|
|
1215
952
|
onDownloadProgress: !0,
|
|
1216
953
|
fetch: !0
|
|
1217
|
-
},
|
|
954
|
+
}, Bt = {
|
|
1218
955
|
method: !0,
|
|
1219
956
|
headers: !0,
|
|
1220
957
|
body: !0,
|
|
@@ -1230,18 +967,18 @@ const Z = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1230
967
|
window: !0,
|
|
1231
968
|
dispatcher: !0,
|
|
1232
969
|
duplex: !0
|
|
1233
|
-
},
|
|
970
|
+
}, Lt = (e) => Xe.includes(e) ? e.toUpperCase() : e, Vt = ["get", "put", "head", "delete", "options", "trace"], Ht = [408, 413, 429, 500, 502, 503, 504], Ke = [413, 429, 503], ve = {
|
|
1234
971
|
limit: 2,
|
|
1235
972
|
methods: Vt,
|
|
1236
|
-
statusCodes:
|
|
1237
|
-
afterStatusCodes:
|
|
973
|
+
statusCodes: Ht,
|
|
974
|
+
afterStatusCodes: Ke,
|
|
1238
975
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1239
976
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1240
977
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1241
|
-
},
|
|
978
|
+
}, Ft = (e = {}) => {
|
|
1242
979
|
if (typeof e == "number")
|
|
1243
980
|
return {
|
|
1244
|
-
...
|
|
981
|
+
...ve,
|
|
1245
982
|
limit: e
|
|
1246
983
|
};
|
|
1247
984
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -1249,22 +986,22 @@ const Z = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1249
986
|
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1250
987
|
throw new Error("retry.statusCodes must be an array");
|
|
1251
988
|
return {
|
|
1252
|
-
...
|
|
989
|
+
...ve,
|
|
1253
990
|
...e,
|
|
1254
|
-
afterStatusCodes:
|
|
991
|
+
afterStatusCodes: Ke
|
|
1255
992
|
};
|
|
1256
993
|
};
|
|
1257
|
-
async function
|
|
994
|
+
async function Ut(e, t, n, a) {
|
|
1258
995
|
return new Promise((i, r) => {
|
|
1259
996
|
const p = setTimeout(() => {
|
|
1260
|
-
n && n.abort(), r(new
|
|
997
|
+
n && n.abort(), r(new qe(e));
|
|
1261
998
|
}, a.timeout);
|
|
1262
999
|
a.fetch(e, t).then(i).catch(r).then(() => {
|
|
1263
1000
|
clearTimeout(p);
|
|
1264
1001
|
});
|
|
1265
1002
|
});
|
|
1266
1003
|
}
|
|
1267
|
-
async function
|
|
1004
|
+
async function Wt(e, { signal: t }) {
|
|
1268
1005
|
return new Promise((n, a) => {
|
|
1269
1006
|
t && (t.throwIfAborted(), t.addEventListener("abort", i, { once: !0 }));
|
|
1270
1007
|
function i() {
|
|
@@ -1275,17 +1012,17 @@ async function $t(e, { signal: t }) {
|
|
|
1275
1012
|
}, e);
|
|
1276
1013
|
});
|
|
1277
1014
|
}
|
|
1278
|
-
const
|
|
1015
|
+
const $t = (e, t) => {
|
|
1279
1016
|
const n = {};
|
|
1280
1017
|
for (const a in t)
|
|
1281
|
-
!(a in
|
|
1018
|
+
!(a in Bt) && !(a in kt) && !(a in e) && (n[a] = t[a]);
|
|
1282
1019
|
return n;
|
|
1283
1020
|
};
|
|
1284
|
-
class
|
|
1021
|
+
class re {
|
|
1285
1022
|
static create(t, n) {
|
|
1286
|
-
const a = new
|
|
1287
|
-
if (typeof a._options.timeout == "number" && a._options.timeout >
|
|
1288
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
1023
|
+
const a = new re(t, n), i = async () => {
|
|
1024
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > be)
|
|
1025
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${be}`);
|
|
1289
1026
|
await Promise.resolve();
|
|
1290
1027
|
let p = await a._fetch();
|
|
1291
1028
|
for (const u of a._options.hooks.afterResponse) {
|
|
@@ -1293,7 +1030,7 @@ class te {
|
|
|
1293
1030
|
y instanceof globalThis.Response && (p = y);
|
|
1294
1031
|
}
|
|
1295
1032
|
if (a._decorateResponse(p), !p.ok && a._options.throwHttpErrors) {
|
|
1296
|
-
let u = new
|
|
1033
|
+
let u = new Ce(p, a.request, a._options);
|
|
1297
1034
|
for (const y of a._options.hooks.beforeError)
|
|
1298
1035
|
u = await y(u);
|
|
1299
1036
|
throw u;
|
|
@@ -1307,7 +1044,7 @@ class te {
|
|
|
1307
1044
|
}
|
|
1308
1045
|
return p;
|
|
1309
1046
|
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(i) : i();
|
|
1310
|
-
for (const [p, u] of Object.entries(
|
|
1047
|
+
for (const [p, u] of Object.entries(Pt))
|
|
1311
1048
|
r[p] = async () => {
|
|
1312
1049
|
a.request.headers.set("accept", a.request.headers.get("accept") || u);
|
|
1313
1050
|
const y = (await r).clone();
|
|
@@ -1352,17 +1089,17 @@ class te {
|
|
|
1352
1089
|
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1353
1090
|
credentials: this._input.credentials || "same-origin",
|
|
1354
1091
|
...n,
|
|
1355
|
-
headers:
|
|
1356
|
-
hooks:
|
|
1092
|
+
headers: Ge(this._input.headers, n.headers),
|
|
1093
|
+
hooks: ge({
|
|
1357
1094
|
beforeRequest: [],
|
|
1358
1095
|
beforeRetry: [],
|
|
1359
1096
|
beforeError: [],
|
|
1360
1097
|
afterResponse: []
|
|
1361
1098
|
}, n.hooks),
|
|
1362
|
-
method:
|
|
1099
|
+
method: Lt(n.method ?? this._input.method),
|
|
1363
1100
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1364
1101
|
prefixUrl: String(n.prefixUrl || ""),
|
|
1365
|
-
retry:
|
|
1102
|
+
retry: Ft(n.retry),
|
|
1366
1103
|
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1367
1104
|
timeout: n.timeout ?? 1e4,
|
|
1368
1105
|
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
@@ -1373,7 +1110,7 @@ class te {
|
|
|
1373
1110
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1374
1111
|
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1375
1112
|
}
|
|
1376
|
-
if (
|
|
1113
|
+
if (Nt) {
|
|
1377
1114
|
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1378
1115
|
const a = this._options.signal;
|
|
1379
1116
|
this._options.signal.addEventListener("abort", () => {
|
|
@@ -1382,15 +1119,15 @@ class te {
|
|
|
1382
1119
|
}
|
|
1383
1120
|
this._options.signal = this.abortController.signal;
|
|
1384
1121
|
}
|
|
1385
|
-
if (
|
|
1122
|
+
if (vt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1386
1123
|
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1387
|
-
(
|
|
1124
|
+
(xt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(i, { ...this.request }), this._options);
|
|
1388
1125
|
}
|
|
1389
1126
|
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 }));
|
|
1390
1127
|
}
|
|
1391
1128
|
_calculateRetryDelay(t) {
|
|
1392
|
-
if (this._retryCount++, this._retryCount
|
|
1393
|
-
if (t instanceof
|
|
1129
|
+
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof qe)) {
|
|
1130
|
+
if (t instanceof Ce) {
|
|
1394
1131
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1395
1132
|
return 0;
|
|
1396
1133
|
const a = t.response.headers.get("Retry-After");
|
|
@@ -1413,16 +1150,16 @@ class te {
|
|
|
1413
1150
|
try {
|
|
1414
1151
|
return await t();
|
|
1415
1152
|
} catch (n) {
|
|
1416
|
-
const a = Math.min(this._calculateRetryDelay(n),
|
|
1153
|
+
const a = Math.min(this._calculateRetryDelay(n), be);
|
|
1417
1154
|
if (a !== 0 && this._retryCount > 0) {
|
|
1418
|
-
await
|
|
1155
|
+
await Wt(a, { signal: this._options.signal });
|
|
1419
1156
|
for (const i of this._options.hooks.beforeRetry)
|
|
1420
1157
|
if (await i({
|
|
1421
1158
|
request: this.request,
|
|
1422
1159
|
options: this._options,
|
|
1423
1160
|
error: n,
|
|
1424
1161
|
retryCount: this._retryCount
|
|
1425
|
-
}) ===
|
|
1162
|
+
}) === je)
|
|
1426
1163
|
return;
|
|
1427
1164
|
return this._retry(t);
|
|
1428
1165
|
}
|
|
@@ -1439,8 +1176,8 @@ class te {
|
|
|
1439
1176
|
if (a instanceof Response)
|
|
1440
1177
|
return a;
|
|
1441
1178
|
}
|
|
1442
|
-
const t =
|
|
1443
|
-
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) :
|
|
1179
|
+
const t = $t(this.request, this._options);
|
|
1180
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ut(this.request.clone(), t, this.abortController, this._options);
|
|
1444
1181
|
}
|
|
1445
1182
|
/* istanbul ignore next */
|
|
1446
1183
|
_stream(t, n) {
|
|
@@ -1477,31 +1214,351 @@ class te {
|
|
|
1477
1214
|
}
|
|
1478
1215
|
}
|
|
1479
1216
|
/*! MIT License © Sindre Sorhus */
|
|
1480
|
-
const
|
|
1481
|
-
const t = (n, a) =>
|
|
1482
|
-
for (const n of
|
|
1483
|
-
t[n] = (a, i) =>
|
|
1484
|
-
return t.create = (n) =>
|
|
1485
|
-
},
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1217
|
+
const he = (e) => {
|
|
1218
|
+
const t = (n, a) => re.create(n, te(e, a));
|
|
1219
|
+
for (const n of Xe)
|
|
1220
|
+
t[n] = (a, i) => re.create(a, te(e, i, { method: n }));
|
|
1221
|
+
return t.create = (n) => he(te(n)), t.extend = (n) => he(te(e, n)), t.stop = je, t;
|
|
1222
|
+
}, Ye = he();
|
|
1223
|
+
let ae;
|
|
1224
|
+
const P = {
|
|
1225
|
+
CachedPrices: `${L.ThorswapApi}/tokenlist/cached-price`,
|
|
1226
|
+
GasRates: `${L.ThorswapApi}/resource-worker/gasPrice/getAll`,
|
|
1227
|
+
Quote: `${L.ThorswapApi}/aggregator/tokens/quote`,
|
|
1228
|
+
Txn: `${L.ThorswapApi}/apiusage/v2/txn`,
|
|
1229
|
+
TokenlistProviders: `${L.ThorswapApi}/tokenlist/providers`,
|
|
1230
|
+
TokenList: `${L.ThorswapStatic}/token-list`,
|
|
1231
|
+
Thorname: `${L.ThorswapApi}/thorname`
|
|
1232
|
+
}, Qe = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Ne = () => ae || (ae = Ye.create({ headers: Qe }), ae), Yn = ({ apiKey: e, ...t }) => {
|
|
1233
|
+
ae = Ye.create({
|
|
1234
|
+
...t,
|
|
1235
|
+
headers: { ...Qe, ...t.headers, "x-api-key": e }
|
|
1236
|
+
});
|
|
1237
|
+
}, g = {
|
|
1238
|
+
get: (e, t) => Ne().get(e, t).json(),
|
|
1239
|
+
post: (e, t) => Ne().post(e, t).json()
|
|
1240
|
+
}, qt = ({ tokens: e, ...t }) => {
|
|
1241
|
+
const n = new URLSearchParams();
|
|
1242
|
+
return e.filter((a, i, r) => r.findIndex((p) => p === a) === i).forEach((a) => n.append("tokens", JSON.stringify(a))), t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), g.post(P.CachedPrices, {
|
|
1243
|
+
body: n.toString(),
|
|
1244
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
1245
|
+
});
|
|
1246
|
+
}, Qn = {
|
|
1247
|
+
getCachedPrices: qt,
|
|
1248
|
+
getQuote: (e) => g.get(P.Quote, { searchParams: e }),
|
|
1249
|
+
getGasRates: () => g.get(P.GasRates),
|
|
1250
|
+
getTxnDetails: (e) => g.get(P.Txn, { searchParams: e }),
|
|
1251
|
+
getTokenlistProviders: () => g.get(P.TokenlistProviders),
|
|
1252
|
+
getTokenList: (e) => g.get(`${P.TokenList}/${e}.json`),
|
|
1253
|
+
getThornameAddresses: (e) => g.get(`${P.Thorname}/${e}`),
|
|
1254
|
+
getThornameRegisteredChains: (e) => g.get(`${P.Thorname}/chains/${e}`),
|
|
1255
|
+
getThornameRlookup: (e, t) => g.get(`${P.Thorname}/rlookup`, { searchParams: { address: e, chain: t } })
|
|
1256
|
+
};
|
|
1257
|
+
var Gt = /* @__PURE__ */ ((e) => (e.SWAP_TC_TO_TC = "SWAP:TC-TC", e.SWAP_ETH_TO_TC = "SWAP:ERC20-TC", e.SWAP_TC_TO_ETH = "SWAP:TC-ERC20", e.SWAP_ETH_TO_ETH = "SWAP:ERC20-ERC20", e.SWAP_AVAX_TO_TC = "SWAP:AVAX-TC", e.SWAP_TC_TO_AVAX = "SWAP:TC-AVAX", e.SWAP_AVAX_TO_AVAX = "SWAP:AVAX-AVAX", e.SWAP_ETH_TO_AVAX = "SWAP:ETH-AVAX", e.SWAP_AVAX_TO_ETH = "SWAP:AVAX-ETH", e.SWAP_TC_TO_GAIA = "SWAP:TC-GAIA", e.SWAP_GAIA_TO_TC = "SWAP:GAIA-TC", e.SWAP_TC_TO_BNB = "SWAP:TC-BNB", e.SWAP_BNB_TO_TC = "SWAP:BNB-TC", e.SWAP_TC_TO_BTC = "SWAP:TC-BTC", e.SWAP_BTC_TO_TC = "SWAP:BTC-TC", e.SWAP_TC_TO_BCH = "SWAP:TC-BCH", e.SWAP_BCH_TO_TC = "SWAP:BCH-TC", e.SWAP_TC_TO_LTC = "SWAP:TC-LTC", e.SWAP_LTC_TO_TC = "SWAP:LTC-TC", e.SWAP_TC_TO_DOGE = "SWAP:TC-DOGE", e.SWAP_DOGE_TO_TC = "SWAP:DOGE-TC", e.TC_STATUS = "TC:STATUS", e.TC_TRANSFER = "TC:TRANSFER", e.TC_DEPOSIT = "TC:DEPOSIT", e.TC_SEND = "TC:SEND", e.TC_SWITCH = "TC:SWITCH", e.TC_LP_ADD = "TC:ADDLIQUIDITY", e.TC_LP_WITHDRAW = "TC:WITHDRAW", e.TC_TNS_CREATE = "TC:TNS-CREATE", e.TC_TNS_EXTEND = "TC:TNS-EXTEND", e.TC_TNS_UPDATE = "TC:TNS-UPDATE", e.TC_SAVINGS_ADD = "TC:ADDSAVINGS", e.TC_SAVINGS_WITHDRAW = "TC:WITHDRAWSAVINGS", e.TC_LENDING_OPEN = "TC:LENDINGOPEN", e.TC_LENDING_CLOSE = "TC:LENDINGCLOSE", e.ETH_APPROVAL = "ETH:APPROVAL", e.ETH_STATUS = "ETH:STATUS", e.ETH_TRANSFER_TO_TC = "ETH:TRANSFER:IN", e.ETH_TRANSFER_FROM_TC = "ETH:TRANSFER:OUT", e.AVAX_APPROVAL = "AVAX:APPROVAL", e.AVAX_STATUS = "AVAX:STATUS", e.AVAX_TRANSFER_TO_TC = "AVAX:TRANSFER:IN", e.AVAX_TRANSFER_FROM_TC = "AVAX:TRANSFER:OUT", e.BSC_APPROVAL = "BSC:APPROVAL", e.BSC_STATUS = "BSC:STATUS", e.BSC_TRANSFER_TO_TC = "BSC:TRANSFER:IN", e.BSC_TRANSFER_FROM_TC = "BSC:TRANSFER:OUT", e.APPROVAL = "APPROVAL", e.STATUS = "STATUS", e.TRANSFER_TO_TC = "TRANSFER:IN", e.TRANSFER_FROM_TC = "TRANSFER:OUT", e.UNSUPPORTED = "UNSUPPORTED", e.TC_LENDING = "TC:LENDING", e))(Gt || {}), Xt = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.SUCCESS = "success", e.CANCELLED = "cancelled", e.REFUNDED = "refunded", e.REPLACED = "replaced", e.ERROR = "error", e.UNKNOWN = "unknown", e.NOT_STARTED = "not_started", e.NOT_FOUND = "not_found", e.RETRIES_EXCEEDED = "retries_exceeded", e.STREAMING = "streaming", e))(Xt || {}), jt = /* @__PURE__ */ ((e) => (e[e.NOT_STARTED = 0] = "NOT_STARTED", e[e.SUCCESS = 1] = "SUCCESS", e[e.REFUNDED = 2] = "REFUNDED", e))(jt || {});
|
|
1258
|
+
const Kt = "0x313ce567", Je = async ({ chain: e, to: t }) => {
|
|
1259
|
+
try {
|
|
1260
|
+
const { result: n } = await g.post(St[e], {
|
|
1261
|
+
headers: {
|
|
1262
|
+
accept: "*/*",
|
|
1263
|
+
"content-type": "application/json",
|
|
1264
|
+
"cache-control": "no-cache"
|
|
1265
|
+
},
|
|
1266
|
+
body: JSON.stringify({
|
|
1267
|
+
id: 44,
|
|
1268
|
+
jsonrpc: "2.0",
|
|
1269
|
+
method: "eth_call",
|
|
1270
|
+
params: [{ to: t.toLowerCase(), data: Kt }, "latest"]
|
|
1271
|
+
})
|
|
1272
|
+
});
|
|
1273
|
+
return parseInt(BigInt(n).toString());
|
|
1274
|
+
} catch (n) {
|
|
1275
|
+
return console.error(n), h[e];
|
|
1276
|
+
}
|
|
1277
|
+
}, Yt = async (e) => {
|
|
1278
|
+
if (e === s.Ethereum)
|
|
1279
|
+
return h.ETH;
|
|
1280
|
+
const [, t] = e.split("-");
|
|
1281
|
+
return t != null && t.startsWith("0x") ? Je({ chain: s.Ethereum, to: t }) : h.ETH;
|
|
1282
|
+
}, Qt = async (e) => {
|
|
1283
|
+
const [, t] = e.split("-");
|
|
1284
|
+
return t != null && t.startsWith("0x") ? Je({ chain: s.Avalanche, to: t.toLowerCase() }) : h.AVAX;
|
|
1285
|
+
}, Jt = async (e) => (e === s.BinanceSmartChain, h.BSC), Zt = async ({ chain: e, symbol: t }) => {
|
|
1286
|
+
switch (e) {
|
|
1287
|
+
case s.Ethereum:
|
|
1288
|
+
return Yt(t);
|
|
1289
|
+
case s.Avalanche:
|
|
1290
|
+
return Qt(t);
|
|
1291
|
+
case s.BinanceSmartChain:
|
|
1292
|
+
return Jt(t);
|
|
1293
|
+
default:
|
|
1294
|
+
return h[e];
|
|
1295
|
+
}
|
|
1296
|
+
}, zt = {
|
|
1297
|
+
[X.Average]: 1.2,
|
|
1298
|
+
[X.Fast]: 1.5,
|
|
1299
|
+
[X.Fastest]: 2
|
|
1300
|
+
}, Ze = ({ chain: e, symbol: t }) => {
|
|
1301
|
+
switch (e) {
|
|
1302
|
+
case s.Bitcoin:
|
|
1303
|
+
case s.BitcoinCash:
|
|
1304
|
+
case s.Litecoin:
|
|
1305
|
+
case s.Dogecoin:
|
|
1306
|
+
case s.Binance:
|
|
1307
|
+
case s.Ethereum:
|
|
1308
|
+
case s.Avalanche:
|
|
1309
|
+
return t === e;
|
|
1310
|
+
case s.Arbitrum:
|
|
1311
|
+
case s.Optimism:
|
|
1312
|
+
return t === "ETH";
|
|
1313
|
+
case s.Maya:
|
|
1314
|
+
return t === "CACAO";
|
|
1315
|
+
case s.Kujira:
|
|
1316
|
+
return t === "KUJI";
|
|
1317
|
+
case s.Cosmos:
|
|
1318
|
+
return t === "ATOM";
|
|
1319
|
+
case s.Polygon:
|
|
1320
|
+
return t === "MATIC";
|
|
1321
|
+
case s.BinanceSmartChain:
|
|
1322
|
+
return t === "BNB";
|
|
1323
|
+
case s.THORChain:
|
|
1324
|
+
return t === "RUNE";
|
|
1325
|
+
}
|
|
1326
|
+
}, en = (e) => {
|
|
1327
|
+
switch (e) {
|
|
1328
|
+
case `${s.Ethereum}.THOR`:
|
|
1329
|
+
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
1330
|
+
case `${s.Ethereum}.vTHOR`:
|
|
1331
|
+
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
1332
|
+
case s.Cosmos:
|
|
1333
|
+
return { identifier: "GAIA.ATOM", decimal: h[e] };
|
|
1334
|
+
case s.THORChain:
|
|
1335
|
+
return { identifier: "THOR.RUNE", decimal: h[e] };
|
|
1336
|
+
case s.BinanceSmartChain:
|
|
1337
|
+
return { identifier: "BSC.BNB", decimal: h[e] };
|
|
1338
|
+
case s.Maya:
|
|
1339
|
+
return { identifier: "MAYA.CACAO", decimal: h.MAYA };
|
|
1340
|
+
case `${s.Maya}.MAYA`:
|
|
1341
|
+
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
1342
|
+
case `${s.Kujira}.USK`:
|
|
1343
|
+
return { identifier: `${s.Kujira}.USK`, decimal: 6 };
|
|
1344
|
+
case s.Kujira:
|
|
1345
|
+
case s.Arbitrum:
|
|
1346
|
+
case s.Optimism:
|
|
1347
|
+
case s.BitcoinCash:
|
|
1348
|
+
case s.Litecoin:
|
|
1349
|
+
case s.Dogecoin:
|
|
1350
|
+
case s.Binance:
|
|
1351
|
+
case s.Avalanche:
|
|
1352
|
+
case s.Polygon:
|
|
1353
|
+
case s.Bitcoin:
|
|
1354
|
+
case s.Ethereum:
|
|
1355
|
+
return { identifier: `${e}.${e}`, decimal: h[e] };
|
|
1356
|
+
}
|
|
1357
|
+
}, tn = ({ chain: e, symbol: t }) => {
|
|
1358
|
+
if (t.includes("/"))
|
|
1359
|
+
return "Synth";
|
|
1360
|
+
switch (e) {
|
|
1361
|
+
case s.Bitcoin:
|
|
1362
|
+
case s.BitcoinCash:
|
|
1363
|
+
case s.Dogecoin:
|
|
1364
|
+
case s.Litecoin:
|
|
1365
|
+
case s.Maya:
|
|
1366
|
+
case s.THORChain:
|
|
1367
|
+
return "Native";
|
|
1368
|
+
case s.Cosmos:
|
|
1369
|
+
return t === "ATOM" ? "Native" : s.Cosmos;
|
|
1370
|
+
case s.Kujira:
|
|
1371
|
+
return t === s.Kujira ? "Native" : s.Kujira;
|
|
1372
|
+
case s.Binance:
|
|
1373
|
+
return t === s.Binance ? "Native" : "BEP2";
|
|
1374
|
+
case s.BinanceSmartChain:
|
|
1375
|
+
return t === s.Binance ? "Native" : "BEP20";
|
|
1376
|
+
case s.Ethereum:
|
|
1377
|
+
return t === s.Ethereum ? "Native" : "ERC20";
|
|
1378
|
+
case s.Avalanche:
|
|
1379
|
+
return t === s.Avalanche ? "Native" : s.Avalanche;
|
|
1380
|
+
case s.Polygon:
|
|
1381
|
+
return t === s.Polygon ? "Native" : "POLYGON";
|
|
1382
|
+
case s.Arbitrum:
|
|
1383
|
+
return [s.Ethereum, s.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
1384
|
+
case s.Optimism:
|
|
1385
|
+
return [s.Ethereum, s.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
1386
|
+
}
|
|
1387
|
+
}, Jn = (e) => {
|
|
1388
|
+
var t;
|
|
1389
|
+
const [n, ...a] = e.split("."), i = e.includes("/"), r = a.join("."), p = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
1390
|
+
return { chain: n, symbol: r, ticker: p, synth: i };
|
|
1391
|
+
}, nn = new RegExp(
|
|
1392
|
+
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
1393
|
+
"gmi"
|
|
1394
|
+
), an = (e) => {
|
|
1395
|
+
const [t, n] = e.split(".");
|
|
1396
|
+
if (!Et.includes(t))
|
|
1397
|
+
return !0;
|
|
1398
|
+
const [, a] = n.split("-");
|
|
1399
|
+
return Ze({ chain: t, symbol: n }) || !!a;
|
|
1400
|
+
}, Zn = (e) => e.filter((t) => {
|
|
1401
|
+
const n = `${t.chain}.${t.symbol}`;
|
|
1402
|
+
return !nn.test(n) && an(n) && t.value !== "0";
|
|
1403
|
+
});
|
|
1404
|
+
function sn({
|
|
1405
|
+
liquidityUnits: e,
|
|
1406
|
+
poolUnits: t,
|
|
1407
|
+
runeDepth: n
|
|
1408
|
+
}) {
|
|
1409
|
+
const a = O(e), i = O(t), r = O(n), p = a.mul(r), u = i.mul(i).mul(2), y = i.mul(a).mul(2), d = a.mul(a), o = i.mul(i).mul(i);
|
|
1410
|
+
return p.mul(u.sub(y).add(d)).div(o);
|
|
1411
|
+
}
|
|
1412
|
+
function rn({
|
|
1413
|
+
liquidityUnits: e,
|
|
1414
|
+
poolUnits: t,
|
|
1415
|
+
assetDepth: n
|
|
1416
|
+
}) {
|
|
1417
|
+
const a = O(e), i = O(t), r = O(n), p = a.mul(r), u = i.mul(i).mul(2), y = i.mul(a).mul(2), d = a.mul(a), o = p.mul(u.sub(y).add(d)), c = i.mul(i).mul(i);
|
|
1418
|
+
return o.div(c);
|
|
1419
|
+
}
|
|
1420
|
+
function zn({
|
|
1421
|
+
percent: e,
|
|
1422
|
+
runeDepth: t,
|
|
1423
|
+
liquidityUnits: n,
|
|
1424
|
+
poolUnits: a
|
|
1425
|
+
}) {
|
|
1426
|
+
return sn({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1427
|
+
}
|
|
1428
|
+
function ea({
|
|
1429
|
+
percent: e,
|
|
1430
|
+
assetDepth: t,
|
|
1431
|
+
liquidityUnits: n,
|
|
1432
|
+
poolUnits: a
|
|
1433
|
+
}) {
|
|
1434
|
+
return rn({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1435
|
+
}
|
|
1436
|
+
function O(e) {
|
|
1437
|
+
return k.fromBigInt(BigInt(e), h.THOR);
|
|
1438
|
+
}
|
|
1439
|
+
function pn({
|
|
1440
|
+
liquidityUnits: e,
|
|
1441
|
+
poolUnits: t,
|
|
1442
|
+
runeDepth: n,
|
|
1443
|
+
assetDepth: a
|
|
1444
|
+
}) {
|
|
1445
|
+
return {
|
|
1446
|
+
assetAmount: O(a).mul(e).div(t),
|
|
1447
|
+
runeAmount: O(n).mul(e).div(t)
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
function ta({
|
|
1451
|
+
liquidityUnits: e,
|
|
1452
|
+
poolUnits: t,
|
|
1453
|
+
runeDepth: n,
|
|
1454
|
+
assetDepth: a,
|
|
1455
|
+
percent: i
|
|
1456
|
+
}) {
|
|
1457
|
+
return Object.fromEntries(
|
|
1458
|
+
Object.entries(pn({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1459
|
+
([r, p]) => [r, p.mul(i)]
|
|
1460
|
+
)
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
function na({
|
|
1464
|
+
runeDepth: e,
|
|
1465
|
+
poolUnits: t,
|
|
1466
|
+
assetDepth: n,
|
|
1467
|
+
liquidityUnits: a,
|
|
1468
|
+
runeAmount: i,
|
|
1469
|
+
assetAmount: r
|
|
1470
|
+
}) {
|
|
1471
|
+
const p = new k({ value: e, decimal: 8 }), u = new k({ value: n, decimal: 8 }), y = new k({ value: t, decimal: 8 }), d = new k({ value: i, decimal: 8 }), o = new k({ value: r, decimal: 8 }), c = d.mul(u), f = o.mul(p), E = d.mul(o), R = p.mul(u), S = y.mul(c.add(f.add(E.mul(2)))), M = c.add(f.add(R.mul(2))), I = S.div(M), B = O(a).add(I);
|
|
1472
|
+
if (I.getBaseValue("number") === 0)
|
|
1473
|
+
return B.div(y).getBaseValue("number");
|
|
1474
|
+
const Te = y.add(B);
|
|
1475
|
+
return B.div(Te).getBaseValue("number");
|
|
1476
|
+
}
|
|
1477
|
+
function aa({
|
|
1478
|
+
runeAmount: e,
|
|
1479
|
+
assetAmount: t,
|
|
1480
|
+
runeDepth: n,
|
|
1481
|
+
assetDepth: a
|
|
1482
|
+
}) {
|
|
1483
|
+
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1484
|
+
return 0;
|
|
1485
|
+
const i = O(n), r = O(a), p = O(t), u = O(e), y = p.mul(i).sub(r.mul(u)), d = r.mul(u).add(i.mul(r));
|
|
1486
|
+
return Math.abs(y.div(d).getBaseValue("number"));
|
|
1487
|
+
}
|
|
1488
|
+
const D = (e, t) => {
|
|
1489
|
+
switch (e) {
|
|
1490
|
+
case _.LEAVE:
|
|
1491
|
+
case _.BOND: {
|
|
1492
|
+
const { address: n } = t;
|
|
1493
|
+
return `${e}:${n}`;
|
|
1494
|
+
}
|
|
1495
|
+
case _.UNBOND: {
|
|
1496
|
+
const { address: n, unbondAmount: a } = t;
|
|
1497
|
+
return `${e}:${n}:${a}`;
|
|
1498
|
+
}
|
|
1499
|
+
case _.THORNAME_REGISTER: {
|
|
1500
|
+
const { name: n, chain: a, address: i, owner: r } = t;
|
|
1501
|
+
return `${e}:${n}:${a}:${i}${r ? `:${r}` : ""}`;
|
|
1502
|
+
}
|
|
1503
|
+
case _.DEPOSIT: {
|
|
1504
|
+
const { chain: n, symbol: a, address: i, singleSide: r } = t;
|
|
1505
|
+
return r ? `${e}:${n}/${a}::t:0` : `${e}:${((p, u) => {
|
|
1506
|
+
switch (p) {
|
|
1507
|
+
case s.Litecoin:
|
|
1508
|
+
return "l";
|
|
1509
|
+
case s.Dogecoin:
|
|
1510
|
+
return "d";
|
|
1511
|
+
case s.BitcoinCash:
|
|
1512
|
+
return "c";
|
|
1513
|
+
default:
|
|
1514
|
+
return `${p}.${u}`;
|
|
1515
|
+
}
|
|
1516
|
+
})(n, a)}:${i || ""}:t:0`;
|
|
1517
|
+
}
|
|
1518
|
+
case _.WITHDRAW: {
|
|
1519
|
+
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: u } = t, y = n === "ETH" && a !== "ETH" ? `${a}-${i.slice(-3)}` : i, d = !u && p ? `:${p}` : "";
|
|
1520
|
+
return `${e}:${n}${u ? "/" : "."}${y}:${r}${d}`;
|
|
1521
|
+
}
|
|
1522
|
+
case _.OPEN_LOAN:
|
|
1523
|
+
case _.CLOSE_LOAN: {
|
|
1524
|
+
const { asset: n, address: a } = t;
|
|
1525
|
+
return `${e}:${n}:${a}`;
|
|
1526
|
+
}
|
|
1527
|
+
default:
|
|
1528
|
+
return "";
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
function ia(e) {
|
|
1532
|
+
if (e < 0)
|
|
1533
|
+
throw new Error("Invalid number of year");
|
|
1534
|
+
return 10 + e;
|
|
1535
|
+
}
|
|
1536
|
+
function sa(e) {
|
|
1537
|
+
if (e.length > 30)
|
|
1538
|
+
return !1;
|
|
1539
|
+
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1540
|
+
return !!e.match(t);
|
|
1541
|
+
}
|
|
1542
|
+
function ra([e, t, n, a, i]) {
|
|
1543
|
+
return `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`;
|
|
1544
|
+
}
|
|
1545
|
+
const De = [...Object.values(s), "TERRA"];
|
|
1546
|
+
function un(e = "") {
|
|
1490
1547
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1491
|
-
if (
|
|
1548
|
+
if (De.includes(n))
|
|
1492
1549
|
return !0;
|
|
1493
1550
|
const [a] = t.split("/");
|
|
1494
|
-
if (
|
|
1551
|
+
if (De.includes(a))
|
|
1495
1552
|
return !0;
|
|
1496
1553
|
throw new Error(
|
|
1497
1554
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1498
1555
|
);
|
|
1499
1556
|
}
|
|
1500
|
-
const
|
|
1501
|
-
function
|
|
1557
|
+
const J = 8, F = (e) => 10n ** BigInt(e), j = (e) => Math.log10(parseFloat(e.toString()));
|
|
1558
|
+
function me({
|
|
1502
1559
|
value: e,
|
|
1503
|
-
bigIntDecimal: t =
|
|
1504
|
-
decimal: n =
|
|
1560
|
+
bigIntDecimal: t = J,
|
|
1561
|
+
decimal: n = J
|
|
1505
1562
|
}) {
|
|
1506
1563
|
if (n === 0)
|
|
1507
1564
|
return e.toString();
|
|
@@ -1516,17 +1573,17 @@ function re({
|
|
|
1516
1573
|
""
|
|
1517
1574
|
);
|
|
1518
1575
|
}
|
|
1519
|
-
var
|
|
1520
|
-
const
|
|
1576
|
+
var W, G, H, $, Ee, ze, ie, _e, pe, Re;
|
|
1577
|
+
const yn = class et {
|
|
1521
1578
|
constructor(t) {
|
|
1522
|
-
|
|
1523
|
-
const n =
|
|
1524
|
-
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier :
|
|
1579
|
+
q(this, W), q(this, H), q(this, Ee), q(this, ie), q(this, pe), C(this, "decimalMultiplier", 10n ** 8n), C(this, "bigIntValue", 0n), C(this, "decimal");
|
|
1580
|
+
const n = Se(t), a = typeof t == "object";
|
|
1581
|
+
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : F(Math.max(nt(ue(n)), this.decimal || 0)), w(this, Ee, ze).call(this, n);
|
|
1525
1582
|
}
|
|
1526
1583
|
static fromBigInt(t, n) {
|
|
1527
|
-
return new
|
|
1584
|
+
return new et({
|
|
1528
1585
|
decimal: n,
|
|
1529
|
-
value:
|
|
1586
|
+
value: me({ value: t, bigIntDecimal: n, decimal: n })
|
|
1530
1587
|
});
|
|
1531
1588
|
}
|
|
1532
1589
|
static shiftDecimals({
|
|
@@ -1535,7 +1592,7 @@ const Yt = class $e {
|
|
|
1535
1592
|
to: a
|
|
1536
1593
|
}) {
|
|
1537
1594
|
return this.fromBigInt(
|
|
1538
|
-
t.getBaseValue("bigint") *
|
|
1595
|
+
t.getBaseValue("bigint") * F(a) / F(n),
|
|
1539
1596
|
a
|
|
1540
1597
|
);
|
|
1541
1598
|
}
|
|
@@ -1543,37 +1600,37 @@ const Yt = class $e {
|
|
|
1543
1600
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1544
1601
|
}
|
|
1545
1602
|
add(...t) {
|
|
1546
|
-
return
|
|
1603
|
+
return w(this, W, G).call(this, "add", ...t);
|
|
1547
1604
|
}
|
|
1548
1605
|
sub(...t) {
|
|
1549
|
-
return
|
|
1606
|
+
return w(this, W, G).call(this, "sub", ...t);
|
|
1550
1607
|
}
|
|
1551
1608
|
mul(...t) {
|
|
1552
|
-
return
|
|
1609
|
+
return w(this, W, G).call(this, "mul", ...t);
|
|
1553
1610
|
}
|
|
1554
1611
|
div(...t) {
|
|
1555
|
-
return
|
|
1612
|
+
return w(this, W, G).call(this, "div", ...t);
|
|
1556
1613
|
}
|
|
1557
1614
|
gt(t) {
|
|
1558
|
-
return
|
|
1615
|
+
return w(this, H, $).call(this, "gt", t);
|
|
1559
1616
|
}
|
|
1560
1617
|
gte(t) {
|
|
1561
|
-
return
|
|
1618
|
+
return w(this, H, $).call(this, "gte", t);
|
|
1562
1619
|
}
|
|
1563
1620
|
lt(t) {
|
|
1564
|
-
return
|
|
1621
|
+
return w(this, H, $).call(this, "lt", t);
|
|
1565
1622
|
}
|
|
1566
1623
|
lte(t) {
|
|
1567
|
-
return
|
|
1624
|
+
return w(this, H, $).call(this, "lte", t);
|
|
1568
1625
|
}
|
|
1569
1626
|
eqValue(t) {
|
|
1570
|
-
return
|
|
1627
|
+
return w(this, H, $).call(this, "eqValue", t);
|
|
1571
1628
|
}
|
|
1572
1629
|
// @ts-expect-error False positive
|
|
1573
1630
|
getValue(t) {
|
|
1574
1631
|
const n = this.formatBigIntToSafeValue(
|
|
1575
1632
|
this.bigIntValue,
|
|
1576
|
-
this.decimal ||
|
|
1633
|
+
this.decimal || j(this.decimalMultiplier)
|
|
1577
1634
|
);
|
|
1578
1635
|
switch (t) {
|
|
1579
1636
|
case "number":
|
|
@@ -1586,7 +1643,7 @@ const Yt = class $e {
|
|
|
1586
1643
|
}
|
|
1587
1644
|
// @ts-expect-error
|
|
1588
1645
|
getBaseValue(t) {
|
|
1589
|
-
const n = this.decimalMultiplier /
|
|
1646
|
+
const n = this.decimalMultiplier / F(this.decimal || h.THOR), a = this.bigIntValue / n;
|
|
1590
1647
|
switch (t) {
|
|
1591
1648
|
case "number":
|
|
1592
1649
|
return Number(a);
|
|
@@ -1599,8 +1656,8 @@ const Yt = class $e {
|
|
|
1599
1656
|
getBigIntValue(t, n) {
|
|
1600
1657
|
if (!n && typeof t == "object")
|
|
1601
1658
|
return t.bigIntValue;
|
|
1602
|
-
const a =
|
|
1603
|
-
return i === "0" || i === "undefined" ? 0n :
|
|
1659
|
+
const a = Se(t), i = ue(a);
|
|
1660
|
+
return i === "0" || i === "undefined" ? 0n : w(this, pe, Re).call(this, i, n);
|
|
1604
1661
|
}
|
|
1605
1662
|
toSignificant(t = 6) {
|
|
1606
1663
|
const [n, a] = this.getValue("string").split("."), i = n || "", r = a || "";
|
|
@@ -1646,9 +1703,9 @@ const Yt = class $e {
|
|
|
1646
1703
|
return `${n === "start" ? t : ""}${o}${n === "end" ? t : ""}`;
|
|
1647
1704
|
}
|
|
1648
1705
|
formatBigIntToSafeValue(t, n) {
|
|
1649
|
-
const a = n || this.decimal ||
|
|
1706
|
+
const a = n || this.decimal || J, i = Math.max(
|
|
1650
1707
|
a,
|
|
1651
|
-
|
|
1708
|
+
j(this.decimalMultiplier)
|
|
1652
1709
|
), r = t < 0n, p = t.toString().substring(r ? 1 : 0), u = i - (p.length - 1), y = u > 0 ? "0".repeat(u) + p : p, d = y.length - i;
|
|
1653
1710
|
let o = y.slice(-i);
|
|
1654
1711
|
return parseInt(o[a]) >= 5 ? o = `${o.substring(0, a - 1)}${(parseInt(o[a - 1]) + 1).toString()}` : o = o.substring(0, a), `${r ? "-" : ""}${y.slice(
|
|
@@ -1657,8 +1714,8 @@ const Yt = class $e {
|
|
|
1657
1714
|
)}.${o}`.replace(/\.?0*$/, "");
|
|
1658
1715
|
}
|
|
1659
1716
|
};
|
|
1660
|
-
|
|
1661
|
-
const n =
|
|
1717
|
+
W = /* @__PURE__ */ new WeakSet(), G = function(e, ...t) {
|
|
1718
|
+
const n = w(this, ie, _e).call(this, this, ...t), a = Math.max(n, j(this.decimalMultiplier)), i = F(a), r = t.reduce(
|
|
1662
1719
|
(u, y) => {
|
|
1663
1720
|
const d = this.getBigIntValue(y, a);
|
|
1664
1721
|
switch (e) {
|
|
@@ -1679,19 +1736,19 @@ H = /* @__PURE__ */ new WeakSet(), U = function(e, ...t) {
|
|
|
1679
1736
|
},
|
|
1680
1737
|
//normalize is to precision multiplier base
|
|
1681
1738
|
this.bigIntValue * i / this.decimalMultiplier
|
|
1682
|
-
), p =
|
|
1739
|
+
), p = me({
|
|
1683
1740
|
bigIntDecimal: a,
|
|
1684
1741
|
decimal: a,
|
|
1685
1742
|
value: r
|
|
1686
1743
|
});
|
|
1687
1744
|
return new this.constructor({
|
|
1688
|
-
decimalMultiplier:
|
|
1745
|
+
decimalMultiplier: F(a),
|
|
1689
1746
|
decimal: this.decimal,
|
|
1690
1747
|
value: p,
|
|
1691
1748
|
identifier: this.toString()
|
|
1692
1749
|
});
|
|
1693
|
-
},
|
|
1694
|
-
const n =
|
|
1750
|
+
}, H = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
1751
|
+
const n = w(this, ie, _e).call(this, this, ...t), a = this.getBigIntValue(t[0], n), i = this.getBigIntValue(this, n);
|
|
1695
1752
|
switch (e) {
|
|
1696
1753
|
case "gt":
|
|
1697
1754
|
return i > a;
|
|
@@ -1704,35 +1761,35 @@ H = /* @__PURE__ */ new WeakSet(), U = function(e, ...t) {
|
|
|
1704
1761
|
case "eqValue":
|
|
1705
1762
|
return i === a;
|
|
1706
1763
|
}
|
|
1707
|
-
},
|
|
1708
|
-
const t =
|
|
1709
|
-
this.bigIntValue =
|
|
1710
|
-
},
|
|
1711
|
-
const t = e.map((n) => typeof n == "object" ? n.decimal ||
|
|
1712
|
-
return Math.max(...t,
|
|
1713
|
-
},
|
|
1714
|
-
const n = t ?
|
|
1764
|
+
}, Ee = /* @__PURE__ */ new WeakSet(), ze = function(e) {
|
|
1765
|
+
const t = ue(e) || "0";
|
|
1766
|
+
this.bigIntValue = w(this, pe, Re).call(this, t);
|
|
1767
|
+
}, ie = /* @__PURE__ */ new WeakSet(), _e = function(...e) {
|
|
1768
|
+
const t = e.map((n) => typeof n == "object" ? n.decimal || j(n.decimalMultiplier) : nt(ue(n))).filter(Boolean);
|
|
1769
|
+
return Math.max(...t, J);
|
|
1770
|
+
}, pe = /* @__PURE__ */ new WeakSet(), Re = function(e, t) {
|
|
1771
|
+
const n = t ? F(t) : this.decimalMultiplier, a = j(n), [i = "", r = ""] = e.split(".");
|
|
1715
1772
|
return BigInt(`${i}${r.padEnd(a, "0")}`);
|
|
1716
1773
|
};
|
|
1717
|
-
let
|
|
1718
|
-
const
|
|
1774
|
+
let tt = yn;
|
|
1775
|
+
const on = Intl.NumberFormat("fullwide", {
|
|
1719
1776
|
useGrouping: !1,
|
|
1720
1777
|
maximumFractionDigits: 20
|
|
1721
1778
|
});
|
|
1722
|
-
function
|
|
1723
|
-
const t = `${typeof e == "number" ?
|
|
1779
|
+
function ue(e) {
|
|
1780
|
+
const t = `${typeof e == "number" ? on.format(e) : Se(e)}`.replaceAll(",", ".").split(".");
|
|
1724
1781
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1725
1782
|
}
|
|
1726
|
-
function
|
|
1783
|
+
function nt(e) {
|
|
1727
1784
|
var t;
|
|
1728
1785
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1729
|
-
return Math.max(n,
|
|
1786
|
+
return Math.max(n, J);
|
|
1730
1787
|
}
|
|
1731
|
-
function
|
|
1788
|
+
function Se(e) {
|
|
1732
1789
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1733
1790
|
}
|
|
1734
|
-
const
|
|
1735
|
-
class x extends
|
|
1791
|
+
const K = /* @__PURE__ */ new Map();
|
|
1792
|
+
class x extends tt {
|
|
1736
1793
|
constructor({
|
|
1737
1794
|
value: t,
|
|
1738
1795
|
decimal: n,
|
|
@@ -1741,9 +1798,9 @@ class x extends We {
|
|
|
1741
1798
|
symbol: r,
|
|
1742
1799
|
identifier: p
|
|
1743
1800
|
}) {
|
|
1744
|
-
super(typeof t == "object" ? t : { decimal: n, value: t }),
|
|
1745
|
-
const u =
|
|
1746
|
-
this.type =
|
|
1801
|
+
super(typeof t == "object" ? t : { decimal: n, value: t }), C(this, "address"), C(this, "chain"), C(this, "isGasAsset", !1), C(this, "isSynthetic", !1), C(this, "symbol"), C(this, "tax"), C(this, "ticker"), C(this, "type");
|
|
1802
|
+
const u = se(p || `${i}.${r}`);
|
|
1803
|
+
this.type = tn(u), this.tax = a, this.chain = u.chain, this.ticker = u.ticker, this.symbol = u.symbol, this.address = u.address, this.isSynthetic = u.isSynthetic, this.isGasAsset = u.isGasAsset;
|
|
1747
1804
|
}
|
|
1748
1805
|
toString() {
|
|
1749
1806
|
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
@@ -1755,7 +1812,7 @@ class x extends We {
|
|
|
1755
1812
|
return this.chain === t && this.symbol === n;
|
|
1756
1813
|
}
|
|
1757
1814
|
chainId() {
|
|
1758
|
-
return
|
|
1815
|
+
return Ue[this.chain];
|
|
1759
1816
|
}
|
|
1760
1817
|
// THOR.RUNE
|
|
1761
1818
|
// THOR.ETH.ETH
|
|
@@ -1765,42 +1822,42 @@ class x extends We {
|
|
|
1765
1822
|
if (!a || !i)
|
|
1766
1823
|
throw new Error("Invalid asset url");
|
|
1767
1824
|
const p = a === s.THORChain && r ? `${a}.${i}/${r}` : t;
|
|
1768
|
-
return
|
|
1825
|
+
return Ae(p, n);
|
|
1769
1826
|
}
|
|
1770
1827
|
static fromString(t, n = 0) {
|
|
1771
|
-
return
|
|
1828
|
+
return Ae(t, n);
|
|
1772
1829
|
}
|
|
1773
1830
|
static fromIdentifier(t, n = 0) {
|
|
1774
|
-
return
|
|
1831
|
+
return Ae(t, n);
|
|
1775
1832
|
}
|
|
1776
1833
|
static fromStringSync(t, n = 0) {
|
|
1777
|
-
const { chain: a, isSynthetic: i } =
|
|
1834
|
+
const { chain: a, isSynthetic: i } = se(t), r = K.get(t.toUpperCase());
|
|
1778
1835
|
if (i)
|
|
1779
|
-
return
|
|
1836
|
+
return xe(t, n);
|
|
1780
1837
|
const { tax: p, decimal: u, identifier: y } = r || {
|
|
1781
|
-
decimal:
|
|
1838
|
+
decimal: h[a],
|
|
1782
1839
|
identifier: t
|
|
1783
1840
|
};
|
|
1784
1841
|
return new x({
|
|
1785
1842
|
tax: p,
|
|
1786
|
-
value:
|
|
1843
|
+
value: Y(n, u),
|
|
1787
1844
|
identifier: i ? t : y,
|
|
1788
1845
|
decimal: i ? 8 : u
|
|
1789
1846
|
});
|
|
1790
1847
|
}
|
|
1791
1848
|
static fromIdentifierSync(t, n = 0) {
|
|
1792
|
-
const { chain: a, isSynthetic: i } =
|
|
1849
|
+
const { chain: a, isSynthetic: i } = se(t), r = K.get(t);
|
|
1793
1850
|
if (i)
|
|
1794
|
-
return
|
|
1851
|
+
return xe(t, n);
|
|
1795
1852
|
const { tax: p, decimal: u, identifier: y } = r || {
|
|
1796
|
-
decimal:
|
|
1853
|
+
decimal: h[a],
|
|
1797
1854
|
identifier: t
|
|
1798
1855
|
};
|
|
1799
|
-
return new x({ tax: p, decimal: u, identifier: y, value:
|
|
1856
|
+
return new x({ tax: p, decimal: u, identifier: y, value: Y(n, u) });
|
|
1800
1857
|
}
|
|
1801
1858
|
static fromChainOrSignature(t, n = 0) {
|
|
1802
|
-
const { decimal: a, identifier: i } =
|
|
1803
|
-
return new x({ value:
|
|
1859
|
+
const { decimal: a, identifier: i } = en(t);
|
|
1860
|
+
return new x({ value: Y(n, a), decimal: a, identifier: i });
|
|
1804
1861
|
}
|
|
1805
1862
|
static loadStaticAssets() {
|
|
1806
1863
|
return new Promise(
|
|
@@ -1810,9 +1867,9 @@ class x extends We {
|
|
|
1810
1867
|
Object.values(a).forEach((i) => {
|
|
1811
1868
|
var r;
|
|
1812
1869
|
(r = i == null ? void 0 : i.tokens) == null || r.forEach(({ identifier: p, chain: u, ...y }) => {
|
|
1813
|
-
|
|
1870
|
+
K.set(p.toUpperCase(), {
|
|
1814
1871
|
identifier: p,
|
|
1815
|
-
decimal: "decimals" in y ? y.decimals :
|
|
1872
|
+
decimal: "decimals" in y ? y.decimals : h[u]
|
|
1816
1873
|
});
|
|
1817
1874
|
});
|
|
1818
1875
|
}), t({ ok: !0 });
|
|
@@ -1827,7 +1884,7 @@ class x extends We {
|
|
|
1827
1884
|
);
|
|
1828
1885
|
}
|
|
1829
1886
|
}
|
|
1830
|
-
function
|
|
1887
|
+
function fe(e) {
|
|
1831
1888
|
const t = x.fromChainOrSignature(e);
|
|
1832
1889
|
switch (e) {
|
|
1833
1890
|
case s.Bitcoin:
|
|
@@ -1848,25 +1905,25 @@ function de(e) {
|
|
|
1848
1905
|
return t.set(1e-8);
|
|
1849
1906
|
}
|
|
1850
1907
|
}
|
|
1851
|
-
async function
|
|
1852
|
-
|
|
1853
|
-
const n =
|
|
1854
|
-
return n ||
|
|
1908
|
+
async function Ae(e, t = 0) {
|
|
1909
|
+
un(e);
|
|
1910
|
+
const n = K.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await Zt(se(e));
|
|
1911
|
+
return n || K.set(e.toUpperCase(), { identifier: e, decimal: a }), new x({ decimal: a, value: Y(t, a), identifier: e });
|
|
1855
1912
|
}
|
|
1856
|
-
function
|
|
1913
|
+
function xe(e, t = 0) {
|
|
1857
1914
|
const [n, a] = e.split(".")[0].toUpperCase() === s.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1858
1915
|
if (!n || !a)
|
|
1859
1916
|
throw new Error("Invalid asset identifier");
|
|
1860
1917
|
return new x({
|
|
1861
1918
|
decimal: 8,
|
|
1862
|
-
value:
|
|
1919
|
+
value: Y(t, 8),
|
|
1863
1920
|
identifier: `${s.THORChain}.${n}/${a}`
|
|
1864
1921
|
});
|
|
1865
1922
|
}
|
|
1866
|
-
function
|
|
1867
|
-
return typeof e == "bigint" ?
|
|
1923
|
+
function Y(e, t) {
|
|
1924
|
+
return typeof e == "bigint" ? me({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1868
1925
|
}
|
|
1869
|
-
function
|
|
1926
|
+
function se(e) {
|
|
1870
1927
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".")[0].toUpperCase() === s.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1871
1928
|
if (t && (!n || !a))
|
|
1872
1929
|
throw new Error("Invalid asset identifier");
|
|
@@ -1874,13 +1931,13 @@ function ee(e) {
|
|
|
1874
1931
|
return {
|
|
1875
1932
|
address: y == null ? void 0 : y.toLowerCase(),
|
|
1876
1933
|
chain: r,
|
|
1877
|
-
isGasAsset:
|
|
1934
|
+
isGasAsset: Ze({ chain: r, symbol: p }),
|
|
1878
1935
|
isSynthetic: t,
|
|
1879
1936
|
symbol: (t ? `${n}/` : "") + (y ? `${u}-${(y == null ? void 0 : y.toLowerCase()) ?? ""}` : p),
|
|
1880
1937
|
ticker: u
|
|
1881
1938
|
};
|
|
1882
1939
|
}
|
|
1883
|
-
const
|
|
1940
|
+
const dn = {
|
|
1884
1941
|
/**
|
|
1885
1942
|
* Core
|
|
1886
1943
|
*/
|
|
@@ -1939,23 +1996,23 @@ const Jt = {
|
|
|
1939
1996
|
*/
|
|
1940
1997
|
helpers_number_different_decimals: 99101
|
|
1941
1998
|
};
|
|
1942
|
-
class
|
|
1999
|
+
class T extends Error {
|
|
1943
2000
|
constructor(t, n) {
|
|
1944
|
-
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code:
|
|
2001
|
+
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: dn[t], message: t } }), Object.setPrototypeOf(this, T.prototype);
|
|
1945
2002
|
}
|
|
1946
2003
|
}
|
|
1947
|
-
class k extends
|
|
2004
|
+
class k extends tt {
|
|
1948
2005
|
eq(t) {
|
|
1949
2006
|
return this.eqValue(t);
|
|
1950
2007
|
}
|
|
1951
2008
|
static fromBigInt(t, n) {
|
|
1952
2009
|
return new k({
|
|
1953
2010
|
decimal: n,
|
|
1954
|
-
value:
|
|
2011
|
+
value: me({ value: t, bigIntDecimal: n, decimal: n })
|
|
1955
2012
|
});
|
|
1956
2013
|
}
|
|
1957
2014
|
}
|
|
1958
|
-
const
|
|
2015
|
+
const ln = [
|
|
1959
2016
|
{
|
|
1960
2017
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1961
2018
|
stateMutability: "nonpayable",
|
|
@@ -2046,7 +2103,7 @@ const Zt = [
|
|
|
2046
2103
|
type: "function"
|
|
2047
2104
|
},
|
|
2048
2105
|
{ stateMutability: "payable", type: "receive" }
|
|
2049
|
-
],
|
|
2106
|
+
], mn = [
|
|
2050
2107
|
{
|
|
2051
2108
|
inputs: [
|
|
2052
2109
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2190,7 +2247,7 @@ const Zt = [
|
|
|
2190
2247
|
type: "function"
|
|
2191
2248
|
},
|
|
2192
2249
|
{ stateMutability: "payable", type: "receive" }
|
|
2193
|
-
],
|
|
2250
|
+
], Tn = [
|
|
2194
2251
|
{
|
|
2195
2252
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2196
2253
|
stateMutability: "nonpayable",
|
|
@@ -2295,7 +2352,7 @@ const Zt = [
|
|
|
2295
2352
|
type: "function"
|
|
2296
2353
|
},
|
|
2297
2354
|
{ stateMutability: "payable", type: "receive" }
|
|
2298
|
-
],
|
|
2355
|
+
], cn = [
|
|
2299
2356
|
{
|
|
2300
2357
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2301
2358
|
stateMutability: "nonpayable",
|
|
@@ -2386,7 +2443,7 @@ const Zt = [
|
|
|
2386
2443
|
type: "function"
|
|
2387
2444
|
},
|
|
2388
2445
|
{ stateMutability: "payable", type: "receive" }
|
|
2389
|
-
],
|
|
2446
|
+
], bn = [
|
|
2390
2447
|
{
|
|
2391
2448
|
inputs: [
|
|
2392
2449
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2530,7 +2587,7 @@ const Zt = [
|
|
|
2530
2587
|
type: "function"
|
|
2531
2588
|
},
|
|
2532
2589
|
{ stateMutability: "payable", type: "receive" }
|
|
2533
|
-
],
|
|
2590
|
+
], _n = [
|
|
2534
2591
|
{
|
|
2535
2592
|
inputs: [
|
|
2536
2593
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2649,7 +2706,7 @@ const Zt = [
|
|
|
2649
2706
|
type: "function"
|
|
2650
2707
|
},
|
|
2651
2708
|
{ stateMutability: "payable", type: "receive" }
|
|
2652
|
-
],
|
|
2709
|
+
], Pe = [
|
|
2653
2710
|
{
|
|
2654
2711
|
inputs: [{ internalType: "address", name: "_WETH", type: "address" }],
|
|
2655
2712
|
stateMutability: "nonpayable",
|
|
@@ -3050,7 +3107,7 @@ const Zt = [
|
|
|
3050
3107
|
type: "function"
|
|
3051
3108
|
},
|
|
3052
3109
|
{ stateMutability: "payable", type: "receive" }
|
|
3053
|
-
],
|
|
3110
|
+
], ke = [
|
|
3054
3111
|
{
|
|
3055
3112
|
inputs: [
|
|
3056
3113
|
{
|
|
@@ -5237,7 +5294,7 @@ const Zt = [
|
|
|
5237
5294
|
stateMutability: "payable",
|
|
5238
5295
|
type: "receive"
|
|
5239
5296
|
}
|
|
5240
|
-
],
|
|
5297
|
+
], Be = [
|
|
5241
5298
|
{
|
|
5242
5299
|
inputs: [
|
|
5243
5300
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -5576,7 +5633,7 @@ const Zt = [
|
|
|
5576
5633
|
type: "function"
|
|
5577
5634
|
},
|
|
5578
5635
|
{ stateMutability: "payable", type: "receive" }
|
|
5579
|
-
],
|
|
5636
|
+
], fn = [
|
|
5580
5637
|
{
|
|
5581
5638
|
inputs: [
|
|
5582
5639
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -5915,7 +5972,7 @@ const Zt = [
|
|
|
5915
5972
|
type: "function"
|
|
5916
5973
|
},
|
|
5917
5974
|
{ stateMutability: "payable", type: "receive" }
|
|
5918
|
-
],
|
|
5975
|
+
], An = [
|
|
5919
5976
|
{
|
|
5920
5977
|
inputs: [
|
|
5921
5978
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6254,7 +6311,7 @@ const Zt = [
|
|
|
6254
6311
|
type: "function"
|
|
6255
6312
|
},
|
|
6256
6313
|
{ stateMutability: "payable", type: "receive" }
|
|
6257
|
-
],
|
|
6314
|
+
], hn = [
|
|
6258
6315
|
{
|
|
6259
6316
|
inputs: [
|
|
6260
6317
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6593,7 +6650,7 @@ const Zt = [
|
|
|
6593
6650
|
type: "function"
|
|
6594
6651
|
},
|
|
6595
6652
|
{ stateMutability: "payable", type: "receive" }
|
|
6596
|
-
],
|
|
6653
|
+
], En = [
|
|
6597
6654
|
{
|
|
6598
6655
|
inputs: [
|
|
6599
6656
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6932,7 +6989,7 @@ const Zt = [
|
|
|
6932
6989
|
type: "function"
|
|
6933
6990
|
},
|
|
6934
6991
|
{ stateMutability: "payable", type: "receive" }
|
|
6935
|
-
],
|
|
6992
|
+
], Rn = [
|
|
6936
6993
|
{
|
|
6937
6994
|
inputs: [
|
|
6938
6995
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -7185,7 +7242,7 @@ const Zt = [
|
|
|
7185
7242
|
type: "function"
|
|
7186
7243
|
},
|
|
7187
7244
|
{ stateMutability: "payable", type: "receive" }
|
|
7188
|
-
],
|
|
7245
|
+
], Sn = [
|
|
7189
7246
|
{
|
|
7190
7247
|
inputs: [
|
|
7191
7248
|
{ internalType: "address", name: "_weth", type: "address" },
|
|
@@ -7355,23 +7412,23 @@ const Zt = [
|
|
|
7355
7412
|
type: "function"
|
|
7356
7413
|
},
|
|
7357
7414
|
{ stateMutability: "payable", type: "receive" }
|
|
7358
|
-
],
|
|
7415
|
+
], wn = {
|
|
7359
7416
|
// AVAX
|
|
7360
|
-
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]:
|
|
7361
|
-
["0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9".toLowerCase()]:
|
|
7362
|
-
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]:
|
|
7363
|
-
["0x1111111254fb6c44bAC0beD2854e76F90643097d".toLowerCase()]:
|
|
7364
|
-
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]:
|
|
7417
|
+
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]: fn,
|
|
7418
|
+
["0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9".toLowerCase()]: Sn,
|
|
7419
|
+
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]: hn,
|
|
7420
|
+
["0x1111111254fb6c44bAC0beD2854e76F90643097d".toLowerCase()]: ke,
|
|
7421
|
+
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: Pe,
|
|
7365
7422
|
// BSC
|
|
7366
|
-
["0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase()]:
|
|
7423
|
+
["0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase()]: Be,
|
|
7367
7424
|
// ETH
|
|
7368
|
-
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]:
|
|
7369
|
-
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]:
|
|
7370
|
-
["0xEfF92A263d31888d860bD50809A8D171709b7b1c".toLowerCase()]:
|
|
7371
|
-
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]:
|
|
7372
|
-
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]:
|
|
7373
|
-
["0x1111111254fb6c44bac0bed2854e76f90643097d".toLowerCase()]:
|
|
7374
|
-
},
|
|
7425
|
+
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: Pe,
|
|
7426
|
+
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]: An,
|
|
7427
|
+
["0xEfF92A263d31888d860bD50809A8D171709b7b1c".toLowerCase()]: Be,
|
|
7428
|
+
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]: En,
|
|
7429
|
+
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]: Rn,
|
|
7430
|
+
["0x1111111254fb6c44bac0bed2854e76f90643097d".toLowerCase()]: ke
|
|
7431
|
+
}, On = [
|
|
7375
7432
|
{
|
|
7376
7433
|
inputs: [
|
|
7377
7434
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7490,7 +7547,7 @@ const Zt = [
|
|
|
7490
7547
|
type: "function"
|
|
7491
7548
|
},
|
|
7492
7549
|
{ stateMutability: "payable", type: "receive" }
|
|
7493
|
-
],
|
|
7550
|
+
], Mn = [
|
|
7494
7551
|
{
|
|
7495
7552
|
inputs: [
|
|
7496
7553
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7609,7 +7666,7 @@ const Zt = [
|
|
|
7609
7666
|
type: "function"
|
|
7610
7667
|
},
|
|
7611
7668
|
{ stateMutability: "payable", type: "receive" }
|
|
7612
|
-
],
|
|
7669
|
+
], In = [
|
|
7613
7670
|
{
|
|
7614
7671
|
inputs: [
|
|
7615
7672
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7728,7 +7785,7 @@ const Zt = [
|
|
|
7728
7785
|
type: "function"
|
|
7729
7786
|
},
|
|
7730
7787
|
{ stateMutability: "payable", type: "receive" }
|
|
7731
|
-
],
|
|
7788
|
+
], gn = [
|
|
7732
7789
|
{
|
|
7733
7790
|
inputs: [
|
|
7734
7791
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7855,7 +7912,7 @@ const Zt = [
|
|
|
7855
7912
|
type: "function"
|
|
7856
7913
|
},
|
|
7857
7914
|
{ stateMutability: "payable", type: "receive" }
|
|
7858
|
-
],
|
|
7915
|
+
], Cn = [
|
|
7859
7916
|
{
|
|
7860
7917
|
inputs: [
|
|
7861
7918
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7982,7 +8039,7 @@ const Zt = [
|
|
|
7982
8039
|
type: "function"
|
|
7983
8040
|
},
|
|
7984
8041
|
{ stateMutability: "payable", type: "receive" }
|
|
7985
|
-
],
|
|
8042
|
+
], vn = [
|
|
7986
8043
|
{
|
|
7987
8044
|
inputs: [
|
|
7988
8045
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8109,7 +8166,7 @@ const Zt = [
|
|
|
8109
8166
|
type: "function"
|
|
8110
8167
|
},
|
|
8111
8168
|
{ stateMutability: "payable", type: "receive" }
|
|
8112
|
-
],
|
|
8169
|
+
], Nn = [
|
|
8113
8170
|
{
|
|
8114
8171
|
inputs: [
|
|
8115
8172
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8236,7 +8293,7 @@ const Zt = [
|
|
|
8236
8293
|
type: "function"
|
|
8237
8294
|
},
|
|
8238
8295
|
{ stateMutability: "payable", type: "receive" }
|
|
8239
|
-
],
|
|
8296
|
+
], Dn = [
|
|
8240
8297
|
{
|
|
8241
8298
|
inputs: [
|
|
8242
8299
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8363,28 +8420,28 @@ const Zt = [
|
|
|
8363
8420
|
type: "function"
|
|
8364
8421
|
},
|
|
8365
8422
|
{ stateMutability: "payable", type: "receive" }
|
|
8366
|
-
],
|
|
8367
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
8368
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
8369
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
8370
|
-
},
|
|
8371
|
-
...
|
|
8372
|
-
...
|
|
8423
|
+
], at = {
|
|
8424
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: ln,
|
|
8425
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Tn,
|
|
8426
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: cn
|
|
8427
|
+
}, xn = {
|
|
8428
|
+
...wn,
|
|
8429
|
+
...at,
|
|
8373
8430
|
// AVAX
|
|
8374
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
8375
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
8376
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
8431
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: _n,
|
|
8432
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: mn,
|
|
8433
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: Mn,
|
|
8377
8434
|
// BSC
|
|
8378
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
8435
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: bn,
|
|
8379
8436
|
// ETH
|
|
8380
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
8381
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
8382
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
8383
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
8384
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
8385
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
8386
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
8387
|
-
},
|
|
8437
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: On,
|
|
8438
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: In,
|
|
8439
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: gn,
|
|
8440
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: Cn,
|
|
8441
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: vn,
|
|
8442
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: Nn,
|
|
8443
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: Dn
|
|
8444
|
+
}, Pn = ({
|
|
8388
8445
|
streamSwap: e,
|
|
8389
8446
|
contractAddress: t,
|
|
8390
8447
|
recipient: n,
|
|
@@ -8397,36 +8454,36 @@ const Zt = [
|
|
|
8397
8454
|
memo: y,
|
|
8398
8455
|
router: d,
|
|
8399
8456
|
memoStreamingSwap: o,
|
|
8400
|
-
tcMemo:
|
|
8457
|
+
tcMemo: c,
|
|
8401
8458
|
tcRouter: f,
|
|
8402
|
-
tcVault:
|
|
8403
|
-
vault:
|
|
8404
|
-
token:
|
|
8459
|
+
tcVault: E,
|
|
8460
|
+
vault: R,
|
|
8461
|
+
token: S
|
|
8405
8462
|
}
|
|
8406
8463
|
}) => {
|
|
8407
|
-
const
|
|
8408
|
-
if (
|
|
8464
|
+
const M = !!at[t.toLowerCase()];
|
|
8465
|
+
if (M && !d)
|
|
8409
8466
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
8410
|
-
const
|
|
8411
|
-
if (!
|
|
8467
|
+
const I = c || y, B = e && o || I;
|
|
8468
|
+
if (!E && !R)
|
|
8412
8469
|
throw new Error("TC Vault is required on calldata");
|
|
8413
8470
|
if (!f && !d)
|
|
8414
8471
|
throw new Error("TC Router is required on calldata");
|
|
8415
|
-
if (!
|
|
8472
|
+
if (!B)
|
|
8416
8473
|
throw new Error("TC Memo is required on calldata");
|
|
8417
|
-
if (!
|
|
8474
|
+
if (!S)
|
|
8418
8475
|
throw new Error("Token is required on calldata");
|
|
8419
|
-
const
|
|
8476
|
+
const Te = [
|
|
8420
8477
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
8421
8478
|
a(f || d),
|
|
8422
|
-
a(
|
|
8423
|
-
|
|
8424
|
-
a(
|
|
8479
|
+
a(E || R),
|
|
8480
|
+
B.replace("{recipientAddress}", n),
|
|
8481
|
+
a(S),
|
|
8425
8482
|
i
|
|
8426
|
-
],
|
|
8427
|
-
return [...
|
|
8428
|
-
},
|
|
8429
|
-
const n =
|
|
8483
|
+
], it = M ? [a(d), p, u] : [r, u];
|
|
8484
|
+
return [...Te, ...it];
|
|
8485
|
+
}, kn = ({ chain: e, txHash: t }) => {
|
|
8486
|
+
const n = We[e];
|
|
8430
8487
|
switch (e) {
|
|
8431
8488
|
case s.Binance:
|
|
8432
8489
|
case s.Maya:
|
|
@@ -8450,8 +8507,8 @@ const Zt = [
|
|
|
8450
8507
|
default:
|
|
8451
8508
|
throw new Error(`Unsupported chain: ${e}`);
|
|
8452
8509
|
}
|
|
8453
|
-
},
|
|
8454
|
-
const n =
|
|
8510
|
+
}, Bn = ({ chain: e, address: t }) => {
|
|
8511
|
+
const n = We[e];
|
|
8455
8512
|
switch (e) {
|
|
8456
8513
|
case s.Arbitrum:
|
|
8457
8514
|
case s.Avalanche:
|
|
@@ -8473,16 +8530,16 @@ const Zt = [
|
|
|
8473
8530
|
default:
|
|
8474
8531
|
throw new Error(`Unsupported chain: ${e}`);
|
|
8475
8532
|
}
|
|
8476
|
-
},
|
|
8477
|
-
const t = e ?
|
|
8478
|
-
return
|
|
8479
|
-
},
|
|
8480
|
-
const t = e ?
|
|
8481
|
-
return
|
|
8482
|
-
},
|
|
8533
|
+
}, Ln = (e) => {
|
|
8534
|
+
const t = e ? Q.ThornodeStagenet : Q.ThornodeMainnet;
|
|
8535
|
+
return g.get(`${t}/thorchain/inbound_addresses`);
|
|
8536
|
+
}, Vn = (e) => {
|
|
8537
|
+
const t = e ? Q.ThornodeStagenet : Q.ThornodeMainnet;
|
|
8538
|
+
return g.get(`${t}/thorchain/mimir`);
|
|
8539
|
+
}, Le = () => Object.values(s).reduce(
|
|
8483
8540
|
(e, t) => (e[t] = null, e),
|
|
8484
8541
|
{}
|
|
8485
|
-
),
|
|
8542
|
+
), Hn = async ({ chain: e, address: t }) => {
|
|
8486
8543
|
if (!t)
|
|
8487
8544
|
return !1;
|
|
8488
8545
|
switch (e) {
|
|
@@ -8492,94 +8549,94 @@ const Zt = [
|
|
|
8492
8549
|
return !0;
|
|
8493
8550
|
}
|
|
8494
8551
|
};
|
|
8495
|
-
var
|
|
8496
|
-
class
|
|
8552
|
+
var U, ye, Z, v, z, ee;
|
|
8553
|
+
class pa {
|
|
8497
8554
|
constructor({ stagenet: t } = {}) {
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8555
|
+
b(this, "connectedChains", Le());
|
|
8556
|
+
b(this, "connectedWallets", Le());
|
|
8557
|
+
b(this, "stagenet", !1);
|
|
8558
|
+
b(this, "getAddress", (t) => {
|
|
8502
8559
|
var n;
|
|
8503
8560
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
8504
8561
|
});
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8562
|
+
b(this, "getExplorerTxUrl", (t, n) => kn({ chain: t, txHash: n }));
|
|
8563
|
+
b(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
8564
|
+
b(this, "getExplorerAddressUrl", (t, n) => Bn({ chain: t, address: n }));
|
|
8565
|
+
b(this, "getBalance", async (t, n) => {
|
|
8509
8566
|
const a = await this.getWalletByChain(t, n);
|
|
8510
8567
|
return (a == null ? void 0 : a.balance) || [];
|
|
8511
8568
|
});
|
|
8512
|
-
|
|
8569
|
+
b(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: i }) => {
|
|
8513
8570
|
var u, y;
|
|
8514
8571
|
const {
|
|
8515
8572
|
meta: { quoteMode: r }
|
|
8516
8573
|
// evmTransactionDetails: contractCallParams,
|
|
8517
8574
|
} = a, p = r.startsWith("ERC20-") ? s.Ethereum : r.startsWith("ARC20-") ? s.Avalanche : r.startsWith("BEP20-") ? s.BinanceSmartChain : void 0;
|
|
8518
8575
|
if (!a.complete)
|
|
8519
|
-
throw new
|
|
8576
|
+
throw new T("core_swap_route_not_complete");
|
|
8520
8577
|
try {
|
|
8521
|
-
if (
|
|
8578
|
+
if (Tt.includes(r) && p) {
|
|
8522
8579
|
const d = this.connectedWallets[p];
|
|
8523
8580
|
if (!(d != null && d.sendTransaction))
|
|
8524
|
-
throw new
|
|
8581
|
+
throw new T("core_wallet_connection_not_found");
|
|
8525
8582
|
if (!(t ? (u = a == null ? void 0 : a.streamingSwap) == null ? void 0 : u.transaction : a == null ? void 0 : a.transaction))
|
|
8526
|
-
throw new
|
|
8527
|
-
const { data:
|
|
8528
|
-
data:
|
|
8583
|
+
throw new T("core_swap_route_transaction_not_found");
|
|
8584
|
+
const { data: c, from: f, to: E, value: R } = a.transaction, S = {
|
|
8585
|
+
data: c,
|
|
8529
8586
|
from: f,
|
|
8530
|
-
to:
|
|
8531
|
-
chainId: BigInt(
|
|
8532
|
-
value:
|
|
8587
|
+
to: E.toLowerCase(),
|
|
8588
|
+
chainId: BigInt(Ue[p]),
|
|
8589
|
+
value: R ? BigInt(R) : 0n
|
|
8533
8590
|
};
|
|
8534
|
-
return d.sendTransaction(
|
|
8591
|
+
return d.sendTransaction(S, i);
|
|
8535
8592
|
}
|
|
8536
|
-
if (
|
|
8593
|
+
if (bt.includes(r)) {
|
|
8537
8594
|
if (!a.calldata.fromAsset)
|
|
8538
|
-
throw new
|
|
8595
|
+
throw new T("core_swap_asset_not_recognized");
|
|
8539
8596
|
const d = await x.fromString(a.calldata.fromAsset);
|
|
8540
8597
|
if (!d)
|
|
8541
|
-
throw new
|
|
8542
|
-
const { address: o } = await
|
|
8543
|
-
contract:
|
|
8544
|
-
calldata: { expiration: f, amountIn:
|
|
8545
|
-
} = a,
|
|
8598
|
+
throw new T("core_swap_asset_not_recognized");
|
|
8599
|
+
const { address: o } = await A(this, U).call(this, d.chain), {
|
|
8600
|
+
contract: c,
|
|
8601
|
+
calldata: { expiration: f, amountIn: E, memo: R, memoStreamingSwap: S }
|
|
8602
|
+
} = a, M = d.add(k.fromBigInt(BigInt(E), d.decimal)), I = t && S || R;
|
|
8546
8603
|
return this.deposit({
|
|
8547
8604
|
expiration: f,
|
|
8548
|
-
assetValue:
|
|
8549
|
-
memo:
|
|
8605
|
+
assetValue: M,
|
|
8606
|
+
memo: I,
|
|
8550
8607
|
feeOptionKey: i,
|
|
8551
|
-
router:
|
|
8608
|
+
router: c,
|
|
8552
8609
|
recipient: o
|
|
8553
8610
|
});
|
|
8554
8611
|
}
|
|
8555
|
-
if (
|
|
8612
|
+
if (ct.includes(r) && p) {
|
|
8556
8613
|
const { calldata: d, contract: o } = a;
|
|
8557
8614
|
if (!o)
|
|
8558
|
-
throw new
|
|
8559
|
-
const
|
|
8560
|
-
if (!(
|
|
8561
|
-
throw new
|
|
8562
|
-
const { getProvider:
|
|
8563
|
-
if (!
|
|
8564
|
-
throw new
|
|
8565
|
-
const
|
|
8566
|
-
...
|
|
8615
|
+
throw new T("core_swap_contract_not_found");
|
|
8616
|
+
const c = this.connectedWallets[p], f = this.getAddress(p);
|
|
8617
|
+
if (!(c != null && c.sendTransaction) || !f)
|
|
8618
|
+
throw new T("core_wallet_connection_not_found");
|
|
8619
|
+
const { getProvider: E, toChecksumAddress: R } = await import("@swapkit/toolbox-evm"), S = E(p), M = xn[o.toLowerCase()];
|
|
8620
|
+
if (!M)
|
|
8621
|
+
throw new T("core_swap_contract_not_supported", { contractAddress: o });
|
|
8622
|
+
const B = await (await ((y = c.createContract) == null ? void 0 : y.call(c, o, M, S))).getFunction("swapIn").populateTransaction(
|
|
8623
|
+
...Pn({
|
|
8567
8624
|
streamSwap: t,
|
|
8568
|
-
toChecksumAddress:
|
|
8625
|
+
toChecksumAddress: R,
|
|
8569
8626
|
contractAddress: o,
|
|
8570
8627
|
recipient: n,
|
|
8571
8628
|
calldata: d
|
|
8572
8629
|
}),
|
|
8573
8630
|
{ from: f }
|
|
8574
8631
|
);
|
|
8575
|
-
return
|
|
8632
|
+
return c.sendTransaction(B, i);
|
|
8576
8633
|
}
|
|
8577
|
-
throw new
|
|
8634
|
+
throw new T("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
8578
8635
|
} catch (d) {
|
|
8579
|
-
throw new
|
|
8636
|
+
throw new T("core_swap_transaction_error", d);
|
|
8580
8637
|
}
|
|
8581
8638
|
});
|
|
8582
|
-
|
|
8639
|
+
b(this, "getWalletByChain", async (t, n) => {
|
|
8583
8640
|
var p, u;
|
|
8584
8641
|
const a = this.getAddress(t);
|
|
8585
8642
|
if (!a)
|
|
@@ -8596,34 +8653,34 @@ class Xn {
|
|
|
8596
8653
|
return console.error(y), { address: a, balance: i, walletType: r };
|
|
8597
8654
|
}
|
|
8598
8655
|
});
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8656
|
+
b(this, "approveAssetValue", (t, n) => A(this, Z).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
8657
|
+
b(this, "isAssetValueApproved", (t, n) => A(this, Z).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
8658
|
+
b(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
8602
8659
|
var a, i;
|
|
8603
8660
|
return (i = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : i.call(a, t);
|
|
8604
8661
|
});
|
|
8605
|
-
|
|
8662
|
+
b(this, "transfer", async (t) => {
|
|
8606
8663
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
8607
8664
|
if (!n)
|
|
8608
|
-
throw new
|
|
8665
|
+
throw new T("core_wallet_connection_not_found");
|
|
8609
8666
|
try {
|
|
8610
|
-
return await n.transfer(
|
|
8667
|
+
return await n.transfer(A(this, ee).call(this, t));
|
|
8611
8668
|
} catch (a) {
|
|
8612
|
-
throw new
|
|
8669
|
+
throw new T("core_swap_transaction_error", a);
|
|
8613
8670
|
}
|
|
8614
8671
|
});
|
|
8615
|
-
|
|
8672
|
+
b(this, "deposit", async ({
|
|
8616
8673
|
assetValue: t,
|
|
8617
8674
|
recipient: n,
|
|
8618
8675
|
router: a,
|
|
8619
8676
|
...i
|
|
8620
8677
|
}) => {
|
|
8621
8678
|
const { chain: r, symbol: p, ticker: u } = t, y = this.connectedWallets[r];
|
|
8622
|
-
if (!await
|
|
8623
|
-
throw new
|
|
8679
|
+
if (!await Hn({ address: await (y == null ? void 0 : y.getAddress()), chain: r }))
|
|
8680
|
+
throw new T("core_transaction_invalid_sender_address");
|
|
8624
8681
|
if (!y)
|
|
8625
|
-
throw new
|
|
8626
|
-
const d =
|
|
8682
|
+
throw new T("core_wallet_connection_not_found");
|
|
8683
|
+
const d = A(this, ee).call(this, { assetValue: t, recipient: n, router: a, ...i });
|
|
8627
8684
|
try {
|
|
8628
8685
|
switch (r) {
|
|
8629
8686
|
case s.THORChain: {
|
|
@@ -8633,10 +8690,10 @@ class Xn {
|
|
|
8633
8690
|
case s.Ethereum:
|
|
8634
8691
|
case s.BinanceSmartChain:
|
|
8635
8692
|
case s.Avalanche: {
|
|
8636
|
-
const { getChecksumAddressFromAsset: o } = await import("@swapkit/toolbox-evm"),
|
|
8693
|
+
const { getChecksumAddressFromAsset: o } = await import("@swapkit/toolbox-evm"), c = r === s.Avalanche ? dt : r === s.BinanceSmartChain ? lt : ot;
|
|
8637
8694
|
return await y.call({
|
|
8638
|
-
abi:
|
|
8639
|
-
contractAddress: a || (await
|
|
8695
|
+
abi: c,
|
|
8696
|
+
contractAddress: a || (await A(this, U).call(this, r)).router,
|
|
8640
8697
|
funcName: "depositWithExpiry",
|
|
8641
8698
|
funcParams: [
|
|
8642
8699
|
n,
|
|
@@ -8655,45 +8712,45 @@ class Xn {
|
|
|
8655
8712
|
return await y.transfer(d);
|
|
8656
8713
|
}
|
|
8657
8714
|
} catch (o) {
|
|
8658
|
-
const
|
|
8659
|
-
throw new
|
|
8715
|
+
const c = ((o == null ? void 0 : o.message) || (o == null ? void 0 : o.toString())).toLowerCase(), f = c == null ? void 0 : c.includes("insufficient funds"), E = c == null ? void 0 : c.includes("gas"), R = c == null ? void 0 : c.includes("server"), S = f ? "core_transaction_deposit_insufficient_funds_error" : E ? "core_transaction_deposit_gas_error" : R ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
8716
|
+
throw new T(S, o);
|
|
8660
8717
|
}
|
|
8661
8718
|
});
|
|
8662
8719
|
/**
|
|
8663
8720
|
* TC related Methods
|
|
8664
8721
|
*/
|
|
8665
|
-
|
|
8722
|
+
b(this, "createLiquidity", async ({
|
|
8666
8723
|
runeAssetValue: t,
|
|
8667
8724
|
assetValue: n
|
|
8668
8725
|
}) => {
|
|
8669
8726
|
if (t.lte(0) || n.lte(0))
|
|
8670
|
-
throw new
|
|
8727
|
+
throw new T("core_transaction_create_liquidity_invalid_params");
|
|
8671
8728
|
let a = "", i = "";
|
|
8672
8729
|
try {
|
|
8673
|
-
a = await
|
|
8730
|
+
a = await A(this, v).call(this, {
|
|
8674
8731
|
assetValue: t,
|
|
8675
|
-
memo:
|
|
8732
|
+
memo: D(_.DEPOSIT, {
|
|
8676
8733
|
...n,
|
|
8677
8734
|
address: this.getAddress(n.chain)
|
|
8678
8735
|
})
|
|
8679
8736
|
});
|
|
8680
8737
|
} catch (r) {
|
|
8681
|
-
throw new
|
|
8738
|
+
throw new T("core_transaction_create_liquidity_rune_error", r);
|
|
8682
8739
|
}
|
|
8683
8740
|
try {
|
|
8684
|
-
i = await
|
|
8741
|
+
i = await A(this, v).call(this, {
|
|
8685
8742
|
assetValue: n,
|
|
8686
|
-
memo:
|
|
8743
|
+
memo: D(_.DEPOSIT, {
|
|
8687
8744
|
...n,
|
|
8688
8745
|
address: this.getAddress(s.THORChain)
|
|
8689
8746
|
})
|
|
8690
8747
|
});
|
|
8691
8748
|
} catch (r) {
|
|
8692
|
-
throw new
|
|
8749
|
+
throw new T("core_transaction_create_liquidity_asset_error", r);
|
|
8693
8750
|
}
|
|
8694
8751
|
return { runeTx: a, assetTx: i };
|
|
8695
8752
|
});
|
|
8696
|
-
|
|
8753
|
+
b(this, "addLiquidity", async ({
|
|
8697
8754
|
runeAssetValue: t,
|
|
8698
8755
|
assetValue: n,
|
|
8699
8756
|
runeAddr: a,
|
|
@@ -8701,55 +8758,55 @@ class Xn {
|
|
|
8701
8758
|
isPendingSymmAsset: r,
|
|
8702
8759
|
mode: p = "sym"
|
|
8703
8760
|
}) => {
|
|
8704
|
-
const { chain: u, symbol: y } = n, d = p === "sym", o = (t == null ? void 0 : t.gt(0)) && (d || p === "rune"),
|
|
8705
|
-
if (!o && !
|
|
8706
|
-
throw new
|
|
8707
|
-
if (f && !
|
|
8708
|
-
throw new
|
|
8709
|
-
let
|
|
8761
|
+
const { chain: u, symbol: y } = n, d = p === "sym", o = (t == null ? void 0 : t.gt(0)) && (d || p === "rune"), c = (n == null ? void 0 : n.gt(0)) && (d || p === "asset"), f = r || o, E = f ? a || this.getAddress(s.THORChain) : "", R = d || p === "asset" ? i || this.getAddress(u) : "";
|
|
8762
|
+
if (!o && !c)
|
|
8763
|
+
throw new T("core_transaction_add_liquidity_invalid_params");
|
|
8764
|
+
if (f && !E)
|
|
8765
|
+
throw new T("core_transaction_add_liquidity_no_rune_address");
|
|
8766
|
+
let S, M;
|
|
8710
8767
|
if (o && t)
|
|
8711
8768
|
try {
|
|
8712
|
-
|
|
8769
|
+
S = await A(this, v).call(this, {
|
|
8713
8770
|
assetValue: t,
|
|
8714
|
-
memo:
|
|
8771
|
+
memo: D(_.DEPOSIT, { chain: u, symbol: y, address: R })
|
|
8715
8772
|
});
|
|
8716
|
-
} catch (
|
|
8717
|
-
throw new
|
|
8773
|
+
} catch (I) {
|
|
8774
|
+
throw new T("core_transaction_add_liquidity_rune_error", I);
|
|
8718
8775
|
}
|
|
8719
|
-
if (
|
|
8776
|
+
if (c && n)
|
|
8720
8777
|
try {
|
|
8721
|
-
|
|
8778
|
+
M = await A(this, v).call(this, {
|
|
8722
8779
|
assetValue: n,
|
|
8723
|
-
memo:
|
|
8780
|
+
memo: D(_.DEPOSIT, { chain: u, symbol: y, address: E })
|
|
8724
8781
|
});
|
|
8725
|
-
} catch (
|
|
8726
|
-
throw new
|
|
8782
|
+
} catch (I) {
|
|
8783
|
+
throw new T("core_transaction_add_liquidity_asset_error", I);
|
|
8727
8784
|
}
|
|
8728
|
-
return { runeTx:
|
|
8785
|
+
return { runeTx: S, assetTx: M };
|
|
8729
8786
|
});
|
|
8730
|
-
|
|
8787
|
+
b(this, "addLiquidityPart", ({
|
|
8731
8788
|
assetValue: t,
|
|
8732
8789
|
poolAddress: n,
|
|
8733
8790
|
address: a,
|
|
8734
8791
|
symmetric: i
|
|
8735
8792
|
}) => {
|
|
8736
8793
|
if (i && !a)
|
|
8737
|
-
throw new
|
|
8738
|
-
const r =
|
|
8794
|
+
throw new T("core_transaction_add_liquidity_invalid_params");
|
|
8795
|
+
const r = D(_.DEPOSIT, {
|
|
8739
8796
|
chain: n.split(".")[0],
|
|
8740
8797
|
symbol: n.split(".")[1],
|
|
8741
8798
|
address: i ? a : ""
|
|
8742
8799
|
});
|
|
8743
|
-
return
|
|
8800
|
+
return A(this, v).call(this, { assetValue: t, memo: r });
|
|
8744
8801
|
});
|
|
8745
|
-
|
|
8802
|
+
b(this, "withdraw", async ({
|
|
8746
8803
|
memo: t,
|
|
8747
8804
|
assetValue: n,
|
|
8748
8805
|
percent: a,
|
|
8749
8806
|
from: i,
|
|
8750
8807
|
to: r
|
|
8751
8808
|
}) => {
|
|
8752
|
-
const p = r === "rune" && i !== "rune" ? x.fromChainOrSignature(s.THORChain) : i === "sym" && r === "sym" || i === "rune" || i === "asset" ? void 0 : n, u =
|
|
8809
|
+
const p = r === "rune" && i !== "rune" ? x.fromChainOrSignature(s.THORChain) : i === "sym" && r === "sym" || i === "rune" || i === "asset" ? void 0 : n, u = fe(i === "asset" ? n.chain : s.THORChain), y = t || D(_.WITHDRAW, {
|
|
8753
8810
|
symbol: n.symbol,
|
|
8754
8811
|
chain: n.chain,
|
|
8755
8812
|
ticker: n.ticker,
|
|
@@ -8757,69 +8814,69 @@ class Xn {
|
|
|
8757
8814
|
targetAssetString: p == null ? void 0 : p.toString(),
|
|
8758
8815
|
singleSide: !1
|
|
8759
8816
|
});
|
|
8760
|
-
return
|
|
8817
|
+
return A(this, v).call(this, { assetValue: u, memo: y });
|
|
8761
8818
|
});
|
|
8762
|
-
|
|
8819
|
+
b(this, "savings", async ({
|
|
8763
8820
|
assetValue: t,
|
|
8764
8821
|
memo: n,
|
|
8765
8822
|
percent: a,
|
|
8766
8823
|
type: i
|
|
8767
8824
|
}) => {
|
|
8768
|
-
const r = i === "add" ?
|
|
8825
|
+
const r = i === "add" ? _.DEPOSIT : _.WITHDRAW, p = n || D(r, {
|
|
8769
8826
|
ticker: t.ticker,
|
|
8770
8827
|
symbol: t.symbol,
|
|
8771
8828
|
chain: t.chain,
|
|
8772
8829
|
singleSide: !0,
|
|
8773
8830
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
8774
|
-
}), u = r ===
|
|
8775
|
-
return
|
|
8831
|
+
}), u = r === _.DEPOSIT ? t : fe(t.chain);
|
|
8832
|
+
return A(this, v).call(this, { memo: p, assetValue: u });
|
|
8776
8833
|
});
|
|
8777
|
-
|
|
8834
|
+
b(this, "loan", ({
|
|
8778
8835
|
assetValue: t,
|
|
8779
8836
|
memo: n,
|
|
8780
8837
|
minAmount: a,
|
|
8781
8838
|
type: i
|
|
8782
|
-
}) =>
|
|
8839
|
+
}) => A(this, v).call(this, {
|
|
8783
8840
|
assetValue: t,
|
|
8784
|
-
memo: n ||
|
|
8841
|
+
memo: n || D(i === "open" ? _.OPEN_LOAN : _.CLOSE_LOAN, {
|
|
8785
8842
|
asset: t.toString(),
|
|
8786
8843
|
minAmount: a.toString(),
|
|
8787
8844
|
address: this.getAddress(t.chain)
|
|
8788
8845
|
})
|
|
8789
8846
|
}));
|
|
8790
|
-
|
|
8847
|
+
b(this, "nodeAction", ({
|
|
8791
8848
|
type: t,
|
|
8792
8849
|
assetValue: n,
|
|
8793
8850
|
address: a
|
|
8794
8851
|
}) => {
|
|
8795
|
-
const i = t === "bond" ?
|
|
8852
|
+
const i = t === "bond" ? _.BOND : t === "unbond" ? _.UNBOND : _.LEAVE, r = D(i, {
|
|
8796
8853
|
address: a,
|
|
8797
8854
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
8798
8855
|
});
|
|
8799
|
-
return
|
|
8856
|
+
return A(this, z).call(this, {
|
|
8800
8857
|
memo: r,
|
|
8801
|
-
assetValue: t === "bond" ? n :
|
|
8858
|
+
assetValue: t === "bond" ? n : fe(s.THORChain)
|
|
8802
8859
|
});
|
|
8803
8860
|
});
|
|
8804
|
-
|
|
8861
|
+
b(this, "registerThorname", ({
|
|
8805
8862
|
assetValue: t,
|
|
8806
8863
|
...n
|
|
8807
|
-
}) =>
|
|
8808
|
-
|
|
8864
|
+
}) => A(this, z).call(this, { assetValue: t, memo: D(_.THORNAME_REGISTER, n) }));
|
|
8865
|
+
b(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: i = {} }) => {
|
|
8809
8866
|
try {
|
|
8810
8867
|
t.forEach((r) => {
|
|
8811
8868
|
this[r.connectMethodName] = r.connect({
|
|
8812
|
-
addChain:
|
|
8869
|
+
addChain: A(this, ye),
|
|
8813
8870
|
config: n || {},
|
|
8814
8871
|
apis: a,
|
|
8815
8872
|
rpcUrls: i
|
|
8816
8873
|
});
|
|
8817
8874
|
});
|
|
8818
8875
|
} catch (r) {
|
|
8819
|
-
throw new
|
|
8876
|
+
throw new T("core_extend_error", r);
|
|
8820
8877
|
}
|
|
8821
8878
|
});
|
|
8822
|
-
|
|
8879
|
+
b(this, "estimateMaxSendableAmount", async ({
|
|
8823
8880
|
chain: t,
|
|
8824
8881
|
params: n
|
|
8825
8882
|
}) => {
|
|
@@ -8852,43 +8909,43 @@ class Xn {
|
|
|
8852
8909
|
});
|
|
8853
8910
|
}
|
|
8854
8911
|
default:
|
|
8855
|
-
throw new
|
|
8912
|
+
throw new T("core_estimated_max_spendable_chain_not_supported");
|
|
8856
8913
|
}
|
|
8857
8914
|
});
|
|
8858
8915
|
/**
|
|
8859
8916
|
* Wallet connection methods
|
|
8860
8917
|
*/
|
|
8861
|
-
|
|
8862
|
-
throw new
|
|
8918
|
+
b(this, "connectXDEFI", async (t) => {
|
|
8919
|
+
throw new T("core_wallet_xdefi_not_installed");
|
|
8863
8920
|
});
|
|
8864
|
-
|
|
8865
|
-
throw new
|
|
8921
|
+
b(this, "connectEVMWallet", async (t, n) => {
|
|
8922
|
+
throw new T("core_wallet_evmwallet_not_installed");
|
|
8866
8923
|
});
|
|
8867
|
-
|
|
8868
|
-
throw new
|
|
8924
|
+
b(this, "connectWalletconnect", async (t, n) => {
|
|
8925
|
+
throw new T("core_wallet_walletconnect_not_installed");
|
|
8869
8926
|
});
|
|
8870
|
-
|
|
8871
|
-
throw new
|
|
8927
|
+
b(this, "connectKeepkey", async (t, n) => {
|
|
8928
|
+
throw new T("core_wallet_keepkey_not_installed");
|
|
8872
8929
|
});
|
|
8873
|
-
|
|
8874
|
-
throw new
|
|
8930
|
+
b(this, "connectKeystore", async (t, n) => {
|
|
8931
|
+
throw new T("core_wallet_keystore_not_installed");
|
|
8875
8932
|
});
|
|
8876
|
-
|
|
8877
|
-
throw new
|
|
8933
|
+
b(this, "connectLedger", async (t, n) => {
|
|
8934
|
+
throw new T("core_wallet_ledger_not_installed");
|
|
8878
8935
|
});
|
|
8879
|
-
|
|
8880
|
-
throw new
|
|
8936
|
+
b(this, "connectTrezor", async (t, n) => {
|
|
8937
|
+
throw new T("core_wallet_trezor_not_installed");
|
|
8881
8938
|
});
|
|
8882
|
-
|
|
8883
|
-
throw new
|
|
8939
|
+
b(this, "connectKeplr", async (t) => {
|
|
8940
|
+
throw new T("core_wallet_keplr_not_installed");
|
|
8884
8941
|
});
|
|
8885
|
-
|
|
8886
|
-
throw new
|
|
8942
|
+
b(this, "connectOkx", async (t) => {
|
|
8943
|
+
throw new T("core_wallet_okx_not_installed");
|
|
8887
8944
|
});
|
|
8888
|
-
|
|
8945
|
+
b(this, "disconnectChain", (t) => {
|
|
8889
8946
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
8890
8947
|
});
|
|
8891
|
-
|
|
8948
|
+
V(this, U, async (t) => {
|
|
8892
8949
|
if (t === s.THORChain)
|
|
8893
8950
|
return {
|
|
8894
8951
|
gas_rate: "0",
|
|
@@ -8897,17 +8954,17 @@ class Xn {
|
|
|
8897
8954
|
halted: !1,
|
|
8898
8955
|
chain: s.THORChain
|
|
8899
8956
|
};
|
|
8900
|
-
const a = (await
|
|
8957
|
+
const a = (await Ln(this.stagenet)).find((i) => i.chain === t);
|
|
8901
8958
|
if (!a)
|
|
8902
|
-
throw new
|
|
8959
|
+
throw new T("core_inbound_data_not_found");
|
|
8903
8960
|
if (a != null && a.halted)
|
|
8904
|
-
throw new
|
|
8961
|
+
throw new T("core_chain_halted");
|
|
8905
8962
|
return a;
|
|
8906
8963
|
});
|
|
8907
|
-
|
|
8964
|
+
V(this, ye, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
8908
8965
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
8909
8966
|
});
|
|
8910
|
-
|
|
8967
|
+
V(this, Z, async ({
|
|
8911
8968
|
assetValue: t,
|
|
8912
8969
|
type: n = "checkOnly",
|
|
8913
8970
|
contractAddress: a
|
|
@@ -8915,30 +8972,30 @@ class Xn {
|
|
|
8915
8972
|
const { address: i, chain: r, isGasAsset: p, isSynthetic: u } = t, y = [s.Ethereum, s.Avalanche, s.BinanceSmartChain].includes(r);
|
|
8916
8973
|
if (y && p || !y || u)
|
|
8917
8974
|
return !0;
|
|
8918
|
-
const o = this.connectedWallets[r],
|
|
8919
|
-
if (!
|
|
8920
|
-
throw new
|
|
8975
|
+
const o = this.connectedWallets[r], c = n === "checkOnly" ? o == null ? void 0 : o.isApproved : o == null ? void 0 : o.approve;
|
|
8976
|
+
if (!c)
|
|
8977
|
+
throw new T("core_wallet_connection_not_found");
|
|
8921
8978
|
const f = this.getAddress(r);
|
|
8922
8979
|
if (!i || !f)
|
|
8923
|
-
throw new
|
|
8924
|
-
const
|
|
8925
|
-
return
|
|
8980
|
+
throw new T("core_approve_asset_address_or_from_not_found");
|
|
8981
|
+
const E = a || (await A(this, U).call(this, r)).router;
|
|
8982
|
+
return c({
|
|
8926
8983
|
amount: t.getBaseValue("bigint"),
|
|
8927
8984
|
assetAddress: i,
|
|
8928
8985
|
from: f,
|
|
8929
|
-
spenderAddress:
|
|
8986
|
+
spenderAddress: E
|
|
8930
8987
|
});
|
|
8931
8988
|
});
|
|
8932
|
-
|
|
8989
|
+
V(this, v, async ({
|
|
8933
8990
|
assetValue: t,
|
|
8934
8991
|
memo: n,
|
|
8935
|
-
feeOptionKey: a =
|
|
8992
|
+
feeOptionKey: a = X.Fast
|
|
8936
8993
|
}) => {
|
|
8937
8994
|
const {
|
|
8938
8995
|
gas_rate: i,
|
|
8939
8996
|
router: r,
|
|
8940
8997
|
address: p
|
|
8941
|
-
} = await
|
|
8998
|
+
} = await A(this, U).call(this, t.chain), u = (parseInt(i) || 0) * zt[a];
|
|
8942
8999
|
return this.deposit({
|
|
8943
9000
|
assetValue: t,
|
|
8944
9001
|
recipient: p,
|
|
@@ -8947,13 +9004,13 @@ class Xn {
|
|
|
8947
9004
|
feeRate: u
|
|
8948
9005
|
});
|
|
8949
9006
|
});
|
|
8950
|
-
|
|
8951
|
-
const a = await
|
|
9007
|
+
V(this, z, async ({ memo: t, assetValue: n }) => {
|
|
9008
|
+
const a = await Vn(this.stagenet);
|
|
8952
9009
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
8953
|
-
throw new
|
|
9010
|
+
throw new T("core_chain_halted");
|
|
8954
9011
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
8955
9012
|
});
|
|
8956
|
-
|
|
9013
|
+
V(this, ee, ({ assetValue: t, ...n }) => ({
|
|
8957
9014
|
...n,
|
|
8958
9015
|
memo: n.memo || "",
|
|
8959
9016
|
from: this.getAddress(t.chain),
|
|
@@ -8962,67 +9019,74 @@ class Xn {
|
|
|
8962
9019
|
this.stagenet = !!t;
|
|
8963
9020
|
}
|
|
8964
9021
|
}
|
|
8965
|
-
|
|
9022
|
+
U = new WeakMap(), ye = new WeakMap(), Z = new WeakMap(), v = new WeakMap(), z = new WeakMap(), ee = new WeakMap();
|
|
8966
9023
|
export {
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
9024
|
+
Tt as AGG_SWAP,
|
|
9025
|
+
P as ApiEndpoints,
|
|
9026
|
+
Wn as ApiError,
|
|
9027
|
+
Q as ApiUrl,
|
|
8970
9028
|
x as AssetValue,
|
|
8971
|
-
|
|
8972
|
-
|
|
9029
|
+
h as BaseDecimal,
|
|
9030
|
+
tt as BigIntArithmetics,
|
|
8973
9031
|
s as Chain,
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
9032
|
+
we as ChainId,
|
|
9033
|
+
Kn as ChainIdToChain,
|
|
9034
|
+
Ue as ChainToChainId,
|
|
9035
|
+
We as ChainToExplorerUrl,
|
|
9036
|
+
jn as ChainToHexChainId,
|
|
9037
|
+
St as ChainToRPC,
|
|
9038
|
+
At as ContractAddress,
|
|
9039
|
+
Gn as CosmosChainList,
|
|
9040
|
+
ht as DerivationPath,
|
|
8983
9041
|
l as ERROR_CODE,
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
9042
|
+
_t as ERROR_MODULE,
|
|
9043
|
+
Ve as ERROR_TYPE,
|
|
9044
|
+
Et as EVMChainList,
|
|
9045
|
+
wt as ErrorCode,
|
|
9046
|
+
X as FeeOption,
|
|
9047
|
+
_ as MemoType,
|
|
9048
|
+
$n as NetworkDerivationPath,
|
|
9049
|
+
mt as QuoteMode,
|
|
9050
|
+
Fe as RPCUrl,
|
|
9051
|
+
g as RequestClient,
|
|
9052
|
+
ct as SWAP_IN,
|
|
9053
|
+
bt as SWAP_OUT,
|
|
9054
|
+
jt as StreamingSwapProgressStatus,
|
|
9055
|
+
Qn as SwapKitApi,
|
|
9056
|
+
pa as SwapKitCore,
|
|
9057
|
+
T as SwapKitError,
|
|
8998
9058
|
k as SwapKitNumber,
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9059
|
+
dt as TCAvalancheDepositABI,
|
|
9060
|
+
lt as TCBscDepositABI,
|
|
9061
|
+
ot as TCEthereumVaultAbi,
|
|
9062
|
+
Xn as TCSupportedChainList,
|
|
9063
|
+
Gt as TransactionType,
|
|
9064
|
+
Xt as TxStatus,
|
|
9065
|
+
qn as UTXOChainList,
|
|
9066
|
+
Ot as WalletOption,
|
|
9067
|
+
Jn as assetFromString,
|
|
9068
|
+
Qe as defaultRequestHeaders,
|
|
9069
|
+
ra as derivationPathToString,
|
|
9070
|
+
Un as erc20ABI,
|
|
9071
|
+
Zn as filterAssets,
|
|
9072
|
+
me as formatBigIntToSafeValue,
|
|
9073
|
+
zt as gasFeeMultiplier,
|
|
9074
|
+
tn as getAssetType,
|
|
9075
|
+
rn as getAsymmetricAssetShare,
|
|
9076
|
+
ea as getAsymmetricAssetWithdrawAmount,
|
|
9077
|
+
sn as getAsymmetricRuneShare,
|
|
9078
|
+
zn as getAsymmetricRuneWithdrawAmount,
|
|
9079
|
+
en as getCommonAssetInfo,
|
|
9080
|
+
Zt as getDecimal,
|
|
9081
|
+
na as getEstimatedPoolShare,
|
|
9082
|
+
aa as getLiquiditySlippage,
|
|
9083
|
+
D as getMemoFor,
|
|
9084
|
+
fe as getMinAmountByChain,
|
|
9085
|
+
pn as getSymmetricPoolShare,
|
|
9086
|
+
ta as getSymmetricWithdraw,
|
|
9087
|
+
ia as getTHORNameCost,
|
|
9088
|
+
Ze as isGasAsset,
|
|
9089
|
+
Yn as setRequestClientConfig,
|
|
9090
|
+
sa as validateTHORName
|
|
9027
9091
|
};
|
|
9028
9092
|
//# sourceMappingURL=index.es.js.map
|