@swapkit/core 1.0.0-rc.30 → 1.0.0-rc.32
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 +336 -334
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (e, t, n) => (
|
|
1
|
+
var Ge = Object.defineProperty;
|
|
2
|
+
var qe = (e, t, n) => t in e ? Ge(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var T = (e, t, n) => (qe(e, typeof t != "symbol" ? t + "" : t, n), n), We = (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) => (We(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
|
|
12
|
+
var je = Object.defineProperty, Ke = (e, t, n) => t in e ? je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, S = (e, t, n) => (Ke(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
13
|
const _n = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
@@ -108,7 +108,7 @@ const _n = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Ye = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const _n = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Xe = [
|
|
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
|
+
], Je = [
|
|
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 Qe = /* @__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))(Qe || {});
|
|
604
|
+
const ze = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], Ze = [
|
|
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
|
+
], et = [
|
|
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 || {}), tt = /* @__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))(tt || {}), 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 nt = {
|
|
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,12 +677,12 @@ const at = {
|
|
|
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
679
|
}, ie = (e, t) => {
|
|
680
|
-
let n =
|
|
680
|
+
let n = nt[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
|
-
|
|
685
|
+
class Ce extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -698,14 +698,14 @@ let fn = class Me extends Error {
|
|
|
698
698
|
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
700
|
const c = r || ie(s, u || []) || "";
|
|
701
|
-
super(c),
|
|
701
|
+
super(c), S(this, "status"), S(this, "revision"), S(this, "type"), S(this, "module"), S(this, "code"), S(this, "message"), S(this, "display"), S(this, "stack"), S(this, "options"), S(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = ie(s, u || []), this.code = s, this.type = o || ve.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 Ce(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -723,9 +723,9 @@ let fn = class Me extends Error {
|
|
|
723
723
|
throw Error(t, { cause: this.stack });
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
|
-
}
|
|
727
|
-
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}),
|
|
728
|
-
const
|
|
726
|
+
}
|
|
727
|
+
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), at = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(at || {}), st = /* @__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))(st || {});
|
|
728
|
+
const fn = {
|
|
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 it = [
|
|
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
|
+
], bn = [
|
|
755
755
|
"BTC",
|
|
756
756
|
"BCH",
|
|
757
757
|
"DOGE",
|
|
758
758
|
"LTC"
|
|
759
759
|
/* Litecoin */
|
|
760
|
-
],
|
|
760
|
+
], wn = [
|
|
761
761
|
"GAIA",
|
|
762
762
|
"THOR",
|
|
763
763
|
"BNB"
|
|
764
764
|
/* Binance */
|
|
765
|
-
],
|
|
765
|
+
], An = [
|
|
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 ae = Object.values(i),
|
|
778
|
+
var Te = /* @__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))(Te || {}), Me = /* @__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))(Me || {}), F = /* @__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))(F || {});
|
|
779
|
+
const ae = Object.values(i), rt = Object.keys(i), he = ae.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
|
-
const n =
|
|
781
|
+
const n = rt.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
786
|
-
(e, t) => (e[t] =
|
|
785
|
+
), ot = ae.reduce(
|
|
786
|
+
(e, t) => (e[t] = Te[he[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), pt = ae.reduce(
|
|
789
|
+
(e, t) => (e[t] = Me[he[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
),
|
|
791
|
+
), En = ae.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
|
-
const n = `${
|
|
794
|
-
return e[t] =
|
|
793
|
+
const n = `${he[t]}Hex`;
|
|
794
|
+
return e[t] = Te[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
|
-
),
|
|
797
|
+
), Rn = {
|
|
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
|
+
}, Ne = {
|
|
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 dt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(dt || {}), 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 || {}), $ = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))($ || {}), ut = /* @__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))(ut || {}), lt = Object.defineProperty, yt = (e, t, n) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (yt(e, typeof t != "symbol" ? t + "" : t, n), n), ct = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
|
-
},
|
|
842
|
+
}, K = (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
|
+
}, x = (e, t, n) => (ct(e, t, "access private method"), n);
|
|
847
|
+
const mt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await
|
|
849
|
+
const { result: n } = await fe.post(pt[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: mt }, "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
|
+
}, Tt = 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") ? xe({ chain: i.Ethereum, to: t }) : A.ETH;
|
|
871
|
+
}, ht = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ?
|
|
874
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? xe({ chain: i.Avalanche, to: t.toLowerCase() }) : A.AVAX;
|
|
874
|
+
}, _t = async (e) => (e === i.BinanceSmartChain, A.BSC), ft = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
|
-
return
|
|
877
|
+
return Tt(t);
|
|
878
878
|
case i.Avalanche:
|
|
879
|
-
return
|
|
879
|
+
return ht(t);
|
|
880
880
|
case i.BinanceSmartChain:
|
|
881
|
-
return
|
|
881
|
+
return _t(t);
|
|
882
882
|
default:
|
|
883
883
|
return A[e];
|
|
884
884
|
}
|
|
885
|
-
},
|
|
886
|
-
[
|
|
887
|
-
[
|
|
888
|
-
[
|
|
889
|
-
},
|
|
885
|
+
}, bt = {
|
|
886
|
+
[$.Average]: 1.2,
|
|
887
|
+
[$.Fast]: 1.5,
|
|
888
|
+
[$.Fastest]: 2
|
|
889
|
+
}, De = ({ 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
|
+
}, wt = (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
|
+
}, At = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
946
946
|
return "Synth";
|
|
947
947
|
switch (e) {
|
|
@@ -971,65 +971,65 @@ 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
|
+
}, gn = (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
|
+
}, Et = new RegExp(
|
|
979
979
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
980
|
"gmi"
|
|
981
|
-
),
|
|
981
|
+
), Rt = (e) => {
|
|
982
982
|
const [t, n] = e.split(".");
|
|
983
|
-
if (!
|
|
983
|
+
if (!it.includes(t))
|
|
984
984
|
return !0;
|
|
985
985
|
const [, a] = n.split("-");
|
|
986
|
-
return
|
|
987
|
-
},
|
|
986
|
+
return De({ chain: t, symbol: n }) || !!a;
|
|
987
|
+
}, On = (e) => e.filter((t) => {
|
|
988
988
|
const n = `${t.chain}.${t.symbol}`;
|
|
989
|
-
return !
|
|
990
|
-
}),
|
|
989
|
+
return !Et.test(n) && Rt(n) && t.value !== "0";
|
|
990
|
+
}), gt = ({
|
|
991
991
|
liquidityUnits: e,
|
|
992
992
|
poolUnits: t,
|
|
993
993
|
runeDepth: n
|
|
994
994
|
}) => {
|
|
995
|
-
const a =
|
|
995
|
+
const a = R(e), s = R(t), r = R(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
|
+
}, Ot = ({
|
|
998
998
|
liquidityUnits: e,
|
|
999
999
|
poolUnits: t,
|
|
1000
1000
|
assetDepth: n
|
|
1001
1001
|
}) => {
|
|
1002
|
-
const a =
|
|
1002
|
+
const a = R(e), s = R(t), r = R(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
|
+
}, In = ({
|
|
1005
1005
|
percent: e,
|
|
1006
1006
|
runeDepth: t,
|
|
1007
1007
|
liquidityUnits: n,
|
|
1008
1008
|
poolUnits: a
|
|
1009
|
-
}) =>
|
|
1009
|
+
}) => gt({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), Sn = ({
|
|
1010
1010
|
percent: e,
|
|
1011
1011
|
assetDepth: t,
|
|
1012
1012
|
liquidityUnits: n,
|
|
1013
1013
|
poolUnits: a
|
|
1014
|
-
}) =>
|
|
1014
|
+
}) => Ot({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), R = (e) => D.fromBigInt(BigInt(e), A.THOR), It = ({
|
|
1015
1015
|
liquidityUnits: e,
|
|
1016
1016
|
poolUnits: t,
|
|
1017
1017
|
runeDepth: n,
|
|
1018
1018
|
assetDepth: a
|
|
1019
1019
|
}) => ({
|
|
1020
|
-
assetAmount:
|
|
1021
|
-
runeAmount:
|
|
1022
|
-
}),
|
|
1020
|
+
assetAmount: R(a).mul(e).div(t),
|
|
1021
|
+
runeAmount: R(n).mul(e).div(t)
|
|
1022
|
+
}), vn = ({
|
|
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(It({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1030
1030
|
([r, o]) => [r, o.mul(s)]
|
|
1031
1031
|
)
|
|
1032
|
-
),
|
|
1032
|
+
), Cn = ({
|
|
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), E = d.mul(c.add(_.add(b.mul(2)))),
|
|
1041
|
-
if (
|
|
1042
|
-
return
|
|
1043
|
-
const P = d.add(
|
|
1044
|
-
return
|
|
1045
|
-
},
|
|
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), E = d.mul(c.add(_.add(b.mul(2)))), g = c.add(_.add(w.mul(2))), O = E.div(g), I = R(a).add(O);
|
|
1041
|
+
if (O.getBaseValue("number") === 0)
|
|
1042
|
+
return I.div(d).getBaseValue("number");
|
|
1043
|
+
const P = d.add(I);
|
|
1044
|
+
return I.div(P).getBaseValue("number");
|
|
1045
|
+
}, Mn = ({
|
|
1046
1046
|
runeAmount: e,
|
|
1047
1047
|
assetAmount: t,
|
|
1048
1048
|
runeDepth: n,
|
|
@@ -1050,13 +1050,13 @@ const Tt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1050
1050
|
}) => {
|
|
1051
1051
|
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1052
1052
|
return 0;
|
|
1053
|
-
const s =
|
|
1053
|
+
const s = R(n), r = R(a), o = R(t), p = R(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
|
+
}, St = ({
|
|
1056
1056
|
symbol: e,
|
|
1057
1057
|
ticker: t,
|
|
1058
1058
|
chain: n
|
|
1059
|
-
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e,
|
|
1059
|
+
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, N = (e, t) => {
|
|
1060
1060
|
switch (e) {
|
|
1061
1061
|
case h.LEAVE:
|
|
1062
1062
|
case h.BOND: {
|
|
@@ -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 = St({ 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
|
+
}, Nn = (e) => {
|
|
1091
1091
|
if (e < 0)
|
|
1092
1092
|
throw new Error("Invalid number of year");
|
|
1093
1093
|
return 10 + e;
|
|
1094
|
-
},
|
|
1094
|
+
}, xn = (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
|
+
}, Dn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1100
|
+
class be 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 Pe extends Error {
|
|
1122
1122
|
constructor(t) {
|
|
1123
1123
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1124
1124
|
enumerable: !0,
|
|
@@ -1128,28 +1128,28 @@ class Be extends Error {
|
|
|
1128
1128
|
}), this.name = "TimeoutError", this.request = t;
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
|
-
const
|
|
1131
|
+
const X = (e) => e !== null && typeof e == "object", Y = (...e) => {
|
|
1132
1132
|
for (const t of e)
|
|
1133
|
-
if ((!
|
|
1133
|
+
if ((!X(t) || Array.isArray(t)) && t !== void 0)
|
|
1134
1134
|
throw new TypeError("The `options` argument must be an object");
|
|
1135
|
-
return
|
|
1136
|
-
},
|
|
1135
|
+
return _e({}, ...e);
|
|
1136
|
+
}, Be = (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
|
+
}, _e = (...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
|
-
else if (
|
|
1146
|
+
else if (X(a)) {
|
|
1147
1147
|
for (let [s, r] of Object.entries(a))
|
|
1148
|
-
|
|
1149
|
-
|
|
1148
|
+
X(r) && s in t && (r = _e(t[s], r)), t = { ...t, [s]: r };
|
|
1149
|
+
X(a.headers) && (n = Be(n, a.headers), t.headers = n);
|
|
1150
1150
|
}
|
|
1151
1151
|
return t;
|
|
1152
|
-
},
|
|
1152
|
+
}, vt = (() => {
|
|
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
|
+
})(), Ct = typeof globalThis.AbortController == "function", Mt = typeof globalThis.ReadableStream == "function", Nt = typeof globalThis.FormData == "function", Le = ["get", "post", "put", "patch", "head", "delete"], xt = {
|
|
1164
1164
|
json: "application/json",
|
|
1165
1165
|
text: "text/*",
|
|
1166
1166
|
formData: "multipart/form-data",
|
|
1167
1167
|
arrayBuffer: "*/*",
|
|
1168
1168
|
blob: "*/*"
|
|
1169
|
-
}, re = 2147483647,
|
|
1169
|
+
}, re = 2147483647, Ve = Symbol("stop"), Dt = {
|
|
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
|
+
}, Pt = {
|
|
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
|
+
}, Bt = (e) => Le.includes(e) ? e.toUpperCase() : e, Lt = ["get", "put", "head", "delete", "options", "trace"], Vt = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], we = {
|
|
1197
1197
|
limit: 2,
|
|
1198
|
-
methods:
|
|
1199
|
-
statusCodes:
|
|
1200
|
-
afterStatusCodes:
|
|
1198
|
+
methods: Lt,
|
|
1199
|
+
statusCodes: Vt,
|
|
1200
|
+
afterStatusCodes: Ue,
|
|
1201
1201
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1202
1202
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1203
1203
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1204
|
-
},
|
|
1204
|
+
}, Ut = (e = {}) => {
|
|
1205
1205
|
if (typeof e == "number")
|
|
1206
1206
|
return {
|
|
1207
|
-
...
|
|
1207
|
+
...we,
|
|
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
|
+
...we,
|
|
1216
1216
|
...e,
|
|
1217
|
-
afterStatusCodes:
|
|
1217
|
+
afterStatusCodes: Ue
|
|
1218
1218
|
};
|
|
1219
1219
|
};
|
|
1220
|
-
async function
|
|
1220
|
+
async function Ht(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 Pe(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 $t(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,10 +1238,10 @@ async function kt(e, { signal: t }) {
|
|
|
1238
1238
|
}, e);
|
|
1239
1239
|
});
|
|
1240
1240
|
}
|
|
1241
|
-
const
|
|
1241
|
+
const kt = (e, t) => {
|
|
1242
1242
|
const n = {};
|
|
1243
1243
|
for (const a in t)
|
|
1244
|
-
!(a in
|
|
1244
|
+
!(a in Pt) && !(a in Dt) && !(a in e) && (n[a] = t[a]);
|
|
1245
1245
|
return n;
|
|
1246
1246
|
};
|
|
1247
1247
|
class Z {
|
|
@@ -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 be(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 (!Mt)
|
|
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(xt))
|
|
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: Be(this._input.headers, n.headers),
|
|
1319
|
+
hooks: _e({
|
|
1320
1320
|
beforeRequest: [],
|
|
1321
1321
|
beforeRetry: [],
|
|
1322
1322
|
beforeError: [],
|
|
1323
1323
|
afterResponse: []
|
|
1324
1324
|
}, n.hooks),
|
|
1325
|
-
method:
|
|
1325
|
+
method: Bt(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: Ut(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 (Ct) {
|
|
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 (vt && (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
|
+
(Nt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
|
|
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 Pe)) {
|
|
1356
|
+
if (t instanceof be) {
|
|
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");
|
|
@@ -1378,14 +1378,14 @@ class Z {
|
|
|
1378
1378
|
} catch (n) {
|
|
1379
1379
|
const a = Math.min(this._calculateRetryDelay(n), re);
|
|
1380
1380
|
if (a !== 0 && this._retryCount > 0) {
|
|
1381
|
-
await
|
|
1381
|
+
await $t(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
|
+
}) === Ve)
|
|
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 = kt(this.request, this._options);
|
|
1406
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ht(this.request.clone(), t, this.abortController, this._options);
|
|
1407
1407
|
}
|
|
1408
1408
|
/* istanbul ignore next */
|
|
1409
1409
|
_stream(t, n) {
|
|
@@ -1441,28 +1441,28 @@ class Z {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
/*! MIT License © Sindre Sorhus */
|
|
1443
1443
|
const pe = (e) => {
|
|
1444
|
-
const t = (n, a) => Z.create(n,
|
|
1445
|
-
for (const n of
|
|
1446
|
-
t[n] = (a, s) => Z.create(a,
|
|
1447
|
-
return t.create = (n) => pe(
|
|
1448
|
-
},
|
|
1449
|
-
get: (e, t) =>
|
|
1450
|
-
post: (e, t) =>
|
|
1451
|
-
},
|
|
1444
|
+
const t = (n, a) => Z.create(n, Y(e, a));
|
|
1445
|
+
for (const n of Le)
|
|
1446
|
+
t[n] = (a, s) => Z.create(a, Y(e, s, { method: n }));
|
|
1447
|
+
return t.create = (n) => pe(Y(n)), t.extend = (n) => pe(Y(e, n)), t.stop = Ve, t;
|
|
1448
|
+
}, Ft = pe(), Gt = Ft, qt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Ae = Gt.create({ headers: qt }), fe = {
|
|
1449
|
+
get: (e, t) => Ae.get(e, t).json(),
|
|
1450
|
+
post: (e, t) => Ae.post(e, t).json()
|
|
1451
|
+
}, Ee = Object.values(i), Wt = (e = "") => {
|
|
1452
1452
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1453
|
-
if (
|
|
1453
|
+
if (Ee.includes(n))
|
|
1454
1454
|
return !0;
|
|
1455
1455
|
const [a] = t.split("/");
|
|
1456
|
-
if (
|
|
1456
|
+
if (Ee.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
|
+
}, G = 8, U = (e) => 10n ** BigInt(e), k = (e) => Math.log10(parseFloat(e.toString()));
|
|
1462
1462
|
function se({
|
|
1463
1463
|
value: e,
|
|
1464
|
-
bigIntDecimal: t =
|
|
1465
|
-
decimal: n =
|
|
1464
|
+
bigIntDecimal: t = G,
|
|
1465
|
+
decimal: n = G
|
|
1466
1466
|
}) {
|
|
1467
1467
|
const a = e < 0n;
|
|
1468
1468
|
let s = e.toString().substring(a ? 1 : 0);
|
|
@@ -1475,17 +1475,17 @@ function se({
|
|
|
1475
1475
|
""
|
|
1476
1476
|
);
|
|
1477
1477
|
}
|
|
1478
|
-
var
|
|
1479
|
-
const
|
|
1478
|
+
var V, H, J, de, ue, Re, ee, le;
|
|
1479
|
+
const jt = class He {
|
|
1480
1480
|
constructor(t) {
|
|
1481
|
-
|
|
1482
|
-
const n =
|
|
1483
|
-
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier =
|
|
1484
|
-
Math.max(
|
|
1485
|
-
),
|
|
1481
|
+
K(this, V), K(this, J), K(this, ue), K(this, ee), v(this, "decimalMultiplier", 10n ** 8n), v(this, "bigIntValue", 0n), v(this, "decimal");
|
|
1482
|
+
const n = Q(t);
|
|
1483
|
+
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = U(
|
|
1484
|
+
Math.max($e(te(n)), this.decimal || 0)
|
|
1485
|
+
), x(this, J, de).call(this, n);
|
|
1486
1486
|
}
|
|
1487
1487
|
static fromBigInt(t, n) {
|
|
1488
|
-
return new
|
|
1488
|
+
return new He({
|
|
1489
1489
|
decimal: n,
|
|
1490
1490
|
value: se({ value: t, bigIntDecimal: n, decimal: n })
|
|
1491
1491
|
});
|
|
@@ -1496,24 +1496,24 @@ const Kt = class ke {
|
|
|
1496
1496
|
to: a
|
|
1497
1497
|
}) {
|
|
1498
1498
|
return this.fromBigInt(
|
|
1499
|
-
t.getBaseValue("bigint") *
|
|
1499
|
+
t.getBaseValue("bigint") * U(a) / U(n),
|
|
1500
1500
|
a
|
|
1501
1501
|
);
|
|
1502
1502
|
}
|
|
1503
1503
|
set(t) {
|
|
1504
|
-
return
|
|
1504
|
+
return x(this, J, de).call(this, Q(t)), this;
|
|
1505
1505
|
}
|
|
1506
1506
|
add(...t) {
|
|
1507
|
-
return
|
|
1507
|
+
return x(this, V, H).call(this, "add", ...t);
|
|
1508
1508
|
}
|
|
1509
1509
|
sub(...t) {
|
|
1510
|
-
return
|
|
1510
|
+
return x(this, V, H).call(this, "sub", ...t);
|
|
1511
1511
|
}
|
|
1512
1512
|
mul(...t) {
|
|
1513
|
-
return
|
|
1513
|
+
return x(this, V, H).call(this, "mul", ...t);
|
|
1514
1514
|
}
|
|
1515
1515
|
div(...t) {
|
|
1516
|
-
return
|
|
1516
|
+
return x(this, V, H).call(this, "div", ...t);
|
|
1517
1517
|
}
|
|
1518
1518
|
gt(t) {
|
|
1519
1519
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1533,7 +1533,7 @@ const Kt = class ke {
|
|
|
1533
1533
|
getValue(t) {
|
|
1534
1534
|
const n = this.formatBigIntToSafeValue(
|
|
1535
1535
|
this.bigIntValue,
|
|
1536
|
-
this.decimal ||
|
|
1536
|
+
this.decimal || k(this.decimalMultiplier)
|
|
1537
1537
|
);
|
|
1538
1538
|
switch (t) {
|
|
1539
1539
|
case "number":
|
|
@@ -1545,7 +1545,7 @@ const Kt = class ke {
|
|
|
1545
1545
|
}
|
|
1546
1546
|
}
|
|
1547
1547
|
getBaseValue(t) {
|
|
1548
|
-
const n = this.decimalMultiplier /
|
|
1548
|
+
const n = this.decimalMultiplier / U(this.decimal || A.THOR), a = this.bigIntValue / n;
|
|
1549
1549
|
switch (t) {
|
|
1550
1550
|
case "number":
|
|
1551
1551
|
return Number(a);
|
|
@@ -1558,13 +1558,13 @@ 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 = Q(t), s = te(a);
|
|
1562
|
+
return s === "0" || s === "undefined" ? 0n : x(this, ee, le).call(this, s, n);
|
|
1563
1563
|
}
|
|
1564
1564
|
formatBigIntToSafeValue(t, n) {
|
|
1565
|
-
const a = n || this.decimal ||
|
|
1565
|
+
const a = n || this.decimal || G, s = Math.max(
|
|
1566
1566
|
a,
|
|
1567
|
-
|
|
1567
|
+
k(this.decimalMultiplier)
|
|
1568
1568
|
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, y = d.length - s;
|
|
1569
1569
|
let u = d.slice(-s);
|
|
1570
1570
|
return parseInt(u[a]) >= 5 ? u = `${u.substring(0, a - 1)}${(parseInt(u[a - 1]) + 1).toString()}` : u = u.substring(0, a), `${r ? "-" : ""}${d.slice(
|
|
@@ -1616,8 +1616,8 @@ const Kt = class ke {
|
|
|
1616
1616
|
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1617
1617
|
}
|
|
1618
1618
|
};
|
|
1619
|
-
|
|
1620
|
-
const n =
|
|
1619
|
+
V = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
|
|
1620
|
+
const n = x(this, ue, Re).call(this, this, ...t), a = U(n), s = t.reduce(
|
|
1621
1621
|
(o, p) => {
|
|
1622
1622
|
const d = this.getBigIntValue(p, n);
|
|
1623
1623
|
switch (e) {
|
|
@@ -1640,61 +1640,63 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1640
1640
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1641
1641
|
), r = se({
|
|
1642
1642
|
bigIntDecimal: n,
|
|
1643
|
-
decimal: Math.max(n,
|
|
1643
|
+
decimal: Math.max(n, k(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
|
-
}, ue = /* @__PURE__ */ new WeakSet(),
|
|
1647
|
+
}, J = /* @__PURE__ */ new WeakSet(), de = function(e) {
|
|
1648
|
+
const t = te(e) || "0";
|
|
1649
|
+
this.bigIntValue = x(this, ee, le).call(this, t);
|
|
1650
|
+
}, ue = /* @__PURE__ */ new WeakSet(), Re = function(...e) {
|
|
1651
1651
|
const t = e.map(
|
|
1652
|
-
(n) => typeof n == "object" ? n.decimal ||
|
|
1652
|
+
(n) => typeof n == "object" ? n.decimal || k(n.decimalMultiplier) : $e(te(n))
|
|
1653
1653
|
).filter(Boolean);
|
|
1654
|
-
return Math.max(...t,
|
|
1654
|
+
return Math.max(...t, G);
|
|
1655
1655
|
}, ee = /* @__PURE__ */ new WeakSet(), le = function(e, t) {
|
|
1656
|
-
const n = t ?
|
|
1656
|
+
const n = t ? U(t) : this.decimalMultiplier, a = k(n), [s = "", r = ""] = e.split(".");
|
|
1657
1657
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1658
|
+
};
|
|
1659
|
+
let ye = jt;
|
|
1660
|
+
const Kt = Intl.NumberFormat("fullwide", {
|
|
1661
|
+
useGrouping: !1,
|
|
1662
|
+
maximumFractionDigits: 20
|
|
1663
|
+
});
|
|
1664
|
+
function te(e) {
|
|
1665
|
+
const t = `${typeof e == "number" ? Kt.format(e) : Q(e)}`.replaceAll(",", ".").split(".");
|
|
1663
1666
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1664
|
-
}
|
|
1667
|
+
}
|
|
1668
|
+
function $e(e) {
|
|
1665
1669
|
var t;
|
|
1666
1670
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1667
|
-
return Math.max(n,
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
function me(e) {
|
|
1671
|
+
return Math.max(n, G);
|
|
1672
|
+
}
|
|
1673
|
+
function Q(e) {
|
|
1671
1674
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1672
1675
|
}
|
|
1673
1676
|
const z = (e, t) => typeof e == "bigint" ? se({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1674
|
-
let
|
|
1675
|
-
const
|
|
1676
|
-
if (!
|
|
1677
|
+
let ce;
|
|
1678
|
+
const ge = (e) => {
|
|
1679
|
+
if (!ce)
|
|
1677
1680
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1678
|
-
return
|
|
1679
|
-
},
|
|
1680
|
-
|
|
1681
|
-
const n = await
|
|
1682
|
-
return new
|
|
1683
|
-
};
|
|
1684
|
-
class
|
|
1681
|
+
return ce.get(e.toUpperCase()) || { decimal: A.THOR, identifier: "" };
|
|
1682
|
+
}, Oe = async (e, t = 0) => {
|
|
1683
|
+
Wt(e);
|
|
1684
|
+
const n = await ft(me(e)), a = z(t, n);
|
|
1685
|
+
return new M({ decimal: n, value: a, identifier: e });
|
|
1686
|
+
}, Ie = /* @__PURE__ */ new Map();
|
|
1687
|
+
class M extends ye {
|
|
1685
1688
|
constructor(t) {
|
|
1686
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}
|
|
1689
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = Ie.get(n);
|
|
1690
|
+
if (a)
|
|
1691
|
+
return a.set(t.value);
|
|
1687
1692
|
super(
|
|
1688
|
-
t.value instanceof
|
|
1689
|
-
),
|
|
1690
|
-
const
|
|
1691
|
-
this.type =
|
|
1692
|
-
}
|
|
1693
|
-
get assetValue() {
|
|
1694
|
-
return `${this.getValue("string")} ${this.ticker}`;
|
|
1693
|
+
t.value instanceof ye ? t.value : { decimal: t.decimal, value: t.value }
|
|
1694
|
+
), v(this, "address"), v(this, "isSynthetic", !1), v(this, "isGasAsset", !1), v(this, "chain"), v(this, "symbol"), v(this, "ticker"), v(this, "type");
|
|
1695
|
+
const s = me(n);
|
|
1696
|
+
this.type = At(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, Ie.set(n, this);
|
|
1695
1697
|
}
|
|
1696
1698
|
toString(t = !1) {
|
|
1697
|
-
const n = this.isSynthetic ? this.symbol.split("-")[0] :
|
|
1699
|
+
const n = this.isSynthetic ? this.symbol.split("-")[0] : this.ticker;
|
|
1698
1700
|
return t ? n : (
|
|
1699
1701
|
// THOR.ETH/ETH | ETH.USDT-0x1234567890
|
|
1700
1702
|
`${this.chain}.${this.symbol}`
|
|
@@ -1704,24 +1706,24 @@ class N extends ce {
|
|
|
1704
1706
|
return this.chain === t && this.symbol === n;
|
|
1705
1707
|
}
|
|
1706
1708
|
static async fromString(t, n = 0) {
|
|
1707
|
-
return
|
|
1709
|
+
return Oe(t, n);
|
|
1708
1710
|
}
|
|
1709
1711
|
static fromStringSync(t, n = 0) {
|
|
1710
|
-
const { isSynthetic: a } =
|
|
1712
|
+
const { isSynthetic: a } = me(t), { decimal: s, identifier: r } = ge(
|
|
1711
1713
|
t
|
|
1712
1714
|
), o = z(n, s);
|
|
1713
|
-
return r ? new
|
|
1715
|
+
return r ? new M({ decimal: s, identifier: r, value: o }) : a ? new M({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1714
1716
|
}
|
|
1715
1717
|
static async fromIdentifier(t, n = 0) {
|
|
1716
|
-
return
|
|
1718
|
+
return Oe(t, n);
|
|
1717
1719
|
}
|
|
1718
1720
|
static fromIdentifierSync(t, n = 0) {
|
|
1719
|
-
const { decimal: a, identifier: s } =
|
|
1720
|
-
return new
|
|
1721
|
+
const { decimal: a, identifier: s } = ge(t), r = z(n, a);
|
|
1722
|
+
return new M({ decimal: a, identifier: s, value: r });
|
|
1721
1723
|
}
|
|
1722
1724
|
static fromChainOrSignature(t, n = 0) {
|
|
1723
|
-
const { decimal: a, identifier: s } =
|
|
1724
|
-
return new
|
|
1725
|
+
const { decimal: a, identifier: s } = wt(t), r = z(n, a);
|
|
1726
|
+
return new M({ value: r, decimal: a, identifier: s });
|
|
1725
1727
|
}
|
|
1726
1728
|
static async loadStaticAssets() {
|
|
1727
1729
|
return new Promise(
|
|
@@ -1734,7 +1736,7 @@ class N extends ce {
|
|
|
1734
1736
|
NativeList: s,
|
|
1735
1737
|
...r
|
|
1736
1738
|
} = await import("@swapkit/tokens");
|
|
1737
|
-
|
|
1739
|
+
ce = [s, ...Object.values(r)].reduce(
|
|
1738
1740
|
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: y, ...u }) => {
|
|
1739
1741
|
const c = "decimals" in u ? u.decimals : A[y];
|
|
1740
1742
|
o.set(d, { identifier: d, decimal: c });
|
|
@@ -1753,7 +1755,7 @@ class N extends ce {
|
|
|
1753
1755
|
}
|
|
1754
1756
|
}
|
|
1755
1757
|
const oe = (e) => {
|
|
1756
|
-
const t =
|
|
1758
|
+
const t = M.fromChainOrSignature(e);
|
|
1757
1759
|
switch (e) {
|
|
1758
1760
|
case i.Bitcoin:
|
|
1759
1761
|
case i.Litecoin:
|
|
@@ -1770,12 +1772,12 @@ const oe = (e) => {
|
|
|
1770
1772
|
default:
|
|
1771
1773
|
return t.set(1e-8);
|
|
1772
1774
|
}
|
|
1773
|
-
},
|
|
1775
|
+
}, me = (e) => {
|
|
1774
1776
|
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
1777
|
return {
|
|
1776
1778
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1777
1779
|
chain: r,
|
|
1778
|
-
isGasAsset:
|
|
1780
|
+
isGasAsset: De({ chain: r, symbol: o }),
|
|
1779
1781
|
isSynthetic: t,
|
|
1780
1782
|
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1781
1783
|
ticker: p
|
|
@@ -1842,7 +1844,7 @@ class m extends Error {
|
|
|
1842
1844
|
console.error(n), super(t, { cause: { code: Yt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1843
1845
|
}
|
|
1844
1846
|
}
|
|
1845
|
-
class D extends
|
|
1847
|
+
class D extends ye {
|
|
1846
1848
|
eq(t) {
|
|
1847
1849
|
return this.eqValue(t);
|
|
1848
1850
|
}
|
|
@@ -3539,12 +3541,12 @@ const Xt = [
|
|
|
3539
3541
|
type: "function"
|
|
3540
3542
|
},
|
|
3541
3543
|
{ stateMutability: "payable", type: "receive" }
|
|
3542
|
-
],
|
|
3544
|
+
], ke = {
|
|
3543
3545
|
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Xt,
|
|
3544
3546
|
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Qt,
|
|
3545
3547
|
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: zt
|
|
3546
3548
|
}, un = {
|
|
3547
|
-
...
|
|
3549
|
+
...ke,
|
|
3548
3550
|
// AVAX
|
|
3549
3551
|
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: en,
|
|
3550
3552
|
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Jt,
|
|
@@ -3579,15 +3581,15 @@ const Xt = [
|
|
|
3579
3581
|
token: E
|
|
3580
3582
|
}
|
|
3581
3583
|
}) => {
|
|
3582
|
-
const
|
|
3583
|
-
if (
|
|
3584
|
+
const g = !!ke[t.toLowerCase()];
|
|
3585
|
+
if (g && !y)
|
|
3584
3586
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3585
|
-
const
|
|
3587
|
+
const O = c || d, I = e && u || O;
|
|
3586
3588
|
if (!b && !w)
|
|
3587
3589
|
throw new Error("TC Vault is required on calldata");
|
|
3588
3590
|
if (!_ && !y)
|
|
3589
3591
|
throw new Error("TC Router is required on calldata");
|
|
3590
|
-
if (!
|
|
3592
|
+
if (!I)
|
|
3591
3593
|
throw new Error("TC Memo is required on calldata");
|
|
3592
3594
|
if (!E)
|
|
3593
3595
|
throw new Error("Token is required on calldata");
|
|
@@ -3595,13 +3597,13 @@ const Xt = [
|
|
|
3595
3597
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3596
3598
|
a(_ || y),
|
|
3597
3599
|
a(b || w),
|
|
3598
|
-
|
|
3600
|
+
I.replace("{recipientAddress}", n),
|
|
3599
3601
|
a(E),
|
|
3600
3602
|
s
|
|
3601
|
-
],
|
|
3602
|
-
return [...P, ...
|
|
3603
|
+
], Fe = g ? [a(y), o, p] : [r, p];
|
|
3604
|
+
return [...P, ...Fe];
|
|
3603
3605
|
}, yn = ({ chain: e, txHash: t }) => {
|
|
3604
|
-
const n =
|
|
3606
|
+
const n = Ne[e];
|
|
3605
3607
|
switch (e) {
|
|
3606
3608
|
case i.Binance:
|
|
3607
3609
|
case i.Bitcoin:
|
|
@@ -3627,7 +3629,7 @@ const Xt = [
|
|
|
3627
3629
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3628
3630
|
}
|
|
3629
3631
|
}, cn = ({ chain: e, address: t }) => {
|
|
3630
|
-
const n =
|
|
3632
|
+
const n = Ne[e];
|
|
3631
3633
|
switch (e) {
|
|
3632
3634
|
case i.Arbitrum:
|
|
3633
3635
|
case i.Avalanche:
|
|
@@ -3651,20 +3653,20 @@ const Xt = [
|
|
|
3651
3653
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3652
3654
|
}
|
|
3653
3655
|
}, mn = (e) => {
|
|
3654
|
-
const t = e ?
|
|
3655
|
-
return
|
|
3656
|
+
const t = e ? F.ThornodeStagenet : F.ThornodeMainnet;
|
|
3657
|
+
return fe.get(`${t}/thorchain/inbound_addresses`);
|
|
3656
3658
|
}, Tn = (e) => {
|
|
3657
|
-
const t = e ?
|
|
3658
|
-
return
|
|
3659
|
-
},
|
|
3659
|
+
const t = e ? F.ThornodeStagenet : F.ThornodeMainnet;
|
|
3660
|
+
return fe.get(`${t}/thorchain/mimir`);
|
|
3661
|
+
}, Se = () => Object.values(i).reduce(
|
|
3660
3662
|
(e, t) => (e[t] = null, e),
|
|
3661
3663
|
{}
|
|
3662
3664
|
);
|
|
3663
|
-
var L, ne,
|
|
3664
|
-
class
|
|
3665
|
+
var L, ne, q, C, W, j;
|
|
3666
|
+
class Pn {
|
|
3665
3667
|
constructor({ stagenet: t } = {}) {
|
|
3666
|
-
T(this, "connectedChains",
|
|
3667
|
-
T(this, "connectedWallets",
|
|
3668
|
+
T(this, "connectedChains", Se());
|
|
3669
|
+
T(this, "connectedWallets", Se());
|
|
3668
3670
|
T(this, "stagenet", !1);
|
|
3669
3671
|
T(this, "getAddress", (t) => {
|
|
3670
3672
|
var n;
|
|
@@ -3683,7 +3685,7 @@ class Bn {
|
|
|
3683
3685
|
if (!a.complete)
|
|
3684
3686
|
throw new m("core_swap_route_not_complete");
|
|
3685
3687
|
try {
|
|
3686
|
-
if (
|
|
3688
|
+
if (ze.includes(r)) {
|
|
3687
3689
|
const y = this.connectedWallets[o];
|
|
3688
3690
|
if (!(y != null && y.sendTransaction))
|
|
3689
3691
|
throw new m("core_wallet_connection_not_found");
|
|
@@ -3693,41 +3695,41 @@ class Bn {
|
|
|
3693
3695
|
data: c,
|
|
3694
3696
|
from: _,
|
|
3695
3697
|
to: b.toLowerCase(),
|
|
3696
|
-
chainId: BigInt(
|
|
3698
|
+
chainId: BigInt(ot[o]),
|
|
3697
3699
|
value: w ? BigInt(w) : 0n
|
|
3698
3700
|
};
|
|
3699
3701
|
return y.sendTransaction(E, s);
|
|
3700
3702
|
}
|
|
3701
|
-
if (
|
|
3703
|
+
if (et.includes(r)) {
|
|
3702
3704
|
if (!a.calldata.fromAsset)
|
|
3703
3705
|
throw new m("core_swap_asset_not_recognized");
|
|
3704
|
-
const y = await
|
|
3706
|
+
const y = await M.fromString(a.calldata.fromAsset);
|
|
3705
3707
|
if (!y)
|
|
3706
3708
|
throw new m("core_swap_asset_not_recognized");
|
|
3707
3709
|
const { address: u } = await f(this, L).call(this, y.chain), {
|
|
3708
3710
|
contract: c,
|
|
3709
3711
|
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap: E }
|
|
3710
|
-
} = a,
|
|
3712
|
+
} = a, g = y.add(D.fromBigInt(BigInt(b), y.decimal)), O = t && E || w;
|
|
3711
3713
|
return this.deposit({
|
|
3712
3714
|
expiration: _,
|
|
3713
|
-
assetValue:
|
|
3714
|
-
memo:
|
|
3715
|
+
assetValue: g,
|
|
3716
|
+
memo: O,
|
|
3715
3717
|
feeOptionKey: s,
|
|
3716
3718
|
router: c,
|
|
3717
3719
|
recipient: u
|
|
3718
3720
|
});
|
|
3719
3721
|
}
|
|
3720
|
-
if (
|
|
3722
|
+
if (Ze.includes(r)) {
|
|
3721
3723
|
const { calldata: y, contract: u } = a;
|
|
3722
3724
|
if (!u)
|
|
3723
3725
|
throw new m("core_swap_contract_not_found");
|
|
3724
3726
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3725
3727
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3726
3728
|
throw new m("core_wallet_connection_not_found");
|
|
3727
|
-
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), E = b(o),
|
|
3728
|
-
if (!
|
|
3729
|
+
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), E = b(o), g = un[u.toLowerCase()];
|
|
3730
|
+
if (!g)
|
|
3729
3731
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3730
|
-
const
|
|
3732
|
+
const I = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, g, E))).getFunction("swapIn").populateTransaction(
|
|
3731
3733
|
...ln({
|
|
3732
3734
|
streamSwap: t,
|
|
3733
3735
|
toChecksumAddress: w,
|
|
@@ -3737,7 +3739,7 @@ class Bn {
|
|
|
3737
3739
|
}),
|
|
3738
3740
|
{ from: _ }
|
|
3739
3741
|
);
|
|
3740
|
-
return c.sendTransaction(
|
|
3742
|
+
return c.sendTransaction(I, s);
|
|
3741
3743
|
}
|
|
3742
3744
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3743
3745
|
} catch (y) {
|
|
@@ -3749,7 +3751,7 @@ class Bn {
|
|
|
3749
3751
|
const a = this.getAddress(t);
|
|
3750
3752
|
if (!a)
|
|
3751
3753
|
return null;
|
|
3752
|
-
const s = [
|
|
3754
|
+
const s = [M.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3753
3755
|
try {
|
|
3754
3756
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3755
3757
|
return this.connectedChains[t] = {
|
|
@@ -3761,8 +3763,8 @@ class Bn {
|
|
|
3761
3763
|
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3762
3764
|
}
|
|
3763
3765
|
});
|
|
3764
|
-
T(this, "approveAssetValue", (t, n) => f(this,
|
|
3765
|
-
T(this, "isAssetValueApproved", (t, n) => f(this,
|
|
3766
|
+
T(this, "approveAssetValue", (t, n) => f(this, q).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3767
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, q).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3766
3768
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3767
3769
|
var a, s;
|
|
3768
3770
|
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
@@ -3772,7 +3774,7 @@ class Bn {
|
|
|
3772
3774
|
if (!n)
|
|
3773
3775
|
throw new m("core_wallet_connection_not_found");
|
|
3774
3776
|
try {
|
|
3775
|
-
return await n.transfer(f(this,
|
|
3777
|
+
return await n.transfer(f(this, j).call(this, t));
|
|
3776
3778
|
} catch (a) {
|
|
3777
3779
|
throw new m("core_swap_transaction_error", a);
|
|
3778
3780
|
}
|
|
@@ -3786,7 +3788,7 @@ class Bn {
|
|
|
3786
3788
|
const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
|
|
3787
3789
|
if (!d)
|
|
3788
3790
|
throw new m("core_wallet_connection_not_found");
|
|
3789
|
-
const y = f(this,
|
|
3791
|
+
const y = f(this, j).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3790
3792
|
try {
|
|
3791
3793
|
switch (r) {
|
|
3792
3794
|
case i.THORChain: {
|
|
@@ -3796,7 +3798,7 @@ class Bn {
|
|
|
3796
3798
|
case i.Ethereum:
|
|
3797
3799
|
case i.BinanceSmartChain:
|
|
3798
3800
|
case i.Avalanche: {
|
|
3799
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ?
|
|
3801
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Xe : r === i.BinanceSmartChain ? Je : Ye;
|
|
3800
3802
|
return await d.call({
|
|
3801
3803
|
abi: c,
|
|
3802
3804
|
contractAddress: a || (await f(this, L).call(this, r)).router,
|
|
@@ -3833,9 +3835,9 @@ class Bn {
|
|
|
3833
3835
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3834
3836
|
let a = "", s = "";
|
|
3835
3837
|
try {
|
|
3836
|
-
a = await f(this,
|
|
3838
|
+
a = await f(this, C).call(this, {
|
|
3837
3839
|
assetValue: t,
|
|
3838
|
-
memo:
|
|
3840
|
+
memo: N(h.DEPOSIT, {
|
|
3839
3841
|
...n,
|
|
3840
3842
|
address: this.getAddress(n.chain)
|
|
3841
3843
|
})
|
|
@@ -3844,9 +3846,9 @@ class Bn {
|
|
|
3844
3846
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3845
3847
|
}
|
|
3846
3848
|
try {
|
|
3847
|
-
s = await f(this,
|
|
3849
|
+
s = await f(this, C).call(this, {
|
|
3848
3850
|
assetValue: n,
|
|
3849
|
-
memo:
|
|
3851
|
+
memo: N(h.DEPOSIT, {
|
|
3850
3852
|
...n,
|
|
3851
3853
|
address: this.getAddress(i.THORChain)
|
|
3852
3854
|
})
|
|
@@ -3870,27 +3872,27 @@ class Bn {
|
|
|
3870
3872
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3871
3873
|
if (b && !w)
|
|
3872
3874
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3873
|
-
let
|
|
3874
|
-
const
|
|
3875
|
+
let g, O;
|
|
3876
|
+
const I = { chain: d, symbol: y.join(".") };
|
|
3875
3877
|
if (c && n)
|
|
3876
3878
|
try {
|
|
3877
|
-
|
|
3879
|
+
g = await f(this, C).call(this, {
|
|
3878
3880
|
assetValue: n,
|
|
3879
|
-
memo:
|
|
3881
|
+
memo: N(h.DEPOSIT, { ...I, address: E })
|
|
3880
3882
|
});
|
|
3881
3883
|
} catch (P) {
|
|
3882
3884
|
throw new m("core_transaction_add_liquidity_rune_error", P);
|
|
3883
3885
|
}
|
|
3884
3886
|
if (_ && a)
|
|
3885
3887
|
try {
|
|
3886
|
-
|
|
3888
|
+
O = await f(this, C).call(this, {
|
|
3887
3889
|
assetValue: a,
|
|
3888
|
-
memo:
|
|
3890
|
+
memo: N(h.DEPOSIT, { ...I, address: w })
|
|
3889
3891
|
});
|
|
3890
3892
|
} catch (P) {
|
|
3891
3893
|
throw new m("core_transaction_add_liquidity_asset_error", P);
|
|
3892
3894
|
}
|
|
3893
|
-
return { runeTx:
|
|
3895
|
+
return { runeTx: g, assetTx: O };
|
|
3894
3896
|
});
|
|
3895
3897
|
T(this, "withdraw", async ({
|
|
3896
3898
|
memo: t,
|
|
@@ -3899,7 +3901,7 @@ class Bn {
|
|
|
3899
3901
|
from: s,
|
|
3900
3902
|
to: r
|
|
3901
3903
|
}) => {
|
|
3902
|
-
const o = r === "rune" ?
|
|
3904
|
+
const o = r === "rune" ? M.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = oe(s === "asset" ? n.chain : i.THORChain), d = t || N(h.WITHDRAW, {
|
|
3903
3905
|
symbol: n.symbol,
|
|
3904
3906
|
chain: n.chain,
|
|
3905
3907
|
ticker: n.ticker,
|
|
@@ -3907,7 +3909,7 @@ class Bn {
|
|
|
3907
3909
|
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3908
3910
|
singleSide: !1
|
|
3909
3911
|
});
|
|
3910
|
-
return f(this,
|
|
3912
|
+
return f(this, C).call(this, { assetValue: p, memo: d });
|
|
3911
3913
|
});
|
|
3912
3914
|
T(this, "savings", async ({
|
|
3913
3915
|
assetValue: t,
|
|
@@ -3915,23 +3917,23 @@ class Bn {
|
|
|
3915
3917
|
percent: a,
|
|
3916
3918
|
type: s
|
|
3917
3919
|
}) => {
|
|
3918
|
-
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n ||
|
|
3920
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || N(r, {
|
|
3919
3921
|
ticker: t.ticker,
|
|
3920
3922
|
symbol: t.symbol,
|
|
3921
3923
|
chain: t.chain,
|
|
3922
3924
|
singleSide: !0,
|
|
3923
3925
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3924
3926
|
}), p = r === h.DEPOSIT ? t : oe(t.chain);
|
|
3925
|
-
return f(this,
|
|
3927
|
+
return f(this, C).call(this, { memo: o, assetValue: p });
|
|
3926
3928
|
});
|
|
3927
3929
|
T(this, "loan", ({
|
|
3928
3930
|
assetValue: t,
|
|
3929
3931
|
memo: n,
|
|
3930
3932
|
minAmount: a,
|
|
3931
3933
|
type: s
|
|
3932
|
-
}) => f(this,
|
|
3934
|
+
}) => f(this, C).call(this, {
|
|
3933
3935
|
assetValue: t,
|
|
3934
|
-
memo: n ||
|
|
3936
|
+
memo: n || N(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3935
3937
|
asset: t.toString(),
|
|
3936
3938
|
minAmount: a.toString(),
|
|
3937
3939
|
address: this.getAddress(t.chain)
|
|
@@ -3942,11 +3944,11 @@ class Bn {
|
|
|
3942
3944
|
assetValue: n,
|
|
3943
3945
|
address: a
|
|
3944
3946
|
}) => {
|
|
3945
|
-
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r =
|
|
3947
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = N(s, {
|
|
3946
3948
|
address: a,
|
|
3947
3949
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
3948
3950
|
});
|
|
3949
|
-
return f(this,
|
|
3951
|
+
return f(this, W).call(this, {
|
|
3950
3952
|
memo: r,
|
|
3951
3953
|
assetValue: t === "bond" ? n : oe(i.THORChain)
|
|
3952
3954
|
});
|
|
@@ -3954,7 +3956,7 @@ class Bn {
|
|
|
3954
3956
|
T(this, "registerThorname", ({
|
|
3955
3957
|
assetValue: t,
|
|
3956
3958
|
...n
|
|
3957
|
-
}) => f(this,
|
|
3959
|
+
}) => f(this, W).call(this, { assetValue: t, memo: N(h.THORNAME_REGISTER, n) }));
|
|
3958
3960
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3959
3961
|
try {
|
|
3960
3962
|
t.forEach((r) => {
|
|
@@ -4054,7 +4056,7 @@ class Bn {
|
|
|
4054
4056
|
B(this, ne, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4055
4057
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4056
4058
|
});
|
|
4057
|
-
B(this,
|
|
4059
|
+
B(this, q, async ({
|
|
4058
4060
|
assetValue: t,
|
|
4059
4061
|
type: n = "checkOnly",
|
|
4060
4062
|
contractAddress: a
|
|
@@ -4076,16 +4078,16 @@ class Bn {
|
|
|
4076
4078
|
spenderAddress: b
|
|
4077
4079
|
});
|
|
4078
4080
|
});
|
|
4079
|
-
B(this,
|
|
4081
|
+
B(this, C, async ({
|
|
4080
4082
|
assetValue: t,
|
|
4081
4083
|
memo: n,
|
|
4082
|
-
feeOptionKey: a =
|
|
4084
|
+
feeOptionKey: a = $.Fast
|
|
4083
4085
|
}) => {
|
|
4084
4086
|
const {
|
|
4085
4087
|
gas_rate: s,
|
|
4086
4088
|
router: r,
|
|
4087
4089
|
address: o
|
|
4088
|
-
} = await f(this, L).call(this, t.chain), p = (parseInt(s) || 0) *
|
|
4090
|
+
} = await f(this, L).call(this, t.chain), p = (parseInt(s) || 0) * bt[a];
|
|
4089
4091
|
return this.deposit({
|
|
4090
4092
|
assetValue: t,
|
|
4091
4093
|
recipient: o,
|
|
@@ -4094,13 +4096,13 @@ class Bn {
|
|
|
4094
4096
|
feeRate: p
|
|
4095
4097
|
});
|
|
4096
4098
|
});
|
|
4097
|
-
B(this,
|
|
4099
|
+
B(this, W, async ({ memo: t, assetValue: n }) => {
|
|
4098
4100
|
const a = await Tn(this.stagenet);
|
|
4099
4101
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4100
4102
|
throw new m("core_chain_halted");
|
|
4101
4103
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
4102
4104
|
});
|
|
4103
|
-
B(this,
|
|
4105
|
+
B(this, j, ({ assetValue: t, ...n }) => ({
|
|
4104
4106
|
...n,
|
|
4105
4107
|
memo: n.memo || "",
|
|
4106
4108
|
from: this.getAddress(t.chain),
|
|
@@ -4109,66 +4111,66 @@ class Bn {
|
|
|
4109
4111
|
this.stagenet = !!t;
|
|
4110
4112
|
}
|
|
4111
4113
|
}
|
|
4112
|
-
L = new WeakMap(), ne = new WeakMap(),
|
|
4114
|
+
L = new WeakMap(), ne = new WeakMap(), q = new WeakMap(), C = new WeakMap(), W = new WeakMap(), j = new WeakMap();
|
|
4113
4115
|
export {
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4116
|
+
ze as AGG_SWAP,
|
|
4117
|
+
Ce as ApiError,
|
|
4118
|
+
F as ApiUrl,
|
|
4119
|
+
M as AssetValue,
|
|
4118
4120
|
A as BaseDecimal,
|
|
4119
|
-
|
|
4121
|
+
ye as BigIntArithmetics,
|
|
4120
4122
|
i as Chain,
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4123
|
+
Te as ChainId,
|
|
4124
|
+
Rn as ChainIdToChain,
|
|
4125
|
+
ot as ChainToChainId,
|
|
4126
|
+
Ne as ChainToExplorerUrl,
|
|
4127
|
+
En as ChainToHexChainId,
|
|
4128
|
+
pt as ChainToRPC,
|
|
4129
|
+
at as ContractAddress,
|
|
4130
|
+
wn as CosmosChainList,
|
|
4131
|
+
st as DerivationPath,
|
|
4130
4132
|
l as ERROR_CODE,
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4133
|
+
tt as ERROR_MODULE,
|
|
4134
|
+
ve as ERROR_TYPE,
|
|
4135
|
+
it as EVMChainList,
|
|
4136
|
+
dt as ErrorCode,
|
|
4137
|
+
$ as FeeOption,
|
|
4136
4138
|
h as MemoType,
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4139
|
+
fn as NetworkDerivationPath,
|
|
4140
|
+
Qe as QuoteMode,
|
|
4141
|
+
Me as RPCUrl,
|
|
4142
|
+
fe as RequestClient,
|
|
4143
|
+
Ze as SWAP_IN,
|
|
4144
|
+
et as SWAP_OUT,
|
|
4145
|
+
Pn as SwapKitCore,
|
|
4144
4146
|
m as SwapKitError,
|
|
4145
4147
|
D as SwapKitNumber,
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4148
|
+
Xe as TCAvalancheDepositABI,
|
|
4149
|
+
Je as TCBscDepositABI,
|
|
4150
|
+
Ye as TCEthereumVaultAbi,
|
|
4151
|
+
An as TCSupportedChainList,
|
|
4152
|
+
bn as UTXOChainList,
|
|
4153
|
+
ut as WalletOption,
|
|
4154
|
+
gn as assetFromString,
|
|
4155
|
+
Dn as derivationPathToString,
|
|
4154
4156
|
_n as erc20ABI,
|
|
4155
|
-
|
|
4157
|
+
On as filterAssets,
|
|
4156
4158
|
se as formatBigIntToSafeValue,
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4159
|
+
bt as gasFeeMultiplier,
|
|
4160
|
+
At as getAssetType,
|
|
4161
|
+
Ot as getAsymmetricAssetShare,
|
|
4162
|
+
Sn as getAsymmetricAssetWithdrawAmount,
|
|
4163
|
+
gt as getAsymmetricRuneShare,
|
|
4164
|
+
In as getAsymmetricRuneWithdrawAmount,
|
|
4165
|
+
wt as getCommonAssetInfo,
|
|
4166
|
+
ft as getDecimal,
|
|
4167
|
+
Cn as getEstimatedPoolShare,
|
|
4168
|
+
Mn as getLiquiditySlippage,
|
|
4169
|
+
N as getMemoFor,
|
|
4168
4170
|
oe as getMinAmountByChain,
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4171
|
+
It as getSymmetricPoolShare,
|
|
4172
|
+
vn as getSymmetricWithdraw,
|
|
4173
|
+
Nn as getTHORNameCost,
|
|
4174
|
+
De as isGasAsset,
|
|
4175
|
+
xn as validateTHORName
|
|
4174
4176
|
};
|