@swapkit/core 1.0.0-rc.13 → 1.0.0-rc.15
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 +1012 -672
- 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 || {}), k = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(k || {}), 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) => {
|
|
834
|
+
}, O = (e, t, n) => (yt(e, t, "access private method"), n);
|
|
835
|
+
const ct = "0x313ce567", xe = async ({ chain: e, to: t }) => {
|
|
845
836
|
try {
|
|
846
|
-
const n =
|
|
847
|
-
|
|
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 }) => {
|
|
870
|
-
try {
|
|
871
|
-
const n = await Ze(
|
|
872
|
-
Ye[e],
|
|
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
|
-
},
|
|
869
|
+
}, _t = {
|
|
906
870
|
[k.Average]: 1.2,
|
|
907
871
|
[k.Fast]: 1.5,
|
|
908
872
|
[k.Fastest]: 2
|
|
909
|
-
},
|
|
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
|
+
}, $t = re(), kt = $t, Ee = kt.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, $, oe, $e, 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, $e).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, $).call(this, "add", ...t);
|
|
1176
1507
|
}
|
|
1177
1508
|
sub(...t) {
|
|
1178
|
-
return
|
|
1509
|
+
return O(this, L, $).call(this, "sub", ...t);
|
|
1179
1510
|
}
|
|
1180
1511
|
mul(...t) {
|
|
1181
|
-
return
|
|
1512
|
+
return O(this, L, $).call(this, "mul", ...t);
|
|
1182
1513
|
}
|
|
1183
1514
|
div(...t) {
|
|
1184
|
-
return
|
|
1515
|
+
return O(this, L, $).call(this, "div", ...t);
|
|
1185
1516
|
}
|
|
1186
1517
|
gt(t) {
|
|
1187
1518
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1226,109 +1557,119 @@ 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,
|
|
1588
|
+
"0"
|
|
1589
|
+
)}`;
|
|
1590
|
+
}
|
|
1591
|
+
toFixed(t = 6) {
|
|
1592
|
+
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
1593
|
+
if (parseInt(s))
|
|
1594
|
+
return `${s}.${r.slice(0, t)}`.padEnd(t, "0");
|
|
1595
|
+
const o = parseInt(r), p = `${o}`.slice(0, t);
|
|
1596
|
+
return `0.${p.padStart(
|
|
1597
|
+
r.length - `${o}`.length + p.length,
|
|
1257
1598
|
"0"
|
|
1258
1599
|
)}`;
|
|
1259
1600
|
}
|
|
1260
1601
|
};
|
|
1261
1602
|
L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
1262
|
-
const n =
|
|
1263
|
-
(
|
|
1264
|
-
const
|
|
1603
|
+
const n = O(this, pe, ge).call(this, this, ...t), a = U(n), s = t.reduce(
|
|
1604
|
+
(o, p) => {
|
|
1605
|
+
const u = this.getBigIntValue(p, n);
|
|
1265
1606
|
switch (e) {
|
|
1266
1607
|
case "add":
|
|
1267
|
-
return
|
|
1608
|
+
return o + u;
|
|
1268
1609
|
case "sub":
|
|
1269
|
-
return
|
|
1610
|
+
return o - u;
|
|
1270
1611
|
case "mul":
|
|
1271
|
-
return
|
|
1612
|
+
return o * u / a;
|
|
1272
1613
|
case "div": {
|
|
1273
|
-
if (
|
|
1614
|
+
if (u === 0n)
|
|
1274
1615
|
throw new RangeError("Division by zero");
|
|
1275
|
-
return
|
|
1616
|
+
return o * a / u;
|
|
1276
1617
|
}
|
|
1277
1618
|
default:
|
|
1278
|
-
return
|
|
1619
|
+
return o;
|
|
1279
1620
|
}
|
|
1280
1621
|
},
|
|
1281
1622
|
//normalize is to precision multiplier base
|
|
1282
1623
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1283
|
-
), r =
|
|
1624
|
+
), r = He({
|
|
1284
1625
|
bigIntDecimal: n,
|
|
1285
1626
|
decimal: Math.max(n, F(this.decimalMultiplier)),
|
|
1286
|
-
value:
|
|
1627
|
+
value: s
|
|
1287
1628
|
});
|
|
1288
1629
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1289
|
-
},
|
|
1290
|
-
const t =
|
|
1291
|
-
this.bigIntValue =
|
|
1292
|
-
},
|
|
1630
|
+
}, oe = /* @__PURE__ */ new WeakSet(), $e = function(e) {
|
|
1631
|
+
const t = O(this, H, G).call(this, e) || "0";
|
|
1632
|
+
this.bigIntValue = O(this, Z, de).call(this, t);
|
|
1633
|
+
}, pe = /* @__PURE__ */ new WeakSet(), ge = function(...e) {
|
|
1293
1634
|
const t = e.map(
|
|
1294
|
-
(n) => typeof n == "object" ? n.decimal || F(n.decimalMultiplier) :
|
|
1635
|
+
(n) => typeof n == "object" ? n.decimal || F(n.decimalMultiplier) : O(this, ee, ue).call(this, O(this, H, G).call(this, n))
|
|
1295
1636
|
).filter(Boolean);
|
|
1296
1637
|
return Math.max(...t, q);
|
|
1297
|
-
},
|
|
1298
|
-
const n = t ? U(t) : this.decimalMultiplier, a = F(n), [
|
|
1299
|
-
return BigInt(`${
|
|
1638
|
+
}, Z = /* @__PURE__ */ new WeakSet(), de = function(e, t) {
|
|
1639
|
+
const n = t ? U(t) : this.decimalMultiplier, a = F(n), [s = "", r = ""] = e.split(".");
|
|
1640
|
+
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1300
1641
|
}, H = /* @__PURE__ */ new WeakSet(), G = function(e) {
|
|
1301
1642
|
const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
|
|
1302
1643
|
useGrouping: !1,
|
|
1303
1644
|
maximumFractionDigits: 20
|
|
1304
|
-
}) :
|
|
1645
|
+
}) : ye(e)}`.replaceAll(",", ".").split(".");
|
|
1305
1646
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1306
|
-
},
|
|
1647
|
+
}, ee = /* @__PURE__ */ new WeakSet(), ue = function(e) {
|
|
1307
1648
|
var t;
|
|
1308
1649
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1309
1650
|
return Math.max(n, q);
|
|
1310
1651
|
};
|
|
1311
|
-
let
|
|
1312
|
-
function
|
|
1652
|
+
let le = Gt;
|
|
1653
|
+
function ye(e) {
|
|
1313
1654
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1314
1655
|
}
|
|
1315
|
-
let
|
|
1316
|
-
const
|
|
1317
|
-
if (!
|
|
1656
|
+
let ce;
|
|
1657
|
+
const ie = (e) => {
|
|
1658
|
+
if (!ce)
|
|
1318
1659
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1319
|
-
return
|
|
1320
|
-
},
|
|
1321
|
-
|
|
1322
|
-
const n = await
|
|
1660
|
+
return ce.get(e.toUpperCase()) || { decimal: b.THOR, identifier: "" };
|
|
1661
|
+
}, Oe = async (e, t = 0) => {
|
|
1662
|
+
Ft(e);
|
|
1663
|
+
const n = await De(me(e));
|
|
1323
1664
|
return new v({ decimal: n, value: t, identifier: e });
|
|
1324
1665
|
};
|
|
1325
|
-
class v extends
|
|
1666
|
+
class v extends le {
|
|
1326
1667
|
constructor(t) {
|
|
1327
1668
|
super(
|
|
1328
|
-
t.value instanceof
|
|
1329
|
-
),
|
|
1330
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a =
|
|
1331
|
-
this.type =
|
|
1669
|
+
t.value instanceof le ? t.value : { decimal: t.decimal, value: t.value }
|
|
1670
|
+
), M(this, "address"), M(this, "chain"), M(this, "isSynthetic", !1), M(this, "isGasAsset", !1), M(this, "symbol"), M(this, "ticker"), M(this, "type");
|
|
1671
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = me(n);
|
|
1672
|
+
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
1673
|
}
|
|
1333
1674
|
get assetValue() {
|
|
1334
1675
|
return `${this.getValue("string")} ${this.ticker}`;
|
|
@@ -1344,36 +1685,36 @@ class v extends re {
|
|
|
1344
1685
|
return this.chain === t && this.symbol === n;
|
|
1345
1686
|
}
|
|
1346
1687
|
static async fromString(t, n = 0) {
|
|
1347
|
-
return
|
|
1688
|
+
return Oe(t, n);
|
|
1348
1689
|
}
|
|
1349
1690
|
static fromStringSync(t, n = 0) {
|
|
1350
|
-
const { decimal: a, identifier:
|
|
1691
|
+
const { decimal: a, identifier: s } = ie(
|
|
1351
1692
|
t
|
|
1352
1693
|
);
|
|
1353
|
-
return
|
|
1694
|
+
return s ? new v({ decimal: a, identifier: s, value: n }) : void 0;
|
|
1354
1695
|
}
|
|
1355
1696
|
static async fromIdentifier(t, n = 0) {
|
|
1356
|
-
return
|
|
1697
|
+
return Oe(t, n);
|
|
1357
1698
|
}
|
|
1358
1699
|
static fromIdentifierSync(t, n = 0) {
|
|
1359
|
-
const { decimal: a, identifier:
|
|
1360
|
-
return new v({ decimal: a, identifier:
|
|
1700
|
+
const { decimal: a, identifier: s } = ie(t);
|
|
1701
|
+
return new v({ decimal: a, identifier: s, value: n });
|
|
1361
1702
|
}
|
|
1362
1703
|
static fromChainOrSignature(t, n = 0) {
|
|
1363
|
-
const { decimal: a, identifier:
|
|
1364
|
-
return new v({ value: n, decimal: a, identifier:
|
|
1704
|
+
const { decimal: a, identifier: s } = bt(t);
|
|
1705
|
+
return new v({ value: n, decimal: a, identifier: s });
|
|
1365
1706
|
}
|
|
1366
1707
|
static async fromTCQuote(t, n = 0) {
|
|
1367
|
-
const a = await
|
|
1368
|
-
return new v({ value:
|
|
1708
|
+
const a = await De(me(t)), s = this.shiftDecimals({ value: n, from: b.THOR, to: a });
|
|
1709
|
+
return new v({ value: s, identifier: t, decimal: a });
|
|
1369
1710
|
}
|
|
1370
1711
|
static fromTCQuoteStatic(t, n = 0) {
|
|
1371
|
-
const a =
|
|
1712
|
+
const a = ie(t), s = this.shiftDecimals({
|
|
1372
1713
|
value: n,
|
|
1373
1714
|
from: b.THOR,
|
|
1374
1715
|
to: a.decimal
|
|
1375
1716
|
});
|
|
1376
|
-
return new v({ ...a, value:
|
|
1717
|
+
return new v({ ...a, value: s });
|
|
1377
1718
|
}
|
|
1378
1719
|
static async loadStaticAssets() {
|
|
1379
1720
|
return new Promise(
|
|
@@ -1383,14 +1724,14 @@ class v extends re {
|
|
|
1383
1724
|
// Omit ThorchainList from import to avoid decimals conflict (TC uses 8 for all)
|
|
1384
1725
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1385
1726
|
ThorchainList: a,
|
|
1386
|
-
NativeList:
|
|
1727
|
+
NativeList: s,
|
|
1387
1728
|
...r
|
|
1388
1729
|
} = await import("@swapkit/tokens");
|
|
1389
|
-
|
|
1390
|
-
(
|
|
1391
|
-
const c = "decimals" in
|
|
1392
|
-
|
|
1393
|
-
}),
|
|
1730
|
+
ce = [s, ...Object.values(r)].reduce(
|
|
1731
|
+
(o, { tokens: p }) => (p.forEach(({ identifier: u, chain: y, ...d }) => {
|
|
1732
|
+
const c = "decimals" in d ? d.decimals : b[y];
|
|
1733
|
+
o.set(u, { identifier: u, decimal: c });
|
|
1734
|
+
}), o),
|
|
1394
1735
|
/* @__PURE__ */ new Map()
|
|
1395
1736
|
), t({ ok: !0 });
|
|
1396
1737
|
} catch (a) {
|
|
@@ -1404,35 +1745,35 @@ class v extends re {
|
|
|
1404
1745
|
);
|
|
1405
1746
|
}
|
|
1406
1747
|
}
|
|
1407
|
-
const
|
|
1748
|
+
const Ie = (e) => {
|
|
1408
1749
|
const t = v.fromChainOrSignature(e);
|
|
1409
1750
|
switch (e) {
|
|
1410
|
-
case
|
|
1411
|
-
case
|
|
1412
|
-
case
|
|
1751
|
+
case i.Bitcoin:
|
|
1752
|
+
case i.Litecoin:
|
|
1753
|
+
case i.BitcoinCash:
|
|
1413
1754
|
return t.add(10001);
|
|
1414
|
-
case
|
|
1755
|
+
case i.Dogecoin:
|
|
1415
1756
|
return t.add(100000001);
|
|
1416
|
-
case
|
|
1417
|
-
case
|
|
1757
|
+
case i.Avalanche:
|
|
1758
|
+
case i.Ethereum:
|
|
1418
1759
|
return t.add(10 * 10 ** 9);
|
|
1419
|
-
case
|
|
1420
|
-
case
|
|
1760
|
+
case i.THORChain:
|
|
1761
|
+
case i.Maya:
|
|
1421
1762
|
return t.add(0);
|
|
1422
1763
|
default:
|
|
1423
1764
|
return t.add(1);
|
|
1424
1765
|
}
|
|
1425
|
-
},
|
|
1426
|
-
const t = e.slice(0, 14).includes("/"), n = e.includes(".") ? e : `${
|
|
1766
|
+
}, me = (e) => {
|
|
1767
|
+
const t = e.slice(0, 14).includes("/"), n = e.includes(".") ? e : `${i.THORChain}.${e}`, [a, s] = n.split("."), [r, o] = s.split("-");
|
|
1427
1768
|
return {
|
|
1428
|
-
address:
|
|
1769
|
+
address: o == null ? void 0 : o.toLowerCase(),
|
|
1429
1770
|
chain: a,
|
|
1430
|
-
isGasAsset:
|
|
1771
|
+
isGasAsset: ft({ chain: a, symbol: s }),
|
|
1431
1772
|
isSynthetic: t,
|
|
1432
|
-
symbol:
|
|
1433
|
-
ticker: t ?
|
|
1773
|
+
symbol: o ? `${r}-${(o == null ? void 0 : o.toLowerCase()) ?? ""}` : s,
|
|
1774
|
+
ticker: t ? s : r
|
|
1434
1775
|
};
|
|
1435
|
-
},
|
|
1776
|
+
}, Wt = {
|
|
1436
1777
|
/**
|
|
1437
1778
|
* Core
|
|
1438
1779
|
*/
|
|
@@ -1491,15 +1832,15 @@ const _e = (e) => {
|
|
|
1491
1832
|
};
|
|
1492
1833
|
class m extends Error {
|
|
1493
1834
|
constructor(t, n) {
|
|
1494
|
-
console.error(n), super(t, { cause: { code:
|
|
1835
|
+
console.error(n), super(t, { cause: { code: Wt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1495
1836
|
}
|
|
1496
1837
|
}
|
|
1497
|
-
class
|
|
1838
|
+
class Te extends le {
|
|
1498
1839
|
eq(t) {
|
|
1499
1840
|
return this.eqValue(t);
|
|
1500
1841
|
}
|
|
1501
1842
|
}
|
|
1502
|
-
const
|
|
1843
|
+
const qt = [
|
|
1503
1844
|
{
|
|
1504
1845
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1505
1846
|
stateMutability: "nonpayable",
|
|
@@ -1590,7 +1931,7 @@ const _t = [
|
|
|
1590
1931
|
type: "function"
|
|
1591
1932
|
},
|
|
1592
1933
|
{ stateMutability: "payable", type: "receive" }
|
|
1593
|
-
],
|
|
1934
|
+
], jt = [
|
|
1594
1935
|
{
|
|
1595
1936
|
inputs: [
|
|
1596
1937
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -1734,7 +2075,7 @@ const _t = [
|
|
|
1734
2075
|
type: "function"
|
|
1735
2076
|
},
|
|
1736
2077
|
{ stateMutability: "payable", type: "receive" }
|
|
1737
|
-
],
|
|
2078
|
+
], Yt = [
|
|
1738
2079
|
{
|
|
1739
2080
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1740
2081
|
stateMutability: "nonpayable",
|
|
@@ -1839,7 +2180,7 @@ const _t = [
|
|
|
1839
2180
|
type: "function"
|
|
1840
2181
|
},
|
|
1841
2182
|
{ stateMutability: "payable", type: "receive" }
|
|
1842
|
-
],
|
|
2183
|
+
], Kt = [
|
|
1843
2184
|
{
|
|
1844
2185
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1845
2186
|
stateMutability: "nonpayable",
|
|
@@ -1930,7 +2271,7 @@ const _t = [
|
|
|
1930
2271
|
type: "function"
|
|
1931
2272
|
},
|
|
1932
2273
|
{ stateMutability: "payable", type: "receive" }
|
|
1933
|
-
],
|
|
2274
|
+
], Xt = [
|
|
1934
2275
|
{
|
|
1935
2276
|
inputs: [
|
|
1936
2277
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2074,7 +2415,7 @@ const _t = [
|
|
|
2074
2415
|
type: "function"
|
|
2075
2416
|
},
|
|
2076
2417
|
{ stateMutability: "payable", type: "receive" }
|
|
2077
|
-
],
|
|
2418
|
+
], Jt = [
|
|
2078
2419
|
{
|
|
2079
2420
|
inputs: [
|
|
2080
2421
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2193,7 +2534,7 @@ const _t = [
|
|
|
2193
2534
|
type: "function"
|
|
2194
2535
|
},
|
|
2195
2536
|
{ stateMutability: "payable", type: "receive" }
|
|
2196
|
-
],
|
|
2537
|
+
], Qt = [
|
|
2197
2538
|
{
|
|
2198
2539
|
inputs: [
|
|
2199
2540
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2312,7 +2653,7 @@ const _t = [
|
|
|
2312
2653
|
type: "function"
|
|
2313
2654
|
},
|
|
2314
2655
|
{ stateMutability: "payable", type: "receive" }
|
|
2315
|
-
],
|
|
2656
|
+
], zt = [
|
|
2316
2657
|
{
|
|
2317
2658
|
inputs: [
|
|
2318
2659
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2431,7 +2772,7 @@ const _t = [
|
|
|
2431
2772
|
type: "function"
|
|
2432
2773
|
},
|
|
2433
2774
|
{ stateMutability: "payable", type: "receive" }
|
|
2434
|
-
],
|
|
2775
|
+
], Zt = [
|
|
2435
2776
|
{
|
|
2436
2777
|
inputs: [
|
|
2437
2778
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2550,7 +2891,7 @@ const _t = [
|
|
|
2550
2891
|
type: "function"
|
|
2551
2892
|
},
|
|
2552
2893
|
{ stateMutability: "payable", type: "receive" }
|
|
2553
|
-
],
|
|
2894
|
+
], en = [
|
|
2554
2895
|
{
|
|
2555
2896
|
inputs: [
|
|
2556
2897
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2677,7 +3018,7 @@ const _t = [
|
|
|
2677
3018
|
type: "function"
|
|
2678
3019
|
},
|
|
2679
3020
|
{ stateMutability: "payable", type: "receive" }
|
|
2680
|
-
],
|
|
3021
|
+
], tn = [
|
|
2681
3022
|
{
|
|
2682
3023
|
inputs: [
|
|
2683
3024
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2804,7 +3145,7 @@ const _t = [
|
|
|
2804
3145
|
type: "function"
|
|
2805
3146
|
},
|
|
2806
3147
|
{ stateMutability: "payable", type: "receive" }
|
|
2807
|
-
],
|
|
3148
|
+
], nn = [
|
|
2808
3149
|
{
|
|
2809
3150
|
inputs: [
|
|
2810
3151
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2931,7 +3272,7 @@ const _t = [
|
|
|
2931
3272
|
type: "function"
|
|
2932
3273
|
},
|
|
2933
3274
|
{ stateMutability: "payable", type: "receive" }
|
|
2934
|
-
],
|
|
3275
|
+
], an = [
|
|
2935
3276
|
{
|
|
2936
3277
|
inputs: [
|
|
2937
3278
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3058,7 +3399,7 @@ const _t = [
|
|
|
3058
3399
|
type: "function"
|
|
3059
3400
|
},
|
|
3060
3401
|
{ stateMutability: "payable", type: "receive" }
|
|
3061
|
-
],
|
|
3402
|
+
], sn = [
|
|
3062
3403
|
{
|
|
3063
3404
|
inputs: [
|
|
3064
3405
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3185,239 +3526,239 @@ const _t = [
|
|
|
3185
3526
|
type: "function"
|
|
3186
3527
|
},
|
|
3187
3528
|
{ stateMutability: "payable", type: "receive" }
|
|
3188
|
-
],
|
|
3189
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3190
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3191
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3192
|
-
},
|
|
3193
|
-
...
|
|
3529
|
+
], ke = {
|
|
3530
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: qt,
|
|
3531
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Yt,
|
|
3532
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Kt
|
|
3533
|
+
}, rn = {
|
|
3534
|
+
...ke,
|
|
3194
3535
|
// AVAX
|
|
3195
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3196
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3197
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3536
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: Jt,
|
|
3537
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: jt,
|
|
3538
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: zt,
|
|
3198
3539
|
// BSC
|
|
3199
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3540
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: Xt,
|
|
3200
3541
|
// ETH
|
|
3201
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3202
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3203
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3204
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3205
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3206
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3207
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3208
|
-
},
|
|
3542
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Qt,
|
|
3543
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Zt,
|
|
3544
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: en,
|
|
3545
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: tn,
|
|
3546
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: nn,
|
|
3547
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: an,
|
|
3548
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: sn
|
|
3549
|
+
}, on = ({
|
|
3209
3550
|
streamSwap: e,
|
|
3210
3551
|
contractAddress: t,
|
|
3211
3552
|
recipient: n,
|
|
3212
3553
|
toChecksumAddress: a,
|
|
3213
3554
|
calldata: {
|
|
3214
|
-
amount:
|
|
3555
|
+
amount: s,
|
|
3215
3556
|
amountOutMin: r = "",
|
|
3216
|
-
data:
|
|
3217
|
-
deadline:
|
|
3218
|
-
memo:
|
|
3219
|
-
router:
|
|
3220
|
-
memoStreamingSwap:
|
|
3557
|
+
data: o = "",
|
|
3558
|
+
deadline: p,
|
|
3559
|
+
memo: u,
|
|
3560
|
+
router: y,
|
|
3561
|
+
memoStreamingSwap: d,
|
|
3221
3562
|
tcMemo: c,
|
|
3222
|
-
tcRouter:
|
|
3223
|
-
tcVault:
|
|
3563
|
+
tcRouter: _,
|
|
3564
|
+
tcVault: A,
|
|
3224
3565
|
vault: R,
|
|
3225
|
-
token:
|
|
3566
|
+
token: g
|
|
3226
3567
|
}
|
|
3227
3568
|
}) => {
|
|
3228
|
-
const E = !!
|
|
3229
|
-
if (E && !
|
|
3569
|
+
const E = !!ke[t.toLowerCase()];
|
|
3570
|
+
if (E && !y)
|
|
3230
3571
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3231
|
-
const I = c ||
|
|
3232
|
-
if (!
|
|
3572
|
+
const I = c || u, S = e && d || I;
|
|
3573
|
+
if (!A && !R)
|
|
3233
3574
|
throw new Error("TC Vault is required on calldata");
|
|
3234
|
-
if (!
|
|
3575
|
+
if (!_ && !y)
|
|
3235
3576
|
throw new Error("TC Router is required on calldata");
|
|
3236
3577
|
if (!S)
|
|
3237
3578
|
throw new Error("TC Memo is required on calldata");
|
|
3238
|
-
if (!
|
|
3579
|
+
if (!g)
|
|
3239
3580
|
throw new Error("Token is required on calldata");
|
|
3240
3581
|
const D = [
|
|
3241
3582
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3242
|
-
a(
|
|
3243
|
-
a(
|
|
3583
|
+
a(_ || y),
|
|
3584
|
+
a(A || R),
|
|
3244
3585
|
S.replace("{recipientAddress}", n),
|
|
3245
|
-
a(
|
|
3246
|
-
|
|
3247
|
-
],
|
|
3248
|
-
return [...D, ...
|
|
3249
|
-
},
|
|
3250
|
-
const n =
|
|
3586
|
+
a(g),
|
|
3587
|
+
s
|
|
3588
|
+
], Fe = E ? [a(y), o, p] : [r, p];
|
|
3589
|
+
return [...D, ...Fe];
|
|
3590
|
+
}, pn = ({ chain: e, txHash: t }) => {
|
|
3591
|
+
const n = Ne[e];
|
|
3251
3592
|
switch (e) {
|
|
3252
|
-
case
|
|
3253
|
-
case
|
|
3254
|
-
case
|
|
3255
|
-
case
|
|
3256
|
-
case
|
|
3257
|
-
case
|
|
3593
|
+
case i.Binance:
|
|
3594
|
+
case i.Bitcoin:
|
|
3595
|
+
case i.BitcoinCash:
|
|
3596
|
+
case i.Maya:
|
|
3597
|
+
case i.Kujira:
|
|
3598
|
+
case i.THORChain:
|
|
3258
3599
|
return `${n}/tx/${t}`;
|
|
3259
|
-
case
|
|
3260
|
-
case
|
|
3261
|
-
case
|
|
3262
|
-
case
|
|
3263
|
-
case
|
|
3264
|
-
case
|
|
3600
|
+
case i.Arbitrum:
|
|
3601
|
+
case i.Avalanche:
|
|
3602
|
+
case i.BinanceSmartChain:
|
|
3603
|
+
case i.Ethereum:
|
|
3604
|
+
case i.Optimism:
|
|
3605
|
+
case i.Polygon:
|
|
3265
3606
|
return `${n}/tx/${t.startsWith("0x") ? t : `0x${t}`}`;
|
|
3266
|
-
case
|
|
3607
|
+
case i.Cosmos:
|
|
3267
3608
|
return `${n}/transactions/${t}`;
|
|
3268
|
-
case
|
|
3609
|
+
case i.Dogecoin:
|
|
3269
3610
|
return `${n}/transaction/${t.toLowerCase()}`;
|
|
3270
|
-
case
|
|
3611
|
+
case i.Litecoin:
|
|
3271
3612
|
return `${n}/${t}`;
|
|
3272
3613
|
default:
|
|
3273
3614
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3274
3615
|
}
|
|
3275
|
-
},
|
|
3276
|
-
const n =
|
|
3616
|
+
}, dn = ({ chain: e, address: t }) => {
|
|
3617
|
+
const n = Ne[e];
|
|
3277
3618
|
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
|
|
3619
|
+
case i.Arbitrum:
|
|
3620
|
+
case i.Avalanche:
|
|
3621
|
+
case i.Binance:
|
|
3622
|
+
case i.BinanceSmartChain:
|
|
3623
|
+
case i.Bitcoin:
|
|
3624
|
+
case i.BitcoinCash:
|
|
3625
|
+
case i.Dogecoin:
|
|
3626
|
+
case i.Ethereum:
|
|
3627
|
+
case i.Maya:
|
|
3628
|
+
case i.Optimism:
|
|
3629
|
+
case i.Polygon:
|
|
3630
|
+
case i.Kujira:
|
|
3631
|
+
case i.THORChain:
|
|
3291
3632
|
return `${n}/address/${t}`;
|
|
3292
|
-
case
|
|
3633
|
+
case i.Cosmos:
|
|
3293
3634
|
return `${n}/account/${t}`;
|
|
3294
|
-
case
|
|
3635
|
+
case i.Litecoin:
|
|
3295
3636
|
return `${n}/${t}`;
|
|
3296
3637
|
default:
|
|
3297
3638
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3298
3639
|
}
|
|
3299
|
-
},
|
|
3640
|
+
}, un = (e) => {
|
|
3300
3641
|
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3301
|
-
return
|
|
3302
|
-
},
|
|
3642
|
+
return be.get(`${t}/thorchain/inbound_addresses`);
|
|
3643
|
+
}, ln = (e) => {
|
|
3303
3644
|
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3304
|
-
return
|
|
3305
|
-
},
|
|
3645
|
+
return be.get(`${t}/thorchain/mimir`);
|
|
3646
|
+
}, Se = () => Object.values(i).reduce(
|
|
3306
3647
|
(e, t) => (e[t] = null, e),
|
|
3307
3648
|
{}
|
|
3308
3649
|
);
|
|
3309
|
-
var
|
|
3310
|
-
class
|
|
3650
|
+
var B, te, j, N, Y, K;
|
|
3651
|
+
class Nn {
|
|
3311
3652
|
constructor({ stagenet: t } = {}) {
|
|
3312
|
-
T(this, "connectedChains",
|
|
3313
|
-
T(this, "connectedWallets",
|
|
3653
|
+
T(this, "connectedChains", Se());
|
|
3654
|
+
T(this, "connectedWallets", Se());
|
|
3314
3655
|
T(this, "stagenet", !1);
|
|
3315
3656
|
T(this, "getAddress", (t) => {
|
|
3316
3657
|
var n;
|
|
3317
3658
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3318
3659
|
});
|
|
3319
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3660
|
+
T(this, "getExplorerTxUrl", (t, n) => pn({ chain: t, txHash: n }));
|
|
3320
3661
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3321
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3662
|
+
T(this, "getExplorerAddressUrl", (t, n) => dn({ chain: t, address: n }));
|
|
3322
3663
|
T(this, "getBalance", async (t, n) => {
|
|
3323
3664
|
const a = await this.getWalletByChain(t, n);
|
|
3324
3665
|
return (a == null ? void 0 : a.balance) || [];
|
|
3325
3666
|
});
|
|
3326
|
-
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey:
|
|
3327
|
-
var
|
|
3328
|
-
const { quoteMode: r } = a.meta,
|
|
3667
|
+
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: s }) => {
|
|
3668
|
+
var p, u;
|
|
3669
|
+
const { quoteMode: r } = a.meta, o = r.startsWith("ERC20-") ? i.Ethereum : r.startsWith("ARC20-") ? i.Avalanche : i.BinanceSmartChain;
|
|
3329
3670
|
if (!a.complete)
|
|
3330
3671
|
throw new m("core_swap_route_not_complete");
|
|
3331
3672
|
try {
|
|
3332
|
-
if (
|
|
3333
|
-
const
|
|
3334
|
-
if (!(
|
|
3673
|
+
if (ze.includes(r)) {
|
|
3674
|
+
const y = this.connectedWallets[o];
|
|
3675
|
+
if (!(y != null && y.sendTransaction))
|
|
3335
3676
|
throw new m("core_wallet_connection_not_found");
|
|
3336
|
-
if (!(t ? (
|
|
3677
|
+
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3337
3678
|
throw new m("core_swap_route_transaction_not_found");
|
|
3338
|
-
const { isHexString: c, parseUnits:
|
|
3339
|
-
data:
|
|
3679
|
+
const { isHexString: c, parseUnits: _ } = await import("./index-cf1865cd.js"), { data: A, from: R, to: g, value: E } = a.transaction, I = {
|
|
3680
|
+
data: A,
|
|
3340
3681
|
from: R,
|
|
3341
|
-
to:
|
|
3342
|
-
chainId: BigInt(
|
|
3343
|
-
value: E ? new
|
|
3344
|
-
value: c(E) ? E :
|
|
3682
|
+
to: g.toLowerCase(),
|
|
3683
|
+
chainId: BigInt(rt[o]),
|
|
3684
|
+
value: E ? new Te({
|
|
3685
|
+
value: c(E) ? E : _(E, "wei").toString(16)
|
|
3345
3686
|
}).baseValueBigInt : 0n
|
|
3346
3687
|
};
|
|
3347
|
-
return
|
|
3688
|
+
return y.sendTransaction(I, s);
|
|
3348
3689
|
}
|
|
3349
|
-
if (
|
|
3690
|
+
if (et.includes(r)) {
|
|
3350
3691
|
if (!a.calldata.fromAsset)
|
|
3351
3692
|
throw new m("core_swap_asset_not_recognized");
|
|
3352
|
-
const
|
|
3353
|
-
if (!
|
|
3693
|
+
const y = await v.fromString(a.calldata.fromAsset);
|
|
3694
|
+
if (!y)
|
|
3354
3695
|
throw new m("core_swap_asset_not_recognized");
|
|
3355
|
-
const { address:
|
|
3696
|
+
const { address: d } = await f(this, B).call(this, y.chain), {
|
|
3356
3697
|
contract: c,
|
|
3357
|
-
calldata: { expiration:
|
|
3358
|
-
} = a, E =
|
|
3698
|
+
calldata: { expiration: _, amountIn: A, memo: R, memoStreamingSwap: g }
|
|
3699
|
+
} = a, E = y.add(Te.fromBigInt(BigInt(A), y.decimal)), I = t && g || R;
|
|
3359
3700
|
return this.deposit({
|
|
3360
|
-
expiration:
|
|
3701
|
+
expiration: _,
|
|
3361
3702
|
assetValue: E,
|
|
3362
3703
|
memo: I,
|
|
3363
|
-
feeOptionKey:
|
|
3704
|
+
feeOptionKey: s,
|
|
3364
3705
|
router: c,
|
|
3365
|
-
recipient:
|
|
3706
|
+
recipient: d
|
|
3366
3707
|
});
|
|
3367
3708
|
}
|
|
3368
|
-
if (
|
|
3369
|
-
const { calldata:
|
|
3370
|
-
if (!
|
|
3709
|
+
if (Ze.includes(r)) {
|
|
3710
|
+
const { calldata: y, contract: d } = a;
|
|
3711
|
+
if (!d)
|
|
3371
3712
|
throw new m("core_swap_contract_not_found");
|
|
3372
|
-
const c = this.connectedWallets[
|
|
3373
|
-
if (!(c != null && c.sendTransaction) || !
|
|
3713
|
+
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3714
|
+
if (!(c != null && c.sendTransaction) || !_)
|
|
3374
3715
|
throw new m("core_wallet_connection_not_found");
|
|
3375
|
-
const { getProvider:
|
|
3716
|
+
const { getProvider: A, toChecksumAddress: R } = await import("@swapkit/toolbox-evm"), g = A(o), E = rn[d.toLowerCase()];
|
|
3376
3717
|
if (!E)
|
|
3377
|
-
throw new m("core_swap_contract_not_supported", { contractAddress:
|
|
3378
|
-
const S = await (await ((
|
|
3379
|
-
...
|
|
3718
|
+
throw new m("core_swap_contract_not_supported", { contractAddress: d });
|
|
3719
|
+
const S = await (await ((u = c.createContract) == null ? void 0 : u.call(c, d, E, g))).getFunction("swapIn").populateTransaction(
|
|
3720
|
+
...on({
|
|
3380
3721
|
streamSwap: t,
|
|
3381
3722
|
toChecksumAddress: R,
|
|
3382
|
-
contractAddress:
|
|
3723
|
+
contractAddress: d,
|
|
3383
3724
|
recipient: n,
|
|
3384
|
-
calldata:
|
|
3725
|
+
calldata: y
|
|
3385
3726
|
}),
|
|
3386
|
-
{ from:
|
|
3727
|
+
{ from: _ }
|
|
3387
3728
|
);
|
|
3388
|
-
return c.sendTransaction(S,
|
|
3729
|
+
return c.sendTransaction(S, s);
|
|
3389
3730
|
}
|
|
3390
3731
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3391
|
-
} catch (
|
|
3392
|
-
throw new m("core_swap_transaction_error",
|
|
3732
|
+
} catch (y) {
|
|
3733
|
+
throw new m("core_swap_transaction_error", y);
|
|
3393
3734
|
}
|
|
3394
3735
|
});
|
|
3395
3736
|
T(this, "getWalletByChain", async (t, n) => {
|
|
3396
|
-
var r,
|
|
3737
|
+
var r, o;
|
|
3397
3738
|
const a = this.getAddress(t);
|
|
3398
3739
|
if (!a)
|
|
3399
3740
|
return null;
|
|
3400
|
-
const
|
|
3741
|
+
const s = await ((r = this.getWallet(t)) == null ? void 0 : r.getBalance(a, n)) ?? [
|
|
3401
3742
|
v.fromChainOrSignature(t)
|
|
3402
3743
|
];
|
|
3403
3744
|
return this.connectedChains[t] = {
|
|
3404
3745
|
address: a,
|
|
3405
|
-
balance:
|
|
3406
|
-
walletType: (
|
|
3746
|
+
balance: s,
|
|
3747
|
+
walletType: (o = this.connectedChains[t]) == null ? void 0 : o.walletType
|
|
3407
3748
|
}, { ...this.connectedChains[t] };
|
|
3408
3749
|
});
|
|
3409
|
-
T(this, "approveAssetValue", (t, n) => f(this,
|
|
3410
|
-
T(this, "isAssetValueApproved", (t, n) => f(this,
|
|
3750
|
+
T(this, "approveAssetValue", (t, n) => f(this, j).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3751
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, j).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3411
3752
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3412
|
-
var a,
|
|
3413
|
-
return (
|
|
3753
|
+
var a, s;
|
|
3754
|
+
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
3414
3755
|
});
|
|
3415
3756
|
T(this, "transfer", async (t) => {
|
|
3416
3757
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
3417
3758
|
if (!n)
|
|
3418
3759
|
throw new m("core_wallet_connection_not_found");
|
|
3419
3760
|
try {
|
|
3420
|
-
return await n.transfer(f(this,
|
|
3761
|
+
return await n.transfer(f(this, K).call(this, t));
|
|
3421
3762
|
} catch (a) {
|
|
3422
3763
|
throw new m("core_swap_transaction_error", a);
|
|
3423
3764
|
}
|
|
@@ -3426,46 +3767,46 @@ class en {
|
|
|
3426
3767
|
assetValue: t,
|
|
3427
3768
|
recipient: n,
|
|
3428
3769
|
router: a,
|
|
3429
|
-
...
|
|
3770
|
+
...s
|
|
3430
3771
|
}) => {
|
|
3431
|
-
const { chain: r, symbol:
|
|
3432
|
-
if (!
|
|
3772
|
+
const { chain: r, symbol: o, ticker: p } = t, u = this.connectedWallets[r];
|
|
3773
|
+
if (!u)
|
|
3433
3774
|
throw new m("core_wallet_connection_not_found");
|
|
3434
|
-
const
|
|
3775
|
+
const y = f(this, K).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3435
3776
|
try {
|
|
3436
3777
|
switch (r) {
|
|
3437
|
-
case
|
|
3438
|
-
const
|
|
3439
|
-
return await (n === "" ?
|
|
3778
|
+
case i.THORChain: {
|
|
3779
|
+
const d = u;
|
|
3780
|
+
return await (n === "" ? d.deposit(y) : d.transfer(y));
|
|
3440
3781
|
}
|
|
3441
|
-
case
|
|
3442
|
-
case
|
|
3443
|
-
case
|
|
3444
|
-
const { getChecksumAddressFromAsset:
|
|
3445
|
-
return await
|
|
3782
|
+
case i.Ethereum:
|
|
3783
|
+
case i.BinanceSmartChain:
|
|
3784
|
+
case i.Avalanche: {
|
|
3785
|
+
const { getChecksumAddressFromAsset: d } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Xe : r === i.BinanceSmartChain ? Je : Ke;
|
|
3786
|
+
return await u.call({
|
|
3446
3787
|
abi: c,
|
|
3447
|
-
contractAddress: a || (await f(this,
|
|
3788
|
+
contractAddress: a || (await f(this, B).call(this, r)).router,
|
|
3448
3789
|
funcName: "depositWithExpiry",
|
|
3449
3790
|
funcParams: [
|
|
3450
3791
|
n,
|
|
3451
|
-
|
|
3792
|
+
d({ chain: r, symbol: o, ticker: p }, r),
|
|
3452
3793
|
// TODO: (@Towan) Re-Check on that conversion 🙏
|
|
3453
3794
|
t.getBaseValue("bigint").toString(),
|
|
3454
|
-
|
|
3455
|
-
|
|
3795
|
+
y.memo,
|
|
3796
|
+
s.expiration
|
|
3456
3797
|
],
|
|
3457
3798
|
txOverrides: {
|
|
3458
|
-
from:
|
|
3799
|
+
from: y.from,
|
|
3459
3800
|
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
3460
3801
|
}
|
|
3461
3802
|
});
|
|
3462
3803
|
}
|
|
3463
3804
|
default:
|
|
3464
|
-
return await
|
|
3805
|
+
return await u.transfer(y);
|
|
3465
3806
|
}
|
|
3466
|
-
} catch (
|
|
3467
|
-
const c = ((
|
|
3468
|
-
throw new m(
|
|
3807
|
+
} catch (d) {
|
|
3808
|
+
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";
|
|
3809
|
+
throw new m(g, d);
|
|
3469
3810
|
}
|
|
3470
3811
|
});
|
|
3471
3812
|
/**
|
|
@@ -3477,11 +3818,11 @@ class en {
|
|
|
3477
3818
|
}) => {
|
|
3478
3819
|
if (t.lte(0) || n.lte(0))
|
|
3479
3820
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3480
|
-
let a = "",
|
|
3821
|
+
let a = "", s = "";
|
|
3481
3822
|
try {
|
|
3482
3823
|
a = await f(this, N).call(this, {
|
|
3483
3824
|
assetValue: t,
|
|
3484
|
-
memo: x(
|
|
3825
|
+
memo: x(h.DEPOSIT, {
|
|
3485
3826
|
...n,
|
|
3486
3827
|
address: this.getAddress(n.chain)
|
|
3487
3828
|
})
|
|
@@ -3490,48 +3831,48 @@ class en {
|
|
|
3490
3831
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3491
3832
|
}
|
|
3492
3833
|
try {
|
|
3493
|
-
|
|
3834
|
+
s = await f(this, N).call(this, {
|
|
3494
3835
|
assetValue: n,
|
|
3495
|
-
memo: x(
|
|
3836
|
+
memo: x(h.DEPOSIT, {
|
|
3496
3837
|
...n,
|
|
3497
|
-
address: this.getAddress(
|
|
3838
|
+
address: this.getAddress(i.THORChain)
|
|
3498
3839
|
})
|
|
3499
3840
|
});
|
|
3500
3841
|
} catch (r) {
|
|
3501
3842
|
throw new m("core_transaction_create_liquidity_asset_error", r);
|
|
3502
3843
|
}
|
|
3503
|
-
return { runeTx: a, assetTx:
|
|
3844
|
+
return { runeTx: a, assetTx: s };
|
|
3504
3845
|
});
|
|
3505
3846
|
T(this, "addLiquidity", async ({
|
|
3506
3847
|
poolIdentifier: t,
|
|
3507
3848
|
runeAssetValue: n,
|
|
3508
3849
|
assetValue: a,
|
|
3509
|
-
runeAddr:
|
|
3850
|
+
runeAddr: s,
|
|
3510
3851
|
assetAddr: r,
|
|
3511
|
-
isPendingSymmAsset:
|
|
3512
|
-
mode:
|
|
3852
|
+
isPendingSymmAsset: o,
|
|
3853
|
+
mode: p = "sym"
|
|
3513
3854
|
}) => {
|
|
3514
|
-
const [
|
|
3515
|
-
if (!c && !
|
|
3855
|
+
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) : "";
|
|
3856
|
+
if (!c && !_)
|
|
3516
3857
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3517
|
-
if (
|
|
3858
|
+
if (A && !R)
|
|
3518
3859
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3519
3860
|
let E, I;
|
|
3520
|
-
const S = { chain:
|
|
3861
|
+
const S = { chain: u, symbol: y.join(".") };
|
|
3521
3862
|
if (c && n)
|
|
3522
3863
|
try {
|
|
3523
3864
|
E = await f(this, N).call(this, {
|
|
3524
3865
|
assetValue: n,
|
|
3525
|
-
memo: x(
|
|
3866
|
+
memo: x(h.DEPOSIT, { ...S, address: g })
|
|
3526
3867
|
});
|
|
3527
3868
|
} catch (D) {
|
|
3528
3869
|
throw new m("core_transaction_add_liquidity_rune_error", D);
|
|
3529
3870
|
}
|
|
3530
|
-
if (
|
|
3871
|
+
if (_ && a)
|
|
3531
3872
|
try {
|
|
3532
3873
|
I = await f(this, N).call(this, {
|
|
3533
3874
|
assetValue: a,
|
|
3534
|
-
memo: x(
|
|
3875
|
+
memo: x(h.DEPOSIT, { ...S, address: R })
|
|
3535
3876
|
});
|
|
3536
3877
|
} catch (D) {
|
|
3537
3878
|
throw new m("core_transaction_add_liquidity_asset_error", D);
|
|
@@ -3542,49 +3883,49 @@ class en {
|
|
|
3542
3883
|
memo: t,
|
|
3543
3884
|
assetValue: n,
|
|
3544
3885
|
percent: a,
|
|
3545
|
-
from:
|
|
3886
|
+
from: s,
|
|
3546
3887
|
to: r
|
|
3547
3888
|
}) => {
|
|
3548
|
-
const
|
|
3889
|
+
const o = r === "rune" ? v.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n;
|
|
3549
3890
|
try {
|
|
3550
3891
|
return await f(this, N).call(this, {
|
|
3551
|
-
assetValue:
|
|
3552
|
-
memo: t || x(
|
|
3892
|
+
assetValue: Ie(s === "asset" ? n.chain : i.THORChain),
|
|
3893
|
+
memo: t || x(h.WITHDRAW, {
|
|
3553
3894
|
symbol: n.symbol,
|
|
3554
3895
|
chain: n.chain,
|
|
3555
3896
|
ticker: n.ticker,
|
|
3556
3897
|
basisPoints: Math.max(1e4, Math.round(a * 100)),
|
|
3557
|
-
targetAssetString:
|
|
3898
|
+
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3558
3899
|
singleSide: !1
|
|
3559
3900
|
})
|
|
3560
3901
|
});
|
|
3561
|
-
} catch (
|
|
3562
|
-
throw new m("core_transaction_withdraw_error",
|
|
3902
|
+
} catch (p) {
|
|
3903
|
+
throw new m("core_transaction_withdraw_error", p);
|
|
3563
3904
|
}
|
|
3564
3905
|
});
|
|
3565
3906
|
T(this, "savings", async ({
|
|
3566
3907
|
assetValue: t,
|
|
3567
3908
|
memo: n,
|
|
3568
3909
|
percent: a,
|
|
3569
|
-
type:
|
|
3910
|
+
type: s
|
|
3570
3911
|
}) => {
|
|
3571
|
-
const r =
|
|
3912
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || x(r, {
|
|
3572
3913
|
ticker: t.ticker,
|
|
3573
3914
|
symbol: t.symbol,
|
|
3574
3915
|
chain: t.chain,
|
|
3575
3916
|
singleSide: !0,
|
|
3576
3917
|
basisPoints: a ? Math.max(1e4, Math.round(a * 100)) : void 0
|
|
3577
3918
|
});
|
|
3578
|
-
return f(this, N).call(this, { assetValue: t, memo:
|
|
3919
|
+
return f(this, N).call(this, { assetValue: t, memo: o });
|
|
3579
3920
|
});
|
|
3580
3921
|
T(this, "loan", ({
|
|
3581
3922
|
assetValue: t,
|
|
3582
3923
|
memo: n,
|
|
3583
3924
|
minAmount: a,
|
|
3584
|
-
type:
|
|
3925
|
+
type: s
|
|
3585
3926
|
}) => f(this, N).call(this, {
|
|
3586
3927
|
assetValue: t,
|
|
3587
|
-
memo: n || x(
|
|
3928
|
+
memo: n || x(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3588
3929
|
asset: t.toString(),
|
|
3589
3930
|
minAmount: a.toString(),
|
|
3590
3931
|
address: this.getAddress(t.chain)
|
|
@@ -3595,27 +3936,27 @@ class en {
|
|
|
3595
3936
|
assetValue: n,
|
|
3596
3937
|
address: a
|
|
3597
3938
|
}) => {
|
|
3598
|
-
const
|
|
3939
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = x(s, {
|
|
3599
3940
|
address: a,
|
|
3600
3941
|
unbondAmount: t === "unbond" ? n.baseValueNumber : void 0
|
|
3601
3942
|
});
|
|
3602
3943
|
return f(this, Y).call(this, {
|
|
3603
3944
|
memo: r,
|
|
3604
|
-
assetValue: t === "bond" ? n :
|
|
3945
|
+
assetValue: t === "bond" ? n : Ie(i.THORChain)
|
|
3605
3946
|
});
|
|
3606
3947
|
});
|
|
3607
3948
|
T(this, "registerThorname", ({
|
|
3608
3949
|
assetValue: t,
|
|
3609
3950
|
...n
|
|
3610
|
-
}) => f(this, Y).call(this, { assetValue: t, memo: x(
|
|
3611
|
-
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls:
|
|
3951
|
+
}) => f(this, Y).call(this, { assetValue: t, memo: x(h.THORNAME_REGISTER, n) }));
|
|
3952
|
+
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3612
3953
|
try {
|
|
3613
3954
|
t.forEach((r) => {
|
|
3614
3955
|
this[r.connectMethodName] = r.connect({
|
|
3615
|
-
addChain: f(this,
|
|
3956
|
+
addChain: f(this, te),
|
|
3616
3957
|
config: n || {},
|
|
3617
3958
|
apis: a,
|
|
3618
|
-
rpcUrls:
|
|
3959
|
+
rpcUrls: s
|
|
3619
3960
|
});
|
|
3620
3961
|
});
|
|
3621
3962
|
} catch (r) {
|
|
@@ -3628,28 +3969,28 @@ class en {
|
|
|
3628
3969
|
}) => {
|
|
3629
3970
|
const a = this.getWallet(t);
|
|
3630
3971
|
switch (t) {
|
|
3631
|
-
case
|
|
3632
|
-
case
|
|
3633
|
-
case
|
|
3634
|
-
case
|
|
3635
|
-
case
|
|
3636
|
-
case
|
|
3637
|
-
const { estimateMaxSendableAmount:
|
|
3638
|
-
return
|
|
3972
|
+
case i.Arbitrum:
|
|
3973
|
+
case i.Avalanche:
|
|
3974
|
+
case i.BinanceSmartChain:
|
|
3975
|
+
case i.Ethereum:
|
|
3976
|
+
case i.Optimism:
|
|
3977
|
+
case i.Polygon: {
|
|
3978
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-evm");
|
|
3979
|
+
return s({
|
|
3639
3980
|
...n,
|
|
3640
3981
|
toolbox: a
|
|
3641
3982
|
});
|
|
3642
3983
|
}
|
|
3643
|
-
case
|
|
3644
|
-
case
|
|
3645
|
-
case
|
|
3646
|
-
case
|
|
3984
|
+
case i.Bitcoin:
|
|
3985
|
+
case i.BitcoinCash:
|
|
3986
|
+
case i.Dogecoin:
|
|
3987
|
+
case i.Litecoin:
|
|
3647
3988
|
return a.estimateMaxSendableAmount(n);
|
|
3648
|
-
case
|
|
3649
|
-
case
|
|
3650
|
-
case
|
|
3651
|
-
const { estimateMaxSendableAmount:
|
|
3652
|
-
return
|
|
3989
|
+
case i.Binance:
|
|
3990
|
+
case i.THORChain:
|
|
3991
|
+
case i.Cosmos: {
|
|
3992
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-cosmos");
|
|
3993
|
+
return s({
|
|
3653
3994
|
...n,
|
|
3654
3995
|
toolbox: a
|
|
3655
3996
|
});
|
|
@@ -3688,72 +4029,72 @@ class en {
|
|
|
3688
4029
|
T(this, "disconnectChain", (t) => {
|
|
3689
4030
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
3690
4031
|
});
|
|
3691
|
-
|
|
3692
|
-
if (t ===
|
|
4032
|
+
P(this, B, async (t) => {
|
|
4033
|
+
if (t === i.THORChain)
|
|
3693
4034
|
return {
|
|
3694
4035
|
gas_rate: "0",
|
|
3695
4036
|
router: "0",
|
|
3696
4037
|
address: "",
|
|
3697
4038
|
halted: !1,
|
|
3698
|
-
chain:
|
|
4039
|
+
chain: i.THORChain
|
|
3699
4040
|
};
|
|
3700
|
-
const a = (await
|
|
4041
|
+
const a = (await un(this.stagenet)).find((s) => s.chain === t);
|
|
3701
4042
|
if (!a)
|
|
3702
4043
|
throw new m("core_inbound_data_not_found");
|
|
3703
4044
|
if (a != null && a.halted)
|
|
3704
4045
|
throw new m("core_chain_halted");
|
|
3705
4046
|
return a;
|
|
3706
4047
|
});
|
|
3707
|
-
|
|
4048
|
+
P(this, te, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
3708
4049
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
3709
4050
|
});
|
|
3710
|
-
|
|
3711
|
-
assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset:
|
|
3712
|
-
type:
|
|
3713
|
-
contractAddress:
|
|
4051
|
+
P(this, j, async ({
|
|
4052
|
+
assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset: s, isSynthetic: r },
|
|
4053
|
+
type: o = "checkOnly",
|
|
4054
|
+
contractAddress: p
|
|
3714
4055
|
}) => {
|
|
3715
|
-
const
|
|
3716
|
-
if (
|
|
4056
|
+
const u = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(a);
|
|
4057
|
+
if (u && s || !u || r)
|
|
3717
4058
|
return !0;
|
|
3718
|
-
const
|
|
4059
|
+
const d = this.connectedWallets[a], c = o === "checkOnly" ? d == null ? void 0 : d.isApproved : d == null ? void 0 : d.approve;
|
|
3719
4060
|
if (!c)
|
|
3720
4061
|
throw new m("core_wallet_connection_not_found");
|
|
3721
|
-
const
|
|
3722
|
-
if (!n || !
|
|
4062
|
+
const _ = this.getAddress(a);
|
|
4063
|
+
if (!n || !_)
|
|
3723
4064
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
3724
|
-
const
|
|
4065
|
+
const A = p || (await f(this, B).call(this, a)).router;
|
|
3725
4066
|
return c({
|
|
3726
4067
|
amount: t,
|
|
3727
4068
|
assetAddress: n,
|
|
3728
|
-
from:
|
|
3729
|
-
spenderAddress:
|
|
4069
|
+
from: _,
|
|
4070
|
+
spenderAddress: A
|
|
3730
4071
|
});
|
|
3731
4072
|
});
|
|
3732
|
-
|
|
4073
|
+
P(this, N, async ({
|
|
3733
4074
|
assetValue: t,
|
|
3734
4075
|
memo: n,
|
|
3735
4076
|
feeOptionKey: a = k.Fast
|
|
3736
4077
|
}) => {
|
|
3737
4078
|
const {
|
|
3738
|
-
gas_rate:
|
|
4079
|
+
gas_rate: s,
|
|
3739
4080
|
router: r,
|
|
3740
|
-
address:
|
|
3741
|
-
} = await f(this,
|
|
4081
|
+
address: o
|
|
4082
|
+
} = await f(this, B).call(this, t.chain), p = (parseInt(s) || 0) * _t[a];
|
|
3742
4083
|
return this.deposit({
|
|
3743
4084
|
assetValue: t,
|
|
3744
|
-
recipient:
|
|
4085
|
+
recipient: o,
|
|
3745
4086
|
memo: n,
|
|
3746
4087
|
router: r,
|
|
3747
|
-
feeRate:
|
|
4088
|
+
feeRate: p
|
|
3748
4089
|
});
|
|
3749
4090
|
});
|
|
3750
|
-
|
|
3751
|
-
const a = await
|
|
4091
|
+
P(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
4092
|
+
const a = await ln(this.stagenet);
|
|
3752
4093
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
3753
4094
|
throw new m("core_chain_halted");
|
|
3754
4095
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
3755
4096
|
});
|
|
3756
|
-
|
|
4097
|
+
P(this, K, ({ assetValue: t, ...n }) => ({
|
|
3757
4098
|
...n,
|
|
3758
4099
|
memo: n.memo || "",
|
|
3759
4100
|
from: this.getAddress(t.chain),
|
|
@@ -3762,66 +4103,65 @@ class en {
|
|
|
3762
4103
|
this.stagenet = !!t;
|
|
3763
4104
|
}
|
|
3764
4105
|
}
|
|
3765
|
-
|
|
4106
|
+
B = new WeakMap(), te = new WeakMap(), j = new WeakMap(), N = new WeakMap(), Y = new WeakMap(), K = new WeakMap();
|
|
3766
4107
|
export {
|
|
3767
|
-
|
|
3768
|
-
|
|
4108
|
+
ze as AGG_SWAP,
|
|
4109
|
+
mn as ApiError,
|
|
3769
4110
|
W as ApiUrl,
|
|
3770
4111
|
v as AssetValue,
|
|
3771
4112
|
b as BaseDecimal,
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
4113
|
+
le as BigIntArithmetics,
|
|
4114
|
+
i as Chain,
|
|
4115
|
+
he as ChainId,
|
|
4116
|
+
wn as ChainIdToChain,
|
|
4117
|
+
rt as ChainToChainId,
|
|
4118
|
+
Ne as ChainToExplorerUrl,
|
|
4119
|
+
bn as ChainToHexChainId,
|
|
4120
|
+
ot as ChainToRPC,
|
|
4121
|
+
at as ContractAddress,
|
|
4122
|
+
fn as CosmosChainList,
|
|
4123
|
+
st as DerivationPath,
|
|
4124
|
+
l as ERROR_CODE,
|
|
4125
|
+
tt as ERROR_MODULE,
|
|
4126
|
+
ve as ERROR_TYPE,
|
|
4127
|
+
hn as EVMChainList,
|
|
4128
|
+
pt as ErrorCode,
|
|
3788
4129
|
k as FeeOption,
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
4130
|
+
h as MemoType,
|
|
4131
|
+
Tn as NetworkDerivationPath,
|
|
4132
|
+
Qe as QuoteMode,
|
|
4133
|
+
Me as RPCUrl,
|
|
4134
|
+
be as RequestClient,
|
|
4135
|
+
Ze as SWAP_IN,
|
|
4136
|
+
et as SWAP_OUT,
|
|
4137
|
+
Nn as SwapKitCore,
|
|
3796
4138
|
m as SwapKitError,
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
4139
|
+
Te as SwapKitNumber,
|
|
4140
|
+
Xe as TCAvalancheDepositABI,
|
|
4141
|
+
Je as TCBscDepositABI,
|
|
4142
|
+
Ke as TCEthereumVaultAbi,
|
|
4143
|
+
_n as UTXOChainList,
|
|
4144
|
+
dt as WalletOption,
|
|
4145
|
+
An as assetFromString,
|
|
4146
|
+
Mn as derivationPathToString,
|
|
4147
|
+
cn as erc20ABI,
|
|
4148
|
+
En as filterAssets,
|
|
4149
|
+
He as formatBigIntToSafeValue,
|
|
4150
|
+
_t as gasFeeMultiplier,
|
|
4151
|
+
wt as getAssetType,
|
|
4152
|
+
Rt as getAsymmetricAssetShare,
|
|
4153
|
+
gn as getAsymmetricAssetWithdrawAmount,
|
|
4154
|
+
Et as getAsymmetricRuneShare,
|
|
4155
|
+
Rn as getAsymmetricRuneWithdrawAmount,
|
|
4156
|
+
bt as getCommonAssetInfo,
|
|
4157
|
+
De as getDecimal,
|
|
4158
|
+
In as getEstimatedPoolShare,
|
|
4159
|
+
Sn as getLiquiditySlippage,
|
|
3818
4160
|
x as getMemoFor,
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
Ze as postRequest,
|
|
3826
|
-
qt as validateTHORName
|
|
4161
|
+
Ie as getMinAmountByChain,
|
|
4162
|
+
gt as getSymmetricPoolShare,
|
|
4163
|
+
On as getSymmetricWithdraw,
|
|
4164
|
+
vn as getTHORNameCost,
|
|
4165
|
+
ft as isGasAsset,
|
|
4166
|
+
Cn as validateTHORName
|
|
3827
4167
|
};
|