@swapkit/core 1.0.0-rc.7 → 1.0.0-rc.70
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 +3 -2
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.es.js +1338 -860
- package/dist/index.es.js.map +1 -0
- package/package.json +17 -20
- package/src/client/__tests__/helpers.test.ts +41 -33
- package/src/client/explorerUrls.ts +7 -8
- package/src/client/index.ts +110 -69
- package/src/client/thornode.ts +3 -3
- package/dist/index-9e36735e.cjs +0 -1
- package/dist/index-cf1865cd.js +0 -649
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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
|
|
7
|
+
var f = (e, t, n) => (We(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
const
|
|
12
|
+
var je = Object.defineProperty, Ke = (e, t, n) => t in e ? je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (Ke(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
+
const _n = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -108,7 +108,7 @@ const Vt = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Xe = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const Vt = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Ye = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const Vt = [
|
|
|
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 Vt = [
|
|
|
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,95 +617,95 @@ const Ue = [
|
|
|
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
|
|
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
|
-
},
|
|
680
|
-
let n =
|
|
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 || {}), 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 || {}), y = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_MAX_500 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(y || {});
|
|
628
|
+
const nt = {
|
|
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_MAX_500]: "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_PROVIDER_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
|
+
}, oe = (e, t) => {
|
|
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
|
-
class
|
|
685
|
+
class Se extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
689
689
|
module: a,
|
|
690
|
-
code:
|
|
690
|
+
code: s,
|
|
691
691
|
message: r,
|
|
692
|
-
type:
|
|
693
|
-
options: { shouldLog:
|
|
692
|
+
type: o,
|
|
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
|
|
701
|
-
super(
|
|
702
|
-
shouldLog:
|
|
703
|
-
shouldTrace:
|
|
704
|
-
shouldThrow:
|
|
700
|
+
const m = r || oe(s, u || []) || "";
|
|
701
|
+
super(m), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = m, this.display = oe(s, u || []), this.code = s, this.type = o || Ie.UNHANDLED_ERROR, this.options = {
|
|
702
|
+
shouldLog: p || !0,
|
|
703
|
+
shouldTrace: l || !0,
|
|
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 Ae extends Error {
|
|
|
714
714
|
return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
|
|
715
715
|
}
|
|
716
716
|
get displayMessage() {
|
|
717
|
-
return
|
|
717
|
+
return oe(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -724,8 +724,8 @@ class Ae extends Error {
|
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
|
-
var
|
|
728
|
-
const
|
|
727
|
+
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), 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],
|
|
@@ -742,8 +742,8 @@ const Lt = {
|
|
|
742
742
|
OP: [44, 60, 0, 0, 0],
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
|
-
var
|
|
746
|
-
const
|
|
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 it = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
749
749
|
"BSC",
|
|
@@ -751,38 +751,50 @@ const Ut = [
|
|
|
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
|
+
], An = [
|
|
766
|
+
"AVAX",
|
|
767
|
+
"BNB",
|
|
768
|
+
"BSC",
|
|
769
|
+
"BTC",
|
|
770
|
+
"BCH",
|
|
771
|
+
"GAIA",
|
|
772
|
+
"DOGE",
|
|
773
|
+
"ETH",
|
|
774
|
+
"LTC",
|
|
775
|
+
"THOR"
|
|
776
|
+
/* THORChain */
|
|
765
777
|
];
|
|
766
|
-
var
|
|
767
|
-
const
|
|
778
|
+
var _e = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(_e || {}), 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 || {}), W = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(W || {});
|
|
779
|
+
const se = Object.values(i), rt = Object.keys(i), fe = se.reduce(
|
|
768
780
|
(e, t) => {
|
|
769
|
-
const n =
|
|
781
|
+
const n = rt.find((a) => i[a] === t);
|
|
770
782
|
return n && (e[t] = n), e;
|
|
771
783
|
},
|
|
772
784
|
{}
|
|
773
|
-
),
|
|
774
|
-
(e, t) => (e[t] =
|
|
785
|
+
), ot = se.reduce(
|
|
786
|
+
(e, t) => (e[t] = _e[fe[t]], e),
|
|
775
787
|
{}
|
|
776
|
-
),
|
|
777
|
-
(e, t) => (e[t] =
|
|
788
|
+
), pt = se.reduce(
|
|
789
|
+
(e, t) => (e[t] = ve[fe[t]], e),
|
|
778
790
|
{}
|
|
779
|
-
),
|
|
791
|
+
), En = se.reduce(
|
|
780
792
|
(e, t) => {
|
|
781
|
-
const n = `${
|
|
782
|
-
return e[t] =
|
|
793
|
+
const n = `${fe[t]}Hex`;
|
|
794
|
+
return e[t] = _e[n], e;
|
|
783
795
|
},
|
|
784
796
|
{}
|
|
785
|
-
),
|
|
797
|
+
), Rn = {
|
|
786
798
|
"0xa4b1": "ARB",
|
|
787
799
|
42161: "ARB",
|
|
788
800
|
"0xa86a": "AVAX",
|
|
@@ -807,332 +819,709 @@ const Z = Object.values(s), qe = Object.keys(s), ce = Z.reduce(
|
|
|
807
819
|
"thorchain-stagenet-v2": "THOR",
|
|
808
820
|
"thorchain-mainnet-v1": "THOR"
|
|
809
821
|
/* THORChain */
|
|
810
|
-
},
|
|
822
|
+
}, Ce = {
|
|
811
823
|
ARB: "https://arbiscan.io",
|
|
812
824
|
AVAX: "https://snowtrace.io",
|
|
813
825
|
BSC: "https://bscscan.com",
|
|
814
826
|
BNB: "https://explorer.binance.org",
|
|
815
|
-
BCH: "https://www.
|
|
816
|
-
BTC: "https://
|
|
827
|
+
BCH: "https://www.blockchair.com/bitcoin-cash",
|
|
828
|
+
BTC: "https://blockchair.com/bitcoin",
|
|
817
829
|
GAIA: "https://cosmos.bigdipper.live",
|
|
818
830
|
DOGE: "https://blockchair.com/dogecoin",
|
|
819
831
|
KUJI: "https://finder.kujira.network/kaiyo-1",
|
|
820
832
|
ETH: "https://etherscan.io",
|
|
821
|
-
LTC: "https://
|
|
833
|
+
LTC: "https://blockchair.com/litecoin",
|
|
822
834
|
MAYA: "https://www.mayascan.org",
|
|
823
835
|
OP: "https://optimistic.etherscan.io",
|
|
824
836
|
MATIC: "https://polygonscan.com",
|
|
825
|
-
THOR: "https://
|
|
837
|
+
THOR: "https://runescan.io"
|
|
826
838
|
};
|
|
827
|
-
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 || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), 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.OKX_MOBILE = "OKX_MOBILE", 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, S = (e, t, n) => (yt(e, typeof t != "symbol" ? t + "" : t, n), n), ct = (e, t, n) => {
|
|
828
840
|
if (!t.has(e))
|
|
829
841
|
throw TypeError("Cannot " + n);
|
|
830
|
-
},
|
|
842
|
+
}, $ = (e, t, n) => {
|
|
831
843
|
if (t.has(e))
|
|
832
844
|
throw TypeError("Cannot add the same private member more than once");
|
|
833
845
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
834
|
-
},
|
|
835
|
-
const
|
|
836
|
-
if (e < 0)
|
|
837
|
-
throw new Error("Invalid number of year");
|
|
838
|
-
return 10 + e;
|
|
839
|
-
}, Wt = (e) => {
|
|
840
|
-
if (e.length > 30)
|
|
841
|
-
return !1;
|
|
842
|
-
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
843
|
-
return !!e.match(t);
|
|
844
|
-
}, qt = ([e, t, n, a, i]) => `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`, Re = async (e, t) => {
|
|
845
|
-
try {
|
|
846
|
-
const n = Object.entries(t || {}).reduce(
|
|
847
|
-
(a, [i, r]) => (r && (a[i] = r), a),
|
|
848
|
-
{}
|
|
849
|
-
);
|
|
850
|
-
return (await fetch(
|
|
851
|
-
`${e}${t ? `?${new URLSearchParams(n).toString()}` : ""}`,
|
|
852
|
-
{ method: "GET", mode: "cors", credentials: "omit", referrer: "https://sk.thorswap.net" }
|
|
853
|
-
)).json();
|
|
854
|
-
} catch (n) {
|
|
855
|
-
return console.error(n), {};
|
|
856
|
-
}
|
|
857
|
-
}, Ze = async (e, t, n, a = !1) => {
|
|
858
|
-
try {
|
|
859
|
-
const i = await fetch(`${e}`, {
|
|
860
|
-
body: t,
|
|
861
|
-
headers: n,
|
|
862
|
-
method: "POST",
|
|
863
|
-
referrer: "https://sk.thorswap.net"
|
|
864
|
-
});
|
|
865
|
-
return a ? i.text() : i.json();
|
|
866
|
-
} catch {
|
|
867
|
-
return {};
|
|
868
|
-
}
|
|
869
|
-
}, et = "0x313ce567", Oe = async ({ chain: e, to: t }) => {
|
|
846
|
+
}, R = (e, t, n) => (ct(e, t, "access private method"), n);
|
|
847
|
+
const mt = "0x313ce567", Me = async ({ chain: e, to: t }) => {
|
|
870
848
|
try {
|
|
871
|
-
const n = await
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
849
|
+
const { result: n } = await we.post(pt[e], {
|
|
850
|
+
headers: {
|
|
851
|
+
accept: "*/*",
|
|
852
|
+
"content-type": "application/json",
|
|
853
|
+
"cache-control": "no-cache"
|
|
854
|
+
},
|
|
855
|
+
body: JSON.stringify({
|
|
876
856
|
id: 44,
|
|
877
|
-
jsonrpc: "2.0"
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
return parseInt(BigInt(
|
|
857
|
+
jsonrpc: "2.0",
|
|
858
|
+
method: "eth_call",
|
|
859
|
+
params: [{ to: t.toLowerCase(), data: mt }, "latest"]
|
|
860
|
+
})
|
|
861
|
+
});
|
|
862
|
+
return parseInt(BigInt(n).toString());
|
|
883
863
|
} catch (n) {
|
|
884
|
-
return console.error(n),
|
|
864
|
+
return console.error(n), A[e];
|
|
885
865
|
}
|
|
886
|
-
},
|
|
887
|
-
if (e ===
|
|
888
|
-
return
|
|
866
|
+
}, Tt = async (e) => {
|
|
867
|
+
if (e === i.Ethereum)
|
|
868
|
+
return A.ETH;
|
|
889
869
|
const [, t] = e.split("-");
|
|
890
|
-
return t != null && t.startsWith("0x") ?
|
|
891
|
-
},
|
|
870
|
+
return t != null && t.startsWith("0x") ? Me({ chain: i.Ethereum, to: t }) : A.ETH;
|
|
871
|
+
}, ht = async (e) => {
|
|
892
872
|
const [, t] = e.split("-");
|
|
893
|
-
return t != null && t.startsWith("0x") ?
|
|
894
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? Me({ chain: i.Avalanche, to: t.toLowerCase() }) : A.AVAX;
|
|
874
|
+
}, _t = async (e) => (e === i.BinanceSmartChain, A.BSC), ft = async ({ chain: e, symbol: t }) => {
|
|
895
875
|
switch (e) {
|
|
896
|
-
case
|
|
897
|
-
return
|
|
898
|
-
case
|
|
899
|
-
return
|
|
900
|
-
case
|
|
901
|
-
return
|
|
876
|
+
case i.Ethereum:
|
|
877
|
+
return Tt(t);
|
|
878
|
+
case i.Avalanche:
|
|
879
|
+
return ht(t);
|
|
880
|
+
case i.BinanceSmartChain:
|
|
881
|
+
return _t(t);
|
|
902
882
|
default:
|
|
903
|
-
return
|
|
883
|
+
return A[e];
|
|
904
884
|
}
|
|
905
|
-
},
|
|
906
|
-
[
|
|
907
|
-
[
|
|
908
|
-
[
|
|
909
|
-
},
|
|
885
|
+
}, bt = {
|
|
886
|
+
[F.Average]: 1.2,
|
|
887
|
+
[F.Fast]: 1.5,
|
|
888
|
+
[F.Fastest]: 2
|
|
889
|
+
}, Ne = ({ chain: e, symbol: t }) => {
|
|
910
890
|
switch (e) {
|
|
911
|
-
case
|
|
912
|
-
case
|
|
913
|
-
case
|
|
914
|
-
case
|
|
915
|
-
case
|
|
916
|
-
case
|
|
917
|
-
case
|
|
891
|
+
case i.Bitcoin:
|
|
892
|
+
case i.BitcoinCash:
|
|
893
|
+
case i.Litecoin:
|
|
894
|
+
case i.Dogecoin:
|
|
895
|
+
case i.Binance:
|
|
896
|
+
case i.Ethereum:
|
|
897
|
+
case i.Avalanche:
|
|
918
898
|
return t === e;
|
|
919
|
-
case
|
|
920
|
-
case
|
|
899
|
+
case i.Arbitrum:
|
|
900
|
+
case i.Optimism:
|
|
921
901
|
return t === "ETH";
|
|
922
|
-
case
|
|
902
|
+
case i.Maya:
|
|
923
903
|
return t === "CACAO";
|
|
924
|
-
case
|
|
904
|
+
case i.Kujira:
|
|
925
905
|
return t === "KUJI";
|
|
926
|
-
case
|
|
906
|
+
case i.Cosmos:
|
|
927
907
|
return t === "ATOM";
|
|
928
|
-
case
|
|
908
|
+
case i.Polygon:
|
|
929
909
|
return t === "MATIC";
|
|
930
|
-
case
|
|
910
|
+
case i.BinanceSmartChain:
|
|
931
911
|
return t === "BNB";
|
|
932
|
-
case
|
|
912
|
+
case i.THORChain:
|
|
933
913
|
return t === "RUNE";
|
|
934
914
|
}
|
|
935
|
-
},
|
|
915
|
+
}, wt = (e) => {
|
|
936
916
|
switch (e) {
|
|
937
917
|
case "ETH.THOR":
|
|
938
918
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
939
919
|
case "ETH.vTHOR":
|
|
940
920
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
941
|
-
case
|
|
942
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
943
|
-
case
|
|
944
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
945
|
-
case
|
|
946
|
-
return { identifier: "BSC.BNB", decimal:
|
|
947
|
-
case
|
|
948
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
921
|
+
case i.Cosmos:
|
|
922
|
+
return { identifier: "GAIA.ATOM", decimal: A[e] };
|
|
923
|
+
case i.THORChain:
|
|
924
|
+
return { identifier: "THOR.RUNE", decimal: A[e] };
|
|
925
|
+
case i.BinanceSmartChain:
|
|
926
|
+
return { identifier: "BSC.BNB", decimal: A[e] };
|
|
927
|
+
case i.Maya:
|
|
928
|
+
return { identifier: "MAYA.CACAO", decimal: A.MAYA };
|
|
949
929
|
case "MAYA.MAYA":
|
|
950
930
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
951
|
-
case
|
|
952
|
-
case
|
|
953
|
-
case
|
|
954
|
-
case
|
|
955
|
-
case
|
|
956
|
-
case
|
|
957
|
-
case
|
|
958
|
-
case
|
|
959
|
-
case
|
|
960
|
-
case
|
|
961
|
-
case
|
|
962
|
-
return { identifier: `${e}.${e}`, decimal:
|
|
963
|
-
}
|
|
964
|
-
},
|
|
931
|
+
case i.Kujira:
|
|
932
|
+
case i.Arbitrum:
|
|
933
|
+
case i.Optimism:
|
|
934
|
+
case i.BitcoinCash:
|
|
935
|
+
case i.Litecoin:
|
|
936
|
+
case i.Dogecoin:
|
|
937
|
+
case i.Binance:
|
|
938
|
+
case i.Avalanche:
|
|
939
|
+
case i.Polygon:
|
|
940
|
+
case i.Bitcoin:
|
|
941
|
+
case i.Ethereum:
|
|
942
|
+
return { identifier: `${e}.${e}`, decimal: A[e] };
|
|
943
|
+
}
|
|
944
|
+
}, At = ({ chain: e, symbol: t }) => {
|
|
965
945
|
if (t.includes("/"))
|
|
966
946
|
return "Synth";
|
|
967
947
|
switch (e) {
|
|
968
|
-
case
|
|
969
|
-
case
|
|
970
|
-
case
|
|
971
|
-
case
|
|
972
|
-
case
|
|
973
|
-
case
|
|
948
|
+
case i.Bitcoin:
|
|
949
|
+
case i.BitcoinCash:
|
|
950
|
+
case i.Dogecoin:
|
|
951
|
+
case i.Litecoin:
|
|
952
|
+
case i.Maya:
|
|
953
|
+
case i.THORChain:
|
|
974
954
|
return "Native";
|
|
975
|
-
case
|
|
976
|
-
return t === "ATOM" ? "Native" :
|
|
977
|
-
case
|
|
978
|
-
return t ===
|
|
979
|
-
case
|
|
980
|
-
return t ===
|
|
981
|
-
case
|
|
982
|
-
return t ===
|
|
983
|
-
case
|
|
984
|
-
return t ===
|
|
985
|
-
case
|
|
986
|
-
return t ===
|
|
987
|
-
case
|
|
988
|
-
return t ===
|
|
989
|
-
case
|
|
990
|
-
return [
|
|
991
|
-
case
|
|
992
|
-
return [
|
|
993
|
-
}
|
|
994
|
-
},
|
|
955
|
+
case i.Cosmos:
|
|
956
|
+
return t === "ATOM" ? "Native" : i.Cosmos;
|
|
957
|
+
case i.Kujira:
|
|
958
|
+
return t === i.Kujira ? "Native" : i.Kujira;
|
|
959
|
+
case i.Binance:
|
|
960
|
+
return t === i.Binance ? "Native" : "BEP2";
|
|
961
|
+
case i.BinanceSmartChain:
|
|
962
|
+
return t === i.Binance ? "Native" : "BEP20";
|
|
963
|
+
case i.Ethereum:
|
|
964
|
+
return t === i.Ethereum ? "Native" : "ERC20";
|
|
965
|
+
case i.Avalanche:
|
|
966
|
+
return t === i.Avalanche ? "Native" : i.Avalanche;
|
|
967
|
+
case i.Polygon:
|
|
968
|
+
return t === i.Polygon ? "Native" : "POLYGON";
|
|
969
|
+
case i.Arbitrum:
|
|
970
|
+
return [i.Ethereum, i.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
971
|
+
case i.Optimism:
|
|
972
|
+
return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
973
|
+
}
|
|
974
|
+
}, gn = (e) => {
|
|
995
975
|
var t;
|
|
996
|
-
const [n, ...a] = e.split("."),
|
|
997
|
-
return { chain: n, symbol: r, ticker:
|
|
998
|
-
},
|
|
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
|
+
return { chain: n, symbol: r, ticker: o, synth: s };
|
|
978
|
+
}, Et = new RegExp(
|
|
979
|
+
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
|
+
"gmi"
|
|
981
|
+
), Rt = (e) => {
|
|
982
|
+
const [t, n] = e.split(".");
|
|
983
|
+
if (!it.includes(t))
|
|
984
|
+
return !0;
|
|
985
|
+
const [, a] = n.split("-");
|
|
986
|
+
return Ne({ chain: t, symbol: n }) || !!a;
|
|
987
|
+
}, On = (e) => e.filter((t) => {
|
|
988
|
+
const n = `${t.chain}.${t.symbol}`;
|
|
989
|
+
return !Et.test(n) && Rt(n) && t.value !== "0";
|
|
990
|
+
});
|
|
991
|
+
function gt({
|
|
999
992
|
liquidityUnits: e,
|
|
1000
993
|
poolUnits: t,
|
|
1001
994
|
runeDepth: n
|
|
1002
|
-
})
|
|
1003
|
-
const a =
|
|
1004
|
-
return
|
|
1005
|
-
}
|
|
995
|
+
}) {
|
|
996
|
+
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = s.mul(s).mul(s);
|
|
997
|
+
return o.mul(p.sub(d).add(l)).div(u);
|
|
998
|
+
}
|
|
999
|
+
function Ot({
|
|
1006
1000
|
liquidityUnits: e,
|
|
1007
1001
|
poolUnits: t,
|
|
1008
1002
|
assetDepth: n
|
|
1009
|
-
})
|
|
1010
|
-
const a =
|
|
1011
|
-
return u.div(
|
|
1012
|
-
}
|
|
1003
|
+
}) {
|
|
1004
|
+
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = o.mul(p.sub(d).add(l)), m = s.mul(s).mul(s);
|
|
1005
|
+
return u.div(m);
|
|
1006
|
+
}
|
|
1007
|
+
function In({
|
|
1013
1008
|
percent: e,
|
|
1014
1009
|
runeDepth: t,
|
|
1015
1010
|
liquidityUnits: n,
|
|
1016
1011
|
poolUnits: a
|
|
1017
|
-
})
|
|
1012
|
+
}) {
|
|
1013
|
+
return gt({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1014
|
+
}
|
|
1015
|
+
function Sn({
|
|
1018
1016
|
percent: e,
|
|
1019
1017
|
assetDepth: t,
|
|
1020
1018
|
liquidityUnits: n,
|
|
1021
1019
|
poolUnits: a
|
|
1022
|
-
})
|
|
1020
|
+
}) {
|
|
1021
|
+
return Ot({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1022
|
+
}
|
|
1023
|
+
function g(e) {
|
|
1024
|
+
return N.fromBigInt(BigInt(e), A.THOR);
|
|
1025
|
+
}
|
|
1026
|
+
function It({
|
|
1023
1027
|
liquidityUnits: e,
|
|
1024
1028
|
poolUnits: t,
|
|
1025
1029
|
runeDepth: n,
|
|
1026
1030
|
assetDepth: a
|
|
1027
|
-
})
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
+
}) {
|
|
1032
|
+
return {
|
|
1033
|
+
assetAmount: g(a).mul(e).div(t),
|
|
1034
|
+
runeAmount: g(n).mul(e).div(t)
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
function vn({
|
|
1031
1038
|
liquidityUnits: e,
|
|
1032
1039
|
poolUnits: t,
|
|
1033
1040
|
runeDepth: n,
|
|
1034
1041
|
assetDepth: a,
|
|
1035
|
-
percent:
|
|
1036
|
-
})
|
|
1037
|
-
Object.
|
|
1038
|
-
(
|
|
1039
|
-
|
|
1040
|
-
)
|
|
1042
|
+
percent: s
|
|
1043
|
+
}) {
|
|
1044
|
+
return Object.fromEntries(
|
|
1045
|
+
Object.entries(It({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1046
|
+
([r, o]) => [r, o.mul(s)]
|
|
1047
|
+
)
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
function Cn({
|
|
1041
1051
|
runeDepth: e,
|
|
1042
1052
|
poolUnits: t,
|
|
1043
1053
|
assetDepth: n,
|
|
1044
1054
|
liquidityUnits: a,
|
|
1045
|
-
runeAmount:
|
|
1055
|
+
runeAmount: s,
|
|
1046
1056
|
assetAmount: r
|
|
1047
|
-
})
|
|
1048
|
-
const
|
|
1049
|
-
if (I.
|
|
1050
|
-
return
|
|
1051
|
-
const
|
|
1052
|
-
return
|
|
1053
|
-
}
|
|
1057
|
+
}) {
|
|
1058
|
+
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 }), m = l.mul(p), _ = u.mul(o), b = l.mul(u), w = o.mul(p), E = d.mul(m.add(_.add(b.mul(2)))), O = m.add(_.add(w.mul(2))), I = E.div(O), D = g(a).add(I);
|
|
1059
|
+
if (I.getBaseValue("number") === 0)
|
|
1060
|
+
return D.div(d).getBaseValue("number");
|
|
1061
|
+
const re = d.add(D);
|
|
1062
|
+
return D.div(re).getBaseValue("number");
|
|
1063
|
+
}
|
|
1064
|
+
function Mn({
|
|
1054
1065
|
runeAmount: e,
|
|
1055
1066
|
assetAmount: t,
|
|
1056
1067
|
runeDepth: n,
|
|
1057
1068
|
assetDepth: a
|
|
1058
|
-
})
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, D = (e, t) => {
|
|
1069
|
+
}) {
|
|
1070
|
+
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1071
|
+
return 0;
|
|
1072
|
+
const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), l = r.mul(p).add(s.mul(r));
|
|
1073
|
+
return Math.abs(d.div(l).getBaseValue("number"));
|
|
1074
|
+
}
|
|
1075
|
+
const M = (e, t) => {
|
|
1066
1076
|
switch (e) {
|
|
1067
|
-
case
|
|
1068
|
-
case
|
|
1077
|
+
case h.LEAVE:
|
|
1078
|
+
case h.BOND: {
|
|
1069
1079
|
const { address: n } = t;
|
|
1070
1080
|
return `${e}:${n}`;
|
|
1071
1081
|
}
|
|
1072
|
-
case
|
|
1082
|
+
case h.UNBOND: {
|
|
1073
1083
|
const { address: n, unbondAmount: a } = t;
|
|
1074
1084
|
return `${e}:${n}:${a * 10 ** 8}`;
|
|
1075
1085
|
}
|
|
1076
|
-
case
|
|
1077
|
-
const { name: n, chain: a, address:
|
|
1078
|
-
return `${e}:${n}:${a}:${
|
|
1086
|
+
case h.THORNAME_REGISTER: {
|
|
1087
|
+
const { name: n, chain: a, address: s, owner: r } = t;
|
|
1088
|
+
return `${e}:${n}:${a}:${s}${r ? `:${r}` : ""}`;
|
|
1079
1089
|
}
|
|
1080
|
-
case
|
|
1081
|
-
const { chain: n, symbol: a, address:
|
|
1082
|
-
return r ? `${e}:${n}/${a}::t:0` : `${e}:${
|
|
1090
|
+
case h.DEPOSIT: {
|
|
1091
|
+
const { chain: n, symbol: a, address: s, singleSide: r } = t;
|
|
1092
|
+
return r ? `${e}:${n}/${a}::t:0` : `${e}:${((o, p) => {
|
|
1093
|
+
switch (o) {
|
|
1094
|
+
case i.Litecoin:
|
|
1095
|
+
return "l";
|
|
1096
|
+
case i.Dogecoin:
|
|
1097
|
+
return "d";
|
|
1098
|
+
case i.BitcoinCash:
|
|
1099
|
+
return "c";
|
|
1100
|
+
default:
|
|
1101
|
+
return `${o}.${p}`;
|
|
1102
|
+
}
|
|
1103
|
+
})(n, a)}:${s || ""}:t:0`;
|
|
1083
1104
|
}
|
|
1084
|
-
case
|
|
1085
|
-
const { chain: n, ticker: a, symbol:
|
|
1086
|
-
return `${e}:${n}${
|
|
1105
|
+
case h.WITHDRAW: {
|
|
1106
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = n === "ETH" && a !== "ETH" ? `${a}-${s.slice(-3)}` : s, l = !p && o ? `:${o}` : "";
|
|
1107
|
+
return `${e}:${n}${p ? "/" : "."}${d}:${r}${l}`;
|
|
1087
1108
|
}
|
|
1088
|
-
case
|
|
1089
|
-
case
|
|
1109
|
+
case h.OPEN_LOAN:
|
|
1110
|
+
case h.CLOSE_LOAN: {
|
|
1090
1111
|
const { asset: n, address: a } = t;
|
|
1091
1112
|
return `${e}:${n}:${a}`;
|
|
1092
1113
|
}
|
|
1093
1114
|
default:
|
|
1094
1115
|
return "";
|
|
1095
1116
|
}
|
|
1096
|
-
}
|
|
1117
|
+
};
|
|
1118
|
+
function Nn(e) {
|
|
1119
|
+
if (e < 0)
|
|
1120
|
+
throw new Error("Invalid number of year");
|
|
1121
|
+
return 10 + e;
|
|
1122
|
+
}
|
|
1123
|
+
function xn(e) {
|
|
1124
|
+
if (e.length > 30)
|
|
1125
|
+
return !1;
|
|
1126
|
+
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1127
|
+
return !!e.match(t);
|
|
1128
|
+
}
|
|
1129
|
+
function Dn([e, t, n, a, s]) {
|
|
1130
|
+
return `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1131
|
+
}
|
|
1132
|
+
class Ae extends Error {
|
|
1133
|
+
constructor(t, n, a) {
|
|
1134
|
+
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
|
|
1135
|
+
super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
|
|
1136
|
+
enumerable: !0,
|
|
1137
|
+
configurable: !0,
|
|
1138
|
+
writable: !0,
|
|
1139
|
+
value: void 0
|
|
1140
|
+
}), Object.defineProperty(this, "request", {
|
|
1141
|
+
enumerable: !0,
|
|
1142
|
+
configurable: !0,
|
|
1143
|
+
writable: !0,
|
|
1144
|
+
value: void 0
|
|
1145
|
+
}), Object.defineProperty(this, "options", {
|
|
1146
|
+
enumerable: !0,
|
|
1147
|
+
configurable: !0,
|
|
1148
|
+
writable: !0,
|
|
1149
|
+
value: void 0
|
|
1150
|
+
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
class xe extends Error {
|
|
1154
|
+
constructor(t) {
|
|
1155
|
+
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1156
|
+
enumerable: !0,
|
|
1157
|
+
configurable: !0,
|
|
1158
|
+
writable: !0,
|
|
1159
|
+
value: void 0
|
|
1160
|
+
}), this.name = "TimeoutError", this.request = t;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
1164
|
+
for (const t of e)
|
|
1165
|
+
if ((!Q(t) || Array.isArray(t)) && t !== void 0)
|
|
1166
|
+
throw new TypeError("The `options` argument must be an object");
|
|
1167
|
+
return be({}, ...e);
|
|
1168
|
+
}, De = (e = {}, t = {}) => {
|
|
1169
|
+
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1170
|
+
for (const [r, o] of s.entries())
|
|
1171
|
+
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
1172
|
+
return n;
|
|
1173
|
+
}, be = (...e) => {
|
|
1174
|
+
let t = {}, n = {};
|
|
1175
|
+
for (const a of e)
|
|
1176
|
+
if (Array.isArray(a))
|
|
1177
|
+
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1178
|
+
else if (Q(a)) {
|
|
1179
|
+
for (let [s, r] of Object.entries(a))
|
|
1180
|
+
Q(r) && s in t && (r = be(t[s], r)), t = { ...t, [s]: r };
|
|
1181
|
+
Q(a.headers) && (n = De(n, a.headers), t.headers = n);
|
|
1182
|
+
}
|
|
1183
|
+
return t;
|
|
1184
|
+
}, St = (() => {
|
|
1185
|
+
let e = !1, t = !1;
|
|
1186
|
+
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1187
|
+
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
1188
|
+
body: new globalThis.ReadableStream(),
|
|
1189
|
+
method: "POST",
|
|
1190
|
+
// @ts-expect-error - Types are outdated.
|
|
1191
|
+
get duplex() {
|
|
1192
|
+
return e = !0, "half";
|
|
1193
|
+
}
|
|
1194
|
+
}).headers.has("Content-Type")), e && !t;
|
|
1195
|
+
})(), vt = typeof globalThis.AbortController == "function", Ct = typeof globalThis.ReadableStream == "function", Mt = typeof globalThis.FormData == "function", Pe = ["get", "post", "put", "patch", "head", "delete"], Nt = {
|
|
1196
|
+
json: "application/json",
|
|
1197
|
+
text: "text/*",
|
|
1198
|
+
formData: "multipart/form-data",
|
|
1199
|
+
arrayBuffer: "*/*",
|
|
1200
|
+
blob: "*/*"
|
|
1201
|
+
}, pe = 2147483647, Be = Symbol("stop"), xt = {
|
|
1202
|
+
json: !0,
|
|
1203
|
+
parseJson: !0,
|
|
1204
|
+
searchParams: !0,
|
|
1205
|
+
prefixUrl: !0,
|
|
1206
|
+
retry: !0,
|
|
1207
|
+
timeout: !0,
|
|
1208
|
+
hooks: !0,
|
|
1209
|
+
throwHttpErrors: !0,
|
|
1210
|
+
onDownloadProgress: !0,
|
|
1211
|
+
fetch: !0
|
|
1212
|
+
}, Dt = {
|
|
1213
|
+
method: !0,
|
|
1214
|
+
headers: !0,
|
|
1215
|
+
body: !0,
|
|
1216
|
+
mode: !0,
|
|
1217
|
+
credentials: !0,
|
|
1218
|
+
cache: !0,
|
|
1219
|
+
redirect: !0,
|
|
1220
|
+
referrer: !0,
|
|
1221
|
+
referrerPolicy: !0,
|
|
1222
|
+
integrity: !0,
|
|
1223
|
+
keepalive: !0,
|
|
1224
|
+
signal: !0,
|
|
1225
|
+
window: !0,
|
|
1226
|
+
dispatcher: !0,
|
|
1227
|
+
duplex: !0
|
|
1228
|
+
}, 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], Ee = {
|
|
1229
|
+
limit: 2,
|
|
1230
|
+
methods: Bt,
|
|
1231
|
+
statusCodes: Lt,
|
|
1232
|
+
afterStatusCodes: Le,
|
|
1233
|
+
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1234
|
+
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1235
|
+
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1236
|
+
}, Vt = (e = {}) => {
|
|
1237
|
+
if (typeof e == "number")
|
|
1238
|
+
return {
|
|
1239
|
+
...Ee,
|
|
1240
|
+
limit: e
|
|
1241
|
+
};
|
|
1242
|
+
if (e.methods && !Array.isArray(e.methods))
|
|
1243
|
+
throw new Error("retry.methods must be an array");
|
|
1244
|
+
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1245
|
+
throw new Error("retry.statusCodes must be an array");
|
|
1246
|
+
return {
|
|
1247
|
+
...Ee,
|
|
1248
|
+
...e,
|
|
1249
|
+
afterStatusCodes: Le
|
|
1250
|
+
};
|
|
1251
|
+
};
|
|
1252
|
+
async function Ut(e, t, n, a) {
|
|
1253
|
+
return new Promise((s, r) => {
|
|
1254
|
+
const o = setTimeout(() => {
|
|
1255
|
+
n && n.abort(), r(new xe(e));
|
|
1256
|
+
}, a.timeout);
|
|
1257
|
+
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1258
|
+
clearTimeout(o);
|
|
1259
|
+
});
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
async function Ht(e, { signal: t }) {
|
|
1263
|
+
return new Promise((n, a) => {
|
|
1264
|
+
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
|
|
1265
|
+
function s() {
|
|
1266
|
+
clearTimeout(r), a(t.reason);
|
|
1267
|
+
}
|
|
1268
|
+
const r = setTimeout(() => {
|
|
1269
|
+
t == null || t.removeEventListener("abort", s), n();
|
|
1270
|
+
}, e);
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
const $t = (e, t) => {
|
|
1274
|
+
const n = {};
|
|
1275
|
+
for (const a in t)
|
|
1276
|
+
!(a in Dt) && !(a in xt) && !(a in e) && (n[a] = t[a]);
|
|
1277
|
+
return n;
|
|
1278
|
+
};
|
|
1279
|
+
class ee {
|
|
1280
|
+
static create(t, n) {
|
|
1281
|
+
const a = new ee(t, n), s = async () => {
|
|
1282
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > pe)
|
|
1283
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${pe}`);
|
|
1284
|
+
await Promise.resolve();
|
|
1285
|
+
let o = await a._fetch();
|
|
1286
|
+
for (const p of a._options.hooks.afterResponse) {
|
|
1287
|
+
const d = await p(a.request, a._options, a._decorateResponse(o.clone()));
|
|
1288
|
+
d instanceof globalThis.Response && (o = d);
|
|
1289
|
+
}
|
|
1290
|
+
if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
|
|
1291
|
+
let p = new Ae(o, a.request, a._options);
|
|
1292
|
+
for (const d of a._options.hooks.beforeError)
|
|
1293
|
+
p = await d(p);
|
|
1294
|
+
throw p;
|
|
1295
|
+
}
|
|
1296
|
+
if (a._options.onDownloadProgress) {
|
|
1297
|
+
if (typeof a._options.onDownloadProgress != "function")
|
|
1298
|
+
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
1299
|
+
if (!Ct)
|
|
1300
|
+
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1301
|
+
return a._stream(o.clone(), a._options.onDownloadProgress);
|
|
1302
|
+
}
|
|
1303
|
+
return o;
|
|
1304
|
+
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
|
|
1305
|
+
for (const [o, p] of Object.entries(Nt))
|
|
1306
|
+
r[o] = async () => {
|
|
1307
|
+
a.request.headers.set("accept", a.request.headers.get("accept") || p);
|
|
1308
|
+
const d = (await r).clone();
|
|
1309
|
+
if (o === "json") {
|
|
1310
|
+
if (d.status === 204 || (await d.clone().arrayBuffer()).byteLength === 0)
|
|
1311
|
+
return "";
|
|
1312
|
+
if (n.parseJson)
|
|
1313
|
+
return n.parseJson(await d.text());
|
|
1314
|
+
}
|
|
1315
|
+
return d[o]();
|
|
1316
|
+
};
|
|
1317
|
+
return r;
|
|
1318
|
+
}
|
|
1319
|
+
// eslint-disable-next-line complexity
|
|
1320
|
+
constructor(t, n = {}) {
|
|
1321
|
+
if (Object.defineProperty(this, "request", {
|
|
1322
|
+
enumerable: !0,
|
|
1323
|
+
configurable: !0,
|
|
1324
|
+
writable: !0,
|
|
1325
|
+
value: void 0
|
|
1326
|
+
}), Object.defineProperty(this, "abortController", {
|
|
1327
|
+
enumerable: !0,
|
|
1328
|
+
configurable: !0,
|
|
1329
|
+
writable: !0,
|
|
1330
|
+
value: void 0
|
|
1331
|
+
}), Object.defineProperty(this, "_retryCount", {
|
|
1332
|
+
enumerable: !0,
|
|
1333
|
+
configurable: !0,
|
|
1334
|
+
writable: !0,
|
|
1335
|
+
value: 0
|
|
1336
|
+
}), Object.defineProperty(this, "_input", {
|
|
1337
|
+
enumerable: !0,
|
|
1338
|
+
configurable: !0,
|
|
1339
|
+
writable: !0,
|
|
1340
|
+
value: void 0
|
|
1341
|
+
}), Object.defineProperty(this, "_options", {
|
|
1342
|
+
enumerable: !0,
|
|
1343
|
+
configurable: !0,
|
|
1344
|
+
writable: !0,
|
|
1345
|
+
value: void 0
|
|
1346
|
+
}), this._input = t, this._options = {
|
|
1347
|
+
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1348
|
+
credentials: this._input.credentials || "same-origin",
|
|
1349
|
+
...n,
|
|
1350
|
+
headers: De(this._input.headers, n.headers),
|
|
1351
|
+
hooks: be({
|
|
1352
|
+
beforeRequest: [],
|
|
1353
|
+
beforeRetry: [],
|
|
1354
|
+
beforeError: [],
|
|
1355
|
+
afterResponse: []
|
|
1356
|
+
}, n.hooks),
|
|
1357
|
+
method: Pt(n.method ?? this._input.method),
|
|
1358
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1359
|
+
prefixUrl: String(n.prefixUrl || ""),
|
|
1360
|
+
retry: Vt(n.retry),
|
|
1361
|
+
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1362
|
+
timeout: n.timeout ?? 1e4,
|
|
1363
|
+
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
1364
|
+
}, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
|
|
1365
|
+
throw new TypeError("`input` must be a string, URL, or Request");
|
|
1366
|
+
if (this._options.prefixUrl && typeof this._input == "string") {
|
|
1367
|
+
if (this._input.startsWith("/"))
|
|
1368
|
+
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1369
|
+
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1370
|
+
}
|
|
1371
|
+
if (vt) {
|
|
1372
|
+
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1373
|
+
const a = this._options.signal;
|
|
1374
|
+
this._options.signal.addEventListener("abort", () => {
|
|
1375
|
+
this.abortController.abort(a.reason);
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
this._options.signal = this.abortController.signal;
|
|
1379
|
+
}
|
|
1380
|
+
if (St && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1381
|
+
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1382
|
+
(Mt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
|
|
1383
|
+
}
|
|
1384
|
+
this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
|
|
1385
|
+
}
|
|
1386
|
+
_calculateRetryDelay(t) {
|
|
1387
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof xe)) {
|
|
1388
|
+
if (t instanceof Ae) {
|
|
1389
|
+
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1390
|
+
return 0;
|
|
1391
|
+
const a = t.response.headers.get("Retry-After");
|
|
1392
|
+
if (a && this._options.retry.afterStatusCodes.includes(t.response.status)) {
|
|
1393
|
+
let s = Number(a);
|
|
1394
|
+
return Number.isNaN(s) ? s = Date.parse(a) - Date.now() : s *= 1e3, this._options.retry.maxRetryAfter !== void 0 && s > this._options.retry.maxRetryAfter ? 0 : s;
|
|
1395
|
+
}
|
|
1396
|
+
if (t.response.status === 413)
|
|
1397
|
+
return 0;
|
|
1398
|
+
}
|
|
1399
|
+
const n = this._options.retry.delay(this._retryCount);
|
|
1400
|
+
return Math.min(this._options.retry.backoffLimit, n);
|
|
1401
|
+
}
|
|
1402
|
+
return 0;
|
|
1403
|
+
}
|
|
1404
|
+
_decorateResponse(t) {
|
|
1405
|
+
return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
|
|
1406
|
+
}
|
|
1407
|
+
async _retry(t) {
|
|
1408
|
+
try {
|
|
1409
|
+
return await t();
|
|
1410
|
+
} catch (n) {
|
|
1411
|
+
const a = Math.min(this._calculateRetryDelay(n), pe);
|
|
1412
|
+
if (a !== 0 && this._retryCount > 0) {
|
|
1413
|
+
await Ht(a, { signal: this._options.signal });
|
|
1414
|
+
for (const s of this._options.hooks.beforeRetry)
|
|
1415
|
+
if (await s({
|
|
1416
|
+
request: this.request,
|
|
1417
|
+
options: this._options,
|
|
1418
|
+
error: n,
|
|
1419
|
+
retryCount: this._retryCount
|
|
1420
|
+
}) === Be)
|
|
1421
|
+
return;
|
|
1422
|
+
return this._retry(t);
|
|
1423
|
+
}
|
|
1424
|
+
throw n;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
async _fetch() {
|
|
1428
|
+
for (const n of this._options.hooks.beforeRequest) {
|
|
1429
|
+
const a = await n(this.request, this._options);
|
|
1430
|
+
if (a instanceof Request) {
|
|
1431
|
+
this.request = a;
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
if (a instanceof Response)
|
|
1435
|
+
return a;
|
|
1436
|
+
}
|
|
1437
|
+
const t = $t(this.request, this._options);
|
|
1438
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ut(this.request.clone(), t, this.abortController, this._options);
|
|
1439
|
+
}
|
|
1440
|
+
/* istanbul ignore next */
|
|
1441
|
+
_stream(t, n) {
|
|
1442
|
+
const a = Number(t.headers.get("content-length")) || 0;
|
|
1443
|
+
let s = 0;
|
|
1444
|
+
return t.status === 204 ? (n && n({ percent: 1, totalBytes: a, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
|
|
1445
|
+
status: t.status,
|
|
1446
|
+
statusText: t.statusText,
|
|
1447
|
+
headers: t.headers
|
|
1448
|
+
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
1449
|
+
async start(r) {
|
|
1450
|
+
const o = t.body.getReader();
|
|
1451
|
+
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1452
|
+
async function p() {
|
|
1453
|
+
const { done: d, value: l } = await o.read();
|
|
1454
|
+
if (d) {
|
|
1455
|
+
r.close();
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
if (n) {
|
|
1459
|
+
s += l.byteLength;
|
|
1460
|
+
const u = a === 0 ? 0 : s / a;
|
|
1461
|
+
n({ percent: u, transferredBytes: s, totalBytes: a }, l);
|
|
1462
|
+
}
|
|
1463
|
+
r.enqueue(l), await p();
|
|
1464
|
+
}
|
|
1465
|
+
await p();
|
|
1466
|
+
}
|
|
1467
|
+
}), {
|
|
1468
|
+
status: t.status,
|
|
1469
|
+
statusText: t.statusText,
|
|
1470
|
+
headers: t.headers
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
/*! MIT License © Sindre Sorhus */
|
|
1475
|
+
const ye = (e) => {
|
|
1476
|
+
const t = (n, a) => ee.create(n, J(e, a));
|
|
1477
|
+
for (const n of Pe)
|
|
1478
|
+
t[n] = (a, s) => ee.create(a, J(e, s, { method: n }));
|
|
1479
|
+
return t.create = (n) => ye(J(n)), t.extend = (n) => ye(J(e, n)), t.stop = Be, t;
|
|
1480
|
+
}, kt = ye(), Ft = kt, Gt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Re = Ft.create({ headers: Gt }), we = {
|
|
1481
|
+
get: (e, t) => Re.get(e, t).json(),
|
|
1482
|
+
post: (e, t) => Re.post(e, t).json()
|
|
1483
|
+
}, ge = [...Object.values(i), "TERRA"];
|
|
1484
|
+
function qt(e = "") {
|
|
1097
1485
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1098
|
-
if (
|
|
1486
|
+
if (ge.includes(n))
|
|
1099
1487
|
return !0;
|
|
1100
1488
|
const [a] = t.split("/");
|
|
1101
|
-
if (
|
|
1489
|
+
if (ge.includes(a))
|
|
1102
1490
|
return !0;
|
|
1103
1491
|
throw new Error(
|
|
1104
1492
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1105
1493
|
);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1494
|
+
}
|
|
1495
|
+
const j = 8, L = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1496
|
+
function ie({
|
|
1108
1497
|
value: e,
|
|
1109
|
-
bigIntDecimal: t =
|
|
1110
|
-
decimal: n =
|
|
1498
|
+
bigIntDecimal: t = j,
|
|
1499
|
+
decimal: n = j
|
|
1111
1500
|
}) {
|
|
1501
|
+
if (n === 0)
|
|
1502
|
+
return e.toString();
|
|
1112
1503
|
const a = e < 0n;
|
|
1113
|
-
let
|
|
1114
|
-
const r = n - (
|
|
1115
|
-
r > 0 && (
|
|
1116
|
-
const
|
|
1117
|
-
let
|
|
1118
|
-
return parseInt(
|
|
1504
|
+
let s = e.toString().substring(a ? 1 : 0);
|
|
1505
|
+
const r = n - (s.length - 1);
|
|
1506
|
+
r > 0 && (s = "0".repeat(r) + s);
|
|
1507
|
+
const o = s.length - n;
|
|
1508
|
+
let p = s.slice(-n);
|
|
1509
|
+
return parseInt(p[t]) >= 5 ? p = `${p.substring(0, t - 1)}${(parseInt(p[t - 1]) + 1).toString()}` : p = p.substring(0, t), `${a ? "-" : ""}${s.slice(0, o)}.${p}`.replace(
|
|
1119
1510
|
/\.?0*$/,
|
|
1120
1511
|
""
|
|
1121
1512
|
);
|
|
1122
1513
|
}
|
|
1123
|
-
var
|
|
1124
|
-
const
|
|
1514
|
+
var U, k, B, H, ce, Ve, z, de, te, me;
|
|
1515
|
+
const Wt = class Ue {
|
|
1125
1516
|
constructor(t) {
|
|
1126
|
-
|
|
1127
|
-
const n =
|
|
1128
|
-
this.decimal =
|
|
1129
|
-
Math.max(g(this, J, re).call(this, g(this, H, G).call(this, n)), this.decimal || 0)
|
|
1130
|
-
), g(this, ae, Se).call(this, n);
|
|
1517
|
+
$(this, U), $(this, B), $(this, ce), $(this, z), $(this, te), S(this, "decimalMultiplier", 10n ** 8n), S(this, "bigIntValue", 0n), S(this, "decimal");
|
|
1518
|
+
const n = Te(t), a = typeof t == "object";
|
|
1519
|
+
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max($e(ne(n)), this.decimal || 0)), R(this, ce, Ve).call(this, n);
|
|
1131
1520
|
}
|
|
1132
1521
|
static fromBigInt(t, n) {
|
|
1133
|
-
return new
|
|
1522
|
+
return new Ue({
|
|
1134
1523
|
decimal: n,
|
|
1135
|
-
value:
|
|
1524
|
+
value: ie({ value: t, bigIntDecimal: n, decimal: n })
|
|
1136
1525
|
});
|
|
1137
1526
|
}
|
|
1138
1527
|
static shiftDecimals({
|
|
@@ -1140,238 +1529,287 @@ const ct = class j {
|
|
|
1140
1529
|
from: n,
|
|
1141
1530
|
to: a
|
|
1142
1531
|
}) {
|
|
1143
|
-
return
|
|
1144
|
-
|
|
1532
|
+
return this.fromBigInt(
|
|
1533
|
+
t.getBaseValue("bigint") * L(a) / L(n),
|
|
1145
1534
|
a
|
|
1146
1535
|
);
|
|
1147
1536
|
}
|
|
1148
|
-
get baseValue() {
|
|
1149
|
-
return this.getBaseValue("string");
|
|
1150
|
-
}
|
|
1151
|
-
get baseValueNumber() {
|
|
1152
|
-
return this.getBaseValue("number");
|
|
1153
|
-
}
|
|
1154
|
-
get baseValueBigInt() {
|
|
1155
|
-
return this.getBaseValue("bigint");
|
|
1156
|
-
}
|
|
1157
1537
|
set(t) {
|
|
1158
1538
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1159
1539
|
}
|
|
1160
1540
|
add(...t) {
|
|
1161
|
-
return
|
|
1541
|
+
return R(this, U, k).call(this, "add", ...t);
|
|
1162
1542
|
}
|
|
1163
1543
|
sub(...t) {
|
|
1164
|
-
return
|
|
1544
|
+
return R(this, U, k).call(this, "sub", ...t);
|
|
1165
1545
|
}
|
|
1166
1546
|
mul(...t) {
|
|
1167
|
-
return
|
|
1547
|
+
return R(this, U, k).call(this, "mul", ...t);
|
|
1168
1548
|
}
|
|
1169
1549
|
div(...t) {
|
|
1170
|
-
return
|
|
1550
|
+
return R(this, U, k).call(this, "div", ...t);
|
|
1171
1551
|
}
|
|
1172
1552
|
gt(t) {
|
|
1173
|
-
return this
|
|
1553
|
+
return R(this, B, H).call(this, "gt", t);
|
|
1174
1554
|
}
|
|
1175
1555
|
gte(t) {
|
|
1176
|
-
return this
|
|
1556
|
+
return R(this, B, H).call(this, "gte", t);
|
|
1177
1557
|
}
|
|
1178
1558
|
lt(t) {
|
|
1179
|
-
return this
|
|
1559
|
+
return R(this, B, H).call(this, "lt", t);
|
|
1180
1560
|
}
|
|
1181
1561
|
lte(t) {
|
|
1182
|
-
return this
|
|
1562
|
+
return R(this, B, H).call(this, "lte", t);
|
|
1183
1563
|
}
|
|
1184
1564
|
eqValue(t) {
|
|
1185
|
-
return this
|
|
1565
|
+
return R(this, B, H).call(this, "eqValue", t);
|
|
1186
1566
|
}
|
|
1567
|
+
// @ts-expect-error False positive
|
|
1187
1568
|
getValue(t) {
|
|
1188
1569
|
const n = this.formatBigIntToSafeValue(
|
|
1189
1570
|
this.bigIntValue,
|
|
1190
|
-
this.decimal ||
|
|
1571
|
+
this.decimal || G(this.decimalMultiplier)
|
|
1191
1572
|
);
|
|
1192
1573
|
switch (t) {
|
|
1193
1574
|
case "number":
|
|
1194
1575
|
return Number(n);
|
|
1195
1576
|
case "string":
|
|
1196
1577
|
return n;
|
|
1197
|
-
|
|
1198
|
-
return this.bigIntValue;
|
|
1578
|
+
case "bigint":
|
|
1579
|
+
return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
|
|
1199
1580
|
}
|
|
1200
1581
|
}
|
|
1582
|
+
// @ts-expect-error
|
|
1201
1583
|
getBaseValue(t) {
|
|
1202
|
-
const n = this.decimalMultiplier /
|
|
1584
|
+
const n = this.decimalMultiplier / L(this.decimal || A.THOR), a = this.bigIntValue / n;
|
|
1203
1585
|
switch (t) {
|
|
1204
1586
|
case "number":
|
|
1205
1587
|
return Number(a);
|
|
1206
1588
|
case "string":
|
|
1207
1589
|
return a.toString();
|
|
1208
|
-
|
|
1209
|
-
return
|
|
1590
|
+
case "bigint":
|
|
1591
|
+
return a;
|
|
1210
1592
|
}
|
|
1211
1593
|
}
|
|
1212
1594
|
getBigIntValue(t, n) {
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
a,
|
|
1218
|
-
F(this.decimalMultiplier)
|
|
1219
|
-
), r = t < 0n, p = t.toString().substring(r ? 1 : 0), o = i - (p.length - 1), y = o > 0 ? "0".repeat(o) + p : p, T = y.length - i;
|
|
1220
|
-
let u = y.slice(-i);
|
|
1221
|
-
return parseInt(u[a]) >= 5 ? u = `${u.substring(0, a - 1)}${(parseInt(u[a - 1]) + 1).toString()}` : u = u.substring(0, a), `${r ? "-" : ""}${y.slice(
|
|
1222
|
-
0,
|
|
1223
|
-
T
|
|
1224
|
-
)}.${u}`.replace(/\.?0*$/, "");
|
|
1595
|
+
if (!n && typeof t == "object")
|
|
1596
|
+
return t.bigIntValue;
|
|
1597
|
+
const a = Te(t), s = ne(a);
|
|
1598
|
+
return s === "0" || s === "undefined" ? 0n : R(this, te, me).call(this, s, n);
|
|
1225
1599
|
}
|
|
1226
1600
|
toSignificant(t = 6) {
|
|
1227
|
-
const [n, a] = this.getValue("string").split("."),
|
|
1228
|
-
if (
|
|
1601
|
+
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
1602
|
+
if ((parseInt(s) ? s.length + r.length : r.length) <= t)
|
|
1229
1603
|
return this.getValue("string");
|
|
1230
|
-
if (
|
|
1231
|
-
return
|
|
1232
|
-
if (parseInt(
|
|
1233
|
-
return `${
|
|
1234
|
-
|
|
1604
|
+
if (s.length >= t)
|
|
1605
|
+
return s.slice(0, t).padEnd(s.length, "0");
|
|
1606
|
+
if (parseInt(s))
|
|
1607
|
+
return `${s}.${r.slice(0, t - s.length)}`.padEnd(
|
|
1608
|
+
t - s.length,
|
|
1235
1609
|
"0"
|
|
1236
1610
|
);
|
|
1237
|
-
const o = parseInt(r),
|
|
1238
|
-
return `0.${
|
|
1239
|
-
r.length - `${o}`.length +
|
|
1611
|
+
const o = parseInt(r), p = `${o}`.slice(0, t);
|
|
1612
|
+
return `0.${p.padStart(
|
|
1613
|
+
r.length - `${o}`.length + p.length,
|
|
1614
|
+
"0"
|
|
1615
|
+
)}`;
|
|
1616
|
+
}
|
|
1617
|
+
toFixed(t = 6) {
|
|
1618
|
+
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
1619
|
+
if (parseInt(s))
|
|
1620
|
+
return `${s}.${r.slice(0, t)}`.padEnd(t, "0");
|
|
1621
|
+
const o = parseInt(r), p = `${o}`.slice(0, t);
|
|
1622
|
+
return `0.${p.padStart(
|
|
1623
|
+
r.length - `${o}`.length + p.length,
|
|
1240
1624
|
"0"
|
|
1241
1625
|
)}`;
|
|
1242
1626
|
}
|
|
1627
|
+
toAbbreviation(t = 2) {
|
|
1628
|
+
const n = this.getValue("number"), a = ["", "K", "M", "B", "T", "Q", "Qi", "S"], s = Math.floor(Math.log10(Math.abs(n)) / 3), r = a[s];
|
|
1629
|
+
if (!r)
|
|
1630
|
+
return this.getValue("string");
|
|
1631
|
+
const o = 10 ** (s * 3);
|
|
1632
|
+
return `${(n / o).toFixed(t)}${r}`;
|
|
1633
|
+
}
|
|
1634
|
+
toCurrency(t = "$", {
|
|
1635
|
+
currencyPosition: n = "start",
|
|
1636
|
+
decimal: a = 2,
|
|
1637
|
+
decimalSeparator: s = ".",
|
|
1638
|
+
thousandSeparator: r = ","
|
|
1639
|
+
} = {}) {
|
|
1640
|
+
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)}` : ""}`;
|
|
1641
|
+
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1642
|
+
}
|
|
1643
|
+
formatBigIntToSafeValue(t, n) {
|
|
1644
|
+
const a = n || this.decimal || j, s = Math.max(
|
|
1645
|
+
a,
|
|
1646
|
+
G(this.decimalMultiplier)
|
|
1647
|
+
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, l = d.length - s;
|
|
1648
|
+
let u = d.slice(-s);
|
|
1649
|
+
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(
|
|
1650
|
+
0,
|
|
1651
|
+
l
|
|
1652
|
+
)}.${u}`.replace(/\.?0*$/, "");
|
|
1653
|
+
}
|
|
1243
1654
|
};
|
|
1244
|
-
|
|
1245
|
-
const n =
|
|
1246
|
-
(p,
|
|
1247
|
-
const
|
|
1655
|
+
U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1656
|
+
const n = R(this, z, de).call(this, this, ...t), a = Math.max(n, G(this.decimalMultiplier)), s = L(a), r = t.reduce(
|
|
1657
|
+
(p, d) => {
|
|
1658
|
+
const l = this.getBigIntValue(d, a);
|
|
1248
1659
|
switch (e) {
|
|
1249
1660
|
case "add":
|
|
1250
|
-
return p +
|
|
1661
|
+
return p + l;
|
|
1251
1662
|
case "sub":
|
|
1252
|
-
return p -
|
|
1663
|
+
return p - l;
|
|
1253
1664
|
case "mul":
|
|
1254
|
-
return p *
|
|
1665
|
+
return p * l / s;
|
|
1255
1666
|
case "div": {
|
|
1256
|
-
if (
|
|
1667
|
+
if (l === 0n)
|
|
1257
1668
|
throw new RangeError("Division by zero");
|
|
1258
|
-
return p *
|
|
1669
|
+
return p * s / l;
|
|
1259
1670
|
}
|
|
1260
1671
|
default:
|
|
1261
1672
|
return p;
|
|
1262
1673
|
}
|
|
1263
1674
|
},
|
|
1264
1675
|
//normalize is to precision multiplier base
|
|
1265
|
-
this.bigIntValue *
|
|
1266
|
-
),
|
|
1267
|
-
bigIntDecimal:
|
|
1268
|
-
decimal:
|
|
1269
|
-
value:
|
|
1676
|
+
this.bigIntValue * s / this.decimalMultiplier
|
|
1677
|
+
), o = ie({
|
|
1678
|
+
bigIntDecimal: a,
|
|
1679
|
+
decimal: a,
|
|
1680
|
+
value: r
|
|
1681
|
+
});
|
|
1682
|
+
return new this.constructor({
|
|
1683
|
+
decimalMultiplier: L(a),
|
|
1684
|
+
decimal: this.decimal,
|
|
1685
|
+
value: o,
|
|
1686
|
+
identifier: this.toString()
|
|
1270
1687
|
});
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1688
|
+
}, B = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
|
|
1689
|
+
const n = R(this, z, de).call(this, this, ...t), a = this.getBigIntValue(t[0], n), s = this.getBigIntValue(this, n);
|
|
1690
|
+
switch (e) {
|
|
1691
|
+
case "gt":
|
|
1692
|
+
return s > a;
|
|
1693
|
+
case "gte":
|
|
1694
|
+
return s >= a;
|
|
1695
|
+
case "lt":
|
|
1696
|
+
return s < a;
|
|
1697
|
+
case "lte":
|
|
1698
|
+
return s <= a;
|
|
1699
|
+
case "eqValue":
|
|
1700
|
+
return s === a;
|
|
1701
|
+
}
|
|
1702
|
+
}, ce = /* @__PURE__ */ new WeakSet(), Ve = function(e) {
|
|
1703
|
+
const t = ne(e) || "0";
|
|
1704
|
+
this.bigIntValue = R(this, te, me).call(this, t);
|
|
1705
|
+
}, z = /* @__PURE__ */ new WeakSet(), de = function(...e) {
|
|
1706
|
+
const t = e.map((n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : $e(ne(n))).filter(Boolean);
|
|
1707
|
+
return Math.max(...t, j);
|
|
1708
|
+
}, te = /* @__PURE__ */ new WeakSet(), me = function(e, t) {
|
|
1709
|
+
const n = t ? L(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
|
|
1710
|
+
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1711
|
+
};
|
|
1712
|
+
let He = Wt;
|
|
1713
|
+
const jt = Intl.NumberFormat("fullwide", {
|
|
1714
|
+
useGrouping: !1,
|
|
1715
|
+
maximumFractionDigits: 20
|
|
1716
|
+
});
|
|
1717
|
+
function ne(e) {
|
|
1718
|
+
const t = `${typeof e == "number" ? jt.format(e) : Te(e)}`.replaceAll(",", ".").split(".");
|
|
1288
1719
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1289
|
-
}
|
|
1720
|
+
}
|
|
1721
|
+
function $e(e) {
|
|
1290
1722
|
var t;
|
|
1291
1723
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1292
|
-
return Math.max(n,
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
function oe(e) {
|
|
1724
|
+
return Math.max(n, j);
|
|
1725
|
+
}
|
|
1726
|
+
function Te(e) {
|
|
1296
1727
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1297
1728
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
t.value instanceof pe ? t.value : { decimal: t.decimal, value: t.value }
|
|
1312
|
-
), N(this, "address"), N(this, "chain"), N(this, "isSynthetic", !1), N(this, "isGasAsset", !1), N(this, "symbol"), N(this, "ticker"), N(this, "type");
|
|
1313
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = ue(n);
|
|
1314
|
-
this.type = pt(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;
|
|
1315
|
-
}
|
|
1316
|
-
get assetValue() {
|
|
1317
|
-
return `${this.getValue("string")} ${this.ticker}`;
|
|
1729
|
+
const q = /* @__PURE__ */ new Map();
|
|
1730
|
+
class x extends He {
|
|
1731
|
+
constructor({
|
|
1732
|
+
value: t,
|
|
1733
|
+
decimal: n,
|
|
1734
|
+
tax: a,
|
|
1735
|
+
chain: s,
|
|
1736
|
+
symbol: r,
|
|
1737
|
+
identifier: o
|
|
1738
|
+
}) {
|
|
1739
|
+
super(typeof t == "object" ? t : { decimal: n, value: t }), S(this, "address"), S(this, "chain"), S(this, "isGasAsset", !1), S(this, "isSynthetic", !1), S(this, "symbol"), S(this, "tax"), S(this, "ticker"), S(this, "type");
|
|
1740
|
+
const p = he(o || `${s}.${r}`);
|
|
1741
|
+
this.type = At(p), this.tax = a, this.chain = p.chain, this.ticker = p.ticker, this.symbol = p.symbol, this.address = p.address, this.isSynthetic = p.isSynthetic, this.isGasAsset = p.isGasAsset;
|
|
1318
1742
|
}
|
|
1319
1743
|
toString() {
|
|
1320
|
-
return `${this.chain}.${this.symbol}`;
|
|
1744
|
+
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
1745
|
+
}
|
|
1746
|
+
toUrl() {
|
|
1747
|
+
return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
|
|
1321
1748
|
}
|
|
1322
1749
|
eq({ chain: t, symbol: n }) {
|
|
1323
1750
|
return this.chain === t && this.symbol === n;
|
|
1324
1751
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1752
|
+
// THOR.RUNE
|
|
1753
|
+
// THOR.ETH.ETH
|
|
1754
|
+
// ETH.THOR-0x1234567890
|
|
1755
|
+
static fromUrl(t, n = 0) {
|
|
1756
|
+
const [a, s, r] = t.split(".");
|
|
1757
|
+
if (!a || !s)
|
|
1758
|
+
throw new Error("Invalid asset url");
|
|
1759
|
+
const o = a === i.THORChain && r ? `${a}.${s}/${r}` : t;
|
|
1760
|
+
return le(o, n);
|
|
1327
1761
|
}
|
|
1328
|
-
static
|
|
1329
|
-
|
|
1330
|
-
t
|
|
1331
|
-
);
|
|
1332
|
-
return i ? new v({ decimal: a, identifier: i, value: n }) : void 0;
|
|
1762
|
+
static fromString(t, n = 0) {
|
|
1763
|
+
return le(t, n);
|
|
1333
1764
|
}
|
|
1334
|
-
static
|
|
1335
|
-
return
|
|
1765
|
+
static fromIdentifier(t, n = 0) {
|
|
1766
|
+
return le(t, n);
|
|
1767
|
+
}
|
|
1768
|
+
static fromStringSync(t, n = 0) {
|
|
1769
|
+
const { isSynthetic: a } = he(t), s = q.get(t.toUpperCase());
|
|
1770
|
+
if (!s) {
|
|
1771
|
+
console.error(
|
|
1772
|
+
`Asset ${t} is not loaded. Use AssetValue.loadStaticAssets() to load it`
|
|
1773
|
+
);
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
const { tax: r, decimal: o, identifier: p } = s;
|
|
1777
|
+
return new x({
|
|
1778
|
+
tax: r,
|
|
1779
|
+
value: Z(n, o),
|
|
1780
|
+
identifier: a ? t : p,
|
|
1781
|
+
decimal: a ? 8 : o
|
|
1782
|
+
});
|
|
1336
1783
|
}
|
|
1337
1784
|
static fromIdentifierSync(t, n = 0) {
|
|
1338
|
-
const
|
|
1339
|
-
|
|
1785
|
+
const a = q.get(t);
|
|
1786
|
+
if (!a) {
|
|
1787
|
+
console.error(
|
|
1788
|
+
`Asset ${t} is not loaded. Use AssetValue.loadStaticAssets() to load it`
|
|
1789
|
+
);
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
const { tax: s, decimal: r, identifier: o } = a;
|
|
1793
|
+
return new x({ tax: s, decimal: r, identifier: o, value: Z(n, r) });
|
|
1340
1794
|
}
|
|
1341
1795
|
static fromChainOrSignature(t, n = 0) {
|
|
1342
|
-
const { decimal: a, identifier:
|
|
1343
|
-
return new
|
|
1344
|
-
}
|
|
1345
|
-
static async fromTCQuote(t, n = 0) {
|
|
1346
|
-
const a = await Ie(ue(t)), i = this.shiftDecimals({ value: n, from: E.THOR, to: a });
|
|
1347
|
-
return new v({ value: i, identifier: t, decimal: a });
|
|
1348
|
-
}
|
|
1349
|
-
static fromTCQuoteStatic(t, n = 0) {
|
|
1350
|
-
const a = ne(t), i = this.shiftDecimals({
|
|
1351
|
-
value: n,
|
|
1352
|
-
from: E.THOR,
|
|
1353
|
-
to: a.decimal
|
|
1354
|
-
});
|
|
1355
|
-
return new v({ ...a, value: i });
|
|
1796
|
+
const { decimal: a, identifier: s } = wt(t);
|
|
1797
|
+
return new x({ value: Z(n, a), decimal: a, identifier: s });
|
|
1356
1798
|
}
|
|
1357
|
-
static
|
|
1799
|
+
static loadStaticAssets() {
|
|
1358
1800
|
return new Promise(
|
|
1359
1801
|
async (t, n) => {
|
|
1360
1802
|
try {
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
p.set(y, { identifier: y, decimal: l });
|
|
1372
|
-
}), p),
|
|
1373
|
-
/* @__PURE__ */ new Map()
|
|
1374
|
-
), t({ ok: !0 });
|
|
1803
|
+
const a = await import("@swapkit/tokens");
|
|
1804
|
+
Object.values(a).forEach((s) => {
|
|
1805
|
+
var r;
|
|
1806
|
+
(r = s == null ? void 0 : s.tokens) == null || r.forEach(({ identifier: o, chain: p, ...d }) => {
|
|
1807
|
+
q.set(o.toUpperCase(), {
|
|
1808
|
+
identifier: o,
|
|
1809
|
+
decimal: "decimals" in d ? d.decimals : A[p]
|
|
1810
|
+
});
|
|
1811
|
+
});
|
|
1812
|
+
}), t({ ok: !0 });
|
|
1375
1813
|
} catch (a) {
|
|
1376
1814
|
console.error(a), n({
|
|
1377
1815
|
ok: !1,
|
|
@@ -1383,35 +1821,45 @@ class v extends pe {
|
|
|
1383
1821
|
);
|
|
1384
1822
|
}
|
|
1385
1823
|
}
|
|
1386
|
-
|
|
1387
|
-
const t =
|
|
1824
|
+
function ue(e) {
|
|
1825
|
+
const t = x.fromChainOrSignature(e);
|
|
1388
1826
|
switch (e) {
|
|
1389
|
-
case
|
|
1390
|
-
case
|
|
1391
|
-
case
|
|
1392
|
-
return t.
|
|
1393
|
-
case
|
|
1394
|
-
return t.
|
|
1395
|
-
case
|
|
1396
|
-
case
|
|
1397
|
-
return t.
|
|
1398
|
-
case
|
|
1399
|
-
case
|
|
1400
|
-
return t.
|
|
1827
|
+
case i.Bitcoin:
|
|
1828
|
+
case i.Litecoin:
|
|
1829
|
+
case i.BitcoinCash:
|
|
1830
|
+
return t.set(10001e-8);
|
|
1831
|
+
case i.Dogecoin:
|
|
1832
|
+
return t.set(1.00000001);
|
|
1833
|
+
case i.Avalanche:
|
|
1834
|
+
case i.Ethereum:
|
|
1835
|
+
return t.set(1e-8);
|
|
1836
|
+
case i.THORChain:
|
|
1837
|
+
case i.Maya:
|
|
1838
|
+
return t.set(0);
|
|
1401
1839
|
default:
|
|
1402
|
-
return t.
|
|
1840
|
+
return t.set(1e-8);
|
|
1403
1841
|
}
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1842
|
+
}
|
|
1843
|
+
async function le(e, t = 0) {
|
|
1844
|
+
qt(e);
|
|
1845
|
+
const n = q.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await ft(he(e));
|
|
1846
|
+
return n || q.set(e.toUpperCase(), { identifier: e, decimal: a }), new x({ decimal: a, value: Z(t, a), identifier: e });
|
|
1847
|
+
}
|
|
1848
|
+
function Z(e, t) {
|
|
1849
|
+
return typeof e == "bigint" ? ie({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1850
|
+
}
|
|
1851
|
+
function he(e) {
|
|
1852
|
+
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("-");
|
|
1406
1853
|
return {
|
|
1407
|
-
address:
|
|
1408
|
-
chain:
|
|
1409
|
-
isGasAsset:
|
|
1854
|
+
address: d == null ? void 0 : d.toLowerCase(),
|
|
1855
|
+
chain: r,
|
|
1856
|
+
isGasAsset: Ne({ chain: r, symbol: o }),
|
|
1410
1857
|
isSynthetic: t,
|
|
1411
|
-
symbol:
|
|
1412
|
-
ticker:
|
|
1858
|
+
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1859
|
+
ticker: p
|
|
1413
1860
|
};
|
|
1414
|
-
}
|
|
1861
|
+
}
|
|
1862
|
+
const Kt = {
|
|
1415
1863
|
/**
|
|
1416
1864
|
* Core
|
|
1417
1865
|
*/
|
|
@@ -1458,6 +1906,7 @@ const he = (e) => {
|
|
|
1458
1906
|
core_transaction_deposit_to_pool_error: 10310,
|
|
1459
1907
|
core_transaction_deposit_insufficient_funds_error: 10311,
|
|
1460
1908
|
core_transaction_deposit_gas_error: 10312,
|
|
1909
|
+
core_transaction_invalid_sender_address: 10313,
|
|
1461
1910
|
core_transaction_deposit_server_error: 10313,
|
|
1462
1911
|
/**
|
|
1463
1912
|
* Wallets
|
|
@@ -1470,15 +1919,21 @@ const he = (e) => {
|
|
|
1470
1919
|
};
|
|
1471
1920
|
class c extends Error {
|
|
1472
1921
|
constructor(t, n) {
|
|
1473
|
-
console.error(n), super(t, { cause: { code:
|
|
1922
|
+
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Kt[t], message: t } }), Object.setPrototypeOf(this, c.prototype);
|
|
1474
1923
|
}
|
|
1475
1924
|
}
|
|
1476
|
-
class
|
|
1925
|
+
class N extends He {
|
|
1477
1926
|
eq(t) {
|
|
1478
1927
|
return this.eqValue(t);
|
|
1479
1928
|
}
|
|
1929
|
+
static fromBigInt(t, n) {
|
|
1930
|
+
return new N({
|
|
1931
|
+
decimal: n,
|
|
1932
|
+
value: ie({ value: t, bigIntDecimal: n, decimal: n })
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1480
1935
|
}
|
|
1481
|
-
const
|
|
1936
|
+
const Xt = [
|
|
1482
1937
|
{
|
|
1483
1938
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1484
1939
|
stateMutability: "nonpayable",
|
|
@@ -1569,7 +2024,7 @@ const Tt = [
|
|
|
1569
2024
|
type: "function"
|
|
1570
2025
|
},
|
|
1571
2026
|
{ stateMutability: "payable", type: "receive" }
|
|
1572
|
-
],
|
|
2027
|
+
], Yt = [
|
|
1573
2028
|
{
|
|
1574
2029
|
inputs: [
|
|
1575
2030
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -1713,7 +2168,7 @@ const Tt = [
|
|
|
1713
2168
|
type: "function"
|
|
1714
2169
|
},
|
|
1715
2170
|
{ stateMutability: "payable", type: "receive" }
|
|
1716
|
-
],
|
|
2171
|
+
], Jt = [
|
|
1717
2172
|
{
|
|
1718
2173
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1719
2174
|
stateMutability: "nonpayable",
|
|
@@ -1818,7 +2273,7 @@ const Tt = [
|
|
|
1818
2273
|
type: "function"
|
|
1819
2274
|
},
|
|
1820
2275
|
{ stateMutability: "payable", type: "receive" }
|
|
1821
|
-
],
|
|
2276
|
+
], Qt = [
|
|
1822
2277
|
{
|
|
1823
2278
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1824
2279
|
stateMutability: "nonpayable",
|
|
@@ -1909,7 +2364,7 @@ const Tt = [
|
|
|
1909
2364
|
type: "function"
|
|
1910
2365
|
},
|
|
1911
2366
|
{ stateMutability: "payable", type: "receive" }
|
|
1912
|
-
],
|
|
2367
|
+
], zt = [
|
|
1913
2368
|
{
|
|
1914
2369
|
inputs: [
|
|
1915
2370
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2053,7 +2508,7 @@ const Tt = [
|
|
|
2053
2508
|
type: "function"
|
|
2054
2509
|
},
|
|
2055
2510
|
{ stateMutability: "payable", type: "receive" }
|
|
2056
|
-
],
|
|
2511
|
+
], Zt = [
|
|
2057
2512
|
{
|
|
2058
2513
|
inputs: [
|
|
2059
2514
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2172,7 +2627,7 @@ const Tt = [
|
|
|
2172
2627
|
type: "function"
|
|
2173
2628
|
},
|
|
2174
2629
|
{ stateMutability: "payable", type: "receive" }
|
|
2175
|
-
],
|
|
2630
|
+
], en = [
|
|
2176
2631
|
{
|
|
2177
2632
|
inputs: [
|
|
2178
2633
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2291,7 +2746,7 @@ const Tt = [
|
|
|
2291
2746
|
type: "function"
|
|
2292
2747
|
},
|
|
2293
2748
|
{ stateMutability: "payable", type: "receive" }
|
|
2294
|
-
],
|
|
2749
|
+
], tn = [
|
|
2295
2750
|
{
|
|
2296
2751
|
inputs: [
|
|
2297
2752
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2410,7 +2865,7 @@ const Tt = [
|
|
|
2410
2865
|
type: "function"
|
|
2411
2866
|
},
|
|
2412
2867
|
{ stateMutability: "payable", type: "receive" }
|
|
2413
|
-
],
|
|
2868
|
+
], nn = [
|
|
2414
2869
|
{
|
|
2415
2870
|
inputs: [
|
|
2416
2871
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2529,7 +2984,7 @@ const Tt = [
|
|
|
2529
2984
|
type: "function"
|
|
2530
2985
|
},
|
|
2531
2986
|
{ stateMutability: "payable", type: "receive" }
|
|
2532
|
-
],
|
|
2987
|
+
], an = [
|
|
2533
2988
|
{
|
|
2534
2989
|
inputs: [
|
|
2535
2990
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2656,7 +3111,7 @@ const Tt = [
|
|
|
2656
3111
|
type: "function"
|
|
2657
3112
|
},
|
|
2658
3113
|
{ stateMutability: "payable", type: "receive" }
|
|
2659
|
-
],
|
|
3114
|
+
], sn = [
|
|
2660
3115
|
{
|
|
2661
3116
|
inputs: [
|
|
2662
3117
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2783,7 +3238,7 @@ const Tt = [
|
|
|
2783
3238
|
type: "function"
|
|
2784
3239
|
},
|
|
2785
3240
|
{ stateMutability: "payable", type: "receive" }
|
|
2786
|
-
],
|
|
3241
|
+
], rn = [
|
|
2787
3242
|
{
|
|
2788
3243
|
inputs: [
|
|
2789
3244
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2910,7 +3365,7 @@ const Tt = [
|
|
|
2910
3365
|
type: "function"
|
|
2911
3366
|
},
|
|
2912
3367
|
{ stateMutability: "payable", type: "receive" }
|
|
2913
|
-
],
|
|
3368
|
+
], on = [
|
|
2914
3369
|
{
|
|
2915
3370
|
inputs: [
|
|
2916
3371
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3037,7 +3492,7 @@ const Tt = [
|
|
|
3037
3492
|
type: "function"
|
|
3038
3493
|
},
|
|
3039
3494
|
{ stateMutability: "payable", type: "receive" }
|
|
3040
|
-
],
|
|
3495
|
+
], pn = [
|
|
3041
3496
|
{
|
|
3042
3497
|
inputs: [
|
|
3043
3498
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3164,297 +3619,312 @@ const Tt = [
|
|
|
3164
3619
|
type: "function"
|
|
3165
3620
|
},
|
|
3166
3621
|
{ stateMutability: "payable", type: "receive" }
|
|
3167
|
-
],
|
|
3168
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3169
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3170
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3171
|
-
},
|
|
3172
|
-
...
|
|
3622
|
+
], ke = {
|
|
3623
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Xt,
|
|
3624
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Jt,
|
|
3625
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Qt
|
|
3626
|
+
}, dn = {
|
|
3627
|
+
...ke,
|
|
3173
3628
|
// AVAX
|
|
3174
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3175
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3176
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3629
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: Zt,
|
|
3630
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Yt,
|
|
3631
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: tn,
|
|
3177
3632
|
// BSC
|
|
3178
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3633
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: zt,
|
|
3179
3634
|
// ETH
|
|
3180
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3181
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3182
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3183
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3184
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3185
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3186
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3187
|
-
},
|
|
3635
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: en,
|
|
3636
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: nn,
|
|
3637
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: an,
|
|
3638
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: sn,
|
|
3639
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: rn,
|
|
3640
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: on,
|
|
3641
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: pn
|
|
3642
|
+
}, un = ({
|
|
3188
3643
|
streamSwap: e,
|
|
3189
3644
|
contractAddress: t,
|
|
3190
3645
|
recipient: n,
|
|
3191
3646
|
toChecksumAddress: a,
|
|
3192
3647
|
calldata: {
|
|
3193
|
-
amount:
|
|
3648
|
+
amount: s,
|
|
3194
3649
|
amountOutMin: r = "",
|
|
3195
|
-
data:
|
|
3196
|
-
deadline:
|
|
3197
|
-
memo:
|
|
3198
|
-
router:
|
|
3650
|
+
data: o = "",
|
|
3651
|
+
deadline: p,
|
|
3652
|
+
memo: d,
|
|
3653
|
+
router: l,
|
|
3199
3654
|
memoStreamingSwap: u,
|
|
3200
|
-
tcMemo:
|
|
3201
|
-
tcRouter:
|
|
3202
|
-
tcVault:
|
|
3203
|
-
vault:
|
|
3204
|
-
token:
|
|
3655
|
+
tcMemo: m,
|
|
3656
|
+
tcRouter: _,
|
|
3657
|
+
tcVault: b,
|
|
3658
|
+
vault: w,
|
|
3659
|
+
token: E
|
|
3205
3660
|
}
|
|
3206
3661
|
}) => {
|
|
3207
|
-
const
|
|
3208
|
-
if (
|
|
3662
|
+
const O = !!ke[t.toLowerCase()];
|
|
3663
|
+
if (O && !l)
|
|
3209
3664
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3210
|
-
const I =
|
|
3211
|
-
if (!
|
|
3665
|
+
const I = m || d, D = e && u || I;
|
|
3666
|
+
if (!b && !w)
|
|
3212
3667
|
throw new Error("TC Vault is required on calldata");
|
|
3213
|
-
if (!
|
|
3668
|
+
if (!_ && !l)
|
|
3214
3669
|
throw new Error("TC Router is required on calldata");
|
|
3215
|
-
if (!
|
|
3670
|
+
if (!D)
|
|
3216
3671
|
throw new Error("TC Memo is required on calldata");
|
|
3217
|
-
if (!
|
|
3672
|
+
if (!E)
|
|
3218
3673
|
throw new Error("Token is required on calldata");
|
|
3219
|
-
const
|
|
3674
|
+
const re = [
|
|
3220
3675
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3221
|
-
a(
|
|
3222
|
-
a(
|
|
3223
|
-
|
|
3224
|
-
a(
|
|
3225
|
-
|
|
3226
|
-
],
|
|
3227
|
-
return [...
|
|
3228
|
-
},
|
|
3229
|
-
const n =
|
|
3676
|
+
a(_ || l),
|
|
3677
|
+
a(b || w),
|
|
3678
|
+
D.replace("{recipientAddress}", n),
|
|
3679
|
+
a(E),
|
|
3680
|
+
s
|
|
3681
|
+
], Fe = O ? [a(l), o, p] : [r, p];
|
|
3682
|
+
return [...re, ...Fe];
|
|
3683
|
+
}, ln = ({ chain: e, txHash: t }) => {
|
|
3684
|
+
const n = Ce[e];
|
|
3230
3685
|
switch (e) {
|
|
3231
|
-
case
|
|
3232
|
-
case
|
|
3233
|
-
case
|
|
3234
|
-
case
|
|
3235
|
-
|
|
3236
|
-
case
|
|
3237
|
-
|
|
3238
|
-
case
|
|
3239
|
-
case
|
|
3240
|
-
case
|
|
3241
|
-
case
|
|
3242
|
-
case s.Optimism:
|
|
3243
|
-
case s.Polygon:
|
|
3686
|
+
case i.Binance:
|
|
3687
|
+
case i.Maya:
|
|
3688
|
+
case i.Kujira:
|
|
3689
|
+
case i.THORChain:
|
|
3690
|
+
return `${n}/tx/${t.startsWith("0x") ? t.slice(2) : t}`;
|
|
3691
|
+
case i.Arbitrum:
|
|
3692
|
+
case i.Avalanche:
|
|
3693
|
+
case i.BinanceSmartChain:
|
|
3694
|
+
case i.Ethereum:
|
|
3695
|
+
case i.Optimism:
|
|
3696
|
+
case i.Polygon:
|
|
3244
3697
|
return `${n}/tx/${t.startsWith("0x") ? t : `0x${t}`}`;
|
|
3245
|
-
case
|
|
3698
|
+
case i.Cosmos:
|
|
3246
3699
|
return `${n}/transactions/${t}`;
|
|
3247
|
-
case
|
|
3700
|
+
case i.Litecoin:
|
|
3701
|
+
case i.Bitcoin:
|
|
3702
|
+
case i.BitcoinCash:
|
|
3703
|
+
case i.Dogecoin:
|
|
3248
3704
|
return `${n}/transaction/${t.toLowerCase()}`;
|
|
3249
|
-
case s.Litecoin:
|
|
3250
|
-
return `${n}/${t}`;
|
|
3251
3705
|
default:
|
|
3252
3706
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3253
3707
|
}
|
|
3254
|
-
},
|
|
3255
|
-
const n =
|
|
3708
|
+
}, yn = ({ chain: e, address: t }) => {
|
|
3709
|
+
const n = Ce[e];
|
|
3256
3710
|
switch (e) {
|
|
3257
|
-
case
|
|
3258
|
-
case
|
|
3259
|
-
case
|
|
3260
|
-
case
|
|
3261
|
-
case
|
|
3262
|
-
case
|
|
3263
|
-
case
|
|
3264
|
-
case
|
|
3265
|
-
case
|
|
3266
|
-
case
|
|
3267
|
-
case
|
|
3268
|
-
case
|
|
3269
|
-
case
|
|
3711
|
+
case i.Arbitrum:
|
|
3712
|
+
case i.Avalanche:
|
|
3713
|
+
case i.Binance:
|
|
3714
|
+
case i.BinanceSmartChain:
|
|
3715
|
+
case i.Bitcoin:
|
|
3716
|
+
case i.BitcoinCash:
|
|
3717
|
+
case i.Dogecoin:
|
|
3718
|
+
case i.Ethereum:
|
|
3719
|
+
case i.Kujira:
|
|
3720
|
+
case i.Litecoin:
|
|
3721
|
+
case i.Maya:
|
|
3722
|
+
case i.Optimism:
|
|
3723
|
+
case i.Polygon:
|
|
3724
|
+
case i.THORChain:
|
|
3270
3725
|
return `${n}/address/${t}`;
|
|
3271
|
-
case
|
|
3726
|
+
case i.Cosmos:
|
|
3272
3727
|
return `${n}/account/${t}`;
|
|
3273
|
-
case s.Litecoin:
|
|
3274
|
-
return `${n}/${t}`;
|
|
3275
3728
|
default:
|
|
3276
3729
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3277
3730
|
}
|
|
3278
|
-
},
|
|
3731
|
+
}, cn = (e) => {
|
|
3279
3732
|
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3280
|
-
return
|
|
3281
|
-
},
|
|
3733
|
+
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3734
|
+
}, mn = (e) => {
|
|
3282
3735
|
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3283
|
-
return
|
|
3284
|
-
},
|
|
3736
|
+
return we.get(`${t}/thorchain/mimir`);
|
|
3737
|
+
}, Oe = () => Object.values(i).reduce(
|
|
3285
3738
|
(e, t) => (e[t] = null, e),
|
|
3286
3739
|
{}
|
|
3287
|
-
)
|
|
3288
|
-
|
|
3289
|
-
|
|
3740
|
+
), Tn = async ({ chain: e, address: t }) => {
|
|
3741
|
+
if (!t)
|
|
3742
|
+
return !1;
|
|
3743
|
+
switch (e) {
|
|
3744
|
+
case i.Bitcoin:
|
|
3745
|
+
return !t.startsWith("bc1p");
|
|
3746
|
+
default:
|
|
3747
|
+
return !0;
|
|
3748
|
+
}
|
|
3749
|
+
};
|
|
3750
|
+
var V, ae, K, v, X, Y;
|
|
3751
|
+
class Pn {
|
|
3290
3752
|
constructor({ stagenet: t } = {}) {
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3753
|
+
T(this, "connectedChains", Oe());
|
|
3754
|
+
T(this, "connectedWallets", Oe());
|
|
3755
|
+
T(this, "stagenet", !1);
|
|
3756
|
+
T(this, "getAddress", (t) => {
|
|
3295
3757
|
var n;
|
|
3296
3758
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3297
3759
|
});
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
if (!n)
|
|
3304
|
-
return ((i = this.connectedChains[t]) == null ? void 0 : i.balance) || [];
|
|
3305
|
-
const a = await this.getWalletByChain(t);
|
|
3760
|
+
T(this, "getExplorerTxUrl", (t, n) => ln({ chain: t, txHash: n }));
|
|
3761
|
+
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3762
|
+
T(this, "getExplorerAddressUrl", (t, n) => yn({ chain: t, address: n }));
|
|
3763
|
+
T(this, "getBalance", async (t, n) => {
|
|
3764
|
+
const a = await this.getWalletByChain(t, n);
|
|
3306
3765
|
return (a == null ? void 0 : a.balance) || [];
|
|
3307
3766
|
});
|
|
3308
|
-
|
|
3309
|
-
var
|
|
3310
|
-
const { quoteMode: r } = a.meta,
|
|
3767
|
+
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: s }) => {
|
|
3768
|
+
var p, d;
|
|
3769
|
+
const { quoteMode: r } = a.meta, o = r.startsWith("ERC20-") ? i.Ethereum : r.startsWith("ARC20-") ? i.Avalanche : i.BinanceSmartChain;
|
|
3311
3770
|
if (!a.complete)
|
|
3312
3771
|
throw new c("core_swap_route_not_complete");
|
|
3313
3772
|
try {
|
|
3314
|
-
if (
|
|
3315
|
-
const l = this.connectedWallets[
|
|
3773
|
+
if (ze.includes(r)) {
|
|
3774
|
+
const l = this.connectedWallets[o];
|
|
3316
3775
|
if (!(l != null && l.sendTransaction))
|
|
3317
3776
|
throw new c("core_wallet_connection_not_found");
|
|
3318
|
-
if (!(t ? (
|
|
3777
|
+
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3319
3778
|
throw new c("core_swap_route_transaction_not_found");
|
|
3320
|
-
const {
|
|
3321
|
-
data:
|
|
3322
|
-
from:
|
|
3323
|
-
to:
|
|
3324
|
-
chainId: BigInt(
|
|
3325
|
-
value:
|
|
3326
|
-
value: _(b) ? b : R(b, "wei").toString(16)
|
|
3327
|
-
}).baseValueBigInt : 0n
|
|
3779
|
+
const { data: m, from: _, to: b, value: w } = a.transaction, E = {
|
|
3780
|
+
data: m,
|
|
3781
|
+
from: _,
|
|
3782
|
+
to: b.toLowerCase(),
|
|
3783
|
+
chainId: BigInt(ot[o]),
|
|
3784
|
+
value: w ? BigInt(w) : 0n
|
|
3328
3785
|
};
|
|
3329
|
-
return l.sendTransaction(
|
|
3786
|
+
return l.sendTransaction(E, s);
|
|
3330
3787
|
}
|
|
3331
|
-
if (
|
|
3788
|
+
if (et.includes(r)) {
|
|
3332
3789
|
if (!a.calldata.fromAsset)
|
|
3333
3790
|
throw new c("core_swap_asset_not_recognized");
|
|
3334
|
-
const l = await
|
|
3791
|
+
const l = await x.fromString(a.calldata.fromAsset);
|
|
3335
3792
|
if (!l)
|
|
3336
3793
|
throw new c("core_swap_asset_not_recognized");
|
|
3337
|
-
const { address:
|
|
3338
|
-
contract:
|
|
3339
|
-
calldata: { amountIn:
|
|
3340
|
-
} = a,
|
|
3341
|
-
return this.deposit({
|
|
3794
|
+
const { address: u } = await f(this, V).call(this, l.chain), {
|
|
3795
|
+
contract: m,
|
|
3796
|
+
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap: E }
|
|
3797
|
+
} = a, O = l.add(N.fromBigInt(BigInt(b), l.decimal)), I = t && E || w;
|
|
3798
|
+
return this.deposit({
|
|
3799
|
+
expiration: _,
|
|
3800
|
+
assetValue: O,
|
|
3801
|
+
memo: I,
|
|
3802
|
+
feeOptionKey: s,
|
|
3803
|
+
router: m,
|
|
3804
|
+
recipient: u
|
|
3805
|
+
});
|
|
3342
3806
|
}
|
|
3343
|
-
if (
|
|
3344
|
-
const { calldata: l, contract:
|
|
3345
|
-
if (!
|
|
3807
|
+
if (Ze.includes(r)) {
|
|
3808
|
+
const { calldata: l, contract: u } = a;
|
|
3809
|
+
if (!u)
|
|
3346
3810
|
throw new c("core_swap_contract_not_found");
|
|
3347
|
-
const
|
|
3348
|
-
if (!(
|
|
3811
|
+
const m = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3812
|
+
if (!(m != null && m.sendTransaction) || !_)
|
|
3349
3813
|
throw new c("core_wallet_connection_not_found");
|
|
3350
|
-
const { getProvider:
|
|
3351
|
-
if (!
|
|
3352
|
-
throw new c("core_swap_contract_not_supported", { contractAddress:
|
|
3353
|
-
const
|
|
3354
|
-
|
|
3355
|
-
...Ct({
|
|
3814
|
+
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), E = b(o), O = dn[u.toLowerCase()];
|
|
3815
|
+
if (!O)
|
|
3816
|
+
throw new c("core_swap_contract_not_supported", { contractAddress: u });
|
|
3817
|
+
const D = await (await ((d = m.createContract) == null ? void 0 : d.call(m, u, O, E))).getFunction("swapIn").populateTransaction(
|
|
3818
|
+
...un({
|
|
3356
3819
|
streamSwap: t,
|
|
3357
|
-
toChecksumAddress:
|
|
3358
|
-
contractAddress:
|
|
3820
|
+
toChecksumAddress: w,
|
|
3821
|
+
contractAddress: u,
|
|
3359
3822
|
recipient: n,
|
|
3360
3823
|
calldata: l
|
|
3361
3824
|
}),
|
|
3362
|
-
{ from:
|
|
3363
|
-
)
|
|
3364
|
-
return
|
|
3825
|
+
{ from: _ }
|
|
3826
|
+
);
|
|
3827
|
+
return m.sendTransaction(D, s);
|
|
3365
3828
|
}
|
|
3366
3829
|
throw new c("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3367
3830
|
} catch (l) {
|
|
3368
3831
|
throw new c("core_swap_transaction_error", l);
|
|
3369
3832
|
}
|
|
3370
3833
|
});
|
|
3371
|
-
|
|
3372
|
-
var
|
|
3373
|
-
const
|
|
3374
|
-
if (!
|
|
3834
|
+
T(this, "getWalletByChain", async (t, n) => {
|
|
3835
|
+
var o, p;
|
|
3836
|
+
const a = this.getAddress(t);
|
|
3837
|
+
if (!a)
|
|
3375
3838
|
return null;
|
|
3376
|
-
const
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3839
|
+
const s = [x.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3840
|
+
try {
|
|
3841
|
+
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3842
|
+
return this.connectedChains[t] = {
|
|
3843
|
+
address: a,
|
|
3844
|
+
balance: d != null && d.length ? d : s,
|
|
3845
|
+
walletType: r
|
|
3846
|
+
}, { ...this.connectedChains[t] };
|
|
3847
|
+
} catch (d) {
|
|
3848
|
+
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3849
|
+
}
|
|
3384
3850
|
});
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
var a,
|
|
3389
|
-
return (
|
|
3851
|
+
T(this, "approveAssetValue", (t, n) => f(this, K).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3852
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, K).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3853
|
+
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3854
|
+
var a, s;
|
|
3855
|
+
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
3390
3856
|
});
|
|
3391
|
-
|
|
3857
|
+
T(this, "transfer", async (t) => {
|
|
3392
3858
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
3393
3859
|
if (!n)
|
|
3394
3860
|
throw new c("core_wallet_connection_not_found");
|
|
3395
3861
|
try {
|
|
3396
|
-
return await n.transfer(
|
|
3862
|
+
return await n.transfer(f(this, Y).call(this, t));
|
|
3397
3863
|
} catch (a) {
|
|
3398
3864
|
throw new c("core_swap_transaction_error", a);
|
|
3399
3865
|
}
|
|
3400
3866
|
});
|
|
3401
|
-
|
|
3867
|
+
T(this, "deposit", async ({
|
|
3402
3868
|
assetValue: t,
|
|
3403
3869
|
recipient: n,
|
|
3404
3870
|
router: a,
|
|
3405
|
-
...
|
|
3871
|
+
...s
|
|
3406
3872
|
}) => {
|
|
3407
|
-
const { chain: r, symbol:
|
|
3408
|
-
if (!
|
|
3873
|
+
const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
|
|
3874
|
+
if (!await Tn({ address: await (d == null ? void 0 : d.getAddress()), chain: r }))
|
|
3875
|
+
throw new c("core_transaction_invalid_sender_address");
|
|
3876
|
+
if (!d)
|
|
3409
3877
|
throw new c("core_wallet_connection_not_found");
|
|
3410
|
-
const
|
|
3878
|
+
const l = f(this, Y).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3411
3879
|
try {
|
|
3412
3880
|
switch (r) {
|
|
3413
|
-
case
|
|
3414
|
-
const u =
|
|
3415
|
-
return await (n === "" ? u.deposit(
|
|
3881
|
+
case i.THORChain: {
|
|
3882
|
+
const u = d;
|
|
3883
|
+
return await (n === "" ? u.deposit(l) : u.transfer(l));
|
|
3416
3884
|
}
|
|
3417
|
-
case
|
|
3418
|
-
case
|
|
3419
|
-
case
|
|
3420
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"),
|
|
3421
|
-
return await
|
|
3422
|
-
abi:
|
|
3423
|
-
contractAddress: a || (await
|
|
3885
|
+
case i.Ethereum:
|
|
3886
|
+
case i.BinanceSmartChain:
|
|
3887
|
+
case i.Avalanche: {
|
|
3888
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ? Ye : r === i.BinanceSmartChain ? Je : Xe;
|
|
3889
|
+
return await d.call({
|
|
3890
|
+
abi: m,
|
|
3891
|
+
contractAddress: a || (await f(this, V).call(this, r)).router,
|
|
3424
3892
|
funcName: "depositWithExpiry",
|
|
3425
3893
|
funcParams: [
|
|
3426
3894
|
n,
|
|
3427
|
-
u({ chain: r, symbol:
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
i.expiration
|
|
3895
|
+
u({ chain: r, symbol: o, ticker: p }, r),
|
|
3896
|
+
t.getBaseValue("string"),
|
|
3897
|
+
l.memo,
|
|
3898
|
+
s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
3432
3899
|
],
|
|
3433
|
-
txOverrides: {
|
|
3900
|
+
txOverrides: {
|
|
3901
|
+
from: l.from,
|
|
3902
|
+
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
3903
|
+
}
|
|
3434
3904
|
});
|
|
3435
3905
|
}
|
|
3436
3906
|
default:
|
|
3437
|
-
return await
|
|
3907
|
+
return await d.transfer(l);
|
|
3438
3908
|
}
|
|
3439
3909
|
} catch (u) {
|
|
3440
|
-
const
|
|
3441
|
-
throw new c(
|
|
3910
|
+
const m = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = m == null ? void 0 : m.includes("insufficient funds"), b = m == null ? void 0 : m.includes("gas"), w = m == null ? void 0 : m.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : w ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3911
|
+
throw new c(E, u);
|
|
3442
3912
|
}
|
|
3443
3913
|
});
|
|
3444
3914
|
/**
|
|
3445
3915
|
* TC related Methods
|
|
3446
3916
|
*/
|
|
3447
|
-
|
|
3917
|
+
T(this, "createLiquidity", async ({
|
|
3448
3918
|
runeAssetValue: t,
|
|
3449
3919
|
assetValue: n
|
|
3450
3920
|
}) => {
|
|
3451
3921
|
if (t.lte(0) || n.lte(0))
|
|
3452
3922
|
throw new c("core_transaction_create_liquidity_invalid_params");
|
|
3453
|
-
let a = "",
|
|
3923
|
+
let a = "", s = "";
|
|
3454
3924
|
try {
|
|
3455
|
-
a = await
|
|
3925
|
+
a = await f(this, v).call(this, {
|
|
3456
3926
|
assetValue: t,
|
|
3457
|
-
memo:
|
|
3927
|
+
memo: M(h.DEPOSIT, {
|
|
3458
3928
|
...n,
|
|
3459
3929
|
address: this.getAddress(n.chain)
|
|
3460
3930
|
})
|
|
@@ -3463,166 +3933,172 @@ class zt {
|
|
|
3463
3933
|
throw new c("core_transaction_create_liquidity_rune_error", r);
|
|
3464
3934
|
}
|
|
3465
3935
|
try {
|
|
3466
|
-
|
|
3936
|
+
s = await f(this, v).call(this, {
|
|
3467
3937
|
assetValue: n,
|
|
3468
|
-
memo:
|
|
3938
|
+
memo: M(h.DEPOSIT, {
|
|
3469
3939
|
...n,
|
|
3470
|
-
address: this.getAddress(
|
|
3940
|
+
address: this.getAddress(i.THORChain)
|
|
3471
3941
|
})
|
|
3472
3942
|
});
|
|
3473
3943
|
} catch (r) {
|
|
3474
3944
|
throw new c("core_transaction_create_liquidity_asset_error", r);
|
|
3475
3945
|
}
|
|
3476
|
-
return { runeTx: a, assetTx:
|
|
3946
|
+
return { runeTx: a, assetTx: s };
|
|
3477
3947
|
});
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
isPendingSymmAsset: p,
|
|
3948
|
+
T(this, "addLiquidity", async ({
|
|
3949
|
+
runeAssetValue: t,
|
|
3950
|
+
assetValue: n,
|
|
3951
|
+
runeAddr: a,
|
|
3952
|
+
assetAddr: s,
|
|
3953
|
+
isPendingSymmAsset: r,
|
|
3485
3954
|
mode: o = "sym"
|
|
3486
3955
|
}) => {
|
|
3487
|
-
const
|
|
3488
|
-
if (!
|
|
3956
|
+
const { chain: p, symbol: d } = n, l = o === "sym", u = (t == null ? void 0 : t.gt(0)) && (l || o === "rune"), m = (n == null ? void 0 : n.gt(0)) && (l || o === "asset"), _ = r || u, b = _ ? a || this.getAddress(i.THORChain) : "", w = l || o === "asset" ? s || this.getAddress(p) : "";
|
|
3957
|
+
if (!u && !m)
|
|
3489
3958
|
throw new c("core_transaction_add_liquidity_invalid_params");
|
|
3490
|
-
if (_ && !
|
|
3959
|
+
if (_ && !b)
|
|
3491
3960
|
throw new c("core_transaction_add_liquidity_no_rune_address");
|
|
3492
|
-
let
|
|
3493
|
-
|
|
3494
|
-
if (l && n)
|
|
3961
|
+
let E, O;
|
|
3962
|
+
if (u && t)
|
|
3495
3963
|
try {
|
|
3496
|
-
|
|
3497
|
-
assetValue:
|
|
3498
|
-
memo:
|
|
3964
|
+
E = await f(this, v).call(this, {
|
|
3965
|
+
assetValue: t,
|
|
3966
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: w })
|
|
3499
3967
|
});
|
|
3500
|
-
} catch (
|
|
3501
|
-
throw new c("core_transaction_add_liquidity_rune_error",
|
|
3968
|
+
} catch (I) {
|
|
3969
|
+
throw new c("core_transaction_add_liquidity_rune_error", I);
|
|
3502
3970
|
}
|
|
3503
|
-
if (
|
|
3971
|
+
if (m && n)
|
|
3504
3972
|
try {
|
|
3505
|
-
|
|
3506
|
-
assetValue:
|
|
3507
|
-
memo:
|
|
3973
|
+
O = await f(this, v).call(this, {
|
|
3974
|
+
assetValue: n,
|
|
3975
|
+
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: b })
|
|
3508
3976
|
});
|
|
3509
|
-
} catch (
|
|
3510
|
-
throw new c("core_transaction_add_liquidity_asset_error",
|
|
3977
|
+
} catch (I) {
|
|
3978
|
+
throw new c("core_transaction_add_liquidity_asset_error", I);
|
|
3511
3979
|
}
|
|
3512
|
-
return { runeTx:
|
|
3980
|
+
return { runeTx: E, assetTx: O };
|
|
3513
3981
|
});
|
|
3514
|
-
|
|
3982
|
+
T(this, "addLiquidityPart", ({
|
|
3983
|
+
assetValue: t,
|
|
3984
|
+
poolAddress: n,
|
|
3985
|
+
address: a,
|
|
3986
|
+
symmetric: s
|
|
3987
|
+
}) => {
|
|
3988
|
+
if (s && !a)
|
|
3989
|
+
throw new c("core_transaction_add_liquidity_invalid_params");
|
|
3990
|
+
const r = M(h.DEPOSIT, {
|
|
3991
|
+
chain: n.split(".")[0],
|
|
3992
|
+
symbol: n.split(".")[1],
|
|
3993
|
+
address: s ? a : ""
|
|
3994
|
+
});
|
|
3995
|
+
return f(this, v).call(this, { assetValue: t, memo: r });
|
|
3996
|
+
});
|
|
3997
|
+
T(this, "withdraw", async ({
|
|
3515
3998
|
memo: t,
|
|
3516
3999
|
assetValue: n,
|
|
3517
4000
|
percent: a,
|
|
3518
|
-
from:
|
|
4001
|
+
from: s,
|
|
3519
4002
|
to: r
|
|
3520
4003
|
}) => {
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
targetAssetString: p == null ? void 0 : p.toString(),
|
|
3531
|
-
singleSide: !1
|
|
3532
|
-
})
|
|
3533
|
-
});
|
|
3534
|
-
} catch (o) {
|
|
3535
|
-
throw new c("core_transaction_withdraw_error", o);
|
|
3536
|
-
}
|
|
4004
|
+
const o = r === "rune" ? x.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = ue(s === "asset" ? n.chain : i.THORChain), d = t || M(h.WITHDRAW, {
|
|
4005
|
+
symbol: n.symbol,
|
|
4006
|
+
chain: n.chain,
|
|
4007
|
+
ticker: n.ticker,
|
|
4008
|
+
basisPoints: Math.min(1e4, Math.round(a * 100)),
|
|
4009
|
+
targetAssetString: o == null ? void 0 : o.toString(),
|
|
4010
|
+
singleSide: !1
|
|
4011
|
+
});
|
|
4012
|
+
return f(this, v).call(this, { assetValue: p, memo: d });
|
|
3537
4013
|
});
|
|
3538
|
-
|
|
4014
|
+
T(this, "savings", async ({
|
|
3539
4015
|
assetValue: t,
|
|
3540
4016
|
memo: n,
|
|
3541
4017
|
percent: a,
|
|
3542
|
-
type:
|
|
4018
|
+
type: s
|
|
3543
4019
|
}) => {
|
|
3544
|
-
const r =
|
|
4020
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || M(r, {
|
|
3545
4021
|
ticker: t.ticker,
|
|
3546
4022
|
symbol: t.symbol,
|
|
3547
4023
|
chain: t.chain,
|
|
3548
4024
|
singleSide: !0,
|
|
3549
|
-
basisPoints: a ? Math.
|
|
3550
|
-
});
|
|
3551
|
-
return
|
|
4025
|
+
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
4026
|
+
}), p = r === h.DEPOSIT ? t : ue(t.chain);
|
|
4027
|
+
return f(this, v).call(this, { memo: o, assetValue: p });
|
|
3552
4028
|
});
|
|
3553
|
-
|
|
4029
|
+
T(this, "loan", ({
|
|
3554
4030
|
assetValue: t,
|
|
3555
4031
|
memo: n,
|
|
3556
4032
|
minAmount: a,
|
|
3557
|
-
type:
|
|
3558
|
-
}) =>
|
|
4033
|
+
type: s
|
|
4034
|
+
}) => f(this, v).call(this, {
|
|
3559
4035
|
assetValue: t,
|
|
3560
|
-
memo: n ||
|
|
4036
|
+
memo: n || M(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3561
4037
|
asset: t.toString(),
|
|
3562
4038
|
minAmount: a.toString(),
|
|
3563
4039
|
address: this.getAddress(t.chain)
|
|
3564
4040
|
})
|
|
3565
4041
|
}));
|
|
3566
|
-
|
|
4042
|
+
T(this, "nodeAction", ({
|
|
3567
4043
|
type: t,
|
|
3568
4044
|
assetValue: n,
|
|
3569
4045
|
address: a
|
|
3570
4046
|
}) => {
|
|
3571
|
-
const
|
|
4047
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = M(s, {
|
|
3572
4048
|
address: a,
|
|
3573
|
-
unbondAmount: t === "unbond" ? n.
|
|
4049
|
+
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
3574
4050
|
});
|
|
3575
|
-
return
|
|
4051
|
+
return f(this, X).call(this, {
|
|
3576
4052
|
memo: r,
|
|
3577
|
-
assetValue: t === "bond" ? n :
|
|
4053
|
+
assetValue: t === "bond" ? n : ue(i.THORChain)
|
|
3578
4054
|
});
|
|
3579
4055
|
});
|
|
3580
|
-
|
|
4056
|
+
T(this, "registerThorname", ({
|
|
3581
4057
|
assetValue: t,
|
|
3582
4058
|
...n
|
|
3583
|
-
}) =>
|
|
3584
|
-
|
|
4059
|
+
}) => f(this, X).call(this, { assetValue: t, memo: M(h.THORNAME_REGISTER, n) }));
|
|
4060
|
+
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3585
4061
|
try {
|
|
3586
4062
|
t.forEach((r) => {
|
|
3587
4063
|
this[r.connectMethodName] = r.connect({
|
|
3588
|
-
addChain:
|
|
4064
|
+
addChain: f(this, ae),
|
|
3589
4065
|
config: n || {},
|
|
3590
4066
|
apis: a,
|
|
3591
|
-
rpcUrls:
|
|
4067
|
+
rpcUrls: s
|
|
3592
4068
|
});
|
|
3593
4069
|
});
|
|
3594
4070
|
} catch (r) {
|
|
3595
4071
|
throw new c("core_extend_error", r);
|
|
3596
4072
|
}
|
|
3597
4073
|
});
|
|
3598
|
-
|
|
4074
|
+
T(this, "estimateMaxSendableAmount", async ({
|
|
3599
4075
|
chain: t,
|
|
3600
4076
|
params: n
|
|
3601
4077
|
}) => {
|
|
3602
4078
|
const a = this.getWallet(t);
|
|
3603
4079
|
switch (t) {
|
|
3604
|
-
case
|
|
3605
|
-
case
|
|
3606
|
-
case
|
|
3607
|
-
case
|
|
3608
|
-
case
|
|
3609
|
-
case
|
|
3610
|
-
const { estimateMaxSendableAmount:
|
|
3611
|
-
return
|
|
4080
|
+
case i.Arbitrum:
|
|
4081
|
+
case i.Avalanche:
|
|
4082
|
+
case i.BinanceSmartChain:
|
|
4083
|
+
case i.Ethereum:
|
|
4084
|
+
case i.Optimism:
|
|
4085
|
+
case i.Polygon: {
|
|
4086
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-evm");
|
|
4087
|
+
return s({
|
|
3612
4088
|
...n,
|
|
3613
4089
|
toolbox: a
|
|
3614
4090
|
});
|
|
3615
4091
|
}
|
|
3616
|
-
case
|
|
3617
|
-
case
|
|
3618
|
-
case
|
|
3619
|
-
case
|
|
4092
|
+
case i.Bitcoin:
|
|
4093
|
+
case i.BitcoinCash:
|
|
4094
|
+
case i.Dogecoin:
|
|
4095
|
+
case i.Litecoin:
|
|
3620
4096
|
return a.estimateMaxSendableAmount(n);
|
|
3621
|
-
case
|
|
3622
|
-
case
|
|
3623
|
-
case
|
|
3624
|
-
const { estimateMaxSendableAmount:
|
|
3625
|
-
return
|
|
4097
|
+
case i.Binance:
|
|
4098
|
+
case i.THORChain:
|
|
4099
|
+
case i.Cosmos: {
|
|
4100
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-cosmos");
|
|
4101
|
+
return s({
|
|
3626
4102
|
...n,
|
|
3627
4103
|
toolbox: a
|
|
3628
4104
|
});
|
|
@@ -3634,99 +4110,99 @@ class zt {
|
|
|
3634
4110
|
/**
|
|
3635
4111
|
* Wallet connection methods
|
|
3636
4112
|
*/
|
|
3637
|
-
|
|
4113
|
+
T(this, "connectXDEFI", async (t) => {
|
|
3638
4114
|
throw new c("core_wallet_xdefi_not_installed");
|
|
3639
4115
|
});
|
|
3640
|
-
|
|
4116
|
+
T(this, "connectEVMWallet", async (t, n) => {
|
|
3641
4117
|
throw new c("core_wallet_evmwallet_not_installed");
|
|
3642
4118
|
});
|
|
3643
|
-
|
|
4119
|
+
T(this, "connectWalletconnect", async (t, n) => {
|
|
3644
4120
|
throw new c("core_wallet_walletconnect_not_installed");
|
|
3645
4121
|
});
|
|
3646
|
-
|
|
4122
|
+
T(this, "connectKeystore", async (t, n) => {
|
|
3647
4123
|
throw new c("core_wallet_keystore_not_installed");
|
|
3648
4124
|
});
|
|
3649
|
-
|
|
4125
|
+
T(this, "connectLedger", async (t, n) => {
|
|
3650
4126
|
throw new c("core_wallet_ledger_not_installed");
|
|
3651
4127
|
});
|
|
3652
|
-
|
|
4128
|
+
T(this, "connectTrezor", async (t, n) => {
|
|
3653
4129
|
throw new c("core_wallet_trezor_not_installed");
|
|
3654
4130
|
});
|
|
3655
|
-
|
|
4131
|
+
T(this, "connectKeplr", async (t) => {
|
|
3656
4132
|
throw new c("core_wallet_keplr_not_installed");
|
|
3657
4133
|
});
|
|
3658
|
-
|
|
4134
|
+
T(this, "connectOkx", async (t) => {
|
|
3659
4135
|
throw new c("core_wallet_okx_not_installed");
|
|
3660
4136
|
});
|
|
3661
|
-
|
|
4137
|
+
T(this, "disconnectChain", (t) => {
|
|
3662
4138
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
3663
4139
|
});
|
|
3664
|
-
|
|
3665
|
-
if (t ===
|
|
4140
|
+
P(this, V, async (t) => {
|
|
4141
|
+
if (t === i.THORChain)
|
|
3666
4142
|
return {
|
|
3667
4143
|
gas_rate: "0",
|
|
3668
4144
|
router: "0",
|
|
3669
4145
|
address: "",
|
|
3670
4146
|
halted: !1,
|
|
3671
|
-
chain:
|
|
4147
|
+
chain: i.THORChain
|
|
3672
4148
|
};
|
|
3673
|
-
const a = (await
|
|
4149
|
+
const a = (await cn(this.stagenet)).find((s) => s.chain === t);
|
|
3674
4150
|
if (!a)
|
|
3675
4151
|
throw new c("core_inbound_data_not_found");
|
|
3676
4152
|
if (a != null && a.halted)
|
|
3677
4153
|
throw new c("core_chain_halted");
|
|
3678
4154
|
return a;
|
|
3679
4155
|
});
|
|
3680
|
-
|
|
4156
|
+
P(this, ae, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
3681
4157
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
3682
4158
|
});
|
|
3683
|
-
|
|
3684
|
-
assetValue:
|
|
3685
|
-
type:
|
|
3686
|
-
contractAddress:
|
|
4159
|
+
P(this, K, async ({
|
|
4160
|
+
assetValue: t,
|
|
4161
|
+
type: n = "checkOnly",
|
|
4162
|
+
contractAddress: a
|
|
3687
4163
|
}) => {
|
|
3688
|
-
const
|
|
3689
|
-
if (
|
|
4164
|
+
const { address: s, chain: r, isGasAsset: o, isSynthetic: p } = t, d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(r);
|
|
4165
|
+
if (d && o || !d || p)
|
|
3690
4166
|
return !0;
|
|
3691
|
-
const u = this.connectedWallets[
|
|
3692
|
-
if (!
|
|
4167
|
+
const u = this.connectedWallets[r], m = n === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
|
|
4168
|
+
if (!m)
|
|
3693
4169
|
throw new c("core_wallet_connection_not_found");
|
|
3694
|
-
const
|
|
3695
|
-
if (!
|
|
4170
|
+
const _ = this.getAddress(r);
|
|
4171
|
+
if (!s || !_)
|
|
3696
4172
|
throw new c("core_approve_asset_address_or_from_not_found");
|
|
3697
|
-
const
|
|
3698
|
-
return
|
|
3699
|
-
amount: t,
|
|
3700
|
-
assetAddress:
|
|
3701
|
-
from:
|
|
3702
|
-
spenderAddress:
|
|
4173
|
+
const b = a || (await f(this, V).call(this, r)).router;
|
|
4174
|
+
return m({
|
|
4175
|
+
amount: t.getBaseValue("bigint"),
|
|
4176
|
+
assetAddress: s,
|
|
4177
|
+
from: _,
|
|
4178
|
+
spenderAddress: b
|
|
3703
4179
|
});
|
|
3704
4180
|
});
|
|
3705
|
-
|
|
4181
|
+
P(this, v, async ({
|
|
3706
4182
|
assetValue: t,
|
|
3707
4183
|
memo: n,
|
|
3708
|
-
feeOptionKey: a =
|
|
4184
|
+
feeOptionKey: a = F.Fast
|
|
3709
4185
|
}) => {
|
|
3710
4186
|
const {
|
|
3711
|
-
gas_rate:
|
|
4187
|
+
gas_rate: s,
|
|
3712
4188
|
router: r,
|
|
3713
|
-
address:
|
|
3714
|
-
} = await
|
|
4189
|
+
address: o
|
|
4190
|
+
} = await f(this, V).call(this, t.chain), p = (parseInt(s) || 0) * bt[a];
|
|
3715
4191
|
return this.deposit({
|
|
3716
4192
|
assetValue: t,
|
|
3717
|
-
recipient:
|
|
4193
|
+
recipient: o,
|
|
3718
4194
|
memo: n,
|
|
3719
4195
|
router: r,
|
|
3720
|
-
feeRate:
|
|
4196
|
+
feeRate: p
|
|
3721
4197
|
});
|
|
3722
4198
|
});
|
|
3723
|
-
|
|
3724
|
-
const a = await
|
|
4199
|
+
P(this, X, async ({ memo: t, assetValue: n }) => {
|
|
4200
|
+
const a = await mn(this.stagenet);
|
|
3725
4201
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
3726
4202
|
throw new c("core_chain_halted");
|
|
3727
4203
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
3728
4204
|
});
|
|
3729
|
-
|
|
4205
|
+
P(this, Y, ({ assetValue: t, ...n }) => ({
|
|
3730
4206
|
...n,
|
|
3731
4207
|
memo: n.memo || "",
|
|
3732
4208
|
from: this.getAddress(t.chain),
|
|
@@ -3735,65 +4211,67 @@ class zt {
|
|
|
3735
4211
|
this.stagenet = !!t;
|
|
3736
4212
|
}
|
|
3737
4213
|
}
|
|
3738
|
-
|
|
4214
|
+
V = new WeakMap(), ae = new WeakMap(), K = new WeakMap(), v = new WeakMap(), X = new WeakMap(), Y = new WeakMap();
|
|
3739
4215
|
export {
|
|
3740
|
-
|
|
3741
|
-
|
|
4216
|
+
ze as AGG_SWAP,
|
|
4217
|
+
Se as ApiError,
|
|
3742
4218
|
W as ApiUrl,
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
4219
|
+
x as AssetValue,
|
|
4220
|
+
A as BaseDecimal,
|
|
4221
|
+
He as BigIntArithmetics,
|
|
4222
|
+
i as Chain,
|
|
4223
|
+
_e as ChainId,
|
|
4224
|
+
Rn as ChainIdToChain,
|
|
4225
|
+
ot as ChainToChainId,
|
|
4226
|
+
Ce as ChainToExplorerUrl,
|
|
4227
|
+
En as ChainToHexChainId,
|
|
4228
|
+
pt as ChainToRPC,
|
|
4229
|
+
at as ContractAddress,
|
|
4230
|
+
wn as CosmosChainList,
|
|
4231
|
+
st as DerivationPath,
|
|
4232
|
+
y as ERROR_CODE,
|
|
4233
|
+
tt as ERROR_MODULE,
|
|
4234
|
+
Ie as ERROR_TYPE,
|
|
4235
|
+
it as EVMChainList,
|
|
4236
|
+
dt as ErrorCode,
|
|
4237
|
+
F as FeeOption,
|
|
4238
|
+
h as MemoType,
|
|
4239
|
+
fn as NetworkDerivationPath,
|
|
4240
|
+
Qe as QuoteMode,
|
|
4241
|
+
ve as RPCUrl,
|
|
4242
|
+
we as RequestClient,
|
|
4243
|
+
Ze as SWAP_IN,
|
|
4244
|
+
et as SWAP_OUT,
|
|
4245
|
+
Pn as SwapKitCore,
|
|
3769
4246
|
c as SwapKitError,
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
4247
|
+
N as SwapKitNumber,
|
|
4248
|
+
Ye as TCAvalancheDepositABI,
|
|
4249
|
+
Je as TCBscDepositABI,
|
|
4250
|
+
Xe as TCEthereumVaultAbi,
|
|
4251
|
+
An as TCSupportedChainList,
|
|
4252
|
+
bn as UTXOChainList,
|
|
4253
|
+
ut as WalletOption,
|
|
4254
|
+
gn as assetFromString,
|
|
4255
|
+
Dn as derivationPathToString,
|
|
4256
|
+
_n as erc20ABI,
|
|
4257
|
+
On as filterAssets,
|
|
4258
|
+
ie as formatBigIntToSafeValue,
|
|
4259
|
+
bt as gasFeeMultiplier,
|
|
4260
|
+
At as getAssetType,
|
|
4261
|
+
Ot as getAsymmetricAssetShare,
|
|
4262
|
+
Sn as getAsymmetricAssetWithdrawAmount,
|
|
4263
|
+
gt as getAsymmetricRuneShare,
|
|
4264
|
+
In as getAsymmetricRuneWithdrawAmount,
|
|
4265
|
+
wt as getCommonAssetInfo,
|
|
4266
|
+
ft as getDecimal,
|
|
4267
|
+
Cn as getEstimatedPoolShare,
|
|
4268
|
+
Mn as getLiquiditySlippage,
|
|
4269
|
+
M as getMemoFor,
|
|
4270
|
+
ue as getMinAmountByChain,
|
|
4271
|
+
It as getSymmetricPoolShare,
|
|
4272
|
+
vn as getSymmetricWithdraw,
|
|
4273
|
+
Nn as getTHORNameCost,
|
|
4274
|
+
Ne as isGasAsset,
|
|
4275
|
+
xn as validateTHORName
|
|
3799
4276
|
};
|
|
4277
|
+
//# sourceMappingURL=index.es.js.map
|