@swapkit/core 1.0.0-rc.35 → 1.0.0-rc.37
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.d.ts +7 -2
- package/dist/index.es.js +359 -351
- package/package.json +13 -13
- package/src/client/index.ts +21 -6
package/dist/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ var T = (e, t, n) => (Ge(e, typeof t != "symbol" ? t + "" : t, n), n), qe = (e,
|
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var f = (e, t, n) => (qe(e, t, "read from private field"), n ? n.call(e) : t.get(e)),
|
|
7
|
+
var f = (e, t, n) => (qe(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
@@ -108,7 +108,7 @@ const hn = [
|
|
|
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 hn = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Ke = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -624,65 +624,65 @@ const Qe = [
|
|
|
624
624
|
"TC-BEP20"
|
|
625
625
|
/* TC_SUPPORTED_TO_BSC */
|
|
626
626
|
];
|
|
627
|
-
var
|
|
627
|
+
var Ie = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(Ie || {}), et = /* @__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))(et || {}), y = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_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))(y || {});
|
|
628
628
|
const tt = {
|
|
629
|
-
[
|
|
630
|
-
[
|
|
631
|
-
[
|
|
632
|
-
[
|
|
633
|
-
[
|
|
634
|
-
[
|
|
635
|
-
[
|
|
636
|
-
[
|
|
637
|
-
[
|
|
638
|
-
[
|
|
639
|
-
[
|
|
640
|
-
[
|
|
641
|
-
[
|
|
642
|
-
[
|
|
643
|
-
[
|
|
644
|
-
[
|
|
645
|
-
[
|
|
646
|
-
[
|
|
647
|
-
[
|
|
648
|
-
[
|
|
649
|
-
[
|
|
650
|
-
[
|
|
651
|
-
[
|
|
652
|
-
[
|
|
653
|
-
[
|
|
654
|
-
[
|
|
655
|
-
[
|
|
656
|
-
[
|
|
657
|
-
[
|
|
658
|
-
[
|
|
659
|
-
[
|
|
660
|
-
[
|
|
661
|
-
[
|
|
662
|
-
[
|
|
663
|
-
[
|
|
664
|
-
[
|
|
665
|
-
[
|
|
666
|
-
[
|
|
667
|
-
[
|
|
668
|
-
[
|
|
669
|
-
[
|
|
670
|
-
[
|
|
671
|
-
[
|
|
672
|
-
[
|
|
673
|
-
[
|
|
674
|
-
[
|
|
675
|
-
[
|
|
676
|
-
[
|
|
677
|
-
[
|
|
678
|
-
[
|
|
679
|
-
},
|
|
629
|
+
[y.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
|
+
[y.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
|
+
[y.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
632
|
+
[y.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
|
|
633
|
+
[y.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
|
|
634
|
+
[y.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
|
|
635
|
+
[y.INVALID_TYPE_GENERIC]: "Invalid type",
|
|
636
|
+
[y.INVALID_NUMBER_STRING]: "Invalid number string.",
|
|
637
|
+
[y.INVALID_NUMBER]: "Invalid number.",
|
|
638
|
+
[y.INVALID_BOOLEAN]: "Invalid boolean.",
|
|
639
|
+
[y.INVALID_OBJECT]: "Invalid object.",
|
|
640
|
+
[y.INVALID_ARRAY]: "Invalid array.",
|
|
641
|
+
[y.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
|
|
642
|
+
[y.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
|
|
643
|
+
[y.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
|
|
644
|
+
[y.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
|
|
645
|
+
[y.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
|
|
646
|
+
[y.AFF_BPS_INTEGER_0_100]: "affiliateBasisPoints must be an integer between 0 and 100.",
|
|
647
|
+
[y.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
|
|
648
|
+
[y.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
|
|
649
|
+
[y.PREFERRED_PROFVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
|
|
650
|
+
[y.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
|
|
651
|
+
[y.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
|
|
652
|
+
[y.INVALID_PROVIDER]: "Invalid provider {0}.",
|
|
653
|
+
[y.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
|
|
654
|
+
[y.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
|
|
655
|
+
[y.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
|
|
656
|
+
[y.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
|
|
657
|
+
[y.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
|
|
658
|
+
[y.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
|
|
659
|
+
[y.INVALID_CHAIN]: "Invalid chain {0}.",
|
|
660
|
+
[y.INVALID_ASSET]: "Invalid asset {0}.",
|
|
661
|
+
[y.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
|
|
662
|
+
[y.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
|
|
663
|
+
[y.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
|
|
664
|
+
[y.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
|
|
665
|
+
[y.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
|
|
666
|
+
[y.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
|
|
667
|
+
[y.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
|
|
668
|
+
[y.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
|
|
669
|
+
[y.INVALID_QUOTE_MODE]: "Invalid quote mode.",
|
|
670
|
+
[y.NO_QUOTES]: "No quotes to service this request.",
|
|
671
|
+
[y.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
|
|
672
|
+
[y.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
|
|
673
|
+
[y.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
|
|
674
|
+
[y.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
|
|
675
|
+
[y.NO_PRICE]: "No price for asset {0}.",
|
|
676
|
+
[y.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
|
+
[y.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
|
+
[y.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
|
+
}, ae = (e, t) => {
|
|
680
680
|
let n = tt[e];
|
|
681
681
|
for (let a = 0; a < t.length; a++)
|
|
682
682
|
n = n.replace(`{${a}}`, t[a]);
|
|
683
683
|
return t.length === 0 ? n.replace("{0}", "") : n;
|
|
684
684
|
};
|
|
685
|
-
class
|
|
685
|
+
class Se extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -690,22 +690,22 @@ class ve extends Error {
|
|
|
690
690
|
code: s,
|
|
691
691
|
message: r,
|
|
692
692
|
type: o,
|
|
693
|
-
options: { shouldLog: p, shouldThrow: d, shouldTrace:
|
|
693
|
+
options: { shouldLog: p, shouldThrow: d, shouldTrace: l } = {
|
|
694
694
|
shouldLog: !0,
|
|
695
695
|
shouldThrow: !0,
|
|
696
696
|
shouldTrace: !0
|
|
697
697
|
},
|
|
698
698
|
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
|
-
const c = r ||
|
|
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 =
|
|
700
|
+
const c = r || ae(s, u || []) || "";
|
|
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 = ae(s, u || []), this.code = s, this.type = o || Ie.UNHANDLED_ERROR, this.options = {
|
|
702
702
|
shouldLog: p || !0,
|
|
703
|
-
shouldTrace:
|
|
703
|
+
shouldTrace: l || !0,
|
|
704
704
|
shouldThrow: d || !1
|
|
705
705
|
}, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new Se(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ class ve 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 ae(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -742,7 +742,7 @@ const _n = {
|
|
|
742
742
|
OP: [44, 60, 0, 0, 0],
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
|
-
var
|
|
745
|
+
var w = /* @__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))(w || {});
|
|
746
746
|
const st = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
@@ -775,23 +775,23 @@ const st = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var
|
|
779
|
-
const
|
|
778
|
+
var me = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(me || {}), ve = /* @__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))(ve || {}), k = /* @__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))(k || {});
|
|
779
|
+
const ee = Object.values(i), it = Object.keys(i), Te = ee.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
781
|
const n = it.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
), rt =
|
|
786
|
-
(e, t) => (e[t] = Te[
|
|
785
|
+
), rt = ee.reduce(
|
|
786
|
+
(e, t) => (e[t] = me[Te[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
), ot =
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), ot = ee.reduce(
|
|
789
|
+
(e, t) => (e[t] = ve[Te[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
), An =
|
|
791
|
+
), An = ee.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
|
-
const n = `${
|
|
794
|
-
return e[t] =
|
|
793
|
+
const n = `${Te[t]}Hex`;
|
|
794
|
+
return e[t] = me[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
797
|
), En = {
|
|
@@ -819,7 +819,7 @@ const ae = Object.values(i), it = Object.keys(i), he = ae.reduce(
|
|
|
819
819
|
"thorchain-stagenet-v2": "THOR",
|
|
820
820
|
"thorchain-mainnet-v1": "THOR"
|
|
821
821
|
/* THORChain */
|
|
822
|
-
},
|
|
822
|
+
}, Ce = {
|
|
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), it = Object.keys(i), he = ae.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://viewblock.io/thorchain"
|
|
838
838
|
};
|
|
839
|
-
var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}), 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 || {}),
|
|
839
|
+
var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}), 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 || {}), H = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(H || {}), dt = /* @__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))(dt || {}), ut = Object.defineProperty, lt = (e, t, n) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (lt(e, typeof t != "symbol" ? t + "" : t, n), n), yt = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
|
-
},
|
|
842
|
+
}, j = (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 ct = "0x313ce567",
|
|
846
|
+
}, D = (e, t, n) => (yt(e, t, "access private method"), n);
|
|
847
|
+
const ct = "0x313ce567", Me = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await
|
|
849
|
+
const { result: n } = await _e.post(ot[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -861,17 +861,17 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
861
861
|
});
|
|
862
862
|
return parseInt(BigInt(n).toString());
|
|
863
863
|
} catch (n) {
|
|
864
|
-
return console.error(n),
|
|
864
|
+
return console.error(n), w[e];
|
|
865
865
|
}
|
|
866
866
|
}, mt = async (e) => {
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
|
-
return
|
|
868
|
+
return w.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
|
-
return t != null && t.startsWith("0x") ?
|
|
870
|
+
return t != null && t.startsWith("0x") ? Me({ chain: i.Ethereum, to: t }) : w.ETH;
|
|
871
871
|
}, Tt = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ?
|
|
874
|
-
}, ht = async (e) => (e === i.BinanceSmartChain,
|
|
873
|
+
return t != null && t.startsWith("0x") ? Me({ chain: i.Avalanche, to: t.toLowerCase() }) : w.AVAX;
|
|
874
|
+
}, ht = async (e) => (e === i.BinanceSmartChain, w.BSC), _t = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
877
|
return mt(t);
|
|
@@ -880,13 +880,13 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
880
880
|
case i.BinanceSmartChain:
|
|
881
881
|
return ht(t);
|
|
882
882
|
default:
|
|
883
|
-
return
|
|
883
|
+
return w[e];
|
|
884
884
|
}
|
|
885
885
|
}, ft = {
|
|
886
|
-
[
|
|
887
|
-
[
|
|
888
|
-
[
|
|
889
|
-
},
|
|
886
|
+
[H.Average]: 1.2,
|
|
887
|
+
[H.Fast]: 1.5,
|
|
888
|
+
[H.Fastest]: 2
|
|
889
|
+
}, Ne = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case i.Bitcoin:
|
|
892
892
|
case i.BitcoinCash:
|
|
@@ -919,13 +919,13 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
919
919
|
case "ETH.vTHOR":
|
|
920
920
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
921
921
|
case i.Cosmos:
|
|
922
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
922
|
+
return { identifier: "GAIA.ATOM", decimal: w[e] };
|
|
923
923
|
case i.THORChain:
|
|
924
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
924
|
+
return { identifier: "THOR.RUNE", decimal: w[e] };
|
|
925
925
|
case i.BinanceSmartChain:
|
|
926
|
-
return { identifier: "BSC.BNB", decimal:
|
|
926
|
+
return { identifier: "BSC.BNB", decimal: w[e] };
|
|
927
927
|
case i.Maya:
|
|
928
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
928
|
+
return { identifier: "MAYA.CACAO", decimal: w.MAYA };
|
|
929
929
|
case "MAYA.MAYA":
|
|
930
930
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
931
931
|
case i.Kujira:
|
|
@@ -939,7 +939,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
939
939
|
case i.Polygon:
|
|
940
940
|
case i.Bitcoin:
|
|
941
941
|
case i.Ethereum:
|
|
942
|
-
return { identifier: `${e}.${e}`, decimal:
|
|
942
|
+
return { identifier: `${e}.${e}`, decimal: w[e] };
|
|
943
943
|
}
|
|
944
944
|
}, wt = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
@@ -983,7 +983,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
983
983
|
if (!st.includes(t))
|
|
984
984
|
return !0;
|
|
985
985
|
const [, a] = n.split("-");
|
|
986
|
-
return
|
|
986
|
+
return Ne({ chain: t, symbol: n }) || !!a;
|
|
987
987
|
}, gn = (e) => e.filter((t) => {
|
|
988
988
|
const n = `${t.chain}.${t.symbol}`;
|
|
989
989
|
return !At.test(n) && Et(n) && t.value !== "0";
|
|
@@ -992,14 +992,14 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
992
992
|
poolUnits: t,
|
|
993
993
|
runeDepth: n
|
|
994
994
|
}) => {
|
|
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),
|
|
996
|
-
return o.mul(p.sub(d).add(
|
|
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), l = a.mul(a), u = s.mul(s).mul(s);
|
|
996
|
+
return o.mul(p.sub(d).add(l)).div(u);
|
|
997
997
|
}, gt = ({
|
|
998
998
|
liquidityUnits: e,
|
|
999
999
|
poolUnits: t,
|
|
1000
1000
|
assetDepth: n
|
|
1001
1001
|
}) => {
|
|
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),
|
|
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), l = a.mul(a), u = o.mul(p.sub(d).add(l)), c = s.mul(s).mul(s);
|
|
1003
1003
|
return u.div(c);
|
|
1004
1004
|
}, On = ({
|
|
1005
1005
|
percent: e,
|
|
@@ -1011,7 +1011,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1011
1011
|
assetDepth: t,
|
|
1012
1012
|
liquidityUnits: n,
|
|
1013
1013
|
poolUnits: a
|
|
1014
|
-
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), R = (e) =>
|
|
1014
|
+
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), R = (e) => N.fromBigInt(BigInt(e), w.THOR), Ot = ({
|
|
1015
1015
|
liquidityUnits: e,
|
|
1016
1016
|
poolUnits: t,
|
|
1017
1017
|
runeDepth: n,
|
|
@@ -1037,11 +1037,11 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1037
1037
|
runeAmount: s,
|
|
1038
1038
|
assetAmount: r
|
|
1039
1039
|
}) => {
|
|
1040
|
-
const o = new
|
|
1040
|
+
const o = new N({ value: e, decimal: 8 }), p = new N({ value: n, decimal: 8 }), d = new N({ value: t, decimal: 8 }), l = new N({ value: s, decimal: 8 }), u = new N({ value: r, decimal: 8 }), c = l.mul(p), _ = u.mul(o), b = l.mul(u), A = o.mul(p), E = d.mul(c.add(_.add(b.mul(2)))), g = c.add(_.add(A.mul(2))), O = E.div(g), x = R(a).add(O);
|
|
1041
1041
|
if (O.getBaseValue("number") === 0)
|
|
1042
|
-
return
|
|
1043
|
-
const
|
|
1044
|
-
return
|
|
1042
|
+
return x.div(d).getBaseValue("number");
|
|
1043
|
+
const ne = d.add(x);
|
|
1044
|
+
return x.div(ne).getBaseValue("number");
|
|
1045
1045
|
}, Cn = ({
|
|
1046
1046
|
runeAmount: e,
|
|
1047
1047
|
assetAmount: t,
|
|
@@ -1050,13 +1050,13 @@ const ct = "0x313ce567", Ne = 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 = R(n), r = R(a), o = R(t), p = R(e), d = o.mul(s).sub(r.mul(p)),
|
|
1054
|
-
return Math.abs(d.div(
|
|
1053
|
+
const s = R(n), r = R(a), o = R(t), p = R(e), d = o.mul(s).sub(r.mul(p)), l = r.mul(p).add(s.mul(r));
|
|
1054
|
+
return Math.abs(d.div(l).getBaseValue("number"));
|
|
1055
1055
|
}, It = ({
|
|
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, M = (e, t) => {
|
|
1060
1060
|
switch (e) {
|
|
1061
1061
|
case h.LEAVE:
|
|
1062
1062
|
case h.BOND: {
|
|
@@ -1076,8 +1076,8 @@ const ct = "0x313ce567", Ne = 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}` : "",
|
|
1080
|
-
return `${e}:${n}${p ? "/" : "."}${
|
|
1079
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", l = It({ chain: n, symbol: s, ticker: a });
|
|
1080
|
+
return `${e}:${n}${p ? "/" : "."}${l}:${r}${d}`;
|
|
1081
1081
|
}
|
|
1082
1082
|
case h.OPEN_LOAN:
|
|
1083
1083
|
case h.CLOSE_LOAN: {
|
|
@@ -1097,7 +1097,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1097
1097
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1098
1098
|
return !!e.match(t);
|
|
1099
1099
|
}, xn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1100
|
-
class
|
|
1100
|
+
class fe 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 be extends Error {
|
|
|
1118
1118
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
class
|
|
1121
|
+
class xe extends Error {
|
|
1122
1122
|
constructor(t) {
|
|
1123
1123
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1124
1124
|
enumerable: !0,
|
|
@@ -1128,25 +1128,25 @@ class De extends Error {
|
|
|
1128
1128
|
}), this.name = "TimeoutError", this.request = t;
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
|
-
const
|
|
1131
|
+
const K = (e) => e !== null && typeof e == "object", Y = (...e) => {
|
|
1132
1132
|
for (const t of e)
|
|
1133
|
-
if ((!
|
|
1133
|
+
if ((!K(t) || Array.isArray(t)) && t !== void 0)
|
|
1134
1134
|
throw new TypeError("The `options` argument must be an object");
|
|
1135
|
-
return
|
|
1136
|
-
},
|
|
1135
|
+
return he({}, ...e);
|
|
1136
|
+
}, De = (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
|
+
}, he = (...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 (K(a)) {
|
|
1147
1147
|
for (let [s, r] of Object.entries(a))
|
|
1148
|
-
|
|
1149
|
-
|
|
1148
|
+
K(r) && s in t && (r = he(t[s], r)), t = { ...t, [s]: r };
|
|
1149
|
+
K(a.headers) && (n = De(n, a.headers), t.headers = n);
|
|
1150
1150
|
}
|
|
1151
1151
|
return t;
|
|
1152
1152
|
}, St = (() => {
|
|
@@ -1160,13 +1160,13 @@ const X = (e) => e !== null && typeof e == "object", Y = (...e) => {
|
|
|
1160
1160
|
return e = !0, "half";
|
|
1161
1161
|
}
|
|
1162
1162
|
}).headers.has("Content-Type")), e && !t;
|
|
1163
|
-
})(), vt = typeof globalThis.AbortController == "function", Ct = typeof globalThis.ReadableStream == "function", Mt = typeof globalThis.FormData == "function",
|
|
1163
|
+
})(), vt = typeof globalThis.AbortController == "function", Ct = typeof globalThis.ReadableStream == "function", Mt = typeof globalThis.FormData == "function", Pe = ["get", "post", "put", "patch", "head", "delete"], Nt = {
|
|
1164
1164
|
json: "application/json",
|
|
1165
1165
|
text: "text/*",
|
|
1166
1166
|
formData: "multipart/form-data",
|
|
1167
1167
|
arrayBuffer: "*/*",
|
|
1168
1168
|
blob: "*/*"
|
|
1169
|
-
},
|
|
1169
|
+
}, se = 2147483647, Be = Symbol("stop"), xt = {
|
|
1170
1170
|
json: !0,
|
|
1171
1171
|
parseJson: !0,
|
|
1172
1172
|
searchParams: !0,
|
|
@@ -1193,18 +1193,18 @@ const X = (e) => e !== null && typeof e == "object", Y = (...e) => {
|
|
|
1193
1193
|
window: !0,
|
|
1194
1194
|
dispatcher: !0,
|
|
1195
1195
|
duplex: !0
|
|
1196
|
-
}, Pt = (e) =>
|
|
1196
|
+
}, Pt = (e) => Pe.includes(e) ? e.toUpperCase() : e, Bt = ["get", "put", "head", "delete", "options", "trace"], Lt = [408, 413, 429, 500, 502, 503, 504], Le = [413, 429, 503], be = {
|
|
1197
1197
|
limit: 2,
|
|
1198
1198
|
methods: Bt,
|
|
1199
1199
|
statusCodes: Lt,
|
|
1200
|
-
afterStatusCodes:
|
|
1200
|
+
afterStatusCodes: Le,
|
|
1201
1201
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1202
1202
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1203
1203
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1204
1204
|
}, Vt = (e = {}) => {
|
|
1205
1205
|
if (typeof e == "number")
|
|
1206
1206
|
return {
|
|
1207
|
-
...
|
|
1207
|
+
...be,
|
|
1208
1208
|
limit: e
|
|
1209
1209
|
};
|
|
1210
1210
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -1212,15 +1212,15 @@ const X = (e) => e !== null && typeof e == "object", Y = (...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
|
+
...be,
|
|
1216
1216
|
...e,
|
|
1217
|
-
afterStatusCodes:
|
|
1217
|
+
afterStatusCodes: Le
|
|
1218
1218
|
};
|
|
1219
1219
|
};
|
|
1220
1220
|
async function Ut(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 xe(e));
|
|
1224
1224
|
}, a.timeout);
|
|
1225
1225
|
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1226
1226
|
clearTimeout(o);
|
|
@@ -1244,11 +1244,11 @@ const $t = (e, t) => {
|
|
|
1244
1244
|
!(a in Dt) && !(a in xt) && !(a in e) && (n[a] = t[a]);
|
|
1245
1245
|
return n;
|
|
1246
1246
|
};
|
|
1247
|
-
class
|
|
1247
|
+
class J {
|
|
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 J(t, n), s = async () => {
|
|
1250
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > se)
|
|
1251
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${se}`);
|
|
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 fe(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;
|
|
@@ -1315,8 +1315,8 @@ 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: De(this._input.headers, n.headers),
|
|
1319
|
+
hooks: he({
|
|
1320
1320
|
beforeRequest: [],
|
|
1321
1321
|
beforeRetry: [],
|
|
1322
1322
|
beforeError: [],
|
|
@@ -1352,8 +1352,8 @@ class Z {
|
|
|
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 xe)) {
|
|
1356
|
+
if (t instanceof fe) {
|
|
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,7 +1376,7 @@ 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), se);
|
|
1380
1380
|
if (a !== 0 && this._retryCount > 0) {
|
|
1381
1381
|
await Ht(a, { signal: this._options.signal });
|
|
1382
1382
|
for (const s of this._options.hooks.beforeRetry)
|
|
@@ -1385,7 +1385,7 @@ class Z {
|
|
|
1385
1385
|
options: this._options,
|
|
1386
1386
|
error: n,
|
|
1387
1387
|
retryCount: this._retryCount
|
|
1388
|
-
}) ===
|
|
1388
|
+
}) === Be)
|
|
1389
1389
|
return;
|
|
1390
1390
|
return this._retry(t);
|
|
1391
1391
|
}
|
|
@@ -1418,17 +1418,17 @@ class Z {
|
|
|
1418
1418
|
const o = t.body.getReader();
|
|
1419
1419
|
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1420
1420
|
async function p() {
|
|
1421
|
-
const { done: d, value:
|
|
1421
|
+
const { done: d, value: l } = await o.read();
|
|
1422
1422
|
if (d) {
|
|
1423
1423
|
r.close();
|
|
1424
1424
|
return;
|
|
1425
1425
|
}
|
|
1426
1426
|
if (n) {
|
|
1427
|
-
s +=
|
|
1427
|
+
s += l.byteLength;
|
|
1428
1428
|
const u = a === 0 ? 0 : s / a;
|
|
1429
|
-
n({ percent: u, transferredBytes: s, totalBytes: a },
|
|
1429
|
+
n({ percent: u, transferredBytes: s, totalBytes: a }, l);
|
|
1430
1430
|
}
|
|
1431
|
-
r.enqueue(
|
|
1431
|
+
r.enqueue(l), await p();
|
|
1432
1432
|
}
|
|
1433
1433
|
await p();
|
|
1434
1434
|
}
|
|
@@ -1440,29 +1440,29 @@ 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
|
-
}, kt =
|
|
1449
|
-
get: (e, t) =>
|
|
1450
|
-
post: (e, t) =>
|
|
1451
|
-
},
|
|
1443
|
+
const re = (e) => {
|
|
1444
|
+
const t = (n, a) => J.create(n, Y(e, a));
|
|
1445
|
+
for (const n of Pe)
|
|
1446
|
+
t[n] = (a, s) => J.create(a, Y(e, s, { method: n }));
|
|
1447
|
+
return t.create = (n) => re(Y(n)), t.extend = (n) => re(Y(e, n)), t.stop = Be, t;
|
|
1448
|
+
}, kt = re(), Ft = kt, Gt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, we = Ft.create({ headers: Gt }), _e = {
|
|
1449
|
+
get: (e, t) => we.get(e, t).json(),
|
|
1450
|
+
post: (e, t) => we.post(e, t).json()
|
|
1451
|
+
}, Ae = Object.values(i), qt = (e = "") => {
|
|
1452
1452
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1453
|
-
if (
|
|
1453
|
+
if (Ae.includes(n))
|
|
1454
1454
|
return !0;
|
|
1455
1455
|
const [a] = t.split("/");
|
|
1456
|
-
if (
|
|
1456
|
+
if (Ae.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
|
-
},
|
|
1462
|
-
function
|
|
1461
|
+
}, F = 8, V = (e) => 10n ** BigInt(e), $ = (e) => Math.log10(parseFloat(e.toString()));
|
|
1462
|
+
function te({
|
|
1463
1463
|
value: e,
|
|
1464
|
-
bigIntDecimal: t =
|
|
1465
|
-
decimal: n =
|
|
1464
|
+
bigIntDecimal: t = F,
|
|
1465
|
+
decimal: n = F
|
|
1466
1466
|
}) {
|
|
1467
1467
|
const a = e < 0n;
|
|
1468
1468
|
let s = e.toString().substring(a ? 1 : 0);
|
|
@@ -1475,19 +1475,19 @@ function se({
|
|
|
1475
1475
|
""
|
|
1476
1476
|
);
|
|
1477
1477
|
}
|
|
1478
|
-
var
|
|
1478
|
+
var L, U, oe, Ve, pe, Ee, Q, de;
|
|
1479
1479
|
const Wt = class Ue {
|
|
1480
1480
|
constructor(t) {
|
|
1481
|
-
|
|
1482
|
-
const n =
|
|
1483
|
-
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier =
|
|
1484
|
-
Math.max(He(
|
|
1485
|
-
),
|
|
1481
|
+
j(this, L), j(this, oe), j(this, pe), j(this, Q), v(this, "decimalMultiplier", 10n ** 8n), v(this, "bigIntValue", 0n), v(this, "decimal");
|
|
1482
|
+
const n = le(t);
|
|
1483
|
+
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = V(
|
|
1484
|
+
Math.max(He(z(n)), this.decimal || 0)
|
|
1485
|
+
), D(this, oe, Ve).call(this, n);
|
|
1486
1486
|
}
|
|
1487
1487
|
static fromBigInt(t, n) {
|
|
1488
1488
|
return new Ue({
|
|
1489
1489
|
decimal: n,
|
|
1490
|
-
value:
|
|
1490
|
+
value: te({ value: t, bigIntDecimal: n, decimal: n })
|
|
1491
1491
|
});
|
|
1492
1492
|
}
|
|
1493
1493
|
static shiftDecimals({
|
|
@@ -1496,24 +1496,24 @@ const Wt = class Ue {
|
|
|
1496
1496
|
to: a
|
|
1497
1497
|
}) {
|
|
1498
1498
|
return this.fromBigInt(
|
|
1499
|
-
t.getBaseValue("bigint") *
|
|
1499
|
+
t.getBaseValue("bigint") * V(a) / V(n),
|
|
1500
1500
|
a
|
|
1501
1501
|
);
|
|
1502
1502
|
}
|
|
1503
1503
|
set(t) {
|
|
1504
|
-
return
|
|
1504
|
+
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1505
1505
|
}
|
|
1506
1506
|
add(...t) {
|
|
1507
|
-
return
|
|
1507
|
+
return D(this, L, U).call(this, "add", ...t);
|
|
1508
1508
|
}
|
|
1509
1509
|
sub(...t) {
|
|
1510
|
-
return
|
|
1510
|
+
return D(this, L, U).call(this, "sub", ...t);
|
|
1511
1511
|
}
|
|
1512
1512
|
mul(...t) {
|
|
1513
|
-
return
|
|
1513
|
+
return D(this, L, U).call(this, "mul", ...t);
|
|
1514
1514
|
}
|
|
1515
1515
|
div(...t) {
|
|
1516
|
-
return
|
|
1516
|
+
return D(this, L, U).call(this, "div", ...t);
|
|
1517
1517
|
}
|
|
1518
1518
|
gt(t) {
|
|
1519
1519
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1533,7 +1533,7 @@ const Wt = class Ue {
|
|
|
1533
1533
|
getValue(t) {
|
|
1534
1534
|
const n = this.formatBigIntToSafeValue(
|
|
1535
1535
|
this.bigIntValue,
|
|
1536
|
-
this.decimal ||
|
|
1536
|
+
this.decimal || $(this.decimalMultiplier)
|
|
1537
1537
|
);
|
|
1538
1538
|
switch (t) {
|
|
1539
1539
|
case "number":
|
|
@@ -1545,7 +1545,7 @@ const Wt = class Ue {
|
|
|
1545
1545
|
}
|
|
1546
1546
|
}
|
|
1547
1547
|
getBaseValue(t) {
|
|
1548
|
-
const n = this.decimalMultiplier /
|
|
1548
|
+
const n = this.decimalMultiplier / V(this.decimal || w.THOR), a = this.bigIntValue / n;
|
|
1549
1549
|
switch (t) {
|
|
1550
1550
|
case "number":
|
|
1551
1551
|
return Number(a);
|
|
@@ -1558,18 +1558,18 @@ const Wt = class Ue {
|
|
|
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 = le(t), s = z(a);
|
|
1562
|
+
return s === "0" || s === "undefined" ? 0n : D(this, Q, de).call(this, s, n);
|
|
1563
1563
|
}
|
|
1564
1564
|
formatBigIntToSafeValue(t, n) {
|
|
1565
|
-
const a = n || this.decimal ||
|
|
1565
|
+
const a = n || this.decimal || F, s = Math.max(
|
|
1566
1566
|
a,
|
|
1567
|
-
|
|
1568
|
-
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o,
|
|
1567
|
+
$(this.decimalMultiplier)
|
|
1568
|
+
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, l = d.length - s;
|
|
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(
|
|
1571
1571
|
0,
|
|
1572
|
-
|
|
1572
|
+
l
|
|
1573
1573
|
)}.${u}`.replace(/\.?0*$/, "");
|
|
1574
1574
|
}
|
|
1575
1575
|
toSignificant(t = 6) {
|
|
@@ -1612,12 +1612,12 @@ const Wt = class Ue {
|
|
|
1612
1612
|
decimalSeparator: s = ".",
|
|
1613
1613
|
thousandSeparator: r = ","
|
|
1614
1614
|
} = {}) {
|
|
1615
|
-
const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."),
|
|
1615
|
+
const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."), l = p.replace(/\B(?=(\d{3})+(?!\d))/g, r), u = !p && !d ? "0.00" : p === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${l}${parseInt(d) ? `${s}${d.slice(0, a)}` : ""}`;
|
|
1616
1616
|
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1617
1617
|
}
|
|
1618
1618
|
};
|
|
1619
|
-
|
|
1620
|
-
const n =
|
|
1619
|
+
L = /* @__PURE__ */ new WeakSet(), U = function(e, ...t) {
|
|
1620
|
+
const n = D(this, pe, Ee).call(this, this, ...t), a = V(n), s = t.reduce(
|
|
1621
1621
|
(o, p) => {
|
|
1622
1622
|
const d = this.getBigIntValue(p, n);
|
|
1623
1623
|
switch (e) {
|
|
@@ -1638,59 +1638,59 @@ V = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
|
|
|
1638
1638
|
},
|
|
1639
1639
|
//normalize is to precision multiplier base
|
|
1640
1640
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1641
|
-
), r =
|
|
1641
|
+
), r = te({
|
|
1642
1642
|
bigIntDecimal: n,
|
|
1643
|
-
decimal: Math.max(n,
|
|
1643
|
+
decimal: Math.max(n, $(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
|
+
}, oe = /* @__PURE__ */ new WeakSet(), Ve = function(e) {
|
|
1648
|
+
const t = z(e) || "0";
|
|
1649
|
+
this.bigIntValue = D(this, Q, de).call(this, t);
|
|
1650
|
+
}, pe = /* @__PURE__ */ new WeakSet(), Ee = function(...e) {
|
|
1651
1651
|
const t = e.map(
|
|
1652
|
-
(n) => typeof n == "object" ? n.decimal ||
|
|
1652
|
+
(n) => typeof n == "object" ? n.decimal || $(n.decimalMultiplier) : He(z(n))
|
|
1653
1653
|
).filter(Boolean);
|
|
1654
|
-
return Math.max(...t,
|
|
1655
|
-
},
|
|
1656
|
-
const n = t ?
|
|
1654
|
+
return Math.max(...t, F);
|
|
1655
|
+
}, Q = /* @__PURE__ */ new WeakSet(), de = function(e, t) {
|
|
1656
|
+
const n = t ? V(t) : this.decimalMultiplier, a = $(n), [s = "", r = ""] = e.split(".");
|
|
1657
1657
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1658
1658
|
};
|
|
1659
|
-
let
|
|
1659
|
+
let ue = Wt;
|
|
1660
1660
|
const jt = Intl.NumberFormat("fullwide", {
|
|
1661
1661
|
useGrouping: !1,
|
|
1662
1662
|
maximumFractionDigits: 20
|
|
1663
1663
|
});
|
|
1664
|
-
function
|
|
1665
|
-
const t = `${typeof e == "number" ? jt.format(e) :
|
|
1664
|
+
function z(e) {
|
|
1665
|
+
const t = `${typeof e == "number" ? jt.format(e) : le(e)}`.replaceAll(",", ".").split(".");
|
|
1666
1666
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1667
1667
|
}
|
|
1668
1668
|
function He(e) {
|
|
1669
1669
|
var t;
|
|
1670
1670
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1671
|
-
return Math.max(n,
|
|
1671
|
+
return Math.max(n, F);
|
|
1672
1672
|
}
|
|
1673
|
-
function
|
|
1673
|
+
function le(e) {
|
|
1674
1674
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1675
1675
|
}
|
|
1676
|
-
const
|
|
1677
|
-
let
|
|
1678
|
-
const
|
|
1679
|
-
if (!
|
|
1676
|
+
const X = (e, t) => typeof e == "bigint" ? te({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1677
|
+
let ye;
|
|
1678
|
+
const Re = (e) => {
|
|
1679
|
+
if (!ye)
|
|
1680
1680
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1681
|
-
return
|
|
1682
|
-
},
|
|
1681
|
+
return ye.get(e.toUpperCase()) || { decimal: w.THOR, identifier: "" };
|
|
1682
|
+
}, ge = async (e, t = 0) => {
|
|
1683
1683
|
qt(e);
|
|
1684
|
-
const n = await _t(
|
|
1685
|
-
return new
|
|
1684
|
+
const n = await _t(ce(e)), a = X(t, n);
|
|
1685
|
+
return new C({ decimal: n, value: a, identifier: e });
|
|
1686
1686
|
};
|
|
1687
|
-
class
|
|
1687
|
+
class C extends ue {
|
|
1688
1688
|
constructor(t) {
|
|
1689
1689
|
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`;
|
|
1690
1690
|
super(
|
|
1691
|
-
t.value instanceof
|
|
1691
|
+
t.value instanceof ue ? t.value : { decimal: t.decimal, value: t.value }
|
|
1692
1692
|
), v(this, "address"), v(this, "isSynthetic", !1), v(this, "isGasAsset", !1), v(this, "chain"), v(this, "symbol"), v(this, "ticker"), v(this, "type");
|
|
1693
|
-
const a =
|
|
1693
|
+
const a = ce(n);
|
|
1694
1694
|
this.type = wt(a), this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset;
|
|
1695
1695
|
}
|
|
1696
1696
|
toString(t = !1) {
|
|
@@ -1704,24 +1704,24 @@ class M extends ye {
|
|
|
1704
1704
|
return this.chain === t && this.symbol === n;
|
|
1705
1705
|
}
|
|
1706
1706
|
static async fromString(t, n = 0) {
|
|
1707
|
-
return
|
|
1707
|
+
return ge(t, n);
|
|
1708
1708
|
}
|
|
1709
1709
|
static fromStringSync(t, n = 0) {
|
|
1710
|
-
const { isSynthetic: a } =
|
|
1710
|
+
const { isSynthetic: a } = ce(t), { decimal: s, identifier: r } = Re(
|
|
1711
1711
|
t
|
|
1712
|
-
), o =
|
|
1713
|
-
return r ? new
|
|
1712
|
+
), o = X(n, s);
|
|
1713
|
+
return r ? new C({ decimal: s, identifier: r, value: o }) : a ? new C({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1714
1714
|
}
|
|
1715
1715
|
static async fromIdentifier(t, n = 0) {
|
|
1716
|
-
return
|
|
1716
|
+
return ge(t, n);
|
|
1717
1717
|
}
|
|
1718
1718
|
static fromIdentifierSync(t, n = 0) {
|
|
1719
|
-
const { decimal: a, identifier: s } =
|
|
1720
|
-
return new
|
|
1719
|
+
const { decimal: a, identifier: s } = Re(t), r = X(n, a);
|
|
1720
|
+
return new C({ decimal: a, identifier: s, value: r });
|
|
1721
1721
|
}
|
|
1722
1722
|
static fromChainOrSignature(t, n = 0) {
|
|
1723
|
-
const { decimal: a, identifier: s } = bt(t), r =
|
|
1724
|
-
return new
|
|
1723
|
+
const { decimal: a, identifier: s } = bt(t), r = X(n, a);
|
|
1724
|
+
return new C({ value: r, decimal: a, identifier: s });
|
|
1725
1725
|
}
|
|
1726
1726
|
static async loadStaticAssets() {
|
|
1727
1727
|
return new Promise(
|
|
@@ -1734,9 +1734,9 @@ class M extends ye {
|
|
|
1734
1734
|
NativeList: s,
|
|
1735
1735
|
...r
|
|
1736
1736
|
} = await import("@swapkit/tokens");
|
|
1737
|
-
|
|
1738
|
-
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain:
|
|
1739
|
-
const c = "decimals" in u ? u.decimals :
|
|
1737
|
+
ye = [s, ...Object.values(r)].reduce(
|
|
1738
|
+
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: l, ...u }) => {
|
|
1739
|
+
const c = "decimals" in u ? u.decimals : w[l];
|
|
1740
1740
|
o.set(d, { identifier: d, decimal: c });
|
|
1741
1741
|
}), o),
|
|
1742
1742
|
/* @__PURE__ */ new Map()
|
|
@@ -1752,8 +1752,8 @@ class M extends ye {
|
|
|
1752
1752
|
);
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
|
-
const
|
|
1756
|
-
const t =
|
|
1755
|
+
const ie = (e) => {
|
|
1756
|
+
const t = C.fromChainOrSignature(e);
|
|
1757
1757
|
switch (e) {
|
|
1758
1758
|
case i.Bitcoin:
|
|
1759
1759
|
case i.Litecoin:
|
|
@@ -1770,17 +1770,17 @@ const oe = (e) => {
|
|
|
1770
1770
|
default:
|
|
1771
1771
|
return t.set(1e-8);
|
|
1772
1772
|
}
|
|
1773
|
-
},
|
|
1773
|
+
}, ce = (e) => {
|
|
1774
1774
|
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
1775
|
return {
|
|
1776
1776
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1777
1777
|
chain: r,
|
|
1778
|
-
isGasAsset:
|
|
1778
|
+
isGasAsset: Ne({ chain: r, symbol: o }),
|
|
1779
1779
|
isSynthetic: t,
|
|
1780
1780
|
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1781
1781
|
ticker: p
|
|
1782
1782
|
};
|
|
1783
|
-
},
|
|
1783
|
+
}, Yt = {
|
|
1784
1784
|
/**
|
|
1785
1785
|
* Core
|
|
1786
1786
|
*/
|
|
@@ -1839,21 +1839,21 @@ const oe = (e) => {
|
|
|
1839
1839
|
};
|
|
1840
1840
|
class m extends Error {
|
|
1841
1841
|
constructor(t, n) {
|
|
1842
|
-
console.error(n), super(t, { cause: { code:
|
|
1842
|
+
console.error(n), super(t, { cause: { code: Yt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1843
1843
|
}
|
|
1844
1844
|
}
|
|
1845
|
-
class
|
|
1845
|
+
class N extends ue {
|
|
1846
1846
|
eq(t) {
|
|
1847
1847
|
return this.eqValue(t);
|
|
1848
1848
|
}
|
|
1849
1849
|
static fromBigInt(t, n) {
|
|
1850
|
-
return new
|
|
1850
|
+
return new N({
|
|
1851
1851
|
decimal: n,
|
|
1852
|
-
value:
|
|
1852
|
+
value: te({ value: t, bigIntDecimal: n, decimal: n })
|
|
1853
1853
|
});
|
|
1854
1854
|
}
|
|
1855
1855
|
}
|
|
1856
|
-
const
|
|
1856
|
+
const Kt = [
|
|
1857
1857
|
{
|
|
1858
1858
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1859
1859
|
stateMutability: "nonpayable",
|
|
@@ -3540,7 +3540,7 @@ const Yt = [
|
|
|
3540
3540
|
},
|
|
3541
3541
|
{ stateMutability: "payable", type: "receive" }
|
|
3542
3542
|
], $e = {
|
|
3543
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3543
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Kt,
|
|
3544
3544
|
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Jt,
|
|
3545
3545
|
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Qt
|
|
3546
3546
|
}, dn = {
|
|
@@ -3570,38 +3570,38 @@ const Yt = [
|
|
|
3570
3570
|
data: o = "",
|
|
3571
3571
|
deadline: p,
|
|
3572
3572
|
memo: d,
|
|
3573
|
-
router:
|
|
3573
|
+
router: l,
|
|
3574
3574
|
memoStreamingSwap: u,
|
|
3575
3575
|
tcMemo: c,
|
|
3576
3576
|
tcRouter: _,
|
|
3577
3577
|
tcVault: b,
|
|
3578
|
-
vault:
|
|
3578
|
+
vault: A,
|
|
3579
3579
|
token: E
|
|
3580
3580
|
}
|
|
3581
3581
|
}) => {
|
|
3582
3582
|
const g = !!$e[t.toLowerCase()];
|
|
3583
|
-
if (g && !
|
|
3583
|
+
if (g && !l)
|
|
3584
3584
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3585
|
-
const O = c || d,
|
|
3586
|
-
if (!b && !
|
|
3585
|
+
const O = c || d, x = e && u || O;
|
|
3586
|
+
if (!b && !A)
|
|
3587
3587
|
throw new Error("TC Vault is required on calldata");
|
|
3588
|
-
if (!_ && !
|
|
3588
|
+
if (!_ && !l)
|
|
3589
3589
|
throw new Error("TC Router is required on calldata");
|
|
3590
|
-
if (!
|
|
3590
|
+
if (!x)
|
|
3591
3591
|
throw new Error("TC Memo is required on calldata");
|
|
3592
3592
|
if (!E)
|
|
3593
3593
|
throw new Error("Token is required on calldata");
|
|
3594
|
-
const
|
|
3594
|
+
const ne = [
|
|
3595
3595
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3596
|
-
a(_ ||
|
|
3597
|
-
a(b ||
|
|
3598
|
-
|
|
3596
|
+
a(_ || l),
|
|
3597
|
+
a(b || A),
|
|
3598
|
+
x.replace("{recipientAddress}", n),
|
|
3599
3599
|
a(E),
|
|
3600
3600
|
s
|
|
3601
|
-
], ke = g ? [a(
|
|
3602
|
-
return [...
|
|
3601
|
+
], ke = g ? [a(l), o, p] : [r, p];
|
|
3602
|
+
return [...ne, ...ke];
|
|
3603
3603
|
}, ln = ({ chain: e, txHash: t }) => {
|
|
3604
|
-
const n =
|
|
3604
|
+
const n = Ce[e];
|
|
3605
3605
|
switch (e) {
|
|
3606
3606
|
case i.Binance:
|
|
3607
3607
|
case i.Bitcoin:
|
|
@@ -3627,7 +3627,7 @@ const Yt = [
|
|
|
3627
3627
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3628
3628
|
}
|
|
3629
3629
|
}, yn = ({ chain: e, address: t }) => {
|
|
3630
|
-
const n =
|
|
3630
|
+
const n = Ce[e];
|
|
3631
3631
|
switch (e) {
|
|
3632
3632
|
case i.Arbitrum:
|
|
3633
3633
|
case i.Avalanche:
|
|
@@ -3651,20 +3651,20 @@ const Yt = [
|
|
|
3651
3651
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3652
3652
|
}
|
|
3653
3653
|
}, cn = (e) => {
|
|
3654
|
-
const t = e ?
|
|
3655
|
-
return
|
|
3654
|
+
const t = e ? k.ThornodeStagenet : k.ThornodeMainnet;
|
|
3655
|
+
return _e.get(`${t}/thorchain/inbound_addresses`);
|
|
3656
3656
|
}, mn = (e) => {
|
|
3657
|
-
const t = e ?
|
|
3658
|
-
return
|
|
3659
|
-
},
|
|
3657
|
+
const t = e ? k.ThornodeStagenet : k.ThornodeMainnet;
|
|
3658
|
+
return _e.get(`${t}/thorchain/mimir`);
|
|
3659
|
+
}, Oe = () => Object.values(i).reduce(
|
|
3660
3660
|
(e, t) => (e[t] = null, e),
|
|
3661
3661
|
{}
|
|
3662
3662
|
);
|
|
3663
|
-
var
|
|
3663
|
+
var B, Z, G, I, q, W;
|
|
3664
3664
|
class Dn {
|
|
3665
3665
|
constructor({ stagenet: t } = {}) {
|
|
3666
|
-
T(this, "connectedChains",
|
|
3667
|
-
T(this, "connectedWallets",
|
|
3666
|
+
T(this, "connectedChains", Oe());
|
|
3667
|
+
T(this, "connectedWallets", Oe());
|
|
3668
3668
|
T(this, "stagenet", !1);
|
|
3669
3669
|
T(this, "getAddress", (t) => {
|
|
3670
3670
|
var n;
|
|
@@ -3684,30 +3684,30 @@ class Dn {
|
|
|
3684
3684
|
throw new m("core_swap_route_not_complete");
|
|
3685
3685
|
try {
|
|
3686
3686
|
if (Qe.includes(r)) {
|
|
3687
|
-
const
|
|
3688
|
-
if (!(
|
|
3687
|
+
const l = this.connectedWallets[o];
|
|
3688
|
+
if (!(l != null && l.sendTransaction))
|
|
3689
3689
|
throw new m("core_wallet_connection_not_found");
|
|
3690
3690
|
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3691
3691
|
throw new m("core_swap_route_transaction_not_found");
|
|
3692
|
-
const { data: c, from: _, to: b, value:
|
|
3692
|
+
const { data: c, from: _, to: b, value: A } = a.transaction, E = {
|
|
3693
3693
|
data: c,
|
|
3694
3694
|
from: _,
|
|
3695
3695
|
to: b.toLowerCase(),
|
|
3696
3696
|
chainId: BigInt(rt[o]),
|
|
3697
|
-
value:
|
|
3697
|
+
value: A ? BigInt(A) : 0n
|
|
3698
3698
|
};
|
|
3699
|
-
return
|
|
3699
|
+
return l.sendTransaction(E, s);
|
|
3700
3700
|
}
|
|
3701
3701
|
if (Ze.includes(r)) {
|
|
3702
3702
|
if (!a.calldata.fromAsset)
|
|
3703
3703
|
throw new m("core_swap_asset_not_recognized");
|
|
3704
|
-
const
|
|
3705
|
-
if (!
|
|
3704
|
+
const l = await C.fromString(a.calldata.fromAsset);
|
|
3705
|
+
if (!l)
|
|
3706
3706
|
throw new m("core_swap_asset_not_recognized");
|
|
3707
|
-
const { address: u } = await f(this,
|
|
3707
|
+
const { address: u } = await f(this, B).call(this, l.chain), {
|
|
3708
3708
|
contract: c,
|
|
3709
|
-
calldata: { expiration: _, amountIn: b, memo:
|
|
3710
|
-
} = a, g =
|
|
3709
|
+
calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
|
|
3710
|
+
} = a, g = l.add(N.fromBigInt(BigInt(b), l.decimal)), O = t && E || A;
|
|
3711
3711
|
return this.deposit({
|
|
3712
3712
|
expiration: _,
|
|
3713
3713
|
assetValue: g,
|
|
@@ -3718,30 +3718,30 @@ class Dn {
|
|
|
3718
3718
|
});
|
|
3719
3719
|
}
|
|
3720
3720
|
if (ze.includes(r)) {
|
|
3721
|
-
const { calldata:
|
|
3721
|
+
const { calldata: l, contract: u } = a;
|
|
3722
3722
|
if (!u)
|
|
3723
3723
|
throw new m("core_swap_contract_not_found");
|
|
3724
3724
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3725
3725
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3726
3726
|
throw new m("core_wallet_connection_not_found");
|
|
3727
|
-
const { getProvider: b, toChecksumAddress:
|
|
3727
|
+
const { getProvider: b, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = b(o), g = dn[u.toLowerCase()];
|
|
3728
3728
|
if (!g)
|
|
3729
3729
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3730
|
-
const
|
|
3730
|
+
const x = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, g, E))).getFunction("swapIn").populateTransaction(
|
|
3731
3731
|
...un({
|
|
3732
3732
|
streamSwap: t,
|
|
3733
|
-
toChecksumAddress:
|
|
3733
|
+
toChecksumAddress: A,
|
|
3734
3734
|
contractAddress: u,
|
|
3735
3735
|
recipient: n,
|
|
3736
|
-
calldata:
|
|
3736
|
+
calldata: l
|
|
3737
3737
|
}),
|
|
3738
3738
|
{ from: _ }
|
|
3739
3739
|
);
|
|
3740
|
-
return c.sendTransaction(
|
|
3740
|
+
return c.sendTransaction(x, s);
|
|
3741
3741
|
}
|
|
3742
3742
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3743
|
-
} catch (
|
|
3744
|
-
throw new m("core_swap_transaction_error",
|
|
3743
|
+
} catch (l) {
|
|
3744
|
+
throw new m("core_swap_transaction_error", l);
|
|
3745
3745
|
}
|
|
3746
3746
|
});
|
|
3747
3747
|
T(this, "getWalletByChain", async (t, n) => {
|
|
@@ -3749,7 +3749,7 @@ class Dn {
|
|
|
3749
3749
|
const a = this.getAddress(t);
|
|
3750
3750
|
if (!a)
|
|
3751
3751
|
return null;
|
|
3752
|
-
const s = [
|
|
3752
|
+
const s = [C.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3753
3753
|
try {
|
|
3754
3754
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3755
3755
|
return this.connectedChains[t] = {
|
|
@@ -3761,8 +3761,8 @@ class Dn {
|
|
|
3761
3761
|
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3762
3762
|
}
|
|
3763
3763
|
});
|
|
3764
|
-
T(this, "approveAssetValue", (t, n) => f(this,
|
|
3765
|
-
T(this, "isAssetValueApproved", (t, n) => f(this,
|
|
3764
|
+
T(this, "approveAssetValue", (t, n) => f(this, G).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3765
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, G).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3766
3766
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3767
3767
|
var a, s;
|
|
3768
3768
|
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
@@ -3772,7 +3772,7 @@ class Dn {
|
|
|
3772
3772
|
if (!n)
|
|
3773
3773
|
throw new m("core_wallet_connection_not_found");
|
|
3774
3774
|
try {
|
|
3775
|
-
return await n.transfer(f(this,
|
|
3775
|
+
return await n.transfer(f(this, W).call(this, t));
|
|
3776
3776
|
} catch (a) {
|
|
3777
3777
|
throw new m("core_swap_transaction_error", a);
|
|
3778
3778
|
}
|
|
@@ -3786,39 +3786,39 @@ class Dn {
|
|
|
3786
3786
|
const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
|
|
3787
3787
|
if (!d)
|
|
3788
3788
|
throw new m("core_wallet_connection_not_found");
|
|
3789
|
-
const
|
|
3789
|
+
const l = f(this, W).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3790
3790
|
try {
|
|
3791
3791
|
switch (r) {
|
|
3792
3792
|
case i.THORChain: {
|
|
3793
3793
|
const u = d;
|
|
3794
|
-
return await (n === "" ? u.deposit(
|
|
3794
|
+
return await (n === "" ? u.deposit(l) : u.transfer(l));
|
|
3795
3795
|
}
|
|
3796
3796
|
case i.Ethereum:
|
|
3797
3797
|
case i.BinanceSmartChain:
|
|
3798
3798
|
case i.Avalanche: {
|
|
3799
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ?
|
|
3799
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Ke : r === i.BinanceSmartChain ? Xe : Ye;
|
|
3800
3800
|
return await d.call({
|
|
3801
3801
|
abi: c,
|
|
3802
|
-
contractAddress: a || (await f(this,
|
|
3802
|
+
contractAddress: a || (await f(this, B).call(this, r)).router,
|
|
3803
3803
|
funcName: "depositWithExpiry",
|
|
3804
3804
|
funcParams: [
|
|
3805
3805
|
n,
|
|
3806
3806
|
u({ chain: r, symbol: o, ticker: p }, r),
|
|
3807
3807
|
t.getBaseValue("string"),
|
|
3808
|
-
|
|
3808
|
+
l.memo,
|
|
3809
3809
|
s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
3810
3810
|
],
|
|
3811
3811
|
txOverrides: {
|
|
3812
|
-
from:
|
|
3812
|
+
from: l.from,
|
|
3813
3813
|
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
3814
3814
|
}
|
|
3815
3815
|
});
|
|
3816
3816
|
}
|
|
3817
3817
|
default:
|
|
3818
|
-
return await d.transfer(
|
|
3818
|
+
return await d.transfer(l);
|
|
3819
3819
|
}
|
|
3820
3820
|
} 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"),
|
|
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"), A = c == null ? void 0 : c.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : A ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3822
3822
|
throw new m(E, u);
|
|
3823
3823
|
}
|
|
3824
3824
|
});
|
|
@@ -3833,9 +3833,9 @@ class Dn {
|
|
|
3833
3833
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3834
3834
|
let a = "", s = "";
|
|
3835
3835
|
try {
|
|
3836
|
-
a = await f(this,
|
|
3836
|
+
a = await f(this, I).call(this, {
|
|
3837
3837
|
assetValue: t,
|
|
3838
|
-
memo:
|
|
3838
|
+
memo: M(h.DEPOSIT, {
|
|
3839
3839
|
...n,
|
|
3840
3840
|
address: this.getAddress(n.chain)
|
|
3841
3841
|
})
|
|
@@ -3844,9 +3844,9 @@ class Dn {
|
|
|
3844
3844
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3845
3845
|
}
|
|
3846
3846
|
try {
|
|
3847
|
-
s = await f(this,
|
|
3847
|
+
s = await f(this, I).call(this, {
|
|
3848
3848
|
assetValue: n,
|
|
3849
|
-
memo:
|
|
3849
|
+
memo: M(h.DEPOSIT, {
|
|
3850
3850
|
...n,
|
|
3851
3851
|
address: this.getAddress(i.THORChain)
|
|
3852
3852
|
})
|
|
@@ -3857,40 +3857,48 @@ class Dn {
|
|
|
3857
3857
|
return { runeTx: a, assetTx: s };
|
|
3858
3858
|
});
|
|
3859
3859
|
T(this, "addLiquidity", async ({
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
mode: p = "sym"
|
|
3860
|
+
runeAssetValue: t,
|
|
3861
|
+
assetValue: n,
|
|
3862
|
+
runeAddr: a,
|
|
3863
|
+
assetAddr: s,
|
|
3864
|
+
isPendingSymmAsset: r,
|
|
3865
|
+
mode: o = "sym"
|
|
3867
3866
|
}) => {
|
|
3868
|
-
const
|
|
3869
|
-
if (!
|
|
3867
|
+
const { chain: p, symbol: d } = n, l = o === "sym", u = (t == null ? void 0 : t.gt(0)) && (l || o === "rune"), c = (n == null ? void 0 : n.gt(0)) && (l || o === "asset"), _ = r || u, b = _ ? a || this.getAddress(i.THORChain) : "", A = l || o === "asset" ? s || this.getAddress(p) : "";
|
|
3868
|
+
if (!u && !c)
|
|
3870
3869
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3871
|
-
if (
|
|
3870
|
+
if (_ && !b)
|
|
3872
3871
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3873
|
-
let
|
|
3874
|
-
|
|
3875
|
-
if (c && n)
|
|
3872
|
+
let E, g;
|
|
3873
|
+
if (u && t)
|
|
3876
3874
|
try {
|
|
3877
|
-
|
|
3878
|
-
assetValue:
|
|
3879
|
-
memo:
|
|
3875
|
+
E = await f(this, I).call(this, {
|
|
3876
|
+
assetValue: t,
|
|
3877
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: A })
|
|
3880
3878
|
});
|
|
3881
|
-
} catch (
|
|
3882
|
-
throw new m("core_transaction_add_liquidity_rune_error",
|
|
3879
|
+
} catch (O) {
|
|
3880
|
+
throw new m("core_transaction_add_liquidity_rune_error", O);
|
|
3883
3881
|
}
|
|
3884
|
-
if (
|
|
3882
|
+
if (c && n)
|
|
3885
3883
|
try {
|
|
3886
|
-
|
|
3887
|
-
assetValue:
|
|
3888
|
-
memo:
|
|
3884
|
+
g = await f(this, I).call(this, {
|
|
3885
|
+
assetValue: n,
|
|
3886
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: b })
|
|
3889
3887
|
});
|
|
3890
|
-
} catch (
|
|
3891
|
-
throw new m("core_transaction_add_liquidity_asset_error",
|
|
3888
|
+
} catch (O) {
|
|
3889
|
+
throw new m("core_transaction_add_liquidity_asset_error", O);
|
|
3892
3890
|
}
|
|
3893
|
-
return { runeTx:
|
|
3891
|
+
return { runeTx: E, assetTx: g };
|
|
3892
|
+
});
|
|
3893
|
+
T(this, "addLiquidityPart", ({
|
|
3894
|
+
assetValue: t,
|
|
3895
|
+
poolAddress: n,
|
|
3896
|
+
address: a,
|
|
3897
|
+
symmetric: s
|
|
3898
|
+
}) => {
|
|
3899
|
+
if (s && !a)
|
|
3900
|
+
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3901
|
+
return f(this, I).call(this, { assetValue: t, memo: `+:${n}:${a || ""}:t:0` });
|
|
3894
3902
|
});
|
|
3895
3903
|
T(this, "withdraw", async ({
|
|
3896
3904
|
memo: t,
|
|
@@ -3899,7 +3907,7 @@ class Dn {
|
|
|
3899
3907
|
from: s,
|
|
3900
3908
|
to: r
|
|
3901
3909
|
}) => {
|
|
3902
|
-
const o = r === "rune" ?
|
|
3910
|
+
const o = r === "rune" ? C.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = ie(s === "asset" ? n.chain : i.THORChain), d = t || M(h.WITHDRAW, {
|
|
3903
3911
|
symbol: n.symbol,
|
|
3904
3912
|
chain: n.chain,
|
|
3905
3913
|
ticker: n.ticker,
|
|
@@ -3907,7 +3915,7 @@ class Dn {
|
|
|
3907
3915
|
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3908
3916
|
singleSide: !1
|
|
3909
3917
|
});
|
|
3910
|
-
return f(this,
|
|
3918
|
+
return f(this, I).call(this, { assetValue: p, memo: d });
|
|
3911
3919
|
});
|
|
3912
3920
|
T(this, "savings", async ({
|
|
3913
3921
|
assetValue: t,
|
|
@@ -3915,23 +3923,23 @@ class Dn {
|
|
|
3915
3923
|
percent: a,
|
|
3916
3924
|
type: s
|
|
3917
3925
|
}) => {
|
|
3918
|
-
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n ||
|
|
3926
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || M(r, {
|
|
3919
3927
|
ticker: t.ticker,
|
|
3920
3928
|
symbol: t.symbol,
|
|
3921
3929
|
chain: t.chain,
|
|
3922
3930
|
singleSide: !0,
|
|
3923
3931
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3924
|
-
}), p = r === h.DEPOSIT ? t :
|
|
3925
|
-
return f(this,
|
|
3932
|
+
}), p = r === h.DEPOSIT ? t : ie(t.chain);
|
|
3933
|
+
return f(this, I).call(this, { memo: o, assetValue: p });
|
|
3926
3934
|
});
|
|
3927
3935
|
T(this, "loan", ({
|
|
3928
3936
|
assetValue: t,
|
|
3929
3937
|
memo: n,
|
|
3930
3938
|
minAmount: a,
|
|
3931
3939
|
type: s
|
|
3932
|
-
}) => f(this,
|
|
3940
|
+
}) => f(this, I).call(this, {
|
|
3933
3941
|
assetValue: t,
|
|
3934
|
-
memo: n ||
|
|
3942
|
+
memo: n || M(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3935
3943
|
asset: t.toString(),
|
|
3936
3944
|
minAmount: a.toString(),
|
|
3937
3945
|
address: this.getAddress(t.chain)
|
|
@@ -3942,24 +3950,24 @@ class Dn {
|
|
|
3942
3950
|
assetValue: n,
|
|
3943
3951
|
address: a
|
|
3944
3952
|
}) => {
|
|
3945
|
-
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r =
|
|
3953
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = M(s, {
|
|
3946
3954
|
address: a,
|
|
3947
3955
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
3948
3956
|
});
|
|
3949
|
-
return f(this,
|
|
3957
|
+
return f(this, q).call(this, {
|
|
3950
3958
|
memo: r,
|
|
3951
|
-
assetValue: t === "bond" ? n :
|
|
3959
|
+
assetValue: t === "bond" ? n : ie(i.THORChain)
|
|
3952
3960
|
});
|
|
3953
3961
|
});
|
|
3954
3962
|
T(this, "registerThorname", ({
|
|
3955
3963
|
assetValue: t,
|
|
3956
3964
|
...n
|
|
3957
|
-
}) => f(this,
|
|
3965
|
+
}) => f(this, q).call(this, { assetValue: t, memo: M(h.THORNAME_REGISTER, n) }));
|
|
3958
3966
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3959
3967
|
try {
|
|
3960
3968
|
t.forEach((r) => {
|
|
3961
3969
|
this[r.connectMethodName] = r.connect({
|
|
3962
|
-
addChain: f(this,
|
|
3970
|
+
addChain: f(this, Z),
|
|
3963
3971
|
config: n || {},
|
|
3964
3972
|
apis: a,
|
|
3965
3973
|
rpcUrls: s
|
|
@@ -4035,7 +4043,7 @@ class Dn {
|
|
|
4035
4043
|
T(this, "disconnectChain", (t) => {
|
|
4036
4044
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
4037
4045
|
});
|
|
4038
|
-
|
|
4046
|
+
P(this, B, async (t) => {
|
|
4039
4047
|
if (t === i.THORChain)
|
|
4040
4048
|
return {
|
|
4041
4049
|
gas_rate: "0",
|
|
@@ -4051,10 +4059,10 @@ class Dn {
|
|
|
4051
4059
|
throw new m("core_chain_halted");
|
|
4052
4060
|
return a;
|
|
4053
4061
|
});
|
|
4054
|
-
|
|
4062
|
+
P(this, Z, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4055
4063
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4056
4064
|
});
|
|
4057
|
-
|
|
4065
|
+
P(this, G, async ({
|
|
4058
4066
|
assetValue: t,
|
|
4059
4067
|
type: n = "checkOnly",
|
|
4060
4068
|
contractAddress: a
|
|
@@ -4068,7 +4076,7 @@ class Dn {
|
|
|
4068
4076
|
const _ = this.getAddress(r);
|
|
4069
4077
|
if (!s || !_)
|
|
4070
4078
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
4071
|
-
const b = a || (await f(this,
|
|
4079
|
+
const b = a || (await f(this, B).call(this, r)).router;
|
|
4072
4080
|
return c({
|
|
4073
4081
|
amount: t.getBaseValue("bigint"),
|
|
4074
4082
|
assetAddress: s,
|
|
@@ -4076,16 +4084,16 @@ class Dn {
|
|
|
4076
4084
|
spenderAddress: b
|
|
4077
4085
|
});
|
|
4078
4086
|
});
|
|
4079
|
-
|
|
4087
|
+
P(this, I, async ({
|
|
4080
4088
|
assetValue: t,
|
|
4081
4089
|
memo: n,
|
|
4082
|
-
feeOptionKey: a =
|
|
4090
|
+
feeOptionKey: a = H.Fast
|
|
4083
4091
|
}) => {
|
|
4084
4092
|
const {
|
|
4085
4093
|
gas_rate: s,
|
|
4086
4094
|
router: r,
|
|
4087
4095
|
address: o
|
|
4088
|
-
} = await f(this,
|
|
4096
|
+
} = await f(this, B).call(this, t.chain), p = (parseInt(s) || 0) * ft[a];
|
|
4089
4097
|
return this.deposit({
|
|
4090
4098
|
assetValue: t,
|
|
4091
4099
|
recipient: o,
|
|
@@ -4094,13 +4102,13 @@ class Dn {
|
|
|
4094
4102
|
feeRate: p
|
|
4095
4103
|
});
|
|
4096
4104
|
});
|
|
4097
|
-
|
|
4105
|
+
P(this, q, async ({ memo: t, assetValue: n }) => {
|
|
4098
4106
|
const a = await mn(this.stagenet);
|
|
4099
4107
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4100
4108
|
throw new m("core_chain_halted");
|
|
4101
4109
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
4102
4110
|
});
|
|
4103
|
-
|
|
4111
|
+
P(this, W, ({ assetValue: t, ...n }) => ({
|
|
4104
4112
|
...n,
|
|
4105
4113
|
memo: n.memo || "",
|
|
4106
4114
|
from: this.getAddress(t.chain),
|
|
@@ -4109,43 +4117,43 @@ class Dn {
|
|
|
4109
4117
|
this.stagenet = !!t;
|
|
4110
4118
|
}
|
|
4111
4119
|
}
|
|
4112
|
-
|
|
4120
|
+
B = new WeakMap(), Z = new WeakMap(), G = new WeakMap(), I = new WeakMap(), q = new WeakMap(), W = new WeakMap();
|
|
4113
4121
|
export {
|
|
4114
4122
|
Qe as AGG_SWAP,
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4123
|
+
Se as ApiError,
|
|
4124
|
+
k as ApiUrl,
|
|
4125
|
+
C as AssetValue,
|
|
4126
|
+
w as BaseDecimal,
|
|
4127
|
+
ue as BigIntArithmetics,
|
|
4120
4128
|
i as Chain,
|
|
4121
|
-
|
|
4129
|
+
me as ChainId,
|
|
4122
4130
|
En as ChainIdToChain,
|
|
4123
4131
|
rt as ChainToChainId,
|
|
4124
|
-
|
|
4132
|
+
Ce as ChainToExplorerUrl,
|
|
4125
4133
|
An as ChainToHexChainId,
|
|
4126
4134
|
ot as ChainToRPC,
|
|
4127
4135
|
nt as ContractAddress,
|
|
4128
4136
|
bn as CosmosChainList,
|
|
4129
4137
|
at as DerivationPath,
|
|
4130
|
-
|
|
4138
|
+
y as ERROR_CODE,
|
|
4131
4139
|
et as ERROR_MODULE,
|
|
4132
|
-
|
|
4140
|
+
Ie as ERROR_TYPE,
|
|
4133
4141
|
st as EVMChainList,
|
|
4134
4142
|
pt as ErrorCode,
|
|
4135
|
-
|
|
4143
|
+
H as FeeOption,
|
|
4136
4144
|
h as MemoType,
|
|
4137
4145
|
_n as NetworkDerivationPath,
|
|
4138
4146
|
Je as QuoteMode,
|
|
4139
|
-
|
|
4140
|
-
|
|
4147
|
+
ve as RPCUrl,
|
|
4148
|
+
_e as RequestClient,
|
|
4141
4149
|
ze as SWAP_IN,
|
|
4142
4150
|
Ze as SWAP_OUT,
|
|
4143
4151
|
Dn as SwapKitCore,
|
|
4144
4152
|
m as SwapKitError,
|
|
4145
|
-
|
|
4146
|
-
|
|
4153
|
+
N as SwapKitNumber,
|
|
4154
|
+
Ke as TCAvalancheDepositABI,
|
|
4147
4155
|
Xe as TCBscDepositABI,
|
|
4148
|
-
|
|
4156
|
+
Ye as TCEthereumVaultAbi,
|
|
4149
4157
|
wn as TCSupportedChainList,
|
|
4150
4158
|
fn as UTXOChainList,
|
|
4151
4159
|
dt as WalletOption,
|
|
@@ -4153,7 +4161,7 @@ export {
|
|
|
4153
4161
|
xn as derivationPathToString,
|
|
4154
4162
|
hn as erc20ABI,
|
|
4155
4163
|
gn as filterAssets,
|
|
4156
|
-
|
|
4164
|
+
te as formatBigIntToSafeValue,
|
|
4157
4165
|
ft as gasFeeMultiplier,
|
|
4158
4166
|
wt as getAssetType,
|
|
4159
4167
|
gt as getAsymmetricAssetShare,
|
|
@@ -4164,11 +4172,11 @@ export {
|
|
|
4164
4172
|
_t as getDecimal,
|
|
4165
4173
|
vn as getEstimatedPoolShare,
|
|
4166
4174
|
Cn as getLiquiditySlippage,
|
|
4167
|
-
|
|
4168
|
-
|
|
4175
|
+
M as getMemoFor,
|
|
4176
|
+
ie as getMinAmountByChain,
|
|
4169
4177
|
Ot as getSymmetricPoolShare,
|
|
4170
4178
|
Sn as getSymmetricWithdraw,
|
|
4171
4179
|
Mn as getTHORNameCost,
|
|
4172
|
-
|
|
4180
|
+
Ne as isGasAsset,
|
|
4173
4181
|
Nn as validateTHORName
|
|
4174
4182
|
};
|