@swapkit/core 1.0.0-rc.30 → 1.0.0-rc.31
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.es.js +323 -324
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (e, t, n) => (
|
|
1
|
+
var We = Object.defineProperty;
|
|
2
|
+
var je = (e, t, n) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var T = (e, t, n) => (je(e, typeof t != "symbol" ? t + "" : t, n), n), Ke = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var f = (e, t, n) => (
|
|
7
|
+
var f = (e, t, n) => (Ke(e, t, "read from private field"), n ? n.call(e) : t.get(e)), B = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
const
|
|
12
|
+
var Ye = Object.defineProperty, Xe = (e, t, n) => t in e ? Ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (Xe(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
+
const fn = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -108,7 +108,7 @@ const _n = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Je = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const _n = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Qe = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const _n = [
|
|
|
447
447
|
stateMutability: "view",
|
|
448
448
|
type: "function"
|
|
449
449
|
}
|
|
450
|
-
],
|
|
450
|
+
], ze = [
|
|
451
451
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
452
452
|
{
|
|
453
453
|
anonymous: !1,
|
|
@@ -600,13 +600,13 @@ const _n = [
|
|
|
600
600
|
type: "function"
|
|
601
601
|
}
|
|
602
602
|
];
|
|
603
|
-
var
|
|
604
|
-
const
|
|
603
|
+
var Ze = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(Ze || {});
|
|
604
|
+
const et = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], tt = [
|
|
610
610
|
"ERC20-TC",
|
|
611
611
|
"ERC20-ARC20",
|
|
612
612
|
"ERC20-BEP20",
|
|
@@ -617,15 +617,15 @@ const Ze = [
|
|
|
617
617
|
"BEP20-ERC20",
|
|
618
618
|
"BEP20-ARC20"
|
|
619
619
|
/* BSC_TO_AVAX */
|
|
620
|
-
],
|
|
620
|
+
], nt = [
|
|
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 Ne = /* @__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))(Ne || {}), at = /* @__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))(at || {}), 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_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(l || {});
|
|
628
|
+
const st = {
|
|
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.",
|
|
@@ -676,13 +676,13 @@ const at = {
|
|
|
676
676
|
[l.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
677
|
[l.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
678
|
[l.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
|
-
},
|
|
680
|
-
let n =
|
|
679
|
+
}, oe = (e, t) => {
|
|
680
|
+
let n = st[e];
|
|
681
681
|
for (let a = 0; a < t.length; a++)
|
|
682
682
|
n = n.replace(`{${a}}`, t[a]);
|
|
683
683
|
return t.length === 0 ? n.replace("{0}", "") : n;
|
|
684
684
|
};
|
|
685
|
-
let
|
|
685
|
+
let bn = class xe extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -697,15 +697,15 @@ let fn = class Me extends Error {
|
|
|
697
697
|
},
|
|
698
698
|
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
|
-
const c = r ||
|
|
701
|
-
super(c), v(this, "status"), v(this, "revision"), v(this, "type"), v(this, "module"), v(this, "code"), v(this, "message"), v(this, "display"), v(this, "stack"), v(this, "options"), v(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display =
|
|
700
|
+
const c = r || oe(s, u || []) || "";
|
|
701
|
+
super(c), v(this, "status"), v(this, "revision"), v(this, "type"), v(this, "module"), v(this, "code"), v(this, "message"), v(this, "display"), v(this, "stack"), v(this, "options"), v(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = oe(s, u || []), this.code = s, this.type = o || Ne.UNHANDLED_ERROR, this.options = {
|
|
702
702
|
shouldLog: p || !0,
|
|
703
703
|
shouldTrace: y || !0,
|
|
704
704
|
shouldThrow: d || !1
|
|
705
705
|
}, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new xe(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ let fn = class Me extends Error {
|
|
|
714
714
|
return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
|
|
715
715
|
}
|
|
716
716
|
get displayMessage() {
|
|
717
|
-
return
|
|
717
|
+
return oe(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -724,8 +724,8 @@ let fn = class Me extends Error {
|
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
726
|
};
|
|
727
|
-
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}),
|
|
728
|
-
const
|
|
727
|
+
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), it = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(it || {}), rt = /* @__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))(rt || {});
|
|
728
|
+
const wn = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
731
731
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -743,7 +743,7 @@ const bn = {
|
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
745
|
var A = /* @__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))(A || {});
|
|
746
|
-
const
|
|
746
|
+
const ot = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
749
749
|
"BSC",
|
|
@@ -751,18 +751,18 @@ const rt = [
|
|
|
751
751
|
"OP",
|
|
752
752
|
"MATIC"
|
|
753
753
|
/* Polygon */
|
|
754
|
-
],
|
|
754
|
+
], An = [
|
|
755
755
|
"BTC",
|
|
756
756
|
"BCH",
|
|
757
757
|
"DOGE",
|
|
758
758
|
"LTC"
|
|
759
759
|
/* Litecoin */
|
|
760
|
-
],
|
|
760
|
+
], En = [
|
|
761
761
|
"GAIA",
|
|
762
762
|
"THOR",
|
|
763
763
|
"BNB"
|
|
764
764
|
/* Binance */
|
|
765
|
-
],
|
|
765
|
+
], Rn = [
|
|
766
766
|
"AVAX",
|
|
767
767
|
"BNB",
|
|
768
768
|
"BSC",
|
|
@@ -775,26 +775,26 @@ const rt = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var
|
|
779
|
-
const
|
|
778
|
+
var fe = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(fe || {}), De = /* @__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))(De || {}), W = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(W || {});
|
|
779
|
+
const ie = Object.values(i), pt = Object.keys(i), be = ie.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
|
-
const n =
|
|
781
|
+
const n = pt.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
786
|
-
(e, t) => (e[t] =
|
|
785
|
+
), dt = ie.reduce(
|
|
786
|
+
(e, t) => (e[t] = fe[be[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), ut = ie.reduce(
|
|
789
|
+
(e, t) => (e[t] = De[be[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
),
|
|
791
|
+
), gn = ie.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
|
-
const n = `${
|
|
794
|
-
return e[t] =
|
|
793
|
+
const n = `${be[t]}Hex`;
|
|
794
|
+
return e[t] = fe[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
|
-
),
|
|
797
|
+
), On = {
|
|
798
798
|
"0xa4b1": "ARB",
|
|
799
799
|
42161: "ARB",
|
|
800
800
|
"0xa86a": "AVAX",
|
|
@@ -819,7 +819,7 @@ const ae = Object.values(i), ot = Object.keys(i), fe = ae.reduce(
|
|
|
819
819
|
"thorchain-stagenet-v2": "THOR",
|
|
820
820
|
"thorchain-mainnet-v1": "THOR"
|
|
821
821
|
/* THORChain */
|
|
822
|
-
},
|
|
822
|
+
}, Pe = {
|
|
823
823
|
ARB: "https://arbiscan.io",
|
|
824
824
|
AVAX: "https://snowtrace.io",
|
|
825
825
|
BSC: "https://bscscan.com",
|
|
@@ -836,17 +836,17 @@ const ae = Object.values(i), ot = Object.keys(i), fe = ae.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://viewblock.io/thorchain"
|
|
838
838
|
};
|
|
839
|
-
var
|
|
839
|
+
var lt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(lt || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), yt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(yt || {}), ct = Object.defineProperty, mt = (e, t, n) => t in e ? ct(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (mt(e, typeof t != "symbol" ? t + "" : t, n), n), Tt = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
842
|
}, V = (e, t, n) => {
|
|
843
843
|
if (t.has(e))
|
|
844
844
|
throw TypeError("Cannot add the same private member more than once");
|
|
845
845
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
846
|
-
},
|
|
847
|
-
const
|
|
846
|
+
}, E = (e, t, n) => (Tt(e, t, "access private method"), n);
|
|
847
|
+
const ht = "0x313ce567", Be = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await
|
|
849
|
+
const { result: n } = await Ae.post(ut[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -856,37 +856,37 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
856
856
|
id: 44,
|
|
857
857
|
jsonrpc: "2.0",
|
|
858
858
|
method: "eth_call",
|
|
859
|
-
params: [{ to: t.toLowerCase(), data:
|
|
859
|
+
params: [{ to: t.toLowerCase(), data: ht }, "latest"]
|
|
860
860
|
})
|
|
861
861
|
});
|
|
862
862
|
return parseInt(BigInt(n).toString());
|
|
863
863
|
} catch (n) {
|
|
864
864
|
return console.error(n), A[e];
|
|
865
865
|
}
|
|
866
|
-
},
|
|
866
|
+
}, _t = async (e) => {
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
868
|
return A.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
|
-
return t != null && t.startsWith("0x") ?
|
|
871
|
-
},
|
|
870
|
+
return t != null && t.startsWith("0x") ? Be({ chain: i.Ethereum, to: t }) : A.ETH;
|
|
871
|
+
}, ft = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ?
|
|
874
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? Be({ chain: i.Avalanche, to: t.toLowerCase() }) : A.AVAX;
|
|
874
|
+
}, bt = async (e) => (e === i.BinanceSmartChain, A.BSC), wt = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
|
-
return ht(t);
|
|
878
|
-
case i.Avalanche:
|
|
879
877
|
return _t(t);
|
|
880
|
-
case i.
|
|
878
|
+
case i.Avalanche:
|
|
881
879
|
return ft(t);
|
|
880
|
+
case i.BinanceSmartChain:
|
|
881
|
+
return bt(t);
|
|
882
882
|
default:
|
|
883
883
|
return A[e];
|
|
884
884
|
}
|
|
885
|
-
},
|
|
885
|
+
}, At = {
|
|
886
886
|
[F.Average]: 1.2,
|
|
887
887
|
[F.Fast]: 1.5,
|
|
888
888
|
[F.Fastest]: 2
|
|
889
|
-
},
|
|
889
|
+
}, Le = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case i.Bitcoin:
|
|
892
892
|
case i.BitcoinCash:
|
|
@@ -912,7 +912,7 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
912
912
|
case i.THORChain:
|
|
913
913
|
return t === "RUNE";
|
|
914
914
|
}
|
|
915
|
-
},
|
|
915
|
+
}, Et = (e) => {
|
|
916
916
|
switch (e) {
|
|
917
917
|
case "ETH.THOR":
|
|
918
918
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
@@ -941,7 +941,7 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
941
941
|
case i.Ethereum:
|
|
942
942
|
return { identifier: `${e}.${e}`, decimal: A[e] };
|
|
943
943
|
}
|
|
944
|
-
},
|
|
944
|
+
}, Rt = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
946
946
|
return "Synth";
|
|
947
947
|
switch (e) {
|
|
@@ -971,47 +971,47 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
971
971
|
case i.Optimism:
|
|
972
972
|
return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
973
973
|
}
|
|
974
|
-
},
|
|
974
|
+
}, In = (e) => {
|
|
975
975
|
var t;
|
|
976
976
|
const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."), o = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
977
977
|
return { chain: n, symbol: r, ticker: o, synth: s };
|
|
978
|
-
},
|
|
978
|
+
}, gt = new RegExp(
|
|
979
979
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
980
|
"gmi"
|
|
981
|
-
),
|
|
981
|
+
), Ot = (e) => {
|
|
982
982
|
const [t, n] = e.split(".");
|
|
983
|
-
if (!
|
|
983
|
+
if (!ot.includes(t))
|
|
984
984
|
return !0;
|
|
985
985
|
const [, a] = n.split("-");
|
|
986
|
-
return
|
|
987
|
-
},
|
|
986
|
+
return Le({ chain: t, symbol: n }) || !!a;
|
|
987
|
+
}, Sn = (e) => e.filter((t) => {
|
|
988
988
|
const n = `${t.chain}.${t.symbol}`;
|
|
989
|
-
return !
|
|
990
|
-
}),
|
|
989
|
+
return !gt.test(n) && Ot(n) && t.value !== "0";
|
|
990
|
+
}), It = ({
|
|
991
991
|
liquidityUnits: e,
|
|
992
992
|
poolUnits: t,
|
|
993
993
|
runeDepth: n
|
|
994
994
|
}) => {
|
|
995
995
|
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = s.mul(s).mul(s);
|
|
996
996
|
return o.mul(p.sub(d).add(y)).div(u);
|
|
997
|
-
},
|
|
997
|
+
}, St = ({
|
|
998
998
|
liquidityUnits: e,
|
|
999
999
|
poolUnits: t,
|
|
1000
1000
|
assetDepth: n
|
|
1001
1001
|
}) => {
|
|
1002
1002
|
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = o.mul(p.sub(d).add(y)), c = s.mul(s).mul(s);
|
|
1003
1003
|
return u.div(c);
|
|
1004
|
-
},
|
|
1004
|
+
}, vn = ({
|
|
1005
1005
|
percent: e,
|
|
1006
1006
|
runeDepth: t,
|
|
1007
1007
|
liquidityUnits: n,
|
|
1008
1008
|
poolUnits: a
|
|
1009
|
-
}) =>
|
|
1009
|
+
}) => It({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), Cn = ({
|
|
1010
1010
|
percent: e,
|
|
1011
1011
|
assetDepth: t,
|
|
1012
1012
|
liquidityUnits: n,
|
|
1013
1013
|
poolUnits: a
|
|
1014
|
-
}) =>
|
|
1014
|
+
}) => St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => D.fromBigInt(BigInt(e), A.THOR), vt = ({
|
|
1015
1015
|
liquidityUnits: e,
|
|
1016
1016
|
poolUnits: t,
|
|
1017
1017
|
runeDepth: n,
|
|
@@ -1019,17 +1019,17 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1019
1019
|
}) => ({
|
|
1020
1020
|
assetAmount: g(a).mul(e).div(t),
|
|
1021
1021
|
runeAmount: g(n).mul(e).div(t)
|
|
1022
|
-
}),
|
|
1022
|
+
}), Mn = ({
|
|
1023
1023
|
liquidityUnits: e,
|
|
1024
1024
|
poolUnits: t,
|
|
1025
1025
|
runeDepth: n,
|
|
1026
1026
|
assetDepth: a,
|
|
1027
1027
|
percent: s
|
|
1028
1028
|
}) => Object.fromEntries(
|
|
1029
|
-
Object.entries(
|
|
1029
|
+
Object.entries(vt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1030
1030
|
([r, o]) => [r, o.mul(s)]
|
|
1031
1031
|
)
|
|
1032
|
-
),
|
|
1032
|
+
), Nn = ({
|
|
1033
1033
|
runeDepth: e,
|
|
1034
1034
|
poolUnits: t,
|
|
1035
1035
|
assetDepth: n,
|
|
@@ -1037,12 +1037,12 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1037
1037
|
runeAmount: s,
|
|
1038
1038
|
assetAmount: r
|
|
1039
1039
|
}) => {
|
|
1040
|
-
const o = new D({ value: e, decimal: 8 }), p = new D({ value: n, decimal: 8 }), d = new D({ value: t, decimal: 8 }), y = new D({ value: s, decimal: 8 }), u = new D({ value: r, decimal: 8 }), c = y.mul(p), _ = u.mul(o), b = y.mul(u), w = o.mul(p),
|
|
1040
|
+
const o = new D({ value: e, decimal: 8 }), p = new D({ value: n, decimal: 8 }), d = new D({ value: t, decimal: 8 }), y = new D({ value: s, decimal: 8 }), u = new D({ value: r, decimal: 8 }), c = y.mul(p), _ = u.mul(o), b = y.mul(u), w = o.mul(p), R = d.mul(c.add(_.add(b.mul(2)))), O = c.add(_.add(w.mul(2))), I = R.div(O), S = g(a).add(I);
|
|
1041
1041
|
if (I.getBaseValue("number") === 0)
|
|
1042
1042
|
return S.div(d).getBaseValue("number");
|
|
1043
1043
|
const P = d.add(S);
|
|
1044
1044
|
return S.div(P).getBaseValue("number");
|
|
1045
|
-
},
|
|
1045
|
+
}, xn = ({
|
|
1046
1046
|
runeAmount: e,
|
|
1047
1047
|
assetAmount: t,
|
|
1048
1048
|
runeDepth: n,
|
|
@@ -1052,7 +1052,7 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1052
1052
|
return 0;
|
|
1053
1053
|
const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), y = r.mul(p).add(s.mul(r));
|
|
1054
1054
|
return Math.abs(d.div(y).getBaseValue("number"));
|
|
1055
|
-
},
|
|
1055
|
+
}, Ct = ({
|
|
1056
1056
|
symbol: e,
|
|
1057
1057
|
ticker: t,
|
|
1058
1058
|
chain: n
|
|
@@ -1076,7 +1076,7 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1076
1076
|
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${s || ""}:t:0`;
|
|
1077
1077
|
}
|
|
1078
1078
|
case h.WITHDRAW: {
|
|
1079
|
-
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", y =
|
|
1079
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", y = Ct({ chain: n, symbol: s, ticker: a });
|
|
1080
1080
|
return `${e}:${n}${p ? "/" : "."}${y}:${r}${d}`;
|
|
1081
1081
|
}
|
|
1082
1082
|
case h.OPEN_LOAN:
|
|
@@ -1087,17 +1087,17 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1087
1087
|
default:
|
|
1088
1088
|
return "";
|
|
1089
1089
|
}
|
|
1090
|
-
},
|
|
1090
|
+
}, Dn = (e) => {
|
|
1091
1091
|
if (e < 0)
|
|
1092
1092
|
throw new Error("Invalid number of year");
|
|
1093
1093
|
return 10 + e;
|
|
1094
|
-
},
|
|
1094
|
+
}, Pn = (e) => {
|
|
1095
1095
|
if (e.length > 30)
|
|
1096
1096
|
return !1;
|
|
1097
1097
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1098
1098
|
return !!e.match(t);
|
|
1099
|
-
},
|
|
1100
|
-
class
|
|
1099
|
+
}, Bn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1100
|
+
class Ee extends Error {
|
|
1101
1101
|
constructor(t, n, a) {
|
|
1102
1102
|
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
|
|
1103
1103
|
super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
|
|
@@ -1118,7 +1118,7 @@ class Ae extends Error {
|
|
|
1118
1118
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
class
|
|
1121
|
+
class Ve extends Error {
|
|
1122
1122
|
constructor(t) {
|
|
1123
1123
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1124
1124
|
enumerable: !0,
|
|
@@ -1132,24 +1132,24 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1132
1132
|
for (const t of e)
|
|
1133
1133
|
if ((!Q(t) || Array.isArray(t)) && t !== void 0)
|
|
1134
1134
|
throw new TypeError("The `options` argument must be an object");
|
|
1135
|
-
return
|
|
1136
|
-
},
|
|
1135
|
+
return we({}, ...e);
|
|
1136
|
+
}, Ue = (e = {}, t = {}) => {
|
|
1137
1137
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1138
1138
|
for (const [r, o] of s.entries())
|
|
1139
1139
|
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
1140
1140
|
return n;
|
|
1141
|
-
},
|
|
1141
|
+
}, we = (...e) => {
|
|
1142
1142
|
let t = {}, n = {};
|
|
1143
1143
|
for (const a of e)
|
|
1144
1144
|
if (Array.isArray(a))
|
|
1145
1145
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1146
1146
|
else if (Q(a)) {
|
|
1147
1147
|
for (let [s, r] of Object.entries(a))
|
|
1148
|
-
Q(r) && s in t && (r =
|
|
1149
|
-
Q(a.headers) && (n =
|
|
1148
|
+
Q(r) && s in t && (r = we(t[s], r)), t = { ...t, [s]: r };
|
|
1149
|
+
Q(a.headers) && (n = Ue(n, a.headers), t.headers = n);
|
|
1150
1150
|
}
|
|
1151
1151
|
return t;
|
|
1152
|
-
},
|
|
1152
|
+
}, Mt = (() => {
|
|
1153
1153
|
let e = !1, t = !1;
|
|
1154
1154
|
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1155
1155
|
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
@@ -1160,13 +1160,13 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1160
1160
|
return e = !0, "half";
|
|
1161
1161
|
}
|
|
1162
1162
|
}).headers.has("Content-Type")), e && !t;
|
|
1163
|
-
})(),
|
|
1163
|
+
})(), Nt = typeof globalThis.AbortController == "function", xt = typeof globalThis.ReadableStream == "function", Dt = typeof globalThis.FormData == "function", He = ["get", "post", "put", "patch", "head", "delete"], Pt = {
|
|
1164
1164
|
json: "application/json",
|
|
1165
1165
|
text: "text/*",
|
|
1166
1166
|
formData: "multipart/form-data",
|
|
1167
1167
|
arrayBuffer: "*/*",
|
|
1168
1168
|
blob: "*/*"
|
|
1169
|
-
},
|
|
1169
|
+
}, pe = 2147483647, $e = Symbol("stop"), Bt = {
|
|
1170
1170
|
json: !0,
|
|
1171
1171
|
parseJson: !0,
|
|
1172
1172
|
searchParams: !0,
|
|
@@ -1177,7 +1177,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1177
1177
|
throwHttpErrors: !0,
|
|
1178
1178
|
onDownloadProgress: !0,
|
|
1179
1179
|
fetch: !0
|
|
1180
|
-
},
|
|
1180
|
+
}, Lt = {
|
|
1181
1181
|
method: !0,
|
|
1182
1182
|
headers: !0,
|
|
1183
1183
|
body: !0,
|
|
@@ -1193,18 +1193,18 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1193
1193
|
window: !0,
|
|
1194
1194
|
dispatcher: !0,
|
|
1195
1195
|
duplex: !0
|
|
1196
|
-
},
|
|
1196
|
+
}, Vt = (e) => He.includes(e) ? e.toUpperCase() : e, Ut = ["get", "put", "head", "delete", "options", "trace"], Ht = [408, 413, 429, 500, 502, 503, 504], ke = [413, 429, 503], Re = {
|
|
1197
1197
|
limit: 2,
|
|
1198
|
-
methods:
|
|
1199
|
-
statusCodes:
|
|
1200
|
-
afterStatusCodes:
|
|
1198
|
+
methods: Ut,
|
|
1199
|
+
statusCodes: Ht,
|
|
1200
|
+
afterStatusCodes: ke,
|
|
1201
1201
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1202
1202
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1203
1203
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1204
|
-
},
|
|
1204
|
+
}, $t = (e = {}) => {
|
|
1205
1205
|
if (typeof e == "number")
|
|
1206
1206
|
return {
|
|
1207
|
-
...
|
|
1207
|
+
...Re,
|
|
1208
1208
|
limit: e
|
|
1209
1209
|
};
|
|
1210
1210
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -1212,22 +1212,22 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1212
1212
|
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1213
1213
|
throw new Error("retry.statusCodes must be an array");
|
|
1214
1214
|
return {
|
|
1215
|
-
...
|
|
1215
|
+
...Re,
|
|
1216
1216
|
...e,
|
|
1217
|
-
afterStatusCodes:
|
|
1217
|
+
afterStatusCodes: ke
|
|
1218
1218
|
};
|
|
1219
1219
|
};
|
|
1220
|
-
async function
|
|
1220
|
+
async function kt(e, t, n, a) {
|
|
1221
1221
|
return new Promise((s, r) => {
|
|
1222
1222
|
const o = setTimeout(() => {
|
|
1223
|
-
n && n.abort(), r(new
|
|
1223
|
+
n && n.abort(), r(new Ve(e));
|
|
1224
1224
|
}, a.timeout);
|
|
1225
1225
|
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1226
1226
|
clearTimeout(o);
|
|
1227
1227
|
});
|
|
1228
1228
|
});
|
|
1229
1229
|
}
|
|
1230
|
-
async function
|
|
1230
|
+
async function Ft(e, { signal: t }) {
|
|
1231
1231
|
return new Promise((n, a) => {
|
|
1232
1232
|
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
|
|
1233
1233
|
function s() {
|
|
@@ -1238,17 +1238,17 @@ async function kt(e, { signal: t }) {
|
|
|
1238
1238
|
}, e);
|
|
1239
1239
|
});
|
|
1240
1240
|
}
|
|
1241
|
-
const
|
|
1241
|
+
const Gt = (e, t) => {
|
|
1242
1242
|
const n = {};
|
|
1243
1243
|
for (const a in t)
|
|
1244
|
-
!(a in
|
|
1244
|
+
!(a in Lt) && !(a in Bt) && !(a in e) && (n[a] = t[a]);
|
|
1245
1245
|
return n;
|
|
1246
1246
|
};
|
|
1247
|
-
class
|
|
1247
|
+
class te {
|
|
1248
1248
|
static create(t, n) {
|
|
1249
|
-
const a = new
|
|
1250
|
-
if (typeof a._options.timeout == "number" && a._options.timeout >
|
|
1251
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
1249
|
+
const a = new te(t, n), s = async () => {
|
|
1250
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > pe)
|
|
1251
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${pe}`);
|
|
1252
1252
|
await Promise.resolve();
|
|
1253
1253
|
let o = await a._fetch();
|
|
1254
1254
|
for (const p of a._options.hooks.afterResponse) {
|
|
@@ -1256,7 +1256,7 @@ class Z {
|
|
|
1256
1256
|
d instanceof globalThis.Response && (o = d);
|
|
1257
1257
|
}
|
|
1258
1258
|
if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
|
|
1259
|
-
let p = new
|
|
1259
|
+
let p = new Ee(o, a.request, a._options);
|
|
1260
1260
|
for (const d of a._options.hooks.beforeError)
|
|
1261
1261
|
p = await d(p);
|
|
1262
1262
|
throw p;
|
|
@@ -1264,13 +1264,13 @@ class Z {
|
|
|
1264
1264
|
if (a._options.onDownloadProgress) {
|
|
1265
1265
|
if (typeof a._options.onDownloadProgress != "function")
|
|
1266
1266
|
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
1267
|
-
if (!
|
|
1267
|
+
if (!xt)
|
|
1268
1268
|
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1269
1269
|
return a._stream(o.clone(), a._options.onDownloadProgress);
|
|
1270
1270
|
}
|
|
1271
1271
|
return o;
|
|
1272
1272
|
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
|
|
1273
|
-
for (const [o, p] of Object.entries(
|
|
1273
|
+
for (const [o, p] of Object.entries(Pt))
|
|
1274
1274
|
r[o] = async () => {
|
|
1275
1275
|
a.request.headers.set("accept", a.request.headers.get("accept") || p);
|
|
1276
1276
|
const d = (await r).clone();
|
|
@@ -1315,17 +1315,17 @@ class Z {
|
|
|
1315
1315
|
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1316
1316
|
credentials: this._input.credentials || "same-origin",
|
|
1317
1317
|
...n,
|
|
1318
|
-
headers:
|
|
1319
|
-
hooks:
|
|
1318
|
+
headers: Ue(this._input.headers, n.headers),
|
|
1319
|
+
hooks: we({
|
|
1320
1320
|
beforeRequest: [],
|
|
1321
1321
|
beforeRetry: [],
|
|
1322
1322
|
beforeError: [],
|
|
1323
1323
|
afterResponse: []
|
|
1324
1324
|
}, n.hooks),
|
|
1325
|
-
method:
|
|
1325
|
+
method: Vt(n.method ?? this._input.method),
|
|
1326
1326
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1327
1327
|
prefixUrl: String(n.prefixUrl || ""),
|
|
1328
|
-
retry:
|
|
1328
|
+
retry: $t(n.retry),
|
|
1329
1329
|
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1330
1330
|
timeout: n.timeout ?? 1e4,
|
|
1331
1331
|
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
@@ -1336,7 +1336,7 @@ class Z {
|
|
|
1336
1336
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1337
1337
|
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1338
1338
|
}
|
|
1339
|
-
if (
|
|
1339
|
+
if (Nt) {
|
|
1340
1340
|
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1341
1341
|
const a = this._options.signal;
|
|
1342
1342
|
this._options.signal.addEventListener("abort", () => {
|
|
@@ -1345,15 +1345,15 @@ class Z {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
this._options.signal = this.abortController.signal;
|
|
1347
1347
|
}
|
|
1348
|
-
if (
|
|
1348
|
+
if (Mt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1349
1349
|
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1350
|
-
(
|
|
1350
|
+
(Dt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
|
|
1351
1351
|
}
|
|
1352
1352
|
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 }));
|
|
1353
1353
|
}
|
|
1354
1354
|
_calculateRetryDelay(t) {
|
|
1355
|
-
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof
|
|
1356
|
-
if (t instanceof
|
|
1355
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof Ve)) {
|
|
1356
|
+
if (t instanceof Ee) {
|
|
1357
1357
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1358
1358
|
return 0;
|
|
1359
1359
|
const a = t.response.headers.get("Retry-After");
|
|
@@ -1376,16 +1376,16 @@ class Z {
|
|
|
1376
1376
|
try {
|
|
1377
1377
|
return await t();
|
|
1378
1378
|
} catch (n) {
|
|
1379
|
-
const a = Math.min(this._calculateRetryDelay(n),
|
|
1379
|
+
const a = Math.min(this._calculateRetryDelay(n), pe);
|
|
1380
1380
|
if (a !== 0 && this._retryCount > 0) {
|
|
1381
|
-
await
|
|
1381
|
+
await Ft(a, { signal: this._options.signal });
|
|
1382
1382
|
for (const s of this._options.hooks.beforeRetry)
|
|
1383
1383
|
if (await s({
|
|
1384
1384
|
request: this.request,
|
|
1385
1385
|
options: this._options,
|
|
1386
1386
|
error: n,
|
|
1387
1387
|
retryCount: this._retryCount
|
|
1388
|
-
}) ===
|
|
1388
|
+
}) === $e)
|
|
1389
1389
|
return;
|
|
1390
1390
|
return this._retry(t);
|
|
1391
1391
|
}
|
|
@@ -1402,8 +1402,8 @@ class Z {
|
|
|
1402
1402
|
if (a instanceof Response)
|
|
1403
1403
|
return a;
|
|
1404
1404
|
}
|
|
1405
|
-
const t =
|
|
1406
|
-
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) :
|
|
1405
|
+
const t = Gt(this.request, this._options);
|
|
1406
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : kt(this.request.clone(), t, this.abortController, this._options);
|
|
1407
1407
|
}
|
|
1408
1408
|
/* istanbul ignore next */
|
|
1409
1409
|
_stream(t, n) {
|
|
@@ -1440,26 +1440,26 @@ class Z {
|
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
1442
1442
|
/*! MIT License © Sindre Sorhus */
|
|
1443
|
-
const
|
|
1444
|
-
const t = (n, a) =>
|
|
1445
|
-
for (const n of
|
|
1446
|
-
t[n] = (a, s) =>
|
|
1447
|
-
return t.create = (n) =>
|
|
1448
|
-
},
|
|
1449
|
-
get: (e, t) =>
|
|
1450
|
-
post: (e, t) =>
|
|
1451
|
-
},
|
|
1443
|
+
const ue = (e) => {
|
|
1444
|
+
const t = (n, a) => te.create(n, J(e, a));
|
|
1445
|
+
for (const n of He)
|
|
1446
|
+
t[n] = (a, s) => te.create(a, J(e, s, { method: n }));
|
|
1447
|
+
return t.create = (n) => ue(J(n)), t.extend = (n) => ue(J(e, n)), t.stop = $e, t;
|
|
1448
|
+
}, qt = ue(), Wt = qt, jt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, ge = Wt.create({ headers: jt }), Ae = {
|
|
1449
|
+
get: (e, t) => ge.get(e, t).json(),
|
|
1450
|
+
post: (e, t) => ge.post(e, t).json()
|
|
1451
|
+
}, Oe = Object.values(i), Kt = (e = "") => {
|
|
1452
1452
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1453
|
-
if (
|
|
1453
|
+
if (Oe.includes(n))
|
|
1454
1454
|
return !0;
|
|
1455
1455
|
const [a] = t.split("/");
|
|
1456
|
-
if (
|
|
1456
|
+
if (Oe.includes(a))
|
|
1457
1457
|
return !0;
|
|
1458
1458
|
throw new Error(
|
|
1459
1459
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1460
1460
|
);
|
|
1461
1461
|
}, j = 8, H = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1462
|
-
function
|
|
1462
|
+
function re({
|
|
1463
1463
|
value: e,
|
|
1464
1464
|
bigIntDecimal: t = j,
|
|
1465
1465
|
decimal: n = j
|
|
@@ -1475,19 +1475,19 @@ function se({
|
|
|
1475
1475
|
""
|
|
1476
1476
|
);
|
|
1477
1477
|
}
|
|
1478
|
-
var U, k,
|
|
1479
|
-
const
|
|
1478
|
+
var U, k, z, le, ye, Ie, ne, ce, $, q, ae, me;
|
|
1479
|
+
const Yt = class Fe {
|
|
1480
1480
|
constructor(t) {
|
|
1481
|
-
V(this, U), V(this,
|
|
1482
|
-
const n =
|
|
1481
|
+
V(this, U), V(this, z), V(this, ye), V(this, ne), V(this, $), V(this, ae), C(this, "decimalMultiplier", 10n ** 8n), C(this, "bigIntValue", 0n), C(this, "decimal");
|
|
1482
|
+
const n = Z(t);
|
|
1483
1483
|
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = H(
|
|
1484
|
-
Math.max(
|
|
1485
|
-
),
|
|
1484
|
+
Math.max(E(this, ae, me).call(this, E(this, $, q).call(this, n)), this.decimal || 0)
|
|
1485
|
+
), E(this, z, le).call(this, n);
|
|
1486
1486
|
}
|
|
1487
1487
|
static fromBigInt(t, n) {
|
|
1488
|
-
return new
|
|
1488
|
+
return new Fe({
|
|
1489
1489
|
decimal: n,
|
|
1490
|
-
value:
|
|
1490
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1491
1491
|
});
|
|
1492
1492
|
}
|
|
1493
1493
|
static shiftDecimals({
|
|
@@ -1501,19 +1501,19 @@ const Kt = class ke {
|
|
|
1501
1501
|
);
|
|
1502
1502
|
}
|
|
1503
1503
|
set(t) {
|
|
1504
|
-
return
|
|
1504
|
+
return E(this, z, le).call(this, Z(t)), this;
|
|
1505
1505
|
}
|
|
1506
1506
|
add(...t) {
|
|
1507
|
-
return
|
|
1507
|
+
return E(this, U, k).call(this, "add", ...t);
|
|
1508
1508
|
}
|
|
1509
1509
|
sub(...t) {
|
|
1510
|
-
return
|
|
1510
|
+
return E(this, U, k).call(this, "sub", ...t);
|
|
1511
1511
|
}
|
|
1512
1512
|
mul(...t) {
|
|
1513
|
-
return
|
|
1513
|
+
return E(this, U, k).call(this, "mul", ...t);
|
|
1514
1514
|
}
|
|
1515
1515
|
div(...t) {
|
|
1516
|
-
return
|
|
1516
|
+
return E(this, U, k).call(this, "div", ...t);
|
|
1517
1517
|
}
|
|
1518
1518
|
gt(t) {
|
|
1519
1519
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1558,8 +1558,8 @@ const Kt = class ke {
|
|
|
1558
1558
|
getBigIntValue(t, n) {
|
|
1559
1559
|
if (!n && typeof t == "object")
|
|
1560
1560
|
return t.bigIntValue;
|
|
1561
|
-
const a =
|
|
1562
|
-
return s === "0" || s === "undefined" ? 0n :
|
|
1561
|
+
const a = Z(t), s = E(this, $, q).call(this, a);
|
|
1562
|
+
return s === "0" || s === "undefined" ? 0n : E(this, ne, ce).call(this, s, n);
|
|
1563
1563
|
}
|
|
1564
1564
|
formatBigIntToSafeValue(t, n) {
|
|
1565
1565
|
const a = n || this.decimal || j, s = Math.max(
|
|
@@ -1617,7 +1617,7 @@ const Kt = class ke {
|
|
|
1617
1617
|
}
|
|
1618
1618
|
};
|
|
1619
1619
|
U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1620
|
-
const n =
|
|
1620
|
+
const n = E(this, ye, Ie).call(this, this, ...t), a = H(n), s = t.reduce(
|
|
1621
1621
|
(o, p) => {
|
|
1622
1622
|
const d = this.getBigIntValue(p, n);
|
|
1623
1623
|
switch (e) {
|
|
@@ -1638,63 +1638,62 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1638
1638
|
},
|
|
1639
1639
|
//normalize is to precision multiplier base
|
|
1640
1640
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1641
|
-
), r =
|
|
1641
|
+
), r = re({
|
|
1642
1642
|
bigIntDecimal: n,
|
|
1643
1643
|
decimal: Math.max(n, G(this.decimalMultiplier)),
|
|
1644
1644
|
value: s
|
|
1645
1645
|
});
|
|
1646
1646
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1647
|
-
},
|
|
1648
|
-
const t =
|
|
1649
|
-
this.bigIntValue =
|
|
1650
|
-
},
|
|
1647
|
+
}, z = /* @__PURE__ */ new WeakSet(), le = function(e) {
|
|
1648
|
+
const t = E(this, $, q).call(this, e) || "0";
|
|
1649
|
+
this.bigIntValue = E(this, ne, ce).call(this, t);
|
|
1650
|
+
}, ye = /* @__PURE__ */ new WeakSet(), Ie = function(...e) {
|
|
1651
1651
|
const t = e.map(
|
|
1652
|
-
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) :
|
|
1652
|
+
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : E(this, ae, me).call(this, E(this, $, q).call(this, n))
|
|
1653
1653
|
).filter(Boolean);
|
|
1654
1654
|
return Math.max(...t, j);
|
|
1655
|
-
},
|
|
1655
|
+
}, ne = /* @__PURE__ */ new WeakSet(), ce = function(e, t) {
|
|
1656
1656
|
const n = t ? H(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
|
|
1657
1657
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1658
1658
|
}, $ = /* @__PURE__ */ new WeakSet(), q = function(e) {
|
|
1659
1659
|
const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
|
|
1660
1660
|
useGrouping: !1,
|
|
1661
1661
|
maximumFractionDigits: 20
|
|
1662
|
-
}) :
|
|
1662
|
+
}) : Z(e)}`.replaceAll(",", ".").split(".");
|
|
1663
1663
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1664
|
-
},
|
|
1664
|
+
}, ae = /* @__PURE__ */ new WeakSet(), me = function(e) {
|
|
1665
1665
|
var t;
|
|
1666
1666
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1667
1667
|
return Math.max(n, j);
|
|
1668
1668
|
};
|
|
1669
|
-
let
|
|
1670
|
-
function
|
|
1669
|
+
let Te = Yt;
|
|
1670
|
+
function Z(e) {
|
|
1671
1671
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1672
1672
|
}
|
|
1673
|
-
const
|
|
1674
|
-
let
|
|
1675
|
-
const
|
|
1676
|
-
if (!
|
|
1673
|
+
const ee = (e, t) => typeof e == "bigint" ? re({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1674
|
+
let he;
|
|
1675
|
+
const Se = (e) => {
|
|
1676
|
+
if (!he)
|
|
1677
1677
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1678
|
-
return
|
|
1679
|
-
},
|
|
1680
|
-
|
|
1681
|
-
const n = await
|
|
1678
|
+
return he.get(e.toUpperCase()) || { decimal: A.THOR, identifier: "" };
|
|
1679
|
+
}, ve = async (e, t = 0) => {
|
|
1680
|
+
Kt(e);
|
|
1681
|
+
const n = await wt(_e(e)), a = ee(t, n);
|
|
1682
1682
|
return new N({ decimal: n, value: a, identifier: e });
|
|
1683
|
-
};
|
|
1684
|
-
class N extends
|
|
1683
|
+
}, Ce = /* @__PURE__ */ new Map();
|
|
1684
|
+
class N extends Te {
|
|
1685
1685
|
constructor(t) {
|
|
1686
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}
|
|
1686
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = Ce.get(n);
|
|
1687
|
+
if (a)
|
|
1688
|
+
return a.set(t.value);
|
|
1687
1689
|
super(
|
|
1688
|
-
t.value instanceof
|
|
1689
|
-
), C(this, "address"), C(this, "
|
|
1690
|
-
const
|
|
1691
|
-
this.type =
|
|
1692
|
-
}
|
|
1693
|
-
get assetValue() {
|
|
1694
|
-
return `${this.getValue("string")} ${this.ticker}`;
|
|
1690
|
+
t.value instanceof Te ? t.value : { decimal: t.decimal, value: t.value }
|
|
1691
|
+
), C(this, "address"), C(this, "isSynthetic", !1), C(this, "isGasAsset", !1), C(this, "chain"), C(this, "symbol"), C(this, "ticker"), C(this, "type");
|
|
1692
|
+
const s = _e(n);
|
|
1693
|
+
this.type = Rt(s), this.chain = s.chain, this.ticker = s.ticker, this.symbol = s.symbol, this.address = s.address, this.isSynthetic = s.isSynthetic, this.isGasAsset = s.isGasAsset, Ce.set(n, this);
|
|
1695
1694
|
}
|
|
1696
1695
|
toString(t = !1) {
|
|
1697
|
-
const n = this.isSynthetic ? this.symbol.split("-")[0] :
|
|
1696
|
+
const n = this.isSynthetic ? this.symbol.split("-")[0] : this.ticker;
|
|
1698
1697
|
return t ? n : (
|
|
1699
1698
|
// THOR.ETH/ETH | ETH.USDT-0x1234567890
|
|
1700
1699
|
`${this.chain}.${this.symbol}`
|
|
@@ -1704,23 +1703,23 @@ class N extends ce {
|
|
|
1704
1703
|
return this.chain === t && this.symbol === n;
|
|
1705
1704
|
}
|
|
1706
1705
|
static async fromString(t, n = 0) {
|
|
1707
|
-
return
|
|
1706
|
+
return ve(t, n);
|
|
1708
1707
|
}
|
|
1709
1708
|
static fromStringSync(t, n = 0) {
|
|
1710
|
-
const { isSynthetic: a } =
|
|
1709
|
+
const { isSynthetic: a } = _e(t), { decimal: s, identifier: r } = Se(
|
|
1711
1710
|
t
|
|
1712
|
-
), o =
|
|
1711
|
+
), o = ee(n, s);
|
|
1713
1712
|
return r ? new N({ decimal: s, identifier: r, value: o }) : a ? new N({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1714
1713
|
}
|
|
1715
1714
|
static async fromIdentifier(t, n = 0) {
|
|
1716
|
-
return
|
|
1715
|
+
return ve(t, n);
|
|
1717
1716
|
}
|
|
1718
1717
|
static fromIdentifierSync(t, n = 0) {
|
|
1719
|
-
const { decimal: a, identifier: s } =
|
|
1718
|
+
const { decimal: a, identifier: s } = Se(t), r = ee(n, a);
|
|
1720
1719
|
return new N({ decimal: a, identifier: s, value: r });
|
|
1721
1720
|
}
|
|
1722
1721
|
static fromChainOrSignature(t, n = 0) {
|
|
1723
|
-
const { decimal: a, identifier: s } =
|
|
1722
|
+
const { decimal: a, identifier: s } = Et(t), r = ee(n, a);
|
|
1724
1723
|
return new N({ value: r, decimal: a, identifier: s });
|
|
1725
1724
|
}
|
|
1726
1725
|
static async loadStaticAssets() {
|
|
@@ -1734,7 +1733,7 @@ class N extends ce {
|
|
|
1734
1733
|
NativeList: s,
|
|
1735
1734
|
...r
|
|
1736
1735
|
} = await import("@swapkit/tokens");
|
|
1737
|
-
|
|
1736
|
+
he = [s, ...Object.values(r)].reduce(
|
|
1738
1737
|
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: y, ...u }) => {
|
|
1739
1738
|
const c = "decimals" in u ? u.decimals : A[y];
|
|
1740
1739
|
o.set(d, { identifier: d, decimal: c });
|
|
@@ -1752,7 +1751,7 @@ class N extends ce {
|
|
|
1752
1751
|
);
|
|
1753
1752
|
}
|
|
1754
1753
|
}
|
|
1755
|
-
const
|
|
1754
|
+
const de = (e) => {
|
|
1756
1755
|
const t = N.fromChainOrSignature(e);
|
|
1757
1756
|
switch (e) {
|
|
1758
1757
|
case i.Bitcoin:
|
|
@@ -1770,17 +1769,17 @@ const oe = (e) => {
|
|
|
1770
1769
|
default:
|
|
1771
1770
|
return t.set(1e-8);
|
|
1772
1771
|
}
|
|
1773
|
-
},
|
|
1772
|
+
}, _e = (e) => {
|
|
1774
1773
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".").pop().split("/"), s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
|
|
1775
1774
|
return {
|
|
1776
1775
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1777
1776
|
chain: r,
|
|
1778
|
-
isGasAsset:
|
|
1777
|
+
isGasAsset: Le({ chain: r, symbol: o }),
|
|
1779
1778
|
isSynthetic: t,
|
|
1780
1779
|
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1781
1780
|
ticker: p
|
|
1782
1781
|
};
|
|
1783
|
-
},
|
|
1782
|
+
}, Xt = {
|
|
1784
1783
|
/**
|
|
1785
1784
|
* Core
|
|
1786
1785
|
*/
|
|
@@ -1839,21 +1838,21 @@ const oe = (e) => {
|
|
|
1839
1838
|
};
|
|
1840
1839
|
class m extends Error {
|
|
1841
1840
|
constructor(t, n) {
|
|
1842
|
-
console.error(n), super(t, { cause: { code:
|
|
1841
|
+
console.error(n), super(t, { cause: { code: Xt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1843
1842
|
}
|
|
1844
1843
|
}
|
|
1845
|
-
class D extends
|
|
1844
|
+
class D extends Te {
|
|
1846
1845
|
eq(t) {
|
|
1847
1846
|
return this.eqValue(t);
|
|
1848
1847
|
}
|
|
1849
1848
|
static fromBigInt(t, n) {
|
|
1850
1849
|
return new D({
|
|
1851
1850
|
decimal: n,
|
|
1852
|
-
value:
|
|
1851
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1853
1852
|
});
|
|
1854
1853
|
}
|
|
1855
1854
|
}
|
|
1856
|
-
const
|
|
1855
|
+
const Jt = [
|
|
1857
1856
|
{
|
|
1858
1857
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1859
1858
|
stateMutability: "nonpayable",
|
|
@@ -1944,7 +1943,7 @@ const Xt = [
|
|
|
1944
1943
|
type: "function"
|
|
1945
1944
|
},
|
|
1946
1945
|
{ stateMutability: "payable", type: "receive" }
|
|
1947
|
-
],
|
|
1946
|
+
], Qt = [
|
|
1948
1947
|
{
|
|
1949
1948
|
inputs: [
|
|
1950
1949
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2088,7 +2087,7 @@ const Xt = [
|
|
|
2088
2087
|
type: "function"
|
|
2089
2088
|
},
|
|
2090
2089
|
{ stateMutability: "payable", type: "receive" }
|
|
2091
|
-
],
|
|
2090
|
+
], zt = [
|
|
2092
2091
|
{
|
|
2093
2092
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2094
2093
|
stateMutability: "nonpayable",
|
|
@@ -2193,7 +2192,7 @@ const Xt = [
|
|
|
2193
2192
|
type: "function"
|
|
2194
2193
|
},
|
|
2195
2194
|
{ stateMutability: "payable", type: "receive" }
|
|
2196
|
-
],
|
|
2195
|
+
], Zt = [
|
|
2197
2196
|
{
|
|
2198
2197
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2199
2198
|
stateMutability: "nonpayable",
|
|
@@ -2284,7 +2283,7 @@ const Xt = [
|
|
|
2284
2283
|
type: "function"
|
|
2285
2284
|
},
|
|
2286
2285
|
{ stateMutability: "payable", type: "receive" }
|
|
2287
|
-
],
|
|
2286
|
+
], en = [
|
|
2288
2287
|
{
|
|
2289
2288
|
inputs: [
|
|
2290
2289
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2428,7 +2427,7 @@ const Xt = [
|
|
|
2428
2427
|
type: "function"
|
|
2429
2428
|
},
|
|
2430
2429
|
{ stateMutability: "payable", type: "receive" }
|
|
2431
|
-
],
|
|
2430
|
+
], tn = [
|
|
2432
2431
|
{
|
|
2433
2432
|
inputs: [
|
|
2434
2433
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2547,7 +2546,7 @@ const Xt = [
|
|
|
2547
2546
|
type: "function"
|
|
2548
2547
|
},
|
|
2549
2548
|
{ stateMutability: "payable", type: "receive" }
|
|
2550
|
-
],
|
|
2549
|
+
], nn = [
|
|
2551
2550
|
{
|
|
2552
2551
|
inputs: [
|
|
2553
2552
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2666,7 +2665,7 @@ const Xt = [
|
|
|
2666
2665
|
type: "function"
|
|
2667
2666
|
},
|
|
2668
2667
|
{ stateMutability: "payable", type: "receive" }
|
|
2669
|
-
],
|
|
2668
|
+
], an = [
|
|
2670
2669
|
{
|
|
2671
2670
|
inputs: [
|
|
2672
2671
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2785,7 +2784,7 @@ const Xt = [
|
|
|
2785
2784
|
type: "function"
|
|
2786
2785
|
},
|
|
2787
2786
|
{ stateMutability: "payable", type: "receive" }
|
|
2788
|
-
],
|
|
2787
|
+
], sn = [
|
|
2789
2788
|
{
|
|
2790
2789
|
inputs: [
|
|
2791
2790
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2904,7 +2903,7 @@ const Xt = [
|
|
|
2904
2903
|
type: "function"
|
|
2905
2904
|
},
|
|
2906
2905
|
{ stateMutability: "payable", type: "receive" }
|
|
2907
|
-
],
|
|
2906
|
+
], rn = [
|
|
2908
2907
|
{
|
|
2909
2908
|
inputs: [
|
|
2910
2909
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3031,7 +3030,7 @@ const Xt = [
|
|
|
3031
3030
|
type: "function"
|
|
3032
3031
|
},
|
|
3033
3032
|
{ stateMutability: "payable", type: "receive" }
|
|
3034
|
-
],
|
|
3033
|
+
], on = [
|
|
3035
3034
|
{
|
|
3036
3035
|
inputs: [
|
|
3037
3036
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3158,7 +3157,7 @@ const Xt = [
|
|
|
3158
3157
|
type: "function"
|
|
3159
3158
|
},
|
|
3160
3159
|
{ stateMutability: "payable", type: "receive" }
|
|
3161
|
-
],
|
|
3160
|
+
], pn = [
|
|
3162
3161
|
{
|
|
3163
3162
|
inputs: [
|
|
3164
3163
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3285,7 +3284,7 @@ const Xt = [
|
|
|
3285
3284
|
type: "function"
|
|
3286
3285
|
},
|
|
3287
3286
|
{ stateMutability: "payable", type: "receive" }
|
|
3288
|
-
],
|
|
3287
|
+
], dn = [
|
|
3289
3288
|
{
|
|
3290
3289
|
inputs: [
|
|
3291
3290
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3412,7 +3411,7 @@ const Xt = [
|
|
|
3412
3411
|
type: "function"
|
|
3413
3412
|
},
|
|
3414
3413
|
{ stateMutability: "payable", type: "receive" }
|
|
3415
|
-
],
|
|
3414
|
+
], un = [
|
|
3416
3415
|
{
|
|
3417
3416
|
inputs: [
|
|
3418
3417
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3539,27 +3538,27 @@ const Xt = [
|
|
|
3539
3538
|
type: "function"
|
|
3540
3539
|
},
|
|
3541
3540
|
{ stateMutability: "payable", type: "receive" }
|
|
3542
|
-
],
|
|
3543
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3544
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3545
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3546
|
-
},
|
|
3547
|
-
...
|
|
3541
|
+
], Ge = {
|
|
3542
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Jt,
|
|
3543
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: zt,
|
|
3544
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Zt
|
|
3545
|
+
}, ln = {
|
|
3546
|
+
...Ge,
|
|
3548
3547
|
// AVAX
|
|
3549
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3550
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3551
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3548
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: tn,
|
|
3549
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Qt,
|
|
3550
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: an,
|
|
3552
3551
|
// BSC
|
|
3553
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3552
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: en,
|
|
3554
3553
|
// ETH
|
|
3555
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3556
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3557
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3558
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3559
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3560
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3561
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3562
|
-
},
|
|
3554
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: nn,
|
|
3555
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: sn,
|
|
3556
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: rn,
|
|
3557
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: on,
|
|
3558
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: pn,
|
|
3559
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: dn,
|
|
3560
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: un
|
|
3561
|
+
}, yn = ({
|
|
3563
3562
|
streamSwap: e,
|
|
3564
3563
|
contractAddress: t,
|
|
3565
3564
|
recipient: n,
|
|
@@ -3576,10 +3575,10 @@ const Xt = [
|
|
|
3576
3575
|
tcRouter: _,
|
|
3577
3576
|
tcVault: b,
|
|
3578
3577
|
vault: w,
|
|
3579
|
-
token:
|
|
3578
|
+
token: R
|
|
3580
3579
|
}
|
|
3581
3580
|
}) => {
|
|
3582
|
-
const O = !!
|
|
3581
|
+
const O = !!Ge[t.toLowerCase()];
|
|
3583
3582
|
if (O && !y)
|
|
3584
3583
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3585
3584
|
const I = c || d, S = e && u || I;
|
|
@@ -3589,19 +3588,19 @@ const Xt = [
|
|
|
3589
3588
|
throw new Error("TC Router is required on calldata");
|
|
3590
3589
|
if (!S)
|
|
3591
3590
|
throw new Error("TC Memo is required on calldata");
|
|
3592
|
-
if (!
|
|
3591
|
+
if (!R)
|
|
3593
3592
|
throw new Error("Token is required on calldata");
|
|
3594
3593
|
const P = [
|
|
3595
3594
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3596
3595
|
a(_ || y),
|
|
3597
3596
|
a(b || w),
|
|
3598
3597
|
S.replace("{recipientAddress}", n),
|
|
3599
|
-
a(
|
|
3598
|
+
a(R),
|
|
3600
3599
|
s
|
|
3601
|
-
],
|
|
3602
|
-
return [...P, ...
|
|
3603
|
-
},
|
|
3604
|
-
const n =
|
|
3600
|
+
], qe = O ? [a(y), o, p] : [r, p];
|
|
3601
|
+
return [...P, ...qe];
|
|
3602
|
+
}, cn = ({ chain: e, txHash: t }) => {
|
|
3603
|
+
const n = Pe[e];
|
|
3605
3604
|
switch (e) {
|
|
3606
3605
|
case i.Binance:
|
|
3607
3606
|
case i.Bitcoin:
|
|
@@ -3626,8 +3625,8 @@ const Xt = [
|
|
|
3626
3625
|
default:
|
|
3627
3626
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3628
3627
|
}
|
|
3629
|
-
},
|
|
3630
|
-
const n =
|
|
3628
|
+
}, mn = ({ chain: e, address: t }) => {
|
|
3629
|
+
const n = Pe[e];
|
|
3631
3630
|
switch (e) {
|
|
3632
3631
|
case i.Arbitrum:
|
|
3633
3632
|
case i.Avalanche:
|
|
@@ -3650,29 +3649,29 @@ const Xt = [
|
|
|
3650
3649
|
default:
|
|
3651
3650
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3652
3651
|
}
|
|
3653
|
-
}, mn = (e) => {
|
|
3654
|
-
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3655
|
-
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3656
3652
|
}, Tn = (e) => {
|
|
3657
3653
|
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3658
|
-
return
|
|
3659
|
-
},
|
|
3654
|
+
return Ae.get(`${t}/thorchain/inbound_addresses`);
|
|
3655
|
+
}, hn = (e) => {
|
|
3656
|
+
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3657
|
+
return Ae.get(`${t}/thorchain/mimir`);
|
|
3658
|
+
}, Me = () => Object.values(i).reduce(
|
|
3660
3659
|
(e, t) => (e[t] = null, e),
|
|
3661
3660
|
{}
|
|
3662
3661
|
);
|
|
3663
|
-
var L,
|
|
3664
|
-
class
|
|
3662
|
+
var L, se, K, M, Y, X;
|
|
3663
|
+
class Ln {
|
|
3665
3664
|
constructor({ stagenet: t } = {}) {
|
|
3666
|
-
T(this, "connectedChains",
|
|
3667
|
-
T(this, "connectedWallets",
|
|
3665
|
+
T(this, "connectedChains", Me());
|
|
3666
|
+
T(this, "connectedWallets", Me());
|
|
3668
3667
|
T(this, "stagenet", !1);
|
|
3669
3668
|
T(this, "getAddress", (t) => {
|
|
3670
3669
|
var n;
|
|
3671
3670
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3672
3671
|
});
|
|
3673
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3672
|
+
T(this, "getExplorerTxUrl", (t, n) => cn({ chain: t, txHash: n }));
|
|
3674
3673
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3675
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3674
|
+
T(this, "getExplorerAddressUrl", (t, n) => mn({ chain: t, address: n }));
|
|
3676
3675
|
T(this, "getBalance", async (t, n) => {
|
|
3677
3676
|
const a = await this.getWalletByChain(t, n);
|
|
3678
3677
|
return (a == null ? void 0 : a.balance) || [];
|
|
@@ -3683,22 +3682,22 @@ class Bn {
|
|
|
3683
3682
|
if (!a.complete)
|
|
3684
3683
|
throw new m("core_swap_route_not_complete");
|
|
3685
3684
|
try {
|
|
3686
|
-
if (
|
|
3685
|
+
if (et.includes(r)) {
|
|
3687
3686
|
const y = this.connectedWallets[o];
|
|
3688
3687
|
if (!(y != null && y.sendTransaction))
|
|
3689
3688
|
throw new m("core_wallet_connection_not_found");
|
|
3690
3689
|
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3691
3690
|
throw new m("core_swap_route_transaction_not_found");
|
|
3692
|
-
const { data: c, from: _, to: b, value: w } = a.transaction,
|
|
3691
|
+
const { data: c, from: _, to: b, value: w } = a.transaction, R = {
|
|
3693
3692
|
data: c,
|
|
3694
3693
|
from: _,
|
|
3695
3694
|
to: b.toLowerCase(),
|
|
3696
|
-
chainId: BigInt(
|
|
3695
|
+
chainId: BigInt(dt[o]),
|
|
3697
3696
|
value: w ? BigInt(w) : 0n
|
|
3698
3697
|
};
|
|
3699
|
-
return y.sendTransaction(
|
|
3698
|
+
return y.sendTransaction(R, s);
|
|
3700
3699
|
}
|
|
3701
|
-
if (
|
|
3700
|
+
if (nt.includes(r)) {
|
|
3702
3701
|
if (!a.calldata.fromAsset)
|
|
3703
3702
|
throw new m("core_swap_asset_not_recognized");
|
|
3704
3703
|
const y = await N.fromString(a.calldata.fromAsset);
|
|
@@ -3706,8 +3705,8 @@ class Bn {
|
|
|
3706
3705
|
throw new m("core_swap_asset_not_recognized");
|
|
3707
3706
|
const { address: u } = await f(this, L).call(this, y.chain), {
|
|
3708
3707
|
contract: c,
|
|
3709
|
-
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap:
|
|
3710
|
-
} = a, O = y.add(D.fromBigInt(BigInt(b), y.decimal)), I = t &&
|
|
3708
|
+
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap: R }
|
|
3709
|
+
} = a, O = y.add(D.fromBigInt(BigInt(b), y.decimal)), I = t && R || w;
|
|
3711
3710
|
return this.deposit({
|
|
3712
3711
|
expiration: _,
|
|
3713
3712
|
assetValue: O,
|
|
@@ -3717,18 +3716,18 @@ class Bn {
|
|
|
3717
3716
|
recipient: u
|
|
3718
3717
|
});
|
|
3719
3718
|
}
|
|
3720
|
-
if (
|
|
3719
|
+
if (tt.includes(r)) {
|
|
3721
3720
|
const { calldata: y, contract: u } = a;
|
|
3722
3721
|
if (!u)
|
|
3723
3722
|
throw new m("core_swap_contract_not_found");
|
|
3724
3723
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3725
3724
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3726
3725
|
throw new m("core_wallet_connection_not_found");
|
|
3727
|
-
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"),
|
|
3726
|
+
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), R = b(o), O = ln[u.toLowerCase()];
|
|
3728
3727
|
if (!O)
|
|
3729
3728
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3730
|
-
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O,
|
|
3731
|
-
...
|
|
3729
|
+
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O, R))).getFunction("swapIn").populateTransaction(
|
|
3730
|
+
...yn({
|
|
3732
3731
|
streamSwap: t,
|
|
3733
3732
|
toChecksumAddress: w,
|
|
3734
3733
|
contractAddress: u,
|
|
@@ -3796,7 +3795,7 @@ class Bn {
|
|
|
3796
3795
|
case i.Ethereum:
|
|
3797
3796
|
case i.BinanceSmartChain:
|
|
3798
3797
|
case i.Avalanche: {
|
|
3799
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ?
|
|
3798
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Qe : r === i.BinanceSmartChain ? ze : Je;
|
|
3800
3799
|
return await d.call({
|
|
3801
3800
|
abi: c,
|
|
3802
3801
|
contractAddress: a || (await f(this, L).call(this, r)).router,
|
|
@@ -3818,8 +3817,8 @@ class Bn {
|
|
|
3818
3817
|
return await d.transfer(y);
|
|
3819
3818
|
}
|
|
3820
3819
|
} catch (u) {
|
|
3821
|
-
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), w = c == null ? void 0 : c.includes("server"),
|
|
3822
|
-
throw new m(
|
|
3820
|
+
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), w = c == null ? void 0 : c.includes("server"), R = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : w ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3821
|
+
throw new m(R, u);
|
|
3823
3822
|
}
|
|
3824
3823
|
});
|
|
3825
3824
|
/**
|
|
@@ -3865,7 +3864,7 @@ class Bn {
|
|
|
3865
3864
|
isPendingSymmAsset: o,
|
|
3866
3865
|
mode: p = "sym"
|
|
3867
3866
|
}) => {
|
|
3868
|
-
const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"), b = o || c, w = b ? s || this.getAddress(i.THORChain) : "",
|
|
3867
|
+
const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"), b = o || c, w = b ? s || this.getAddress(i.THORChain) : "", R = u || p === "asset" ? r || this.getAddress(d) : "";
|
|
3869
3868
|
if (!c && !_)
|
|
3870
3869
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3871
3870
|
if (b && !w)
|
|
@@ -3876,7 +3875,7 @@ class Bn {
|
|
|
3876
3875
|
try {
|
|
3877
3876
|
O = await f(this, M).call(this, {
|
|
3878
3877
|
assetValue: n,
|
|
3879
|
-
memo: x(h.DEPOSIT, { ...S, address:
|
|
3878
|
+
memo: x(h.DEPOSIT, { ...S, address: R })
|
|
3880
3879
|
});
|
|
3881
3880
|
} catch (P) {
|
|
3882
3881
|
throw new m("core_transaction_add_liquidity_rune_error", P);
|
|
@@ -3899,7 +3898,7 @@ class Bn {
|
|
|
3899
3898
|
from: s,
|
|
3900
3899
|
to: r
|
|
3901
3900
|
}) => {
|
|
3902
|
-
const o = r === "rune" ? N.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p =
|
|
3901
|
+
const o = r === "rune" ? N.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = de(s === "asset" ? n.chain : i.THORChain), d = t || x(h.WITHDRAW, {
|
|
3903
3902
|
symbol: n.symbol,
|
|
3904
3903
|
chain: n.chain,
|
|
3905
3904
|
ticker: n.ticker,
|
|
@@ -3921,7 +3920,7 @@ class Bn {
|
|
|
3921
3920
|
chain: t.chain,
|
|
3922
3921
|
singleSide: !0,
|
|
3923
3922
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3924
|
-
}), p = r === h.DEPOSIT ? t :
|
|
3923
|
+
}), p = r === h.DEPOSIT ? t : de(t.chain);
|
|
3925
3924
|
return f(this, M).call(this, { memo: o, assetValue: p });
|
|
3926
3925
|
});
|
|
3927
3926
|
T(this, "loan", ({
|
|
@@ -3948,7 +3947,7 @@ class Bn {
|
|
|
3948
3947
|
});
|
|
3949
3948
|
return f(this, Y).call(this, {
|
|
3950
3949
|
memo: r,
|
|
3951
|
-
assetValue: t === "bond" ? n :
|
|
3950
|
+
assetValue: t === "bond" ? n : de(i.THORChain)
|
|
3952
3951
|
});
|
|
3953
3952
|
});
|
|
3954
3953
|
T(this, "registerThorname", ({
|
|
@@ -3959,7 +3958,7 @@ class Bn {
|
|
|
3959
3958
|
try {
|
|
3960
3959
|
t.forEach((r) => {
|
|
3961
3960
|
this[r.connectMethodName] = r.connect({
|
|
3962
|
-
addChain: f(this,
|
|
3961
|
+
addChain: f(this, se),
|
|
3963
3962
|
config: n || {},
|
|
3964
3963
|
apis: a,
|
|
3965
3964
|
rpcUrls: s
|
|
@@ -4044,14 +4043,14 @@ class Bn {
|
|
|
4044
4043
|
halted: !1,
|
|
4045
4044
|
chain: i.THORChain
|
|
4046
4045
|
};
|
|
4047
|
-
const a = (await
|
|
4046
|
+
const a = (await Tn(this.stagenet)).find((s) => s.chain === t);
|
|
4048
4047
|
if (!a)
|
|
4049
4048
|
throw new m("core_inbound_data_not_found");
|
|
4050
4049
|
if (a != null && a.halted)
|
|
4051
4050
|
throw new m("core_chain_halted");
|
|
4052
4051
|
return a;
|
|
4053
4052
|
});
|
|
4054
|
-
B(this,
|
|
4053
|
+
B(this, se, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4055
4054
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4056
4055
|
});
|
|
4057
4056
|
B(this, K, async ({
|
|
@@ -4085,7 +4084,7 @@ class Bn {
|
|
|
4085
4084
|
gas_rate: s,
|
|
4086
4085
|
router: r,
|
|
4087
4086
|
address: o
|
|
4088
|
-
} = await f(this, L).call(this, t.chain), p = (parseInt(s) || 0) *
|
|
4087
|
+
} = await f(this, L).call(this, t.chain), p = (parseInt(s) || 0) * At[a];
|
|
4089
4088
|
return this.deposit({
|
|
4090
4089
|
assetValue: t,
|
|
4091
4090
|
recipient: o,
|
|
@@ -4095,7 +4094,7 @@ class Bn {
|
|
|
4095
4094
|
});
|
|
4096
4095
|
});
|
|
4097
4096
|
B(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
4098
|
-
const a = await
|
|
4097
|
+
const a = await hn(this.stagenet);
|
|
4099
4098
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4100
4099
|
throw new m("core_chain_halted");
|
|
4101
4100
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
@@ -4109,66 +4108,66 @@ class Bn {
|
|
|
4109
4108
|
this.stagenet = !!t;
|
|
4110
4109
|
}
|
|
4111
4110
|
}
|
|
4112
|
-
L = new WeakMap(),
|
|
4111
|
+
L = new WeakMap(), se = new WeakMap(), K = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
|
|
4113
4112
|
export {
|
|
4114
|
-
|
|
4115
|
-
|
|
4113
|
+
et as AGG_SWAP,
|
|
4114
|
+
bn as ApiError,
|
|
4116
4115
|
W as ApiUrl,
|
|
4117
4116
|
N as AssetValue,
|
|
4118
4117
|
A as BaseDecimal,
|
|
4119
|
-
|
|
4118
|
+
Te as BigIntArithmetics,
|
|
4120
4119
|
i as Chain,
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4120
|
+
fe as ChainId,
|
|
4121
|
+
On as ChainIdToChain,
|
|
4122
|
+
dt as ChainToChainId,
|
|
4123
|
+
Pe as ChainToExplorerUrl,
|
|
4124
|
+
gn as ChainToHexChainId,
|
|
4125
|
+
ut as ChainToRPC,
|
|
4126
|
+
it as ContractAddress,
|
|
4127
|
+
En as CosmosChainList,
|
|
4128
|
+
rt as DerivationPath,
|
|
4130
4129
|
l as ERROR_CODE,
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4130
|
+
at as ERROR_MODULE,
|
|
4131
|
+
Ne as ERROR_TYPE,
|
|
4132
|
+
ot as EVMChainList,
|
|
4133
|
+
lt as ErrorCode,
|
|
4135
4134
|
F as FeeOption,
|
|
4136
4135
|
h as MemoType,
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4136
|
+
wn as NetworkDerivationPath,
|
|
4137
|
+
Ze as QuoteMode,
|
|
4138
|
+
De as RPCUrl,
|
|
4139
|
+
Ae as RequestClient,
|
|
4140
|
+
tt as SWAP_IN,
|
|
4141
|
+
nt as SWAP_OUT,
|
|
4142
|
+
Ln as SwapKitCore,
|
|
4144
4143
|
m as SwapKitError,
|
|
4145
4144
|
D as SwapKitNumber,
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4145
|
+
Qe as TCAvalancheDepositABI,
|
|
4146
|
+
ze as TCBscDepositABI,
|
|
4147
|
+
Je as TCEthereumVaultAbi,
|
|
4148
|
+
Rn as TCSupportedChainList,
|
|
4149
|
+
An as UTXOChainList,
|
|
4150
|
+
yt as WalletOption,
|
|
4151
|
+
In as assetFromString,
|
|
4152
|
+
Bn as derivationPathToString,
|
|
4153
|
+
fn as erc20ABI,
|
|
4154
|
+
Sn as filterAssets,
|
|
4155
|
+
re as formatBigIntToSafeValue,
|
|
4156
|
+
At as gasFeeMultiplier,
|
|
4157
|
+
Rt as getAssetType,
|
|
4158
|
+
St as getAsymmetricAssetShare,
|
|
4159
|
+
Cn as getAsymmetricAssetWithdrawAmount,
|
|
4160
|
+
It as getAsymmetricRuneShare,
|
|
4161
|
+
vn as getAsymmetricRuneWithdrawAmount,
|
|
4162
|
+
Et as getCommonAssetInfo,
|
|
4163
|
+
wt as getDecimal,
|
|
4164
|
+
Nn as getEstimatedPoolShare,
|
|
4165
|
+
xn as getLiquiditySlippage,
|
|
4167
4166
|
x as getMemoFor,
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4167
|
+
de as getMinAmountByChain,
|
|
4168
|
+
vt as getSymmetricPoolShare,
|
|
4169
|
+
Mn as getSymmetricWithdraw,
|
|
4170
|
+
Dn as getTHORNameCost,
|
|
4171
|
+
Le as isGasAsset,
|
|
4172
|
+
Pn as validateTHORName
|
|
4174
4173
|
};
|