@swapkit/core 1.0.0-rc.13 → 1.0.0-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.es.js +1008 -678
- package/package.json +13 -13
- package/src/client/thornode.ts +3 -3
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (e, t, n) => (
|
|
1
|
+
var Ge = Object.defineProperty;
|
|
2
|
+
var We = (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) => (We(e, typeof t != "symbol" ? t + "" : t, n), n), qe = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var f = (e, t, n) => (
|
|
7
|
+
var f = (e, t, n) => (qe(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
const
|
|
12
|
+
var je = Object.defineProperty, Ye = (e, t, n) => t in e ? je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (Ye(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
+
const cn = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -108,7 +108,7 @@ const Lt = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Ke = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const Lt = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Xe = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const Lt = [
|
|
|
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 Lt = [
|
|
|
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 ve = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(ve || {}), tt = /* @__PURE__ */ ((e) => (e.HEALTH_CONTROLLER = "1000", e.LIQUIDITY_CONTROLLER = "1001", e.PROVIDER_CONTROLLER = "1002", e.QUOTE_CONTROLLER = "1003", e.SWAP_CONTROLLER = "1004", e.UTIL_CONTROLLER = "1005", e.AIRDROP_CONTROLLER = "1006", e.PROVIDER = "2000", e.ASSET = "2001", e.TOKEN_LIST = "2002", e.QUOTE = "2100", e.QUOTE_TXN_DETAILS = "2101", e.THORCHAIN_PROVIDER = "3000", e.UNISWAPV2_ETH_PROVIDER = "3001", e.UNISWAPV3_ETH_PROVIDER = "3002", e.SUSHISWAP_ETH_PROVIDER = "3003", e.PANCAKESWAP_BSC_PROVIDER = "3004", e.PANCAKESWAP_ETH_PROVIDER = "3005", e.ONEINCH_ETH_PROVIDER = "3006", e.ONEINCH_BSC_PROVIDER = "3007", e.ONEINCH_AVAX_PROVIDER = "3008", e.ZEROX_ETH_PROVIDER = "3009", e.WOOFI_AVAX_PROVIDER = "3010", e.PANGOLIN_AVAX_PROVIDER = "3011", e.TRADERJOE_AVAX_PROVIDER = "3012", e.KYBER_ETH_PROVIDER = "3013", e.KYBER_AVAX_PROVIDER = "3014", e.WOOFI_BSC_PROVIDER = "3015", e.STARGATE_PROVIDER = "3016", e.PROVIDER_UTIL = "4000", e.TXN_DETAILS = "5000", e.AIRDROP_UTIL = "6000", e))(tt || {}), l = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(l || {});
|
|
628
|
+
const nt = {
|
|
629
|
+
[l.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
|
+
[l.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
|
+
[l.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
632
|
+
[l.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
|
|
633
|
+
[l.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
|
|
634
|
+
[l.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
|
|
635
|
+
[l.INVALID_TYPE_GENERIC]: "Invalid type",
|
|
636
|
+
[l.INVALID_NUMBER_STRING]: "Invalid number string.",
|
|
637
|
+
[l.INVALID_NUMBER]: "Invalid number.",
|
|
638
|
+
[l.INVALID_BOOLEAN]: "Invalid boolean.",
|
|
639
|
+
[l.INVALID_OBJECT]: "Invalid object.",
|
|
640
|
+
[l.INVALID_ARRAY]: "Invalid array.",
|
|
641
|
+
[l.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
|
|
642
|
+
[l.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
|
|
643
|
+
[l.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
|
|
644
|
+
[l.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
|
|
645
|
+
[l.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
|
|
646
|
+
[l.AFF_BPS_INTEGER_0_100]: "affiliateBasisPoints must be an integer between 0 and 100.",
|
|
647
|
+
[l.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
|
|
648
|
+
[l.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
|
|
649
|
+
[l.PREFERRED_PROFVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
|
|
650
|
+
[l.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
|
|
651
|
+
[l.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
|
|
652
|
+
[l.INVALID_PROVIDER]: "Invalid provider {0}.",
|
|
653
|
+
[l.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
|
|
654
|
+
[l.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
|
|
655
|
+
[l.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
|
|
656
|
+
[l.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
|
|
657
|
+
[l.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
|
|
658
|
+
[l.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
|
|
659
|
+
[l.INVALID_CHAIN]: "Invalid chain {0}.",
|
|
660
|
+
[l.INVALID_ASSET]: "Invalid asset {0}.",
|
|
661
|
+
[l.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
|
|
662
|
+
[l.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
|
|
663
|
+
[l.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
|
|
664
|
+
[l.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
|
|
665
|
+
[l.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
|
|
666
|
+
[l.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
|
|
667
|
+
[l.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
|
|
668
|
+
[l.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
|
|
669
|
+
[l.INVALID_QUOTE_MODE]: "Invalid quote mode.",
|
|
670
|
+
[l.NO_QUOTES]: "No quotes to service this request.",
|
|
671
|
+
[l.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
|
|
672
|
+
[l.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
|
|
673
|
+
[l.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
|
|
674
|
+
[l.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
|
|
675
|
+
[l.NO_PRICE]: "No price for asset {0}.",
|
|
676
|
+
[l.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
|
+
[l.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
|
+
[l.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
|
+
}, ae = (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
|
+
let mn = class Ce 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: u, shouldTrace: y } = {
|
|
694
694
|
shouldLog: !0,
|
|
695
695
|
shouldThrow: !0,
|
|
696
696
|
shouldTrace: !0
|
|
697
697
|
},
|
|
698
|
-
displayMessageParams:
|
|
698
|
+
displayMessageParams: d
|
|
699
699
|
}) {
|
|
700
|
-
const c = r ||
|
|
701
|
-
super(c),
|
|
702
|
-
shouldLog:
|
|
703
|
-
shouldTrace:
|
|
704
|
-
shouldThrow:
|
|
705
|
-
}, this.displayMessageParams =
|
|
700
|
+
const c = r || ae(s, d || []) || "";
|
|
701
|
+
super(c), 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 = c, this.display = ae(s, d || []), this.code = s, this.type = o || ve.UNHANDLED_ERROR, this.options = {
|
|
702
|
+
shouldLog: p || !0,
|
|
703
|
+
shouldTrace: y || !0,
|
|
704
|
+
shouldThrow: u || !1
|
|
705
|
+
}, this.displayMessageParams = d || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new Ce(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ class be extends Error {
|
|
|
714
714
|
return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
|
|
715
715
|
}
|
|
716
716
|
get displayMessage() {
|
|
717
|
-
return
|
|
717
|
+
return ae(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -723,9 +723,9 @@ class be extends Error {
|
|
|
723
723
|
throw Error(t, { cause: this.stack });
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
|
-
}
|
|
727
|
-
var
|
|
728
|
-
const
|
|
726
|
+
};
|
|
727
|
+
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), at = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(at || {}), st = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(st || {});
|
|
728
|
+
const Tn = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
731
731
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -743,7 +743,7 @@ const Ut = {
|
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
745
|
var b = /* @__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))(b || {});
|
|
746
|
-
const
|
|
746
|
+
const hn = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
749
749
|
"BSC",
|
|
@@ -751,38 +751,38 @@ const Ht = [
|
|
|
751
751
|
"OP",
|
|
752
752
|
"MATIC"
|
|
753
753
|
/* Polygon */
|
|
754
|
-
],
|
|
754
|
+
], _n = [
|
|
755
755
|
"BTC",
|
|
756
756
|
"BCH",
|
|
757
757
|
"DOGE",
|
|
758
758
|
"LTC"
|
|
759
759
|
/* Litecoin */
|
|
760
|
-
],
|
|
760
|
+
], fn = [
|
|
761
761
|
"GAIA",
|
|
762
762
|
"THOR",
|
|
763
763
|
"BNB"
|
|
764
764
|
/* Binance */
|
|
765
765
|
];
|
|
766
|
-
var
|
|
767
|
-
const
|
|
766
|
+
var he = /* @__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))(he || {}), Me = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Me || {}), W = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(W || {});
|
|
767
|
+
const ne = Object.values(i), it = Object.keys(i), _e = ne.reduce(
|
|
768
768
|
(e, t) => {
|
|
769
|
-
const n =
|
|
769
|
+
const n = it.find((a) => i[a] === t);
|
|
770
770
|
return n && (e[t] = n), e;
|
|
771
771
|
},
|
|
772
772
|
{}
|
|
773
|
-
),
|
|
774
|
-
(e, t) => (e[t] =
|
|
773
|
+
), rt = ne.reduce(
|
|
774
|
+
(e, t) => (e[t] = he[_e[t]], e),
|
|
775
775
|
{}
|
|
776
|
-
),
|
|
777
|
-
(e, t) => (e[t] =
|
|
776
|
+
), ot = ne.reduce(
|
|
777
|
+
(e, t) => (e[t] = Me[_e[t]], e),
|
|
778
778
|
{}
|
|
779
|
-
),
|
|
779
|
+
), bn = ne.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
|
-
const n = `${
|
|
782
|
-
return e[t] =
|
|
781
|
+
const n = `${_e[t]}Hex`;
|
|
782
|
+
return e[t] = he[n], e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
785
|
+
), wn = {
|
|
786
786
|
"0xa4b1": "ARB",
|
|
787
787
|
42161: "ARB",
|
|
788
788
|
"0xa86a": "AVAX",
|
|
@@ -807,7 +807,7 @@ const Z = Object.values(s), qe = Object.keys(s), le = Z.reduce(
|
|
|
807
807
|
"thorchain-stagenet-v2": "THOR",
|
|
808
808
|
"thorchain-mainnet-v1": "THOR"
|
|
809
809
|
/* THORChain */
|
|
810
|
-
},
|
|
810
|
+
}, Ne = {
|
|
811
811
|
ARB: "https://arbiscan.io",
|
|
812
812
|
AVAX: "https://snowtrace.io",
|
|
813
813
|
BSC: "https://bscscan.com",
|
|
@@ -824,320 +824,651 @@ const Z = Object.values(s), qe = Object.keys(s), le = Z.reduce(
|
|
|
824
824
|
MATIC: "https://polygonscan.com",
|
|
825
825
|
THOR: "https://viewblock.io/thorchain"
|
|
826
826
|
};
|
|
827
|
-
var
|
|
827
|
+
var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), $ = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))($ || {}), dt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(dt || {}), ut = Object.defineProperty, lt = (e, t, n) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, M = (e, t, n) => (lt(e, typeof t != "symbol" ? t + "" : t, n), n), yt = (e, t, n) => {
|
|
828
828
|
if (!t.has(e))
|
|
829
829
|
throw TypeError("Cannot " + n);
|
|
830
830
|
}, V = (e, t, n) => {
|
|
831
831
|
if (t.has(e))
|
|
832
832
|
throw TypeError("Cannot add the same private member more than once");
|
|
833
833
|
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
|
-
}, qt = (e) => {
|
|
840
|
-
if (e.length > 30)
|
|
841
|
-
return !1;
|
|
842
|
-
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
843
|
-
return !!e.match(t);
|
|
844
|
-
}, Kt = ([e, t, n, a, i]) => `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`, Ee = 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", Re = async ({ chain: e, to: t }) => {
|
|
834
|
+
}, O = (e, t, n) => (yt(e, t, "access private method"), n);
|
|
835
|
+
const ct = "0x313ce567", xe = async ({ chain: e, to: t }) => {
|
|
870
836
|
try {
|
|
871
|
-
const n = await
|
|
872
|
-
|
|
873
|
-
JSON.stringify({
|
|
874
|
-
method: "eth_call",
|
|
875
|
-
params: [{ to: t.toLowerCase(), data: et }, "latest"],
|
|
837
|
+
const { result: n } = await be.post(ot[e], {
|
|
838
|
+
headers: { accept: "*/*", "cache-control": "no-cache" },
|
|
839
|
+
body: JSON.stringify({
|
|
876
840
|
id: 44,
|
|
877
|
-
jsonrpc: "2.0"
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
return parseInt(BigInt(
|
|
841
|
+
jsonrpc: "2.0",
|
|
842
|
+
method: "eth_call",
|
|
843
|
+
params: [{ to: t.toLowerCase(), data: ct }, "latest"]
|
|
844
|
+
})
|
|
845
|
+
});
|
|
846
|
+
return parseInt(BigInt(n).toString());
|
|
883
847
|
} catch (n) {
|
|
884
848
|
return console.error(n), b[e];
|
|
885
849
|
}
|
|
886
|
-
},
|
|
887
|
-
if (e ===
|
|
850
|
+
}, mt = async (e) => {
|
|
851
|
+
if (e === i.Ethereum)
|
|
888
852
|
return b.ETH;
|
|
889
853
|
const [, t] = e.split("-");
|
|
890
|
-
return t != null && t.startsWith("0x") ?
|
|
891
|
-
},
|
|
854
|
+
return t != null && t.startsWith("0x") ? xe({ chain: i.Ethereum, to: t }) : b.ETH;
|
|
855
|
+
}, Tt = async (e) => {
|
|
892
856
|
const [, t] = e.split("-");
|
|
893
|
-
return t != null && t.startsWith("0x") ?
|
|
894
|
-
},
|
|
857
|
+
return t != null && t.startsWith("0x") ? xe({ chain: i.Avalanche, to: t.toLowerCase() }) : b.AVAX;
|
|
858
|
+
}, ht = async (e) => (e === i.BinanceSmartChain, b.BSC), De = async ({ chain: e, symbol: t }) => {
|
|
895
859
|
switch (e) {
|
|
896
|
-
case
|
|
897
|
-
return
|
|
898
|
-
case
|
|
899
|
-
return
|
|
900
|
-
case
|
|
901
|
-
return
|
|
860
|
+
case i.Ethereum:
|
|
861
|
+
return mt(t);
|
|
862
|
+
case i.Avalanche:
|
|
863
|
+
return Tt(t);
|
|
864
|
+
case i.BinanceSmartChain:
|
|
865
|
+
return ht(t);
|
|
902
866
|
default:
|
|
903
867
|
return b[e];
|
|
904
868
|
}
|
|
905
|
-
},
|
|
906
|
-
[
|
|
907
|
-
[
|
|
908
|
-
[
|
|
909
|
-
},
|
|
869
|
+
}, _t = {
|
|
870
|
+
[$.Average]: 1.2,
|
|
871
|
+
[$.Fast]: 1.5,
|
|
872
|
+
[$.Fastest]: 2
|
|
873
|
+
}, ft = ({ chain: e, symbol: t }) => {
|
|
910
874
|
switch (e) {
|
|
911
|
-
case
|
|
912
|
-
case
|
|
913
|
-
case
|
|
914
|
-
case
|
|
915
|
-
case
|
|
916
|
-
case
|
|
917
|
-
case
|
|
875
|
+
case i.Bitcoin:
|
|
876
|
+
case i.BitcoinCash:
|
|
877
|
+
case i.Litecoin:
|
|
878
|
+
case i.Dogecoin:
|
|
879
|
+
case i.Binance:
|
|
880
|
+
case i.Ethereum:
|
|
881
|
+
case i.Avalanche:
|
|
918
882
|
return t === e;
|
|
919
|
-
case
|
|
920
|
-
case
|
|
883
|
+
case i.Arbitrum:
|
|
884
|
+
case i.Optimism:
|
|
921
885
|
return t === "ETH";
|
|
922
|
-
case
|
|
886
|
+
case i.Maya:
|
|
923
887
|
return t === "CACAO";
|
|
924
|
-
case
|
|
888
|
+
case i.Kujira:
|
|
925
889
|
return t === "KUJI";
|
|
926
|
-
case
|
|
890
|
+
case i.Cosmos:
|
|
927
891
|
return t === "ATOM";
|
|
928
|
-
case
|
|
892
|
+
case i.Polygon:
|
|
929
893
|
return t === "MATIC";
|
|
930
|
-
case
|
|
894
|
+
case i.BinanceSmartChain:
|
|
931
895
|
return t === "BNB";
|
|
932
|
-
case
|
|
896
|
+
case i.THORChain:
|
|
933
897
|
return t === "RUNE";
|
|
934
898
|
}
|
|
935
|
-
},
|
|
899
|
+
}, bt = (e) => {
|
|
936
900
|
switch (e) {
|
|
937
901
|
case "ETH.THOR":
|
|
938
902
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
939
903
|
case "ETH.vTHOR":
|
|
940
904
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
941
|
-
case
|
|
905
|
+
case i.Cosmos:
|
|
942
906
|
return { identifier: "GAIA.ATOM", decimal: b[e] };
|
|
943
|
-
case
|
|
907
|
+
case i.THORChain:
|
|
944
908
|
return { identifier: "THOR.RUNE", decimal: b[e] };
|
|
945
|
-
case
|
|
909
|
+
case i.BinanceSmartChain:
|
|
946
910
|
return { identifier: "BSC.BNB", decimal: b[e] };
|
|
947
|
-
case
|
|
911
|
+
case i.Maya:
|
|
948
912
|
return { identifier: "MAYA.CACAO", decimal: b.MAYA };
|
|
949
913
|
case "MAYA.MAYA":
|
|
950
914
|
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
|
|
915
|
+
case i.Kujira:
|
|
916
|
+
case i.Arbitrum:
|
|
917
|
+
case i.Optimism:
|
|
918
|
+
case i.BitcoinCash:
|
|
919
|
+
case i.Litecoin:
|
|
920
|
+
case i.Dogecoin:
|
|
921
|
+
case i.Binance:
|
|
922
|
+
case i.Avalanche:
|
|
923
|
+
case i.Polygon:
|
|
924
|
+
case i.Bitcoin:
|
|
925
|
+
case i.Ethereum:
|
|
962
926
|
return { identifier: `${e}.${e}`, decimal: b[e] };
|
|
963
927
|
}
|
|
964
|
-
},
|
|
928
|
+
}, wt = ({ chain: e, symbol: t }) => {
|
|
965
929
|
if (t.includes("/"))
|
|
966
930
|
return "Synth";
|
|
967
931
|
switch (e) {
|
|
968
|
-
case
|
|
969
|
-
case
|
|
970
|
-
case
|
|
971
|
-
case
|
|
972
|
-
case
|
|
973
|
-
case
|
|
932
|
+
case i.Bitcoin:
|
|
933
|
+
case i.BitcoinCash:
|
|
934
|
+
case i.Dogecoin:
|
|
935
|
+
case i.Litecoin:
|
|
936
|
+
case i.Maya:
|
|
937
|
+
case i.THORChain:
|
|
974
938
|
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
|
-
},
|
|
939
|
+
case i.Cosmos:
|
|
940
|
+
return t === "ATOM" ? "Native" : i.Cosmos;
|
|
941
|
+
case i.Kujira:
|
|
942
|
+
return t === i.Kujira ? "Native" : i.Kujira;
|
|
943
|
+
case i.Binance:
|
|
944
|
+
return t === i.Binance ? "Native" : "BEP2";
|
|
945
|
+
case i.BinanceSmartChain:
|
|
946
|
+
return t === i.Binance ? "Native" : "BEP20";
|
|
947
|
+
case i.Ethereum:
|
|
948
|
+
return t === i.Ethereum ? "Native" : "ERC20";
|
|
949
|
+
case i.Avalanche:
|
|
950
|
+
return t === i.Avalanche ? "Native" : i.Avalanche;
|
|
951
|
+
case i.Polygon:
|
|
952
|
+
return t === i.Polygon ? "Native" : "POLYGON";
|
|
953
|
+
case i.Arbitrum:
|
|
954
|
+
return [i.Ethereum, i.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
955
|
+
case i.Optimism:
|
|
956
|
+
return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
957
|
+
}
|
|
958
|
+
}, An = (e) => {
|
|
995
959
|
var t;
|
|
996
|
-
const [n, ...a] = e.split("."),
|
|
997
|
-
return { chain: n, symbol: r, ticker:
|
|
998
|
-
},
|
|
960
|
+
const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."), o = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
961
|
+
return { chain: n, symbol: r, ticker: o, synth: s };
|
|
962
|
+
}, At = new RegExp(
|
|
999
963
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
1000
964
|
"gmi"
|
|
1001
|
-
),
|
|
1002
|
-
(t) => !
|
|
1003
|
-
),
|
|
965
|
+
), En = (e) => e.filter(
|
|
966
|
+
(t) => !At.test(t.toString()) && !t.toString().includes("undefined")
|
|
967
|
+
), Et = ({
|
|
1004
968
|
liquidityUnits: e,
|
|
1005
969
|
poolUnits: t,
|
|
1006
970
|
runeDepth: n
|
|
1007
971
|
}) => {
|
|
1008
|
-
const a =
|
|
1009
|
-
return
|
|
1010
|
-
},
|
|
972
|
+
const a = w(e), s = w(t), r = w(n), o = a.mul(r), p = s.mul(s).mul(2), u = s.mul(a).mul(2), y = a.mul(a), d = s.mul(s).mul(s);
|
|
973
|
+
return o.mul(p.sub(u).add(y)).div(d);
|
|
974
|
+
}, Rt = ({
|
|
1011
975
|
liquidityUnits: e,
|
|
1012
976
|
poolUnits: t,
|
|
1013
977
|
assetDepth: n
|
|
1014
978
|
}) => {
|
|
1015
|
-
const a =
|
|
1016
|
-
return
|
|
1017
|
-
},
|
|
979
|
+
const a = w(e), s = w(t), r = w(n), o = a.mul(r), p = s.mul(s).mul(2), u = s.mul(a).mul(2), y = a.mul(a), d = o.mul(p.sub(u).add(y)), c = s.mul(s).mul(s);
|
|
980
|
+
return d.div(c);
|
|
981
|
+
}, Rn = ({
|
|
1018
982
|
percent: e,
|
|
1019
983
|
runeDepth: t,
|
|
1020
984
|
liquidityUnits: n,
|
|
1021
985
|
poolUnits: a
|
|
1022
|
-
}) =>
|
|
986
|
+
}) => Et({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), gn = ({
|
|
1023
987
|
percent: e,
|
|
1024
988
|
assetDepth: t,
|
|
1025
989
|
liquidityUnits: n,
|
|
1026
990
|
poolUnits: a
|
|
1027
|
-
}) =>
|
|
991
|
+
}) => Rt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), w = (e) => new Te({ value: e, decimal: b.THOR }), gt = ({
|
|
1028
992
|
liquidityUnits: e,
|
|
1029
993
|
poolUnits: t,
|
|
1030
994
|
runeDepth: n,
|
|
1031
995
|
assetDepth: a
|
|
1032
996
|
}) => ({
|
|
1033
|
-
assetAmount:
|
|
1034
|
-
runeAmount:
|
|
1035
|
-
}),
|
|
997
|
+
assetAmount: w(a).mul(e).div(t),
|
|
998
|
+
runeAmount: w(n).mul(e).div(t)
|
|
999
|
+
}), On = ({
|
|
1036
1000
|
liquidityUnits: e,
|
|
1037
1001
|
poolUnits: t,
|
|
1038
1002
|
runeDepth: n,
|
|
1039
1003
|
assetDepth: a,
|
|
1040
|
-
percent:
|
|
1004
|
+
percent: s
|
|
1041
1005
|
}) => Object.fromEntries(
|
|
1042
|
-
Object.entries(
|
|
1043
|
-
([r,
|
|
1006
|
+
Object.entries(gt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1007
|
+
([r, o]) => [r, o.mul(s)]
|
|
1044
1008
|
)
|
|
1045
|
-
),
|
|
1009
|
+
), In = ({
|
|
1046
1010
|
runeDepth: e,
|
|
1047
1011
|
poolUnits: t,
|
|
1048
1012
|
assetDepth: n,
|
|
1049
1013
|
liquidityUnits: a,
|
|
1050
|
-
runeAmount:
|
|
1014
|
+
runeAmount: s,
|
|
1051
1015
|
assetAmount: r
|
|
1052
1016
|
}) => {
|
|
1053
|
-
const
|
|
1017
|
+
const o = w(e), p = w(n), u = w(t), y = w(s), d = w(r), c = y.mul(p), _ = d.mul(o), A = y.mul(d), R = o.mul(p), g = u.mul(c.add(_.add(A.mul(2)))), E = c.add(_.add(R.mul(2))), I = g.div(E), S = w(a).add(I);
|
|
1054
1018
|
if (I.baseValueNumber === 0)
|
|
1055
|
-
return S.div(
|
|
1056
|
-
const D =
|
|
1019
|
+
return S.div(u).baseValueNumber;
|
|
1020
|
+
const D = u.add(S);
|
|
1057
1021
|
return S.div(D).baseValueNumber;
|
|
1058
|
-
},
|
|
1022
|
+
}, Sn = ({
|
|
1059
1023
|
runeAmount: e,
|
|
1060
1024
|
assetAmount: t,
|
|
1061
1025
|
runeDepth: n,
|
|
1062
1026
|
assetDepth: a
|
|
1063
1027
|
}) => {
|
|
1064
|
-
const
|
|
1065
|
-
return Math.abs(
|
|
1066
|
-
},
|
|
1028
|
+
const s = w(n), r = w(a), o = w(t), p = w(e), u = o.mul(s).sub(r.mul(p)), y = r.mul(p).add(s.mul(r));
|
|
1029
|
+
return Math.abs(u.div(y).baseValueNumber);
|
|
1030
|
+
}, Ot = ({
|
|
1067
1031
|
symbol: e,
|
|
1068
1032
|
ticker: t,
|
|
1069
1033
|
chain: n
|
|
1070
1034
|
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, x = (e, t) => {
|
|
1071
1035
|
switch (e) {
|
|
1072
|
-
case
|
|
1073
|
-
case
|
|
1036
|
+
case h.LEAVE:
|
|
1037
|
+
case h.BOND: {
|
|
1074
1038
|
const { address: n } = t;
|
|
1075
1039
|
return `${e}:${n}`;
|
|
1076
1040
|
}
|
|
1077
|
-
case
|
|
1041
|
+
case h.UNBOND: {
|
|
1078
1042
|
const { address: n, unbondAmount: a } = t;
|
|
1079
1043
|
return `${e}:${n}:${a * 10 ** 8}`;
|
|
1080
1044
|
}
|
|
1081
|
-
case
|
|
1082
|
-
const { name: n, chain: a, address:
|
|
1083
|
-
return `${e}:${n}:${a}:${
|
|
1045
|
+
case h.THORNAME_REGISTER: {
|
|
1046
|
+
const { name: n, chain: a, address: s, owner: r } = t;
|
|
1047
|
+
return `${e}:${n}:${a}:${s}${r ? `:${r}` : ""}`;
|
|
1084
1048
|
}
|
|
1085
|
-
case
|
|
1086
|
-
const { chain: n, symbol: a, address:
|
|
1087
|
-
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${
|
|
1049
|
+
case h.DEPOSIT: {
|
|
1050
|
+
const { chain: n, symbol: a, address: s, singleSide: r } = t;
|
|
1051
|
+
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${s || ""}:t:0`;
|
|
1088
1052
|
}
|
|
1089
|
-
case
|
|
1090
|
-
const { chain: n, ticker: a, symbol:
|
|
1091
|
-
return `${e}:${n}${
|
|
1053
|
+
case h.WITHDRAW: {
|
|
1054
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, u = !p && o ? `:${o}` : "", y = Ot({ chain: n, symbol: s, ticker: a });
|
|
1055
|
+
return `${e}:${n}${p ? "/" : "."}${y}:${r}${u}`;
|
|
1092
1056
|
}
|
|
1093
|
-
case
|
|
1094
|
-
case
|
|
1057
|
+
case h.OPEN_LOAN:
|
|
1058
|
+
case h.CLOSE_LOAN: {
|
|
1095
1059
|
const { asset: n, address: a } = t;
|
|
1096
1060
|
return `${e}:${n}:${a}`;
|
|
1097
1061
|
}
|
|
1098
1062
|
default:
|
|
1099
1063
|
return "";
|
|
1100
1064
|
}
|
|
1101
|
-
},
|
|
1065
|
+
}, vn = (e) => {
|
|
1066
|
+
if (e < 0)
|
|
1067
|
+
throw new Error("Invalid number of year");
|
|
1068
|
+
return 10 + e;
|
|
1069
|
+
}, Cn = (e) => {
|
|
1070
|
+
if (e.length > 30)
|
|
1071
|
+
return !1;
|
|
1072
|
+
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1073
|
+
return !!e.match(t);
|
|
1074
|
+
}, Mn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1075
|
+
class we extends Error {
|
|
1076
|
+
constructor(t, n, a) {
|
|
1077
|
+
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
|
|
1078
|
+
super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
|
|
1079
|
+
enumerable: !0,
|
|
1080
|
+
configurable: !0,
|
|
1081
|
+
writable: !0,
|
|
1082
|
+
value: void 0
|
|
1083
|
+
}), Object.defineProperty(this, "request", {
|
|
1084
|
+
enumerable: !0,
|
|
1085
|
+
configurable: !0,
|
|
1086
|
+
writable: !0,
|
|
1087
|
+
value: void 0
|
|
1088
|
+
}), Object.defineProperty(this, "options", {
|
|
1089
|
+
enumerable: !0,
|
|
1090
|
+
configurable: !0,
|
|
1091
|
+
writable: !0,
|
|
1092
|
+
value: void 0
|
|
1093
|
+
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
class Pe extends Error {
|
|
1097
|
+
constructor(t) {
|
|
1098
|
+
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1099
|
+
enumerable: !0,
|
|
1100
|
+
configurable: !0,
|
|
1101
|
+
writable: !0,
|
|
1102
|
+
value: void 0
|
|
1103
|
+
}), this.name = "TimeoutError", this.request = t;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
const J = (e) => e !== null && typeof e == "object", X = (...e) => {
|
|
1107
|
+
for (const t of e)
|
|
1108
|
+
if ((!J(t) || Array.isArray(t)) && t !== void 0)
|
|
1109
|
+
throw new TypeError("The `options` argument must be an object");
|
|
1110
|
+
return fe({}, ...e);
|
|
1111
|
+
}, Be = (e = {}, t = {}) => {
|
|
1112
|
+
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1113
|
+
for (const [r, o] of s.entries())
|
|
1114
|
+
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
1115
|
+
return n;
|
|
1116
|
+
}, fe = (...e) => {
|
|
1117
|
+
let t = {}, n = {};
|
|
1118
|
+
for (const a of e)
|
|
1119
|
+
if (Array.isArray(a))
|
|
1120
|
+
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1121
|
+
else if (J(a)) {
|
|
1122
|
+
for (let [s, r] of Object.entries(a))
|
|
1123
|
+
J(r) && s in t && (r = fe(t[s], r)), t = { ...t, [s]: r };
|
|
1124
|
+
J(a.headers) && (n = Be(n, a.headers), t.headers = n);
|
|
1125
|
+
}
|
|
1126
|
+
return t;
|
|
1127
|
+
}, It = (() => {
|
|
1128
|
+
let e = !1, t = !1;
|
|
1129
|
+
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1130
|
+
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
1131
|
+
body: new globalThis.ReadableStream(),
|
|
1132
|
+
method: "POST",
|
|
1133
|
+
// @ts-expect-error - Types are outdated.
|
|
1134
|
+
get duplex() {
|
|
1135
|
+
return e = !0, "half";
|
|
1136
|
+
}
|
|
1137
|
+
}).headers.has("Content-Type")), e && !t;
|
|
1138
|
+
})(), St = typeof globalThis.AbortController == "function", vt = typeof globalThis.ReadableStream == "function", Ct = typeof globalThis.FormData == "function", Ve = ["get", "post", "put", "patch", "head", "delete"], Mt = {
|
|
1139
|
+
json: "application/json",
|
|
1140
|
+
text: "text/*",
|
|
1141
|
+
formData: "multipart/form-data",
|
|
1142
|
+
arrayBuffer: "*/*",
|
|
1143
|
+
blob: "*/*"
|
|
1144
|
+
}, se = 2147483647, Le = Symbol("stop"), Nt = {
|
|
1145
|
+
json: !0,
|
|
1146
|
+
parseJson: !0,
|
|
1147
|
+
searchParams: !0,
|
|
1148
|
+
prefixUrl: !0,
|
|
1149
|
+
retry: !0,
|
|
1150
|
+
timeout: !0,
|
|
1151
|
+
hooks: !0,
|
|
1152
|
+
throwHttpErrors: !0,
|
|
1153
|
+
onDownloadProgress: !0,
|
|
1154
|
+
fetch: !0
|
|
1155
|
+
}, xt = {
|
|
1156
|
+
method: !0,
|
|
1157
|
+
headers: !0,
|
|
1158
|
+
body: !0,
|
|
1159
|
+
mode: !0,
|
|
1160
|
+
credentials: !0,
|
|
1161
|
+
cache: !0,
|
|
1162
|
+
redirect: !0,
|
|
1163
|
+
referrer: !0,
|
|
1164
|
+
referrerPolicy: !0,
|
|
1165
|
+
integrity: !0,
|
|
1166
|
+
keepalive: !0,
|
|
1167
|
+
signal: !0,
|
|
1168
|
+
window: !0,
|
|
1169
|
+
dispatcher: !0,
|
|
1170
|
+
duplex: !0
|
|
1171
|
+
}, Dt = (e) => Ve.includes(e) ? e.toUpperCase() : e, Pt = ["get", "put", "head", "delete", "options", "trace"], Bt = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], Ae = {
|
|
1172
|
+
limit: 2,
|
|
1173
|
+
methods: Pt,
|
|
1174
|
+
statusCodes: Bt,
|
|
1175
|
+
afterStatusCodes: Ue,
|
|
1176
|
+
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1177
|
+
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1178
|
+
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1179
|
+
}, Vt = (e = {}) => {
|
|
1180
|
+
if (typeof e == "number")
|
|
1181
|
+
return {
|
|
1182
|
+
...Ae,
|
|
1183
|
+
limit: e
|
|
1184
|
+
};
|
|
1185
|
+
if (e.methods && !Array.isArray(e.methods))
|
|
1186
|
+
throw new Error("retry.methods must be an array");
|
|
1187
|
+
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1188
|
+
throw new Error("retry.statusCodes must be an array");
|
|
1189
|
+
return {
|
|
1190
|
+
...Ae,
|
|
1191
|
+
...e,
|
|
1192
|
+
afterStatusCodes: Ue
|
|
1193
|
+
};
|
|
1194
|
+
};
|
|
1195
|
+
async function Lt(e, t, n, a) {
|
|
1196
|
+
return new Promise((s, r) => {
|
|
1197
|
+
const o = setTimeout(() => {
|
|
1198
|
+
n && n.abort(), r(new Pe(e));
|
|
1199
|
+
}, a.timeout);
|
|
1200
|
+
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1201
|
+
clearTimeout(o);
|
|
1202
|
+
});
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
async function Ut(e, { signal: t }) {
|
|
1206
|
+
return new Promise((n, a) => {
|
|
1207
|
+
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
|
|
1208
|
+
function s() {
|
|
1209
|
+
clearTimeout(r), a(t.reason);
|
|
1210
|
+
}
|
|
1211
|
+
const r = setTimeout(() => {
|
|
1212
|
+
t == null || t.removeEventListener("abort", s), n();
|
|
1213
|
+
}, e);
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
const Ht = (e, t) => {
|
|
1217
|
+
const n = {};
|
|
1218
|
+
for (const a in t)
|
|
1219
|
+
!(a in xt) && !(a in Nt) && !(a in e) && (n[a] = t[a]);
|
|
1220
|
+
return n;
|
|
1221
|
+
};
|
|
1222
|
+
class z {
|
|
1223
|
+
static create(t, n) {
|
|
1224
|
+
const a = new z(t, n), s = async () => {
|
|
1225
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > se)
|
|
1226
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${se}`);
|
|
1227
|
+
await Promise.resolve();
|
|
1228
|
+
let o = await a._fetch();
|
|
1229
|
+
for (const p of a._options.hooks.afterResponse) {
|
|
1230
|
+
const u = await p(a.request, a._options, a._decorateResponse(o.clone()));
|
|
1231
|
+
u instanceof globalThis.Response && (o = u);
|
|
1232
|
+
}
|
|
1233
|
+
if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
|
|
1234
|
+
let p = new we(o, a.request, a._options);
|
|
1235
|
+
for (const u of a._options.hooks.beforeError)
|
|
1236
|
+
p = await u(p);
|
|
1237
|
+
throw p;
|
|
1238
|
+
}
|
|
1239
|
+
if (a._options.onDownloadProgress) {
|
|
1240
|
+
if (typeof a._options.onDownloadProgress != "function")
|
|
1241
|
+
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
1242
|
+
if (!vt)
|
|
1243
|
+
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1244
|
+
return a._stream(o.clone(), a._options.onDownloadProgress);
|
|
1245
|
+
}
|
|
1246
|
+
return o;
|
|
1247
|
+
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
|
|
1248
|
+
for (const [o, p] of Object.entries(Mt))
|
|
1249
|
+
r[o] = async () => {
|
|
1250
|
+
a.request.headers.set("accept", a.request.headers.get("accept") || p);
|
|
1251
|
+
const u = (await r).clone();
|
|
1252
|
+
if (o === "json") {
|
|
1253
|
+
if (u.status === 204 || (await u.clone().arrayBuffer()).byteLength === 0)
|
|
1254
|
+
return "";
|
|
1255
|
+
if (n.parseJson)
|
|
1256
|
+
return n.parseJson(await u.text());
|
|
1257
|
+
}
|
|
1258
|
+
return u[o]();
|
|
1259
|
+
};
|
|
1260
|
+
return r;
|
|
1261
|
+
}
|
|
1262
|
+
// eslint-disable-next-line complexity
|
|
1263
|
+
constructor(t, n = {}) {
|
|
1264
|
+
if (Object.defineProperty(this, "request", {
|
|
1265
|
+
enumerable: !0,
|
|
1266
|
+
configurable: !0,
|
|
1267
|
+
writable: !0,
|
|
1268
|
+
value: void 0
|
|
1269
|
+
}), Object.defineProperty(this, "abortController", {
|
|
1270
|
+
enumerable: !0,
|
|
1271
|
+
configurable: !0,
|
|
1272
|
+
writable: !0,
|
|
1273
|
+
value: void 0
|
|
1274
|
+
}), Object.defineProperty(this, "_retryCount", {
|
|
1275
|
+
enumerable: !0,
|
|
1276
|
+
configurable: !0,
|
|
1277
|
+
writable: !0,
|
|
1278
|
+
value: 0
|
|
1279
|
+
}), Object.defineProperty(this, "_input", {
|
|
1280
|
+
enumerable: !0,
|
|
1281
|
+
configurable: !0,
|
|
1282
|
+
writable: !0,
|
|
1283
|
+
value: void 0
|
|
1284
|
+
}), Object.defineProperty(this, "_options", {
|
|
1285
|
+
enumerable: !0,
|
|
1286
|
+
configurable: !0,
|
|
1287
|
+
writable: !0,
|
|
1288
|
+
value: void 0
|
|
1289
|
+
}), this._input = t, this._options = {
|
|
1290
|
+
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1291
|
+
credentials: this._input.credentials || "same-origin",
|
|
1292
|
+
...n,
|
|
1293
|
+
headers: Be(this._input.headers, n.headers),
|
|
1294
|
+
hooks: fe({
|
|
1295
|
+
beforeRequest: [],
|
|
1296
|
+
beforeRetry: [],
|
|
1297
|
+
beforeError: [],
|
|
1298
|
+
afterResponse: []
|
|
1299
|
+
}, n.hooks),
|
|
1300
|
+
method: Dt(n.method ?? this._input.method),
|
|
1301
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1302
|
+
prefixUrl: String(n.prefixUrl || ""),
|
|
1303
|
+
retry: Vt(n.retry),
|
|
1304
|
+
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1305
|
+
timeout: n.timeout ?? 1e4,
|
|
1306
|
+
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
1307
|
+
}, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
|
|
1308
|
+
throw new TypeError("`input` must be a string, URL, or Request");
|
|
1309
|
+
if (this._options.prefixUrl && typeof this._input == "string") {
|
|
1310
|
+
if (this._input.startsWith("/"))
|
|
1311
|
+
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1312
|
+
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1313
|
+
}
|
|
1314
|
+
if (St) {
|
|
1315
|
+
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1316
|
+
const a = this._options.signal;
|
|
1317
|
+
this._options.signal.addEventListener("abort", () => {
|
|
1318
|
+
this.abortController.abort(a.reason);
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
this._options.signal = this.abortController.signal;
|
|
1322
|
+
}
|
|
1323
|
+
if (It && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1324
|
+
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1325
|
+
(Ct && 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);
|
|
1326
|
+
}
|
|
1327
|
+
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 }));
|
|
1328
|
+
}
|
|
1329
|
+
_calculateRetryDelay(t) {
|
|
1330
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof Pe)) {
|
|
1331
|
+
if (t instanceof we) {
|
|
1332
|
+
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1333
|
+
return 0;
|
|
1334
|
+
const a = t.response.headers.get("Retry-After");
|
|
1335
|
+
if (a && this._options.retry.afterStatusCodes.includes(t.response.status)) {
|
|
1336
|
+
let s = Number(a);
|
|
1337
|
+
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;
|
|
1338
|
+
}
|
|
1339
|
+
if (t.response.status === 413)
|
|
1340
|
+
return 0;
|
|
1341
|
+
}
|
|
1342
|
+
const n = this._options.retry.delay(this._retryCount);
|
|
1343
|
+
return Math.min(this._options.retry.backoffLimit, n);
|
|
1344
|
+
}
|
|
1345
|
+
return 0;
|
|
1346
|
+
}
|
|
1347
|
+
_decorateResponse(t) {
|
|
1348
|
+
return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
|
|
1349
|
+
}
|
|
1350
|
+
async _retry(t) {
|
|
1351
|
+
try {
|
|
1352
|
+
return await t();
|
|
1353
|
+
} catch (n) {
|
|
1354
|
+
const a = Math.min(this._calculateRetryDelay(n), se);
|
|
1355
|
+
if (a !== 0 && this._retryCount > 0) {
|
|
1356
|
+
await Ut(a, { signal: this._options.signal });
|
|
1357
|
+
for (const s of this._options.hooks.beforeRetry)
|
|
1358
|
+
if (await s({
|
|
1359
|
+
request: this.request,
|
|
1360
|
+
options: this._options,
|
|
1361
|
+
error: n,
|
|
1362
|
+
retryCount: this._retryCount
|
|
1363
|
+
}) === Le)
|
|
1364
|
+
return;
|
|
1365
|
+
return this._retry(t);
|
|
1366
|
+
}
|
|
1367
|
+
throw n;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
async _fetch() {
|
|
1371
|
+
for (const n of this._options.hooks.beforeRequest) {
|
|
1372
|
+
const a = await n(this.request, this._options);
|
|
1373
|
+
if (a instanceof Request) {
|
|
1374
|
+
this.request = a;
|
|
1375
|
+
break;
|
|
1376
|
+
}
|
|
1377
|
+
if (a instanceof Response)
|
|
1378
|
+
return a;
|
|
1379
|
+
}
|
|
1380
|
+
const t = Ht(this.request, this._options);
|
|
1381
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Lt(this.request.clone(), t, this.abortController, this._options);
|
|
1382
|
+
}
|
|
1383
|
+
/* istanbul ignore next */
|
|
1384
|
+
_stream(t, n) {
|
|
1385
|
+
const a = Number(t.headers.get("content-length")) || 0;
|
|
1386
|
+
let s = 0;
|
|
1387
|
+
return t.status === 204 ? (n && n({ percent: 1, totalBytes: a, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
|
|
1388
|
+
status: t.status,
|
|
1389
|
+
statusText: t.statusText,
|
|
1390
|
+
headers: t.headers
|
|
1391
|
+
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
1392
|
+
async start(r) {
|
|
1393
|
+
const o = t.body.getReader();
|
|
1394
|
+
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1395
|
+
async function p() {
|
|
1396
|
+
const { done: u, value: y } = await o.read();
|
|
1397
|
+
if (u) {
|
|
1398
|
+
r.close();
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
if (n) {
|
|
1402
|
+
s += y.byteLength;
|
|
1403
|
+
const d = a === 0 ? 0 : s / a;
|
|
1404
|
+
n({ percent: d, transferredBytes: s, totalBytes: a }, y);
|
|
1405
|
+
}
|
|
1406
|
+
r.enqueue(y), await p();
|
|
1407
|
+
}
|
|
1408
|
+
await p();
|
|
1409
|
+
}
|
|
1410
|
+
}), {
|
|
1411
|
+
status: t.status,
|
|
1412
|
+
statusText: t.statusText,
|
|
1413
|
+
headers: t.headers
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
/*! MIT License © Sindre Sorhus */
|
|
1418
|
+
const re = (e) => {
|
|
1419
|
+
const t = (n, a) => z.create(n, X(e, a));
|
|
1420
|
+
for (const n of Ve)
|
|
1421
|
+
t[n] = (a, s) => z.create(a, X(e, s, { method: n }));
|
|
1422
|
+
return t.create = (n) => re(X(n)), t.extend = (n) => re(X(e, n)), t.stop = Le, t;
|
|
1423
|
+
}, kt = re(), $t = kt, Ee = $t.create({
|
|
1424
|
+
headers: {
|
|
1425
|
+
referrer: "https://sk.thorswap.net",
|
|
1426
|
+
referer: "https://sk.thorswap.net",
|
|
1427
|
+
"Content-Type": "application/json"
|
|
1428
|
+
}
|
|
1429
|
+
}), be = {
|
|
1430
|
+
get: (e, t) => Ee.get(e, t).json(),
|
|
1431
|
+
post: (e, t) => Ee.post(e, t).json()
|
|
1432
|
+
}, Re = Object.values(i), Ft = (e = "") => {
|
|
1102
1433
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1103
|
-
if (
|
|
1434
|
+
if (Re.includes(n))
|
|
1104
1435
|
return !0;
|
|
1105
1436
|
const [a] = t.split("/");
|
|
1106
|
-
if (
|
|
1437
|
+
if (Re.includes(a))
|
|
1107
1438
|
return !0;
|
|
1108
1439
|
throw new Error(
|
|
1109
1440
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1110
1441
|
);
|
|
1111
1442
|
}, q = 8, U = (e) => 10n ** BigInt(e), F = (e) => Math.log10(parseFloat(e.toString()));
|
|
1112
|
-
function
|
|
1443
|
+
function He({
|
|
1113
1444
|
value: e,
|
|
1114
1445
|
bigIntDecimal: t = q,
|
|
1115
1446
|
decimal: n = q
|
|
1116
1447
|
}) {
|
|
1117
1448
|
const a = e < 0n;
|
|
1118
|
-
let
|
|
1119
|
-
const r = n - (
|
|
1120
|
-
r > 0 && (
|
|
1121
|
-
const
|
|
1122
|
-
let
|
|
1123
|
-
return parseInt(
|
|
1449
|
+
let s = e.toString().substring(a ? 1 : 0);
|
|
1450
|
+
const r = n - (s.length - 1);
|
|
1451
|
+
r > 0 && (s = "0".repeat(r) + s);
|
|
1452
|
+
const o = s.length - n;
|
|
1453
|
+
let p = s.slice(-n);
|
|
1454
|
+
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(
|
|
1124
1455
|
/\.?0*$/,
|
|
1125
1456
|
""
|
|
1126
1457
|
);
|
|
1127
1458
|
}
|
|
1128
|
-
var L,
|
|
1129
|
-
const
|
|
1459
|
+
var L, k, oe, ke, pe, ge, Z, de, H, G, ee, ue;
|
|
1460
|
+
const Gt = class Q {
|
|
1130
1461
|
constructor(t) {
|
|
1131
|
-
V(this, L), V(this,
|
|
1132
|
-
const n =
|
|
1462
|
+
V(this, L), V(this, oe), V(this, pe), V(this, Z), V(this, H), V(this, ee), M(this, "decimalMultiplier", 10n ** 8n), M(this, "bigIntValue", 0n), M(this, "decimal");
|
|
1463
|
+
const n = ye(t);
|
|
1133
1464
|
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = U(
|
|
1134
|
-
Math.max(
|
|
1135
|
-
),
|
|
1465
|
+
Math.max(O(this, ee, ue).call(this, O(this, H, G).call(this, n)), this.decimal || 0)
|
|
1466
|
+
), O(this, oe, ke).call(this, n);
|
|
1136
1467
|
}
|
|
1137
1468
|
static fromBigInt(t, n) {
|
|
1138
|
-
return new
|
|
1469
|
+
return new Q({
|
|
1139
1470
|
decimal: n,
|
|
1140
|
-
value:
|
|
1471
|
+
value: He({ value: t, bigIntDecimal: n, decimal: n })
|
|
1141
1472
|
});
|
|
1142
1473
|
}
|
|
1143
1474
|
static shiftDecimals({
|
|
@@ -1145,8 +1476,8 @@ const mt = class j {
|
|
|
1145
1476
|
from: n,
|
|
1146
1477
|
to: a
|
|
1147
1478
|
}) {
|
|
1148
|
-
return
|
|
1149
|
-
new
|
|
1479
|
+
return Q.fromBigInt(
|
|
1480
|
+
new Q(t).bigIntValue * U(a) / U(n),
|
|
1150
1481
|
a
|
|
1151
1482
|
);
|
|
1152
1483
|
}
|
|
@@ -1172,16 +1503,16 @@ const mt = class j {
|
|
|
1172
1503
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1173
1504
|
}
|
|
1174
1505
|
add(...t) {
|
|
1175
|
-
return
|
|
1506
|
+
return O(this, L, k).call(this, "add", ...t);
|
|
1176
1507
|
}
|
|
1177
1508
|
sub(...t) {
|
|
1178
|
-
return
|
|
1509
|
+
return O(this, L, k).call(this, "sub", ...t);
|
|
1179
1510
|
}
|
|
1180
1511
|
mul(...t) {
|
|
1181
|
-
return
|
|
1512
|
+
return O(this, L, k).call(this, "mul", ...t);
|
|
1182
1513
|
}
|
|
1183
1514
|
div(...t) {
|
|
1184
|
-
return
|
|
1515
|
+
return O(this, L, k).call(this, "div", ...t);
|
|
1185
1516
|
}
|
|
1186
1517
|
gt(t) {
|
|
1187
1518
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1226,109 +1557,109 @@ const mt = class j {
|
|
|
1226
1557
|
getBigIntValue(t, n) {
|
|
1227
1558
|
if (!n && typeof t == "object")
|
|
1228
1559
|
return t.bigIntValue;
|
|
1229
|
-
const a =
|
|
1230
|
-
return
|
|
1560
|
+
const a = ye(t), s = O(this, H, G).call(this, a);
|
|
1561
|
+
return s === "0" || s === "undefined" ? 0n : O(this, Z, de).call(this, s, n);
|
|
1231
1562
|
}
|
|
1232
1563
|
formatBigIntToSafeValue(t, n) {
|
|
1233
|
-
const a = n || this.decimal || q,
|
|
1564
|
+
const a = n || this.decimal || q, s = Math.max(
|
|
1234
1565
|
a,
|
|
1235
1566
|
F(this.decimalMultiplier)
|
|
1236
|
-
), r = t < 0n,
|
|
1237
|
-
let
|
|
1238
|
-
return parseInt(
|
|
1567
|
+
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), u = p > 0 ? "0".repeat(p) + o : o, y = u.length - s;
|
|
1568
|
+
let d = u.slice(-s);
|
|
1569
|
+
return parseInt(d[a]) >= 5 ? d = `${d.substring(0, a - 1)}${(parseInt(d[a - 1]) + 1).toString()}` : d = d.substring(0, a), `${r ? "-" : ""}${u.slice(
|
|
1239
1570
|
0,
|
|
1240
|
-
|
|
1241
|
-
)}.${
|
|
1571
|
+
y
|
|
1572
|
+
)}.${d}`.replace(/\.?0*$/, "");
|
|
1242
1573
|
}
|
|
1243
1574
|
toSignificant(t = 6) {
|
|
1244
|
-
const [n, a] = this.getValue("string").split("."),
|
|
1245
|
-
if (
|
|
1575
|
+
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "", o = parseInt(s) ? s.length + r.length : r.length;
|
|
1576
|
+
if (o <= t)
|
|
1246
1577
|
return this.getValue("string");
|
|
1247
|
-
if (
|
|
1248
|
-
return
|
|
1249
|
-
if (parseInt(
|
|
1250
|
-
return `${
|
|
1251
|
-
|
|
1578
|
+
if (s.length >= t)
|
|
1579
|
+
return s.slice(0, t).padEnd(s.length, "0");
|
|
1580
|
+
if (parseInt(s))
|
|
1581
|
+
return `${s}.${r.slice(0, t - s.length)}`.padEnd(
|
|
1582
|
+
o - t,
|
|
1252
1583
|
"0"
|
|
1253
1584
|
);
|
|
1254
|
-
const
|
|
1255
|
-
return `0.${
|
|
1256
|
-
r.length - `${
|
|
1585
|
+
const p = parseInt(r), u = `${p}`.slice(0, t);
|
|
1586
|
+
return `0.${u.padStart(
|
|
1587
|
+
r.length - `${p}`.length + u.length,
|
|
1257
1588
|
"0"
|
|
1258
1589
|
)}`;
|
|
1259
1590
|
}
|
|
1260
1591
|
};
|
|
1261
|
-
L = /* @__PURE__ */ new WeakSet(),
|
|
1262
|
-
const n =
|
|
1263
|
-
(
|
|
1264
|
-
const
|
|
1592
|
+
L = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1593
|
+
const n = O(this, pe, ge).call(this, this, ...t), a = U(n), s = t.reduce(
|
|
1594
|
+
(o, p) => {
|
|
1595
|
+
const u = this.getBigIntValue(p, n);
|
|
1265
1596
|
switch (e) {
|
|
1266
1597
|
case "add":
|
|
1267
|
-
return
|
|
1598
|
+
return o + u;
|
|
1268
1599
|
case "sub":
|
|
1269
|
-
return
|
|
1600
|
+
return o - u;
|
|
1270
1601
|
case "mul":
|
|
1271
|
-
return
|
|
1602
|
+
return o * u / a;
|
|
1272
1603
|
case "div": {
|
|
1273
|
-
if (
|
|
1604
|
+
if (u === 0n)
|
|
1274
1605
|
throw new RangeError("Division by zero");
|
|
1275
|
-
return
|
|
1606
|
+
return o * a / u;
|
|
1276
1607
|
}
|
|
1277
1608
|
default:
|
|
1278
|
-
return
|
|
1609
|
+
return o;
|
|
1279
1610
|
}
|
|
1280
1611
|
},
|
|
1281
1612
|
//normalize is to precision multiplier base
|
|
1282
1613
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1283
|
-
), r =
|
|
1614
|
+
), r = He({
|
|
1284
1615
|
bigIntDecimal: n,
|
|
1285
1616
|
decimal: Math.max(n, F(this.decimalMultiplier)),
|
|
1286
|
-
value:
|
|
1617
|
+
value: s
|
|
1287
1618
|
});
|
|
1288
1619
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1289
|
-
},
|
|
1290
|
-
const t =
|
|
1291
|
-
this.bigIntValue =
|
|
1292
|
-
},
|
|
1620
|
+
}, oe = /* @__PURE__ */ new WeakSet(), ke = function(e) {
|
|
1621
|
+
const t = O(this, H, G).call(this, e) || "0";
|
|
1622
|
+
this.bigIntValue = O(this, Z, de).call(this, t);
|
|
1623
|
+
}, pe = /* @__PURE__ */ new WeakSet(), ge = function(...e) {
|
|
1293
1624
|
const t = e.map(
|
|
1294
|
-
(n) => typeof n == "object" ? n.decimal || F(n.decimalMultiplier) :
|
|
1625
|
+
(n) => typeof n == "object" ? n.decimal || F(n.decimalMultiplier) : O(this, ee, ue).call(this, O(this, H, G).call(this, n))
|
|
1295
1626
|
).filter(Boolean);
|
|
1296
1627
|
return Math.max(...t, q);
|
|
1297
|
-
},
|
|
1298
|
-
const n = t ? U(t) : this.decimalMultiplier, a = F(n), [
|
|
1299
|
-
return BigInt(`${
|
|
1628
|
+
}, Z = /* @__PURE__ */ new WeakSet(), de = function(e, t) {
|
|
1629
|
+
const n = t ? U(t) : this.decimalMultiplier, a = F(n), [s = "", r = ""] = e.split(".");
|
|
1630
|
+
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1300
1631
|
}, H = /* @__PURE__ */ new WeakSet(), G = function(e) {
|
|
1301
1632
|
const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
|
|
1302
1633
|
useGrouping: !1,
|
|
1303
1634
|
maximumFractionDigits: 20
|
|
1304
|
-
}) :
|
|
1635
|
+
}) : ye(e)}`.replaceAll(",", ".").split(".");
|
|
1305
1636
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1306
|
-
},
|
|
1637
|
+
}, ee = /* @__PURE__ */ new WeakSet(), ue = function(e) {
|
|
1307
1638
|
var t;
|
|
1308
1639
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1309
1640
|
return Math.max(n, q);
|
|
1310
1641
|
};
|
|
1311
|
-
let
|
|
1312
|
-
function
|
|
1642
|
+
let le = Gt;
|
|
1643
|
+
function ye(e) {
|
|
1313
1644
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1314
1645
|
}
|
|
1315
|
-
let
|
|
1316
|
-
const
|
|
1317
|
-
if (!
|
|
1646
|
+
let ce;
|
|
1647
|
+
const ie = (e) => {
|
|
1648
|
+
if (!ce)
|
|
1318
1649
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1319
|
-
return
|
|
1320
|
-
},
|
|
1321
|
-
|
|
1322
|
-
const n = await
|
|
1650
|
+
return ce.get(e.toUpperCase()) || { decimal: b.THOR, identifier: "" };
|
|
1651
|
+
}, Oe = async (e, t = 0) => {
|
|
1652
|
+
Ft(e);
|
|
1653
|
+
const n = await De(me(e));
|
|
1323
1654
|
return new v({ decimal: n, value: t, identifier: e });
|
|
1324
1655
|
};
|
|
1325
|
-
class v extends
|
|
1656
|
+
class v extends le {
|
|
1326
1657
|
constructor(t) {
|
|
1327
1658
|
super(
|
|
1328
|
-
t.value instanceof
|
|
1329
|
-
),
|
|
1330
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a =
|
|
1331
|
-
this.type =
|
|
1659
|
+
t.value instanceof le ? t.value : { decimal: t.decimal, value: t.value }
|
|
1660
|
+
), M(this, "address"), M(this, "chain"), M(this, "isSynthetic", !1), M(this, "isGasAsset", !1), M(this, "symbol"), M(this, "ticker"), M(this, "type");
|
|
1661
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = me(n);
|
|
1662
|
+
this.type = wt(a), this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset;
|
|
1332
1663
|
}
|
|
1333
1664
|
get assetValue() {
|
|
1334
1665
|
return `${this.getValue("string")} ${this.ticker}`;
|
|
@@ -1344,36 +1675,36 @@ class v extends re {
|
|
|
1344
1675
|
return this.chain === t && this.symbol === n;
|
|
1345
1676
|
}
|
|
1346
1677
|
static async fromString(t, n = 0) {
|
|
1347
|
-
return
|
|
1678
|
+
return Oe(t, n);
|
|
1348
1679
|
}
|
|
1349
1680
|
static fromStringSync(t, n = 0) {
|
|
1350
|
-
const { decimal: a, identifier:
|
|
1681
|
+
const { decimal: a, identifier: s } = ie(
|
|
1351
1682
|
t
|
|
1352
1683
|
);
|
|
1353
|
-
return
|
|
1684
|
+
return s ? new v({ decimal: a, identifier: s, value: n }) : void 0;
|
|
1354
1685
|
}
|
|
1355
1686
|
static async fromIdentifier(t, n = 0) {
|
|
1356
|
-
return
|
|
1687
|
+
return Oe(t, n);
|
|
1357
1688
|
}
|
|
1358
1689
|
static fromIdentifierSync(t, n = 0) {
|
|
1359
|
-
const { decimal: a, identifier:
|
|
1360
|
-
return new v({ decimal: a, identifier:
|
|
1690
|
+
const { decimal: a, identifier: s } = ie(t);
|
|
1691
|
+
return new v({ decimal: a, identifier: s, value: n });
|
|
1361
1692
|
}
|
|
1362
1693
|
static fromChainOrSignature(t, n = 0) {
|
|
1363
|
-
const { decimal: a, identifier:
|
|
1364
|
-
return new v({ value: n, decimal: a, identifier:
|
|
1694
|
+
const { decimal: a, identifier: s } = bt(t);
|
|
1695
|
+
return new v({ value: n, decimal: a, identifier: s });
|
|
1365
1696
|
}
|
|
1366
1697
|
static async fromTCQuote(t, n = 0) {
|
|
1367
|
-
const a = await
|
|
1368
|
-
return new v({ value:
|
|
1698
|
+
const a = await De(me(t)), s = this.shiftDecimals({ value: n, from: b.THOR, to: a });
|
|
1699
|
+
return new v({ value: s, identifier: t, decimal: a });
|
|
1369
1700
|
}
|
|
1370
1701
|
static fromTCQuoteStatic(t, n = 0) {
|
|
1371
|
-
const a =
|
|
1702
|
+
const a = ie(t), s = this.shiftDecimals({
|
|
1372
1703
|
value: n,
|
|
1373
1704
|
from: b.THOR,
|
|
1374
1705
|
to: a.decimal
|
|
1375
1706
|
});
|
|
1376
|
-
return new v({ ...a, value:
|
|
1707
|
+
return new v({ ...a, value: s });
|
|
1377
1708
|
}
|
|
1378
1709
|
static async loadStaticAssets() {
|
|
1379
1710
|
return new Promise(
|
|
@@ -1383,14 +1714,14 @@ class v extends re {
|
|
|
1383
1714
|
// Omit ThorchainList from import to avoid decimals conflict (TC uses 8 for all)
|
|
1384
1715
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1385
1716
|
ThorchainList: a,
|
|
1386
|
-
NativeList:
|
|
1717
|
+
NativeList: s,
|
|
1387
1718
|
...r
|
|
1388
1719
|
} = await import("@swapkit/tokens");
|
|
1389
|
-
|
|
1390
|
-
(
|
|
1391
|
-
const c = "decimals" in
|
|
1392
|
-
|
|
1393
|
-
}),
|
|
1720
|
+
ce = [s, ...Object.values(r)].reduce(
|
|
1721
|
+
(o, { tokens: p }) => (p.forEach(({ identifier: u, chain: y, ...d }) => {
|
|
1722
|
+
const c = "decimals" in d ? d.decimals : b[y];
|
|
1723
|
+
o.set(u, { identifier: u, decimal: c });
|
|
1724
|
+
}), o),
|
|
1394
1725
|
/* @__PURE__ */ new Map()
|
|
1395
1726
|
), t({ ok: !0 });
|
|
1396
1727
|
} catch (a) {
|
|
@@ -1404,35 +1735,35 @@ class v extends re {
|
|
|
1404
1735
|
);
|
|
1405
1736
|
}
|
|
1406
1737
|
}
|
|
1407
|
-
const
|
|
1738
|
+
const Ie = (e) => {
|
|
1408
1739
|
const t = v.fromChainOrSignature(e);
|
|
1409
1740
|
switch (e) {
|
|
1410
|
-
case
|
|
1411
|
-
case
|
|
1412
|
-
case
|
|
1741
|
+
case i.Bitcoin:
|
|
1742
|
+
case i.Litecoin:
|
|
1743
|
+
case i.BitcoinCash:
|
|
1413
1744
|
return t.add(10001);
|
|
1414
|
-
case
|
|
1745
|
+
case i.Dogecoin:
|
|
1415
1746
|
return t.add(100000001);
|
|
1416
|
-
case
|
|
1417
|
-
case
|
|
1747
|
+
case i.Avalanche:
|
|
1748
|
+
case i.Ethereum:
|
|
1418
1749
|
return t.add(10 * 10 ** 9);
|
|
1419
|
-
case
|
|
1420
|
-
case
|
|
1750
|
+
case i.THORChain:
|
|
1751
|
+
case i.Maya:
|
|
1421
1752
|
return t.add(0);
|
|
1422
1753
|
default:
|
|
1423
1754
|
return t.add(1);
|
|
1424
1755
|
}
|
|
1425
|
-
},
|
|
1426
|
-
const t = e.slice(0, 14).includes("/"), n = e.includes(".") ? e : `${
|
|
1756
|
+
}, me = (e) => {
|
|
1757
|
+
const t = e.slice(0, 14).includes("/"), n = e.includes(".") ? e : `${i.THORChain}.${e}`, [a, s] = n.split("."), [r, o] = s.split("-");
|
|
1427
1758
|
return {
|
|
1428
|
-
address:
|
|
1759
|
+
address: o == null ? void 0 : o.toLowerCase(),
|
|
1429
1760
|
chain: a,
|
|
1430
|
-
isGasAsset:
|
|
1761
|
+
isGasAsset: ft({ chain: a, symbol: s }),
|
|
1431
1762
|
isSynthetic: t,
|
|
1432
|
-
symbol:
|
|
1433
|
-
ticker: t ?
|
|
1763
|
+
symbol: o ? `${r}-${(o == null ? void 0 : o.toLowerCase()) ?? ""}` : s,
|
|
1764
|
+
ticker: t ? s : r
|
|
1434
1765
|
};
|
|
1435
|
-
},
|
|
1766
|
+
}, Wt = {
|
|
1436
1767
|
/**
|
|
1437
1768
|
* Core
|
|
1438
1769
|
*/
|
|
@@ -1491,15 +1822,15 @@ const _e = (e) => {
|
|
|
1491
1822
|
};
|
|
1492
1823
|
class m extends Error {
|
|
1493
1824
|
constructor(t, n) {
|
|
1494
|
-
console.error(n), super(t, { cause: { code:
|
|
1825
|
+
console.error(n), super(t, { cause: { code: Wt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1495
1826
|
}
|
|
1496
1827
|
}
|
|
1497
|
-
class
|
|
1828
|
+
class Te extends le {
|
|
1498
1829
|
eq(t) {
|
|
1499
1830
|
return this.eqValue(t);
|
|
1500
1831
|
}
|
|
1501
1832
|
}
|
|
1502
|
-
const
|
|
1833
|
+
const qt = [
|
|
1503
1834
|
{
|
|
1504
1835
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1505
1836
|
stateMutability: "nonpayable",
|
|
@@ -1590,7 +1921,7 @@ const _t = [
|
|
|
1590
1921
|
type: "function"
|
|
1591
1922
|
},
|
|
1592
1923
|
{ stateMutability: "payable", type: "receive" }
|
|
1593
|
-
],
|
|
1924
|
+
], jt = [
|
|
1594
1925
|
{
|
|
1595
1926
|
inputs: [
|
|
1596
1927
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -1734,7 +2065,7 @@ const _t = [
|
|
|
1734
2065
|
type: "function"
|
|
1735
2066
|
},
|
|
1736
2067
|
{ stateMutability: "payable", type: "receive" }
|
|
1737
|
-
],
|
|
2068
|
+
], Yt = [
|
|
1738
2069
|
{
|
|
1739
2070
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1740
2071
|
stateMutability: "nonpayable",
|
|
@@ -1839,7 +2170,7 @@ const _t = [
|
|
|
1839
2170
|
type: "function"
|
|
1840
2171
|
},
|
|
1841
2172
|
{ stateMutability: "payable", type: "receive" }
|
|
1842
|
-
],
|
|
2173
|
+
], Kt = [
|
|
1843
2174
|
{
|
|
1844
2175
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1845
2176
|
stateMutability: "nonpayable",
|
|
@@ -1930,7 +2261,7 @@ const _t = [
|
|
|
1930
2261
|
type: "function"
|
|
1931
2262
|
},
|
|
1932
2263
|
{ stateMutability: "payable", type: "receive" }
|
|
1933
|
-
],
|
|
2264
|
+
], Xt = [
|
|
1934
2265
|
{
|
|
1935
2266
|
inputs: [
|
|
1936
2267
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2074,7 +2405,7 @@ const _t = [
|
|
|
2074
2405
|
type: "function"
|
|
2075
2406
|
},
|
|
2076
2407
|
{ stateMutability: "payable", type: "receive" }
|
|
2077
|
-
],
|
|
2408
|
+
], Jt = [
|
|
2078
2409
|
{
|
|
2079
2410
|
inputs: [
|
|
2080
2411
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2193,7 +2524,7 @@ const _t = [
|
|
|
2193
2524
|
type: "function"
|
|
2194
2525
|
},
|
|
2195
2526
|
{ stateMutability: "payable", type: "receive" }
|
|
2196
|
-
],
|
|
2527
|
+
], Qt = [
|
|
2197
2528
|
{
|
|
2198
2529
|
inputs: [
|
|
2199
2530
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2312,7 +2643,7 @@ const _t = [
|
|
|
2312
2643
|
type: "function"
|
|
2313
2644
|
},
|
|
2314
2645
|
{ stateMutability: "payable", type: "receive" }
|
|
2315
|
-
],
|
|
2646
|
+
], zt = [
|
|
2316
2647
|
{
|
|
2317
2648
|
inputs: [
|
|
2318
2649
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2431,7 +2762,7 @@ const _t = [
|
|
|
2431
2762
|
type: "function"
|
|
2432
2763
|
},
|
|
2433
2764
|
{ stateMutability: "payable", type: "receive" }
|
|
2434
|
-
],
|
|
2765
|
+
], Zt = [
|
|
2435
2766
|
{
|
|
2436
2767
|
inputs: [
|
|
2437
2768
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2550,7 +2881,7 @@ const _t = [
|
|
|
2550
2881
|
type: "function"
|
|
2551
2882
|
},
|
|
2552
2883
|
{ stateMutability: "payable", type: "receive" }
|
|
2553
|
-
],
|
|
2884
|
+
], en = [
|
|
2554
2885
|
{
|
|
2555
2886
|
inputs: [
|
|
2556
2887
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2677,7 +3008,7 @@ const _t = [
|
|
|
2677
3008
|
type: "function"
|
|
2678
3009
|
},
|
|
2679
3010
|
{ stateMutability: "payable", type: "receive" }
|
|
2680
|
-
],
|
|
3011
|
+
], tn = [
|
|
2681
3012
|
{
|
|
2682
3013
|
inputs: [
|
|
2683
3014
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2804,7 +3135,7 @@ const _t = [
|
|
|
2804
3135
|
type: "function"
|
|
2805
3136
|
},
|
|
2806
3137
|
{ stateMutability: "payable", type: "receive" }
|
|
2807
|
-
],
|
|
3138
|
+
], nn = [
|
|
2808
3139
|
{
|
|
2809
3140
|
inputs: [
|
|
2810
3141
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2931,7 +3262,7 @@ const _t = [
|
|
|
2931
3262
|
type: "function"
|
|
2932
3263
|
},
|
|
2933
3264
|
{ stateMutability: "payable", type: "receive" }
|
|
2934
|
-
],
|
|
3265
|
+
], an = [
|
|
2935
3266
|
{
|
|
2936
3267
|
inputs: [
|
|
2937
3268
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3058,7 +3389,7 @@ const _t = [
|
|
|
3058
3389
|
type: "function"
|
|
3059
3390
|
},
|
|
3060
3391
|
{ stateMutability: "payable", type: "receive" }
|
|
3061
|
-
],
|
|
3392
|
+
], sn = [
|
|
3062
3393
|
{
|
|
3063
3394
|
inputs: [
|
|
3064
3395
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3185,239 +3516,239 @@ const _t = [
|
|
|
3185
3516
|
type: "function"
|
|
3186
3517
|
},
|
|
3187
3518
|
{ stateMutability: "payable", type: "receive" }
|
|
3188
|
-
],
|
|
3189
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3190
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3191
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3192
|
-
},
|
|
3193
|
-
|
|
3519
|
+
], $e = {
|
|
3520
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: qt,
|
|
3521
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Yt,
|
|
3522
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Kt
|
|
3523
|
+
}, rn = {
|
|
3524
|
+
...$e,
|
|
3194
3525
|
// AVAX
|
|
3195
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3196
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3197
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3526
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: Jt,
|
|
3527
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: jt,
|
|
3528
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: zt,
|
|
3198
3529
|
// BSC
|
|
3199
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3530
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: Xt,
|
|
3200
3531
|
// ETH
|
|
3201
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3202
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3203
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3204
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3205
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3206
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3207
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3208
|
-
},
|
|
3532
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Qt,
|
|
3533
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Zt,
|
|
3534
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: en,
|
|
3535
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: tn,
|
|
3536
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: nn,
|
|
3537
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: an,
|
|
3538
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: sn
|
|
3539
|
+
}, on = ({
|
|
3209
3540
|
streamSwap: e,
|
|
3210
3541
|
contractAddress: t,
|
|
3211
3542
|
recipient: n,
|
|
3212
3543
|
toChecksumAddress: a,
|
|
3213
3544
|
calldata: {
|
|
3214
|
-
amount:
|
|
3545
|
+
amount: s,
|
|
3215
3546
|
amountOutMin: r = "",
|
|
3216
|
-
data:
|
|
3217
|
-
deadline:
|
|
3218
|
-
memo:
|
|
3219
|
-
router:
|
|
3220
|
-
memoStreamingSwap:
|
|
3547
|
+
data: o = "",
|
|
3548
|
+
deadline: p,
|
|
3549
|
+
memo: u,
|
|
3550
|
+
router: y,
|
|
3551
|
+
memoStreamingSwap: d,
|
|
3221
3552
|
tcMemo: c,
|
|
3222
|
-
tcRouter:
|
|
3223
|
-
tcVault:
|
|
3553
|
+
tcRouter: _,
|
|
3554
|
+
tcVault: A,
|
|
3224
3555
|
vault: R,
|
|
3225
|
-
token:
|
|
3556
|
+
token: g
|
|
3226
3557
|
}
|
|
3227
3558
|
}) => {
|
|
3228
|
-
const E =
|
|
3229
|
-
if (E && !
|
|
3559
|
+
const E = !!$e[t.toLowerCase()];
|
|
3560
|
+
if (E && !y)
|
|
3230
3561
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3231
|
-
const I = c ||
|
|
3232
|
-
if (!
|
|
3562
|
+
const I = c || u, S = e && d || I;
|
|
3563
|
+
if (!A && !R)
|
|
3233
3564
|
throw new Error("TC Vault is required on calldata");
|
|
3234
|
-
if (!
|
|
3565
|
+
if (!_ && !y)
|
|
3235
3566
|
throw new Error("TC Router is required on calldata");
|
|
3236
3567
|
if (!S)
|
|
3237
3568
|
throw new Error("TC Memo is required on calldata");
|
|
3238
|
-
if (!
|
|
3569
|
+
if (!g)
|
|
3239
3570
|
throw new Error("Token is required on calldata");
|
|
3240
3571
|
const D = [
|
|
3241
3572
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3242
|
-
a(
|
|
3243
|
-
a(
|
|
3573
|
+
a(_ || y),
|
|
3574
|
+
a(A || R),
|
|
3244
3575
|
S.replace("{recipientAddress}", n),
|
|
3245
|
-
a(
|
|
3246
|
-
|
|
3247
|
-
],
|
|
3248
|
-
return [...D, ...
|
|
3249
|
-
},
|
|
3250
|
-
const n =
|
|
3576
|
+
a(g),
|
|
3577
|
+
s
|
|
3578
|
+
], Fe = E ? [a(y), o, p] : [r, p];
|
|
3579
|
+
return [...D, ...Fe];
|
|
3580
|
+
}, pn = ({ chain: e, txHash: t }) => {
|
|
3581
|
+
const n = Ne[e];
|
|
3251
3582
|
switch (e) {
|
|
3252
|
-
case
|
|
3253
|
-
case
|
|
3254
|
-
case
|
|
3255
|
-
case
|
|
3256
|
-
case
|
|
3257
|
-
case
|
|
3583
|
+
case i.Binance:
|
|
3584
|
+
case i.Bitcoin:
|
|
3585
|
+
case i.BitcoinCash:
|
|
3586
|
+
case i.Maya:
|
|
3587
|
+
case i.Kujira:
|
|
3588
|
+
case i.THORChain:
|
|
3258
3589
|
return `${n}/tx/${t}`;
|
|
3259
|
-
case
|
|
3260
|
-
case
|
|
3261
|
-
case
|
|
3262
|
-
case
|
|
3263
|
-
case
|
|
3264
|
-
case
|
|
3590
|
+
case i.Arbitrum:
|
|
3591
|
+
case i.Avalanche:
|
|
3592
|
+
case i.BinanceSmartChain:
|
|
3593
|
+
case i.Ethereum:
|
|
3594
|
+
case i.Optimism:
|
|
3595
|
+
case i.Polygon:
|
|
3265
3596
|
return `${n}/tx/${t.startsWith("0x") ? t : `0x${t}`}`;
|
|
3266
|
-
case
|
|
3597
|
+
case i.Cosmos:
|
|
3267
3598
|
return `${n}/transactions/${t}`;
|
|
3268
|
-
case
|
|
3599
|
+
case i.Dogecoin:
|
|
3269
3600
|
return `${n}/transaction/${t.toLowerCase()}`;
|
|
3270
|
-
case
|
|
3601
|
+
case i.Litecoin:
|
|
3271
3602
|
return `${n}/${t}`;
|
|
3272
3603
|
default:
|
|
3273
3604
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3274
3605
|
}
|
|
3275
|
-
},
|
|
3276
|
-
const n =
|
|
3606
|
+
}, dn = ({ chain: e, address: t }) => {
|
|
3607
|
+
const n = Ne[e];
|
|
3277
3608
|
switch (e) {
|
|
3278
|
-
case
|
|
3279
|
-
case
|
|
3280
|
-
case
|
|
3281
|
-
case
|
|
3282
|
-
case
|
|
3283
|
-
case
|
|
3284
|
-
case
|
|
3285
|
-
case
|
|
3286
|
-
case
|
|
3287
|
-
case
|
|
3288
|
-
case
|
|
3289
|
-
case
|
|
3290
|
-
case
|
|
3609
|
+
case i.Arbitrum:
|
|
3610
|
+
case i.Avalanche:
|
|
3611
|
+
case i.Binance:
|
|
3612
|
+
case i.BinanceSmartChain:
|
|
3613
|
+
case i.Bitcoin:
|
|
3614
|
+
case i.BitcoinCash:
|
|
3615
|
+
case i.Dogecoin:
|
|
3616
|
+
case i.Ethereum:
|
|
3617
|
+
case i.Maya:
|
|
3618
|
+
case i.Optimism:
|
|
3619
|
+
case i.Polygon:
|
|
3620
|
+
case i.Kujira:
|
|
3621
|
+
case i.THORChain:
|
|
3291
3622
|
return `${n}/address/${t}`;
|
|
3292
|
-
case
|
|
3623
|
+
case i.Cosmos:
|
|
3293
3624
|
return `${n}/account/${t}`;
|
|
3294
|
-
case
|
|
3625
|
+
case i.Litecoin:
|
|
3295
3626
|
return `${n}/${t}`;
|
|
3296
3627
|
default:
|
|
3297
3628
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3298
3629
|
}
|
|
3299
|
-
},
|
|
3630
|
+
}, un = (e) => {
|
|
3300
3631
|
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3301
|
-
return
|
|
3302
|
-
},
|
|
3632
|
+
return be.get(`${t}/thorchain/inbound_addresses`);
|
|
3633
|
+
}, ln = (e) => {
|
|
3303
3634
|
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3304
|
-
return
|
|
3305
|
-
},
|
|
3635
|
+
return be.get(`${t}/thorchain/mimir`);
|
|
3636
|
+
}, Se = () => Object.values(i).reduce(
|
|
3306
3637
|
(e, t) => (e[t] = null, e),
|
|
3307
3638
|
{}
|
|
3308
3639
|
);
|
|
3309
|
-
var
|
|
3310
|
-
class
|
|
3640
|
+
var B, te, j, N, Y, K;
|
|
3641
|
+
class Nn {
|
|
3311
3642
|
constructor({ stagenet: t } = {}) {
|
|
3312
|
-
T(this, "connectedChains",
|
|
3313
|
-
T(this, "connectedWallets",
|
|
3643
|
+
T(this, "connectedChains", Se());
|
|
3644
|
+
T(this, "connectedWallets", Se());
|
|
3314
3645
|
T(this, "stagenet", !1);
|
|
3315
3646
|
T(this, "getAddress", (t) => {
|
|
3316
3647
|
var n;
|
|
3317
3648
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3318
3649
|
});
|
|
3319
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3650
|
+
T(this, "getExplorerTxUrl", (t, n) => pn({ chain: t, txHash: n }));
|
|
3320
3651
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3321
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3652
|
+
T(this, "getExplorerAddressUrl", (t, n) => dn({ chain: t, address: n }));
|
|
3322
3653
|
T(this, "getBalance", async (t, n) => {
|
|
3323
3654
|
const a = await this.getWalletByChain(t, n);
|
|
3324
3655
|
return (a == null ? void 0 : a.balance) || [];
|
|
3325
3656
|
});
|
|
3326
|
-
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey:
|
|
3327
|
-
var
|
|
3328
|
-
const { quoteMode: r } = a.meta,
|
|
3657
|
+
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: s }) => {
|
|
3658
|
+
var p, u;
|
|
3659
|
+
const { quoteMode: r } = a.meta, o = r.startsWith("ERC20-") ? i.Ethereum : r.startsWith("ARC20-") ? i.Avalanche : i.BinanceSmartChain;
|
|
3329
3660
|
if (!a.complete)
|
|
3330
3661
|
throw new m("core_swap_route_not_complete");
|
|
3331
3662
|
try {
|
|
3332
|
-
if (
|
|
3333
|
-
const
|
|
3334
|
-
if (!(
|
|
3663
|
+
if (ze.includes(r)) {
|
|
3664
|
+
const y = this.connectedWallets[o];
|
|
3665
|
+
if (!(y != null && y.sendTransaction))
|
|
3335
3666
|
throw new m("core_wallet_connection_not_found");
|
|
3336
|
-
if (!(t ? (
|
|
3667
|
+
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3337
3668
|
throw new m("core_swap_route_transaction_not_found");
|
|
3338
|
-
const { isHexString: c, parseUnits:
|
|
3339
|
-
data:
|
|
3669
|
+
const { isHexString: c, parseUnits: _ } = await import("./index-cf1865cd.js"), { data: A, from: R, to: g, value: E } = a.transaction, I = {
|
|
3670
|
+
data: A,
|
|
3340
3671
|
from: R,
|
|
3341
|
-
to:
|
|
3342
|
-
chainId: BigInt(
|
|
3343
|
-
value: E ? new
|
|
3344
|
-
value: c(E) ? E :
|
|
3672
|
+
to: g.toLowerCase(),
|
|
3673
|
+
chainId: BigInt(rt[o]),
|
|
3674
|
+
value: E ? new Te({
|
|
3675
|
+
value: c(E) ? E : _(E, "wei").toString(16)
|
|
3345
3676
|
}).baseValueBigInt : 0n
|
|
3346
3677
|
};
|
|
3347
|
-
return
|
|
3678
|
+
return y.sendTransaction(I, s);
|
|
3348
3679
|
}
|
|
3349
|
-
if (
|
|
3680
|
+
if (et.includes(r)) {
|
|
3350
3681
|
if (!a.calldata.fromAsset)
|
|
3351
3682
|
throw new m("core_swap_asset_not_recognized");
|
|
3352
|
-
const
|
|
3353
|
-
if (!
|
|
3683
|
+
const y = await v.fromString(a.calldata.fromAsset);
|
|
3684
|
+
if (!y)
|
|
3354
3685
|
throw new m("core_swap_asset_not_recognized");
|
|
3355
|
-
const { address:
|
|
3686
|
+
const { address: d } = await f(this, B).call(this, y.chain), {
|
|
3356
3687
|
contract: c,
|
|
3357
|
-
calldata: { expiration:
|
|
3358
|
-
} = a, E =
|
|
3688
|
+
calldata: { expiration: _, amountIn: A, memo: R, memoStreamingSwap: g }
|
|
3689
|
+
} = a, E = y.add(Te.fromBigInt(BigInt(A), y.decimal)), I = t && g || R;
|
|
3359
3690
|
return this.deposit({
|
|
3360
|
-
expiration:
|
|
3691
|
+
expiration: _,
|
|
3361
3692
|
assetValue: E,
|
|
3362
3693
|
memo: I,
|
|
3363
|
-
feeOptionKey:
|
|
3694
|
+
feeOptionKey: s,
|
|
3364
3695
|
router: c,
|
|
3365
|
-
recipient:
|
|
3696
|
+
recipient: d
|
|
3366
3697
|
});
|
|
3367
3698
|
}
|
|
3368
|
-
if (
|
|
3369
|
-
const { calldata:
|
|
3370
|
-
if (!
|
|
3699
|
+
if (Ze.includes(r)) {
|
|
3700
|
+
const { calldata: y, contract: d } = a;
|
|
3701
|
+
if (!d)
|
|
3371
3702
|
throw new m("core_swap_contract_not_found");
|
|
3372
|
-
const c = this.connectedWallets[
|
|
3373
|
-
if (!(c != null && c.sendTransaction) || !
|
|
3703
|
+
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3704
|
+
if (!(c != null && c.sendTransaction) || !_)
|
|
3374
3705
|
throw new m("core_wallet_connection_not_found");
|
|
3375
|
-
const { getProvider:
|
|
3706
|
+
const { getProvider: A, toChecksumAddress: R } = await import("@swapkit/toolbox-evm"), g = A(o), E = rn[d.toLowerCase()];
|
|
3376
3707
|
if (!E)
|
|
3377
|
-
throw new m("core_swap_contract_not_supported", { contractAddress:
|
|
3378
|
-
const S = await (await ((
|
|
3379
|
-
...
|
|
3708
|
+
throw new m("core_swap_contract_not_supported", { contractAddress: d });
|
|
3709
|
+
const S = await (await ((u = c.createContract) == null ? void 0 : u.call(c, d, E, g))).getFunction("swapIn").populateTransaction(
|
|
3710
|
+
...on({
|
|
3380
3711
|
streamSwap: t,
|
|
3381
3712
|
toChecksumAddress: R,
|
|
3382
|
-
contractAddress:
|
|
3713
|
+
contractAddress: d,
|
|
3383
3714
|
recipient: n,
|
|
3384
|
-
calldata:
|
|
3715
|
+
calldata: y
|
|
3385
3716
|
}),
|
|
3386
|
-
{ from:
|
|
3717
|
+
{ from: _ }
|
|
3387
3718
|
);
|
|
3388
|
-
return c.sendTransaction(S,
|
|
3719
|
+
return c.sendTransaction(S, s);
|
|
3389
3720
|
}
|
|
3390
3721
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3391
|
-
} catch (
|
|
3392
|
-
throw new m("core_swap_transaction_error",
|
|
3722
|
+
} catch (y) {
|
|
3723
|
+
throw new m("core_swap_transaction_error", y);
|
|
3393
3724
|
}
|
|
3394
3725
|
});
|
|
3395
3726
|
T(this, "getWalletByChain", async (t, n) => {
|
|
3396
|
-
var r,
|
|
3727
|
+
var r, o;
|
|
3397
3728
|
const a = this.getAddress(t);
|
|
3398
3729
|
if (!a)
|
|
3399
3730
|
return null;
|
|
3400
|
-
const
|
|
3731
|
+
const s = await ((r = this.getWallet(t)) == null ? void 0 : r.getBalance(a, n)) ?? [
|
|
3401
3732
|
v.fromChainOrSignature(t)
|
|
3402
3733
|
];
|
|
3403
3734
|
return this.connectedChains[t] = {
|
|
3404
3735
|
address: a,
|
|
3405
|
-
balance:
|
|
3406
|
-
walletType: (
|
|
3736
|
+
balance: s,
|
|
3737
|
+
walletType: (o = this.connectedChains[t]) == null ? void 0 : o.walletType
|
|
3407
3738
|
}, { ...this.connectedChains[t] };
|
|
3408
3739
|
});
|
|
3409
|
-
T(this, "approveAssetValue", (t, n) => f(this,
|
|
3410
|
-
T(this, "isAssetValueApproved", (t, n) => f(this,
|
|
3740
|
+
T(this, "approveAssetValue", (t, n) => f(this, j).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3741
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, j).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3411
3742
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3412
|
-
var a,
|
|
3413
|
-
return (
|
|
3743
|
+
var a, s;
|
|
3744
|
+
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
3414
3745
|
});
|
|
3415
3746
|
T(this, "transfer", async (t) => {
|
|
3416
3747
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
3417
3748
|
if (!n)
|
|
3418
3749
|
throw new m("core_wallet_connection_not_found");
|
|
3419
3750
|
try {
|
|
3420
|
-
return await n.transfer(f(this,
|
|
3751
|
+
return await n.transfer(f(this, K).call(this, t));
|
|
3421
3752
|
} catch (a) {
|
|
3422
3753
|
throw new m("core_swap_transaction_error", a);
|
|
3423
3754
|
}
|
|
@@ -3426,46 +3757,46 @@ class en {
|
|
|
3426
3757
|
assetValue: t,
|
|
3427
3758
|
recipient: n,
|
|
3428
3759
|
router: a,
|
|
3429
|
-
...
|
|
3760
|
+
...s
|
|
3430
3761
|
}) => {
|
|
3431
|
-
const { chain: r, symbol:
|
|
3432
|
-
if (!
|
|
3762
|
+
const { chain: r, symbol: o, ticker: p } = t, u = this.connectedWallets[r];
|
|
3763
|
+
if (!u)
|
|
3433
3764
|
throw new m("core_wallet_connection_not_found");
|
|
3434
|
-
const
|
|
3765
|
+
const y = f(this, K).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3435
3766
|
try {
|
|
3436
3767
|
switch (r) {
|
|
3437
|
-
case
|
|
3438
|
-
const
|
|
3439
|
-
return await (n === "" ?
|
|
3768
|
+
case i.THORChain: {
|
|
3769
|
+
const d = u;
|
|
3770
|
+
return await (n === "" ? d.deposit(y) : d.transfer(y));
|
|
3440
3771
|
}
|
|
3441
|
-
case
|
|
3442
|
-
case
|
|
3443
|
-
case
|
|
3444
|
-
const { getChecksumAddressFromAsset:
|
|
3445
|
-
return await
|
|
3772
|
+
case i.Ethereum:
|
|
3773
|
+
case i.BinanceSmartChain:
|
|
3774
|
+
case i.Avalanche: {
|
|
3775
|
+
const { getChecksumAddressFromAsset: d } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Xe : r === i.BinanceSmartChain ? Je : Ke;
|
|
3776
|
+
return await u.call({
|
|
3446
3777
|
abi: c,
|
|
3447
|
-
contractAddress: a || (await f(this,
|
|
3778
|
+
contractAddress: a || (await f(this, B).call(this, r)).router,
|
|
3448
3779
|
funcName: "depositWithExpiry",
|
|
3449
3780
|
funcParams: [
|
|
3450
3781
|
n,
|
|
3451
|
-
|
|
3782
|
+
d({ chain: r, symbol: o, ticker: p }, r),
|
|
3452
3783
|
// TODO: (@Towan) Re-Check on that conversion 🙏
|
|
3453
3784
|
t.getBaseValue("bigint").toString(),
|
|
3454
|
-
|
|
3455
|
-
|
|
3785
|
+
y.memo,
|
|
3786
|
+
s.expiration
|
|
3456
3787
|
],
|
|
3457
3788
|
txOverrides: {
|
|
3458
|
-
from:
|
|
3789
|
+
from: y.from,
|
|
3459
3790
|
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
3460
3791
|
}
|
|
3461
3792
|
});
|
|
3462
3793
|
}
|
|
3463
3794
|
default:
|
|
3464
|
-
return await
|
|
3795
|
+
return await u.transfer(y);
|
|
3465
3796
|
}
|
|
3466
|
-
} catch (
|
|
3467
|
-
const c = ((
|
|
3468
|
-
throw new m(
|
|
3797
|
+
} catch (d) {
|
|
3798
|
+
const c = ((d == null ? void 0 : d.message) || (d == null ? void 0 : d.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), A = c == null ? void 0 : c.includes("gas"), R = c == null ? void 0 : c.includes("server"), g = _ ? "core_transaction_deposit_insufficient_funds_error" : A ? "core_transaction_deposit_gas_error" : R ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3799
|
+
throw new m(g, d);
|
|
3469
3800
|
}
|
|
3470
3801
|
});
|
|
3471
3802
|
/**
|
|
@@ -3477,11 +3808,11 @@ class en {
|
|
|
3477
3808
|
}) => {
|
|
3478
3809
|
if (t.lte(0) || n.lte(0))
|
|
3479
3810
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3480
|
-
let a = "",
|
|
3811
|
+
let a = "", s = "";
|
|
3481
3812
|
try {
|
|
3482
3813
|
a = await f(this, N).call(this, {
|
|
3483
3814
|
assetValue: t,
|
|
3484
|
-
memo: x(
|
|
3815
|
+
memo: x(h.DEPOSIT, {
|
|
3485
3816
|
...n,
|
|
3486
3817
|
address: this.getAddress(n.chain)
|
|
3487
3818
|
})
|
|
@@ -3490,48 +3821,48 @@ class en {
|
|
|
3490
3821
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3491
3822
|
}
|
|
3492
3823
|
try {
|
|
3493
|
-
|
|
3824
|
+
s = await f(this, N).call(this, {
|
|
3494
3825
|
assetValue: n,
|
|
3495
|
-
memo: x(
|
|
3826
|
+
memo: x(h.DEPOSIT, {
|
|
3496
3827
|
...n,
|
|
3497
|
-
address: this.getAddress(
|
|
3828
|
+
address: this.getAddress(i.THORChain)
|
|
3498
3829
|
})
|
|
3499
3830
|
});
|
|
3500
3831
|
} catch (r) {
|
|
3501
3832
|
throw new m("core_transaction_create_liquidity_asset_error", r);
|
|
3502
3833
|
}
|
|
3503
|
-
return { runeTx: a, assetTx:
|
|
3834
|
+
return { runeTx: a, assetTx: s };
|
|
3504
3835
|
});
|
|
3505
3836
|
T(this, "addLiquidity", async ({
|
|
3506
3837
|
poolIdentifier: t,
|
|
3507
3838
|
runeAssetValue: n,
|
|
3508
3839
|
assetValue: a,
|
|
3509
|
-
runeAddr:
|
|
3840
|
+
runeAddr: s,
|
|
3510
3841
|
assetAddr: r,
|
|
3511
|
-
isPendingSymmAsset:
|
|
3512
|
-
mode:
|
|
3842
|
+
isPendingSymmAsset: o,
|
|
3843
|
+
mode: p = "sym"
|
|
3513
3844
|
}) => {
|
|
3514
|
-
const [
|
|
3515
|
-
if (!c && !
|
|
3845
|
+
const [u, ...y] = t.split("."), d = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (d || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (d || p === "asset"), A = o || c, R = A ? s || this.getAddress(i.THORChain) : "", g = d || p === "asset" ? r || this.getAddress(u) : "";
|
|
3846
|
+
if (!c && !_)
|
|
3516
3847
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3517
|
-
if (
|
|
3848
|
+
if (A && !R)
|
|
3518
3849
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3519
3850
|
let E, I;
|
|
3520
|
-
const S = { chain:
|
|
3851
|
+
const S = { chain: u, symbol: y.join(".") };
|
|
3521
3852
|
if (c && n)
|
|
3522
3853
|
try {
|
|
3523
3854
|
E = await f(this, N).call(this, {
|
|
3524
3855
|
assetValue: n,
|
|
3525
|
-
memo: x(
|
|
3856
|
+
memo: x(h.DEPOSIT, { ...S, address: g })
|
|
3526
3857
|
});
|
|
3527
3858
|
} catch (D) {
|
|
3528
3859
|
throw new m("core_transaction_add_liquidity_rune_error", D);
|
|
3529
3860
|
}
|
|
3530
|
-
if (
|
|
3861
|
+
if (_ && a)
|
|
3531
3862
|
try {
|
|
3532
3863
|
I = await f(this, N).call(this, {
|
|
3533
3864
|
assetValue: a,
|
|
3534
|
-
memo: x(
|
|
3865
|
+
memo: x(h.DEPOSIT, { ...S, address: R })
|
|
3535
3866
|
});
|
|
3536
3867
|
} catch (D) {
|
|
3537
3868
|
throw new m("core_transaction_add_liquidity_asset_error", D);
|
|
@@ -3542,49 +3873,49 @@ class en {
|
|
|
3542
3873
|
memo: t,
|
|
3543
3874
|
assetValue: n,
|
|
3544
3875
|
percent: a,
|
|
3545
|
-
from:
|
|
3876
|
+
from: s,
|
|
3546
3877
|
to: r
|
|
3547
3878
|
}) => {
|
|
3548
|
-
const
|
|
3879
|
+
const o = r === "rune" ? v.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n;
|
|
3549
3880
|
try {
|
|
3550
3881
|
return await f(this, N).call(this, {
|
|
3551
|
-
assetValue:
|
|
3552
|
-
memo: t || x(
|
|
3882
|
+
assetValue: Ie(s === "asset" ? n.chain : i.THORChain),
|
|
3883
|
+
memo: t || x(h.WITHDRAW, {
|
|
3553
3884
|
symbol: n.symbol,
|
|
3554
3885
|
chain: n.chain,
|
|
3555
3886
|
ticker: n.ticker,
|
|
3556
3887
|
basisPoints: Math.max(1e4, Math.round(a * 100)),
|
|
3557
|
-
targetAssetString:
|
|
3888
|
+
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3558
3889
|
singleSide: !1
|
|
3559
3890
|
})
|
|
3560
3891
|
});
|
|
3561
|
-
} catch (
|
|
3562
|
-
throw new m("core_transaction_withdraw_error",
|
|
3892
|
+
} catch (p) {
|
|
3893
|
+
throw new m("core_transaction_withdraw_error", p);
|
|
3563
3894
|
}
|
|
3564
3895
|
});
|
|
3565
3896
|
T(this, "savings", async ({
|
|
3566
3897
|
assetValue: t,
|
|
3567
3898
|
memo: n,
|
|
3568
3899
|
percent: a,
|
|
3569
|
-
type:
|
|
3900
|
+
type: s
|
|
3570
3901
|
}) => {
|
|
3571
|
-
const r =
|
|
3902
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || x(r, {
|
|
3572
3903
|
ticker: t.ticker,
|
|
3573
3904
|
symbol: t.symbol,
|
|
3574
3905
|
chain: t.chain,
|
|
3575
3906
|
singleSide: !0,
|
|
3576
3907
|
basisPoints: a ? Math.max(1e4, Math.round(a * 100)) : void 0
|
|
3577
3908
|
});
|
|
3578
|
-
return f(this, N).call(this, { assetValue: t, memo:
|
|
3909
|
+
return f(this, N).call(this, { assetValue: t, memo: o });
|
|
3579
3910
|
});
|
|
3580
3911
|
T(this, "loan", ({
|
|
3581
3912
|
assetValue: t,
|
|
3582
3913
|
memo: n,
|
|
3583
3914
|
minAmount: a,
|
|
3584
|
-
type:
|
|
3915
|
+
type: s
|
|
3585
3916
|
}) => f(this, N).call(this, {
|
|
3586
3917
|
assetValue: t,
|
|
3587
|
-
memo: n || x(
|
|
3918
|
+
memo: n || x(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3588
3919
|
asset: t.toString(),
|
|
3589
3920
|
minAmount: a.toString(),
|
|
3590
3921
|
address: this.getAddress(t.chain)
|
|
@@ -3595,27 +3926,27 @@ class en {
|
|
|
3595
3926
|
assetValue: n,
|
|
3596
3927
|
address: a
|
|
3597
3928
|
}) => {
|
|
3598
|
-
const
|
|
3929
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = x(s, {
|
|
3599
3930
|
address: a,
|
|
3600
3931
|
unbondAmount: t === "unbond" ? n.baseValueNumber : void 0
|
|
3601
3932
|
});
|
|
3602
3933
|
return f(this, Y).call(this, {
|
|
3603
3934
|
memo: r,
|
|
3604
|
-
assetValue: t === "bond" ? n :
|
|
3935
|
+
assetValue: t === "bond" ? n : Ie(i.THORChain)
|
|
3605
3936
|
});
|
|
3606
3937
|
});
|
|
3607
3938
|
T(this, "registerThorname", ({
|
|
3608
3939
|
assetValue: t,
|
|
3609
3940
|
...n
|
|
3610
|
-
}) => f(this, Y).call(this, { assetValue: t, memo: x(
|
|
3611
|
-
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls:
|
|
3941
|
+
}) => f(this, Y).call(this, { assetValue: t, memo: x(h.THORNAME_REGISTER, n) }));
|
|
3942
|
+
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3612
3943
|
try {
|
|
3613
3944
|
t.forEach((r) => {
|
|
3614
3945
|
this[r.connectMethodName] = r.connect({
|
|
3615
|
-
addChain: f(this,
|
|
3946
|
+
addChain: f(this, te),
|
|
3616
3947
|
config: n || {},
|
|
3617
3948
|
apis: a,
|
|
3618
|
-
rpcUrls:
|
|
3949
|
+
rpcUrls: s
|
|
3619
3950
|
});
|
|
3620
3951
|
});
|
|
3621
3952
|
} catch (r) {
|
|
@@ -3628,28 +3959,28 @@ class en {
|
|
|
3628
3959
|
}) => {
|
|
3629
3960
|
const a = this.getWallet(t);
|
|
3630
3961
|
switch (t) {
|
|
3631
|
-
case
|
|
3632
|
-
case
|
|
3633
|
-
case
|
|
3634
|
-
case
|
|
3635
|
-
case
|
|
3636
|
-
case
|
|
3637
|
-
const { estimateMaxSendableAmount:
|
|
3638
|
-
return
|
|
3962
|
+
case i.Arbitrum:
|
|
3963
|
+
case i.Avalanche:
|
|
3964
|
+
case i.BinanceSmartChain:
|
|
3965
|
+
case i.Ethereum:
|
|
3966
|
+
case i.Optimism:
|
|
3967
|
+
case i.Polygon: {
|
|
3968
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-evm");
|
|
3969
|
+
return s({
|
|
3639
3970
|
...n,
|
|
3640
3971
|
toolbox: a
|
|
3641
3972
|
});
|
|
3642
3973
|
}
|
|
3643
|
-
case
|
|
3644
|
-
case
|
|
3645
|
-
case
|
|
3646
|
-
case
|
|
3974
|
+
case i.Bitcoin:
|
|
3975
|
+
case i.BitcoinCash:
|
|
3976
|
+
case i.Dogecoin:
|
|
3977
|
+
case i.Litecoin:
|
|
3647
3978
|
return a.estimateMaxSendableAmount(n);
|
|
3648
|
-
case
|
|
3649
|
-
case
|
|
3650
|
-
case
|
|
3651
|
-
const { estimateMaxSendableAmount:
|
|
3652
|
-
return
|
|
3979
|
+
case i.Binance:
|
|
3980
|
+
case i.THORChain:
|
|
3981
|
+
case i.Cosmos: {
|
|
3982
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-cosmos");
|
|
3983
|
+
return s({
|
|
3653
3984
|
...n,
|
|
3654
3985
|
toolbox: a
|
|
3655
3986
|
});
|
|
@@ -3688,72 +4019,72 @@ class en {
|
|
|
3688
4019
|
T(this, "disconnectChain", (t) => {
|
|
3689
4020
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
3690
4021
|
});
|
|
3691
|
-
|
|
3692
|
-
if (t ===
|
|
4022
|
+
P(this, B, async (t) => {
|
|
4023
|
+
if (t === i.THORChain)
|
|
3693
4024
|
return {
|
|
3694
4025
|
gas_rate: "0",
|
|
3695
4026
|
router: "0",
|
|
3696
4027
|
address: "",
|
|
3697
4028
|
halted: !1,
|
|
3698
|
-
chain:
|
|
4029
|
+
chain: i.THORChain
|
|
3699
4030
|
};
|
|
3700
|
-
const a = (await
|
|
4031
|
+
const a = (await un(this.stagenet)).find((s) => s.chain === t);
|
|
3701
4032
|
if (!a)
|
|
3702
4033
|
throw new m("core_inbound_data_not_found");
|
|
3703
4034
|
if (a != null && a.halted)
|
|
3704
4035
|
throw new m("core_chain_halted");
|
|
3705
4036
|
return a;
|
|
3706
4037
|
});
|
|
3707
|
-
|
|
4038
|
+
P(this, te, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
3708
4039
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
3709
4040
|
});
|
|
3710
|
-
|
|
3711
|
-
assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset:
|
|
3712
|
-
type:
|
|
3713
|
-
contractAddress:
|
|
4041
|
+
P(this, j, async ({
|
|
4042
|
+
assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset: s, isSynthetic: r },
|
|
4043
|
+
type: o = "checkOnly",
|
|
4044
|
+
contractAddress: p
|
|
3714
4045
|
}) => {
|
|
3715
|
-
const
|
|
3716
|
-
if (
|
|
4046
|
+
const u = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(a);
|
|
4047
|
+
if (u && s || !u || r)
|
|
3717
4048
|
return !0;
|
|
3718
|
-
const
|
|
4049
|
+
const d = this.connectedWallets[a], c = o === "checkOnly" ? d == null ? void 0 : d.isApproved : d == null ? void 0 : d.approve;
|
|
3719
4050
|
if (!c)
|
|
3720
4051
|
throw new m("core_wallet_connection_not_found");
|
|
3721
|
-
const
|
|
3722
|
-
if (!n || !
|
|
4052
|
+
const _ = this.getAddress(a);
|
|
4053
|
+
if (!n || !_)
|
|
3723
4054
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
3724
|
-
const
|
|
4055
|
+
const A = p || (await f(this, B).call(this, a)).router;
|
|
3725
4056
|
return c({
|
|
3726
4057
|
amount: t,
|
|
3727
4058
|
assetAddress: n,
|
|
3728
|
-
from:
|
|
3729
|
-
spenderAddress:
|
|
4059
|
+
from: _,
|
|
4060
|
+
spenderAddress: A
|
|
3730
4061
|
});
|
|
3731
4062
|
});
|
|
3732
|
-
|
|
4063
|
+
P(this, N, async ({
|
|
3733
4064
|
assetValue: t,
|
|
3734
4065
|
memo: n,
|
|
3735
|
-
feeOptionKey: a =
|
|
4066
|
+
feeOptionKey: a = $.Fast
|
|
3736
4067
|
}) => {
|
|
3737
4068
|
const {
|
|
3738
|
-
gas_rate:
|
|
4069
|
+
gas_rate: s,
|
|
3739
4070
|
router: r,
|
|
3740
|
-
address:
|
|
3741
|
-
} = await f(this,
|
|
4071
|
+
address: o
|
|
4072
|
+
} = await f(this, B).call(this, t.chain), p = (parseInt(s) || 0) * _t[a];
|
|
3742
4073
|
return this.deposit({
|
|
3743
4074
|
assetValue: t,
|
|
3744
|
-
recipient:
|
|
4075
|
+
recipient: o,
|
|
3745
4076
|
memo: n,
|
|
3746
4077
|
router: r,
|
|
3747
|
-
feeRate:
|
|
4078
|
+
feeRate: p
|
|
3748
4079
|
});
|
|
3749
4080
|
});
|
|
3750
|
-
|
|
3751
|
-
const a = await
|
|
4081
|
+
P(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
4082
|
+
const a = await ln(this.stagenet);
|
|
3752
4083
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
3753
4084
|
throw new m("core_chain_halted");
|
|
3754
4085
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
3755
4086
|
});
|
|
3756
|
-
|
|
4087
|
+
P(this, K, ({ assetValue: t, ...n }) => ({
|
|
3757
4088
|
...n,
|
|
3758
4089
|
memo: n.memo || "",
|
|
3759
4090
|
from: this.getAddress(t.chain),
|
|
@@ -3762,66 +4093,65 @@ class en {
|
|
|
3762
4093
|
this.stagenet = !!t;
|
|
3763
4094
|
}
|
|
3764
4095
|
}
|
|
3765
|
-
|
|
4096
|
+
B = new WeakMap(), te = new WeakMap(), j = new WeakMap(), N = new WeakMap(), Y = new WeakMap(), K = new WeakMap();
|
|
3766
4097
|
export {
|
|
3767
|
-
|
|
3768
|
-
|
|
4098
|
+
ze as AGG_SWAP,
|
|
4099
|
+
mn as ApiError,
|
|
3769
4100
|
W as ApiUrl,
|
|
3770
4101
|
v as AssetValue,
|
|
3771
4102
|
b as BaseDecimal,
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
4103
|
+
le as BigIntArithmetics,
|
|
4104
|
+
i as Chain,
|
|
4105
|
+
he as ChainId,
|
|
4106
|
+
wn as ChainIdToChain,
|
|
4107
|
+
rt as ChainToChainId,
|
|
4108
|
+
Ne as ChainToExplorerUrl,
|
|
4109
|
+
bn as ChainToHexChainId,
|
|
4110
|
+
ot as ChainToRPC,
|
|
4111
|
+
at as ContractAddress,
|
|
4112
|
+
fn as CosmosChainList,
|
|
4113
|
+
st as DerivationPath,
|
|
4114
|
+
l as ERROR_CODE,
|
|
4115
|
+
tt as ERROR_MODULE,
|
|
4116
|
+
ve as ERROR_TYPE,
|
|
4117
|
+
hn as EVMChainList,
|
|
4118
|
+
pt as ErrorCode,
|
|
4119
|
+
$ as FeeOption,
|
|
4120
|
+
h as MemoType,
|
|
4121
|
+
Tn as NetworkDerivationPath,
|
|
4122
|
+
Qe as QuoteMode,
|
|
4123
|
+
Me as RPCUrl,
|
|
4124
|
+
be as RequestClient,
|
|
4125
|
+
Ze as SWAP_IN,
|
|
4126
|
+
et as SWAP_OUT,
|
|
4127
|
+
Nn as SwapKitCore,
|
|
3796
4128
|
m as SwapKitError,
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
4129
|
+
Te as SwapKitNumber,
|
|
4130
|
+
Xe as TCAvalancheDepositABI,
|
|
4131
|
+
Je as TCBscDepositABI,
|
|
4132
|
+
Ke as TCEthereumVaultAbi,
|
|
4133
|
+
_n as UTXOChainList,
|
|
4134
|
+
dt as WalletOption,
|
|
4135
|
+
An as assetFromString,
|
|
4136
|
+
Mn as derivationPathToString,
|
|
4137
|
+
cn as erc20ABI,
|
|
4138
|
+
En as filterAssets,
|
|
4139
|
+
He as formatBigIntToSafeValue,
|
|
4140
|
+
_t as gasFeeMultiplier,
|
|
4141
|
+
wt as getAssetType,
|
|
4142
|
+
Rt as getAsymmetricAssetShare,
|
|
4143
|
+
gn as getAsymmetricAssetWithdrawAmount,
|
|
4144
|
+
Et as getAsymmetricRuneShare,
|
|
4145
|
+
Rn as getAsymmetricRuneWithdrawAmount,
|
|
4146
|
+
bt as getCommonAssetInfo,
|
|
4147
|
+
De as getDecimal,
|
|
4148
|
+
In as getEstimatedPoolShare,
|
|
4149
|
+
Sn as getLiquiditySlippage,
|
|
3818
4150
|
x as getMemoFor,
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
Ze as postRequest,
|
|
3826
|
-
qt as validateTHORName
|
|
4151
|
+
Ie as getMinAmountByChain,
|
|
4152
|
+
gt as getSymmetricPoolShare,
|
|
4153
|
+
On as getSymmetricWithdraw,
|
|
4154
|
+
vn as getTHORNameCost,
|
|
4155
|
+
ft as isGasAsset,
|
|
4156
|
+
Cn as validateTHORName
|
|
3827
4157
|
};
|