@swapkit/core 1.0.0-rc.3 → 1.0.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.es.js +1243 -823
- package/package.json +14 -14
- package/src/client/explorerUrls.ts +2 -0
- package/src/client/index.ts +61 -54
- package/src/client/thornode.ts +3 -3
- package/src/client/types.ts +2 -0
- package/dist/index-9e36735e.cjs +0 -1
- package/dist/index-cf1865cd.js +0 -649
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (e, t, n) => (
|
|
1
|
+
var We = Object.defineProperty;
|
|
2
|
+
var je = (e, t, n) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var T = (e, t, n) => (je(e, typeof t != "symbol" ? t + "" : t, n), n), Ke = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var f = (e, t, n) => (Ke(e, t, "read from private field"), n ? n.call(e) : t.get(e)), B = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
const
|
|
12
|
+
var Ye = Object.defineProperty, Xe = (e, t, n) => t in e ? Ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (Xe(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
+
const fn = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -108,7 +108,7 @@ const Ut = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Je = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const Ut = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Qe = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const Ut = [
|
|
|
447
447
|
stateMutability: "view",
|
|
448
448
|
type: "function"
|
|
449
449
|
}
|
|
450
|
-
],
|
|
450
|
+
], ze = [
|
|
451
451
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
452
452
|
{
|
|
453
453
|
anonymous: !1,
|
|
@@ -600,13 +600,13 @@ const Ut = [
|
|
|
600
600
|
type: "function"
|
|
601
601
|
}
|
|
602
602
|
];
|
|
603
|
-
var
|
|
604
|
-
const
|
|
603
|
+
var Ze = /* @__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))(Ze || {});
|
|
604
|
+
const et = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], tt = [
|
|
610
610
|
"ERC20-TC",
|
|
611
611
|
"ERC20-ARC20",
|
|
612
612
|
"ERC20-BEP20",
|
|
@@ -617,95 +617,95 @@ const He = [
|
|
|
617
617
|
"BEP20-ERC20",
|
|
618
618
|
"BEP20-ARC20"
|
|
619
619
|
/* BSC_TO_AVAX */
|
|
620
|
-
],
|
|
620
|
+
], nt = [
|
|
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 Ne = /* @__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))(Ne || {}), at = /* @__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))(at || {}), 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 st = {
|
|
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
|
+
}, oe = (e, t) => {
|
|
680
|
+
let n = st[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
|
-
let
|
|
685
|
+
let bn = class xe extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
689
689
|
module: a,
|
|
690
|
-
code:
|
|
690
|
+
code: s,
|
|
691
691
|
message: r,
|
|
692
|
-
type:
|
|
693
|
-
options: { shouldLog:
|
|
692
|
+
type: o,
|
|
693
|
+
options: { shouldLog: p, shouldThrow: d, shouldTrace: y } = {
|
|
694
694
|
shouldLog: !0,
|
|
695
695
|
shouldThrow: !0,
|
|
696
696
|
shouldTrace: !0
|
|
697
697
|
},
|
|
698
|
-
displayMessageParams:
|
|
698
|
+
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
|
-
const
|
|
701
|
-
super(
|
|
702
|
-
shouldLog:
|
|
703
|
-
shouldTrace:
|
|
704
|
-
shouldThrow:
|
|
705
|
-
}, this.displayMessageParams =
|
|
700
|
+
const c = r || oe(s, u || []) || "";
|
|
701
|
+
super(c), v(this, "status"), v(this, "revision"), v(this, "type"), v(this, "module"), v(this, "code"), v(this, "message"), v(this, "display"), v(this, "stack"), v(this, "options"), v(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = oe(s, u || []), this.code = s, this.type = o || Ne.UNHANDLED_ERROR, this.options = {
|
|
702
|
+
shouldLog: p || !0,
|
|
703
|
+
shouldTrace: y || !0,
|
|
704
|
+
shouldThrow: d || !1
|
|
705
|
+
}, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new xe(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ let Ht = class we extends Error {
|
|
|
714
714
|
return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
|
|
715
715
|
}
|
|
716
716
|
get displayMessage() {
|
|
717
|
-
return
|
|
717
|
+
return oe(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -724,8 +724,8 @@ let Ht = class we extends Error {
|
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
726
|
};
|
|
727
|
-
var
|
|
728
|
-
const
|
|
727
|
+
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), it = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(it || {}), rt = /* @__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))(rt || {});
|
|
728
|
+
const wn = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
731
731
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -735,14 +735,15 @@ const $t = {
|
|
|
735
735
|
DOGE: [44, 3, 0, 0, 0],
|
|
736
736
|
ETH: [44, 60, 0, 0, 0],
|
|
737
737
|
GAIA: [44, 118, 0, 0, 0],
|
|
738
|
+
KUJI: [44, 118, 0, 0, 0],
|
|
738
739
|
LTC: [84, 2, 0, 0, 0],
|
|
739
740
|
MATIC: [44, 60, 0, 0, 0],
|
|
740
741
|
MAYA: [44, 931, 0, 0, 0],
|
|
741
742
|
OP: [44, 60, 0, 0, 0],
|
|
742
743
|
THOR: [44, 931, 0, 0, 0]
|
|
743
744
|
};
|
|
744
|
-
var
|
|
745
|
-
const
|
|
745
|
+
var A = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(A || {});
|
|
746
|
+
const ot = [
|
|
746
747
|
"ETH",
|
|
747
748
|
"AVAX",
|
|
748
749
|
"BSC",
|
|
@@ -750,38 +751,50 @@ const kt = [
|
|
|
750
751
|
"OP",
|
|
751
752
|
"MATIC"
|
|
752
753
|
/* Polygon */
|
|
753
|
-
],
|
|
754
|
+
], An = [
|
|
754
755
|
"BTC",
|
|
755
756
|
"BCH",
|
|
756
757
|
"DOGE",
|
|
757
758
|
"LTC"
|
|
758
759
|
/* Litecoin */
|
|
759
|
-
],
|
|
760
|
+
], En = [
|
|
760
761
|
"GAIA",
|
|
761
762
|
"THOR",
|
|
762
763
|
"BNB"
|
|
763
764
|
/* Binance */
|
|
765
|
+
], Rn = [
|
|
766
|
+
"AVAX",
|
|
767
|
+
"BNB",
|
|
768
|
+
"BSC",
|
|
769
|
+
"BTC",
|
|
770
|
+
"BCH",
|
|
771
|
+
"GAIA",
|
|
772
|
+
"DOGE",
|
|
773
|
+
"ETH",
|
|
774
|
+
"LTC",
|
|
775
|
+
"THOR"
|
|
776
|
+
/* THORChain */
|
|
764
777
|
];
|
|
765
|
-
var
|
|
766
|
-
const
|
|
778
|
+
var fe = /* @__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))(fe || {}), De = /* @__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))(De || {}), 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 || {});
|
|
779
|
+
const ie = Object.values(i), pt = Object.keys(i), be = ie.reduce(
|
|
767
780
|
(e, t) => {
|
|
768
|
-
const n =
|
|
781
|
+
const n = pt.find((a) => i[a] === t);
|
|
769
782
|
return n && (e[t] = n), e;
|
|
770
783
|
},
|
|
771
784
|
{}
|
|
772
|
-
),
|
|
773
|
-
(e, t) => (e[t] =
|
|
785
|
+
), dt = ie.reduce(
|
|
786
|
+
(e, t) => (e[t] = fe[be[t]], e),
|
|
774
787
|
{}
|
|
775
|
-
),
|
|
776
|
-
(e, t) => (e[t] =
|
|
788
|
+
), ut = ie.reduce(
|
|
789
|
+
(e, t) => (e[t] = De[be[t]], e),
|
|
777
790
|
{}
|
|
778
|
-
),
|
|
791
|
+
), gn = ie.reduce(
|
|
779
792
|
(e, t) => {
|
|
780
|
-
const n = `${
|
|
781
|
-
return e[t] =
|
|
793
|
+
const n = `${be[t]}Hex`;
|
|
794
|
+
return e[t] = fe[n], e;
|
|
782
795
|
},
|
|
783
796
|
{}
|
|
784
|
-
),
|
|
797
|
+
), On = {
|
|
785
798
|
"0xa4b1": "ARB",
|
|
786
799
|
42161: "ARB",
|
|
787
800
|
"0xa86a": "AVAX",
|
|
@@ -794,6 +807,7 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
794
807
|
"cosmoshub-4": "GAIA",
|
|
795
808
|
dogecoin: "DOGE",
|
|
796
809
|
"0x1": "ETH",
|
|
810
|
+
"kaiyo-1": "KUJI",
|
|
797
811
|
1: "ETH",
|
|
798
812
|
litecoin: "LTC",
|
|
799
813
|
"mayachain-stagenet-v1": "MAYA",
|
|
@@ -805,7 +819,7 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
805
819
|
"thorchain-stagenet-v2": "THOR",
|
|
806
820
|
"thorchain-mainnet-v1": "THOR"
|
|
807
821
|
/* THORChain */
|
|
808
|
-
},
|
|
822
|
+
}, Pe = {
|
|
809
823
|
ARB: "https://arbiscan.io",
|
|
810
824
|
AVAX: "https://snowtrace.io",
|
|
811
825
|
BSC: "https://bscscan.com",
|
|
@@ -814,6 +828,7 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
814
828
|
BTC: "https://blockstream.info",
|
|
815
829
|
GAIA: "https://cosmos.bigdipper.live",
|
|
816
830
|
DOGE: "https://blockchair.com/dogecoin",
|
|
831
|
+
KUJI: "https://finder.kujira.network/kaiyo-1",
|
|
817
832
|
ETH: "https://etherscan.io",
|
|
818
833
|
LTC: "https://ltc.bitaps.com",
|
|
819
834
|
MAYA: "https://www.mayascan.org",
|
|
@@ -821,301 +836,658 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
821
836
|
MATIC: "https://polygonscan.com",
|
|
822
837
|
THOR: "https://viewblock.io/thorchain"
|
|
823
838
|
};
|
|
824
|
-
var
|
|
839
|
+
var lt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(lt || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), yt = /* @__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))(yt || {}), ct = Object.defineProperty, mt = (e, t, n) => t in e ? ct(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (mt(e, typeof t != "symbol" ? t + "" : t, n), n), Tt = (e, t, n) => {
|
|
825
840
|
if (!t.has(e))
|
|
826
841
|
throw TypeError("Cannot " + n);
|
|
827
|
-
},
|
|
842
|
+
}, V = (e, t, n) => {
|
|
828
843
|
if (t.has(e))
|
|
829
844
|
throw TypeError("Cannot add the same private member more than once");
|
|
830
845
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
831
|
-
},
|
|
832
|
-
const
|
|
833
|
-
if (e < 0)
|
|
834
|
-
throw new Error("Invalid number of year");
|
|
835
|
-
return 10 + e;
|
|
836
|
-
}, Xt = (e) => {
|
|
837
|
-
if (e.length > 30)
|
|
838
|
-
return !1;
|
|
839
|
-
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
840
|
-
return !!e.match(t);
|
|
841
|
-
}, Kt = ([e, t, n, a, i]) => `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`, Oe = async (e, t) => {
|
|
842
|
-
const n = Object.entries(t || {}).reduce(
|
|
843
|
-
(a, [i, r]) => (r && (a[i] = r), a),
|
|
844
|
-
{}
|
|
845
|
-
);
|
|
846
|
-
return (await fetch(
|
|
847
|
-
`${e}${t ? `?${new URLSearchParams(n).toString()}` : ""}`,
|
|
848
|
-
{ method: "GET", mode: "cors", credentials: "omit", referrer: "https://sk.thorswap.net" }
|
|
849
|
-
)).json();
|
|
850
|
-
}, tt = async (e, t, n, a = !1) => {
|
|
851
|
-
const i = await fetch(`${e}`, {
|
|
852
|
-
body: t,
|
|
853
|
-
headers: n,
|
|
854
|
-
method: "POST",
|
|
855
|
-
referrer: "https://sk.thorswap.net"
|
|
856
|
-
});
|
|
857
|
-
return a ? i.text() : i.json();
|
|
858
|
-
}, nt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
|
|
846
|
+
}, E = (e, t, n) => (Tt(e, t, "access private method"), n);
|
|
847
|
+
const ht = "0x313ce567", Be = async ({ chain: e, to: t }) => {
|
|
859
848
|
try {
|
|
860
|
-
const n = await
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
849
|
+
const { result: n } = await Ae.post(ut[e], {
|
|
850
|
+
headers: {
|
|
851
|
+
accept: "*/*",
|
|
852
|
+
"content-type": "application/json",
|
|
853
|
+
"cache-control": "no-cache"
|
|
854
|
+
},
|
|
855
|
+
body: JSON.stringify({
|
|
865
856
|
id: 44,
|
|
866
|
-
jsonrpc: "2.0"
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
return parseInt(BigInt(
|
|
857
|
+
jsonrpc: "2.0",
|
|
858
|
+
method: "eth_call",
|
|
859
|
+
params: [{ to: t.toLowerCase(), data: ht }, "latest"]
|
|
860
|
+
})
|
|
861
|
+
});
|
|
862
|
+
return parseInt(BigInt(n).toString());
|
|
872
863
|
} catch (n) {
|
|
873
|
-
return console.error(n),
|
|
864
|
+
return console.error(n), A[e];
|
|
874
865
|
}
|
|
875
|
-
},
|
|
876
|
-
if (e ===
|
|
877
|
-
return
|
|
866
|
+
}, _t = async (e) => {
|
|
867
|
+
if (e === i.Ethereum)
|
|
868
|
+
return A.ETH;
|
|
878
869
|
const [, t] = e.split("-");
|
|
879
|
-
return t != null && t.startsWith("0x") ?
|
|
880
|
-
},
|
|
870
|
+
return t != null && t.startsWith("0x") ? Be({ chain: i.Ethereum, to: t }) : A.ETH;
|
|
871
|
+
}, ft = async (e) => {
|
|
881
872
|
const [, t] = e.split("-");
|
|
882
|
-
return t != null && t.startsWith("0x") ?
|
|
883
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? Be({ chain: i.Avalanche, to: t.toLowerCase() }) : A.AVAX;
|
|
874
|
+
}, bt = async (e) => (e === i.BinanceSmartChain, A.BSC), wt = async ({ chain: e, symbol: t }) => {
|
|
884
875
|
switch (e) {
|
|
885
|
-
case
|
|
886
|
-
return
|
|
887
|
-
case
|
|
888
|
-
return
|
|
889
|
-
case
|
|
890
|
-
return
|
|
876
|
+
case i.Ethereum:
|
|
877
|
+
return _t(t);
|
|
878
|
+
case i.Avalanche:
|
|
879
|
+
return ft(t);
|
|
880
|
+
case i.BinanceSmartChain:
|
|
881
|
+
return bt(t);
|
|
891
882
|
default:
|
|
892
|
-
return
|
|
883
|
+
return A[e];
|
|
893
884
|
}
|
|
894
|
-
},
|
|
885
|
+
}, At = {
|
|
895
886
|
[F.Average]: 1.2,
|
|
896
887
|
[F.Fast]: 1.5,
|
|
897
888
|
[F.Fastest]: 2
|
|
898
|
-
},
|
|
889
|
+
}, Le = ({ chain: e, symbol: t }) => {
|
|
899
890
|
switch (e) {
|
|
900
|
-
case
|
|
901
|
-
case
|
|
902
|
-
case
|
|
903
|
-
case
|
|
904
|
-
case
|
|
905
|
-
case
|
|
906
|
-
case
|
|
891
|
+
case i.Bitcoin:
|
|
892
|
+
case i.BitcoinCash:
|
|
893
|
+
case i.Litecoin:
|
|
894
|
+
case i.Dogecoin:
|
|
895
|
+
case i.Binance:
|
|
896
|
+
case i.Ethereum:
|
|
897
|
+
case i.Avalanche:
|
|
907
898
|
return t === e;
|
|
908
|
-
case
|
|
909
|
-
case
|
|
899
|
+
case i.Arbitrum:
|
|
900
|
+
case i.Optimism:
|
|
910
901
|
return t === "ETH";
|
|
911
|
-
case
|
|
902
|
+
case i.Maya:
|
|
912
903
|
return t === "CACAO";
|
|
913
|
-
case
|
|
904
|
+
case i.Kujira:
|
|
905
|
+
return t === "KUJI";
|
|
906
|
+
case i.Cosmos:
|
|
914
907
|
return t === "ATOM";
|
|
915
|
-
case
|
|
908
|
+
case i.Polygon:
|
|
916
909
|
return t === "MATIC";
|
|
917
|
-
case
|
|
910
|
+
case i.BinanceSmartChain:
|
|
918
911
|
return t === "BNB";
|
|
919
|
-
case
|
|
912
|
+
case i.THORChain:
|
|
920
913
|
return t === "RUNE";
|
|
921
914
|
}
|
|
922
|
-
},
|
|
915
|
+
}, Et = (e) => {
|
|
923
916
|
switch (e) {
|
|
924
917
|
case "ETH.THOR":
|
|
925
918
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
926
919
|
case "ETH.vTHOR":
|
|
927
920
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
928
|
-
case
|
|
929
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
930
|
-
case
|
|
931
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
932
|
-
case
|
|
933
|
-
return { identifier: "BSC.BNB", decimal:
|
|
934
|
-
case
|
|
935
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
921
|
+
case i.Cosmos:
|
|
922
|
+
return { identifier: "GAIA.ATOM", decimal: A[e] };
|
|
923
|
+
case i.THORChain:
|
|
924
|
+
return { identifier: "THOR.RUNE", decimal: A[e] };
|
|
925
|
+
case i.BinanceSmartChain:
|
|
926
|
+
return { identifier: "BSC.BNB", decimal: A[e] };
|
|
927
|
+
case i.Maya:
|
|
928
|
+
return { identifier: "MAYA.CACAO", decimal: A.MAYA };
|
|
936
929
|
case "MAYA.MAYA":
|
|
937
930
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
938
|
-
case
|
|
939
|
-
case
|
|
940
|
-
case
|
|
941
|
-
case
|
|
942
|
-
case
|
|
943
|
-
case
|
|
944
|
-
case
|
|
945
|
-
case
|
|
946
|
-
case
|
|
947
|
-
case
|
|
948
|
-
|
|
931
|
+
case i.Kujira:
|
|
932
|
+
case i.Arbitrum:
|
|
933
|
+
case i.Optimism:
|
|
934
|
+
case i.BitcoinCash:
|
|
935
|
+
case i.Litecoin:
|
|
936
|
+
case i.Dogecoin:
|
|
937
|
+
case i.Binance:
|
|
938
|
+
case i.Avalanche:
|
|
939
|
+
case i.Polygon:
|
|
940
|
+
case i.Bitcoin:
|
|
941
|
+
case i.Ethereum:
|
|
942
|
+
return { identifier: `${e}.${e}`, decimal: A[e] };
|
|
949
943
|
}
|
|
950
|
-
},
|
|
944
|
+
}, Rt = ({ chain: e, symbol: t }) => {
|
|
951
945
|
if (t.includes("/"))
|
|
952
946
|
return "Synth";
|
|
953
947
|
switch (e) {
|
|
954
|
-
case
|
|
955
|
-
case
|
|
956
|
-
case
|
|
957
|
-
case
|
|
958
|
-
case
|
|
959
|
-
case
|
|
948
|
+
case i.Bitcoin:
|
|
949
|
+
case i.BitcoinCash:
|
|
950
|
+
case i.Dogecoin:
|
|
951
|
+
case i.Litecoin:
|
|
952
|
+
case i.Maya:
|
|
953
|
+
case i.THORChain:
|
|
960
954
|
return "Native";
|
|
961
|
-
case
|
|
962
|
-
return t === "ATOM" ? "Native" :
|
|
963
|
-
case
|
|
964
|
-
return t ===
|
|
965
|
-
case
|
|
966
|
-
return t ===
|
|
967
|
-
case
|
|
968
|
-
return t ===
|
|
969
|
-
case
|
|
970
|
-
return t ===
|
|
971
|
-
case
|
|
972
|
-
return t ===
|
|
973
|
-
case
|
|
974
|
-
return
|
|
975
|
-
case
|
|
976
|
-
return [
|
|
955
|
+
case i.Cosmos:
|
|
956
|
+
return t === "ATOM" ? "Native" : i.Cosmos;
|
|
957
|
+
case i.Kujira:
|
|
958
|
+
return t === i.Kujira ? "Native" : i.Kujira;
|
|
959
|
+
case i.Binance:
|
|
960
|
+
return t === i.Binance ? "Native" : "BEP2";
|
|
961
|
+
case i.BinanceSmartChain:
|
|
962
|
+
return t === i.Binance ? "Native" : "BEP20";
|
|
963
|
+
case i.Ethereum:
|
|
964
|
+
return t === i.Ethereum ? "Native" : "ERC20";
|
|
965
|
+
case i.Avalanche:
|
|
966
|
+
return t === i.Avalanche ? "Native" : i.Avalanche;
|
|
967
|
+
case i.Polygon:
|
|
968
|
+
return t === i.Polygon ? "Native" : "POLYGON";
|
|
969
|
+
case i.Arbitrum:
|
|
970
|
+
return [i.Ethereum, i.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
971
|
+
case i.Optimism:
|
|
972
|
+
return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
977
973
|
}
|
|
978
|
-
},
|
|
974
|
+
}, In = (e) => {
|
|
979
975
|
var t;
|
|
980
|
-
const [n, ...a] = e.split("."),
|
|
981
|
-
return { chain: n, symbol: r, ticker:
|
|
982
|
-
},
|
|
976
|
+
const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."), o = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
977
|
+
return { chain: n, symbol: r, ticker: o, synth: s };
|
|
978
|
+
}, gt = new RegExp(
|
|
979
|
+
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
|
+
"gmi"
|
|
981
|
+
), Ot = (e) => {
|
|
982
|
+
const [t, n] = e.split(".");
|
|
983
|
+
if (!ot.includes(t))
|
|
984
|
+
return !0;
|
|
985
|
+
const [, a] = n.split("-");
|
|
986
|
+
return Le({ chain: t, symbol: n }) || !!a;
|
|
987
|
+
}, Sn = (e) => e.filter((t) => {
|
|
988
|
+
const n = `${t.chain}.${t.symbol}`;
|
|
989
|
+
return !gt.test(n) && Ot(n) && t.value !== "0";
|
|
990
|
+
}), It = ({
|
|
983
991
|
liquidityUnits: e,
|
|
984
992
|
poolUnits: t,
|
|
985
993
|
runeDepth: n
|
|
986
994
|
}) => {
|
|
987
|
-
const a =
|
|
988
|
-
return
|
|
989
|
-
},
|
|
995
|
+
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = s.mul(s).mul(s);
|
|
996
|
+
return o.mul(p.sub(d).add(y)).div(u);
|
|
997
|
+
}, St = ({
|
|
990
998
|
liquidityUnits: e,
|
|
991
999
|
poolUnits: t,
|
|
992
1000
|
assetDepth: n
|
|
993
1001
|
}) => {
|
|
994
|
-
const a =
|
|
995
|
-
return
|
|
996
|
-
},
|
|
1002
|
+
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = o.mul(p.sub(d).add(y)), c = s.mul(s).mul(s);
|
|
1003
|
+
return u.div(c);
|
|
1004
|
+
}, vn = ({
|
|
997
1005
|
percent: e,
|
|
998
1006
|
runeDepth: t,
|
|
999
1007
|
liquidityUnits: n,
|
|
1000
1008
|
poolUnits: a
|
|
1001
|
-
}) =>
|
|
1009
|
+
}) => It({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), Cn = ({
|
|
1002
1010
|
percent: e,
|
|
1003
1011
|
assetDepth: t,
|
|
1004
1012
|
liquidityUnits: n,
|
|
1005
1013
|
poolUnits: a
|
|
1006
|
-
}) =>
|
|
1014
|
+
}) => St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => D.fromBigInt(BigInt(e), A.THOR), vt = ({
|
|
1007
1015
|
liquidityUnits: e,
|
|
1008
1016
|
poolUnits: t,
|
|
1009
1017
|
runeDepth: n,
|
|
1010
1018
|
assetDepth: a
|
|
1011
1019
|
}) => ({
|
|
1012
|
-
assetAmount:
|
|
1013
|
-
runeAmount:
|
|
1014
|
-
}),
|
|
1020
|
+
assetAmount: g(a).mul(e).div(t),
|
|
1021
|
+
runeAmount: g(n).mul(e).div(t)
|
|
1022
|
+
}), Mn = ({
|
|
1015
1023
|
liquidityUnits: e,
|
|
1016
1024
|
poolUnits: t,
|
|
1017
1025
|
runeDepth: n,
|
|
1018
1026
|
assetDepth: a,
|
|
1019
|
-
percent:
|
|
1027
|
+
percent: s
|
|
1020
1028
|
}) => Object.fromEntries(
|
|
1021
|
-
Object.entries(
|
|
1022
|
-
([r,
|
|
1029
|
+
Object.entries(vt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1030
|
+
([r, o]) => [r, o.mul(s)]
|
|
1023
1031
|
)
|
|
1024
|
-
),
|
|
1032
|
+
), Nn = ({
|
|
1025
1033
|
runeDepth: e,
|
|
1026
1034
|
poolUnits: t,
|
|
1027
1035
|
assetDepth: n,
|
|
1028
1036
|
liquidityUnits: a,
|
|
1029
|
-
runeAmount:
|
|
1037
|
+
runeAmount: s,
|
|
1030
1038
|
assetAmount: r
|
|
1031
1039
|
}) => {
|
|
1032
|
-
const
|
|
1033
|
-
if (
|
|
1034
|
-
return
|
|
1035
|
-
const
|
|
1036
|
-
return
|
|
1037
|
-
},
|
|
1040
|
+
const o = new D({ value: e, decimal: 8 }), p = new D({ value: n, decimal: 8 }), d = new D({ value: t, decimal: 8 }), y = new D({ value: s, decimal: 8 }), u = new D({ value: r, decimal: 8 }), c = y.mul(p), _ = u.mul(o), b = y.mul(u), w = o.mul(p), R = d.mul(c.add(_.add(b.mul(2)))), O = c.add(_.add(w.mul(2))), I = R.div(O), S = g(a).add(I);
|
|
1041
|
+
if (I.getBaseValue("number") === 0)
|
|
1042
|
+
return S.div(d).getBaseValue("number");
|
|
1043
|
+
const P = d.add(S);
|
|
1044
|
+
return S.div(P).getBaseValue("number");
|
|
1045
|
+
}, xn = ({
|
|
1038
1046
|
runeAmount: e,
|
|
1039
1047
|
assetAmount: t,
|
|
1040
1048
|
runeDepth: n,
|
|
1041
1049
|
assetDepth: a
|
|
1042
1050
|
}) => {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1051
|
+
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1052
|
+
return 0;
|
|
1053
|
+
const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), y = r.mul(p).add(s.mul(r));
|
|
1054
|
+
return Math.abs(d.div(y).getBaseValue("number"));
|
|
1055
|
+
}, Ct = ({
|
|
1046
1056
|
symbol: e,
|
|
1047
1057
|
ticker: t,
|
|
1048
1058
|
chain: n
|
|
1049
1059
|
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, x = (e, t) => {
|
|
1050
1060
|
switch (e) {
|
|
1051
|
-
case
|
|
1052
|
-
case
|
|
1061
|
+
case h.LEAVE:
|
|
1062
|
+
case h.BOND: {
|
|
1053
1063
|
const { address: n } = t;
|
|
1054
1064
|
return `${e}:${n}`;
|
|
1055
1065
|
}
|
|
1056
|
-
case
|
|
1066
|
+
case h.UNBOND: {
|
|
1057
1067
|
const { address: n, unbondAmount: a } = t;
|
|
1058
1068
|
return `${e}:${n}:${a * 10 ** 8}`;
|
|
1059
1069
|
}
|
|
1060
|
-
case
|
|
1061
|
-
const { name: n, chain: a, address:
|
|
1062
|
-
return `${e}:${n}:${a}:${
|
|
1070
|
+
case h.THORNAME_REGISTER: {
|
|
1071
|
+
const { name: n, chain: a, address: s, owner: r } = t;
|
|
1072
|
+
return `${e}:${n}:${a}:${s}${r ? `:${r}` : ""}`;
|
|
1063
1073
|
}
|
|
1064
|
-
case
|
|
1065
|
-
const { chain: n, symbol: a, address:
|
|
1066
|
-
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${
|
|
1074
|
+
case h.DEPOSIT: {
|
|
1075
|
+
const { chain: n, symbol: a, address: s, singleSide: r } = t;
|
|
1076
|
+
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${s || ""}:t:0`;
|
|
1067
1077
|
}
|
|
1068
|
-
case
|
|
1069
|
-
const { chain: n, ticker: a, symbol:
|
|
1070
|
-
return `${e}:${n}${
|
|
1078
|
+
case h.WITHDRAW: {
|
|
1079
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", y = Ct({ chain: n, symbol: s, ticker: a });
|
|
1080
|
+
return `${e}:${n}${p ? "/" : "."}${y}:${r}${d}`;
|
|
1071
1081
|
}
|
|
1072
|
-
case
|
|
1073
|
-
case
|
|
1082
|
+
case h.OPEN_LOAN:
|
|
1083
|
+
case h.CLOSE_LOAN: {
|
|
1074
1084
|
const { asset: n, address: a } = t;
|
|
1075
1085
|
return `${e}:${n}:${a}`;
|
|
1076
1086
|
}
|
|
1077
1087
|
default:
|
|
1078
1088
|
return "";
|
|
1079
1089
|
}
|
|
1080
|
-
},
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}) => {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
""
|
|
1094
|
-
|
|
1095
|
-
|
|
1090
|
+
}, Dn = (e) => {
|
|
1091
|
+
if (e < 0)
|
|
1092
|
+
throw new Error("Invalid number of year");
|
|
1093
|
+
return 10 + e;
|
|
1094
|
+
}, Pn = (e) => {
|
|
1095
|
+
if (e.length > 30)
|
|
1096
|
+
return !1;
|
|
1097
|
+
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1098
|
+
return !!e.match(t);
|
|
1099
|
+
}, Bn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1100
|
+
class Ee extends Error {
|
|
1101
|
+
constructor(t, n, a) {
|
|
1102
|
+
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
|
|
1103
|
+
super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
|
|
1104
|
+
enumerable: !0,
|
|
1105
|
+
configurable: !0,
|
|
1106
|
+
writable: !0,
|
|
1107
|
+
value: void 0
|
|
1108
|
+
}), Object.defineProperty(this, "request", {
|
|
1109
|
+
enumerable: !0,
|
|
1110
|
+
configurable: !0,
|
|
1111
|
+
writable: !0,
|
|
1112
|
+
value: void 0
|
|
1113
|
+
}), Object.defineProperty(this, "options", {
|
|
1114
|
+
enumerable: !0,
|
|
1115
|
+
configurable: !0,
|
|
1116
|
+
writable: !0,
|
|
1117
|
+
value: void 0
|
|
1118
|
+
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
class Ve extends Error {
|
|
1122
|
+
constructor(t) {
|
|
1123
|
+
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1124
|
+
enumerable: !0,
|
|
1125
|
+
configurable: !0,
|
|
1126
|
+
writable: !0,
|
|
1127
|
+
value: void 0
|
|
1128
|
+
}), this.name = "TimeoutError", this.request = t;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
1132
|
+
for (const t of e)
|
|
1133
|
+
if ((!Q(t) || Array.isArray(t)) && t !== void 0)
|
|
1134
|
+
throw new TypeError("The `options` argument must be an object");
|
|
1135
|
+
return we({}, ...e);
|
|
1136
|
+
}, Ue = (e = {}, t = {}) => {
|
|
1137
|
+
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1138
|
+
for (const [r, o] of s.entries())
|
|
1139
|
+
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
1140
|
+
return n;
|
|
1141
|
+
}, we = (...e) => {
|
|
1142
|
+
let t = {}, n = {};
|
|
1143
|
+
for (const a of e)
|
|
1144
|
+
if (Array.isArray(a))
|
|
1145
|
+
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1146
|
+
else if (Q(a)) {
|
|
1147
|
+
for (let [s, r] of Object.entries(a))
|
|
1148
|
+
Q(r) && s in t && (r = we(t[s], r)), t = { ...t, [s]: r };
|
|
1149
|
+
Q(a.headers) && (n = Ue(n, a.headers), t.headers = n);
|
|
1150
|
+
}
|
|
1151
|
+
return t;
|
|
1152
|
+
}, Mt = (() => {
|
|
1153
|
+
let e = !1, t = !1;
|
|
1154
|
+
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1155
|
+
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
1156
|
+
body: new globalThis.ReadableStream(),
|
|
1157
|
+
method: "POST",
|
|
1158
|
+
// @ts-expect-error - Types are outdated.
|
|
1159
|
+
get duplex() {
|
|
1160
|
+
return e = !0, "half";
|
|
1161
|
+
}
|
|
1162
|
+
}).headers.has("Content-Type")), e && !t;
|
|
1163
|
+
})(), Nt = typeof globalThis.AbortController == "function", xt = typeof globalThis.ReadableStream == "function", Dt = typeof globalThis.FormData == "function", He = ["get", "post", "put", "patch", "head", "delete"], Pt = {
|
|
1164
|
+
json: "application/json",
|
|
1165
|
+
text: "text/*",
|
|
1166
|
+
formData: "multipart/form-data",
|
|
1167
|
+
arrayBuffer: "*/*",
|
|
1168
|
+
blob: "*/*"
|
|
1169
|
+
}, pe = 2147483647, $e = Symbol("stop"), Bt = {
|
|
1170
|
+
json: !0,
|
|
1171
|
+
parseJson: !0,
|
|
1172
|
+
searchParams: !0,
|
|
1173
|
+
prefixUrl: !0,
|
|
1174
|
+
retry: !0,
|
|
1175
|
+
timeout: !0,
|
|
1176
|
+
hooks: !0,
|
|
1177
|
+
throwHttpErrors: !0,
|
|
1178
|
+
onDownloadProgress: !0,
|
|
1179
|
+
fetch: !0
|
|
1180
|
+
}, Lt = {
|
|
1181
|
+
method: !0,
|
|
1182
|
+
headers: !0,
|
|
1183
|
+
body: !0,
|
|
1184
|
+
mode: !0,
|
|
1185
|
+
credentials: !0,
|
|
1186
|
+
cache: !0,
|
|
1187
|
+
redirect: !0,
|
|
1188
|
+
referrer: !0,
|
|
1189
|
+
referrerPolicy: !0,
|
|
1190
|
+
integrity: !0,
|
|
1191
|
+
keepalive: !0,
|
|
1192
|
+
signal: !0,
|
|
1193
|
+
window: !0,
|
|
1194
|
+
dispatcher: !0,
|
|
1195
|
+
duplex: !0
|
|
1196
|
+
}, Vt = (e) => He.includes(e) ? e.toUpperCase() : e, Ut = ["get", "put", "head", "delete", "options", "trace"], Ht = [408, 413, 429, 500, 502, 503, 504], ke = [413, 429, 503], Re = {
|
|
1197
|
+
limit: 2,
|
|
1198
|
+
methods: Ut,
|
|
1199
|
+
statusCodes: Ht,
|
|
1200
|
+
afterStatusCodes: ke,
|
|
1201
|
+
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1202
|
+
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1203
|
+
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1204
|
+
}, $t = (e = {}) => {
|
|
1205
|
+
if (typeof e == "number")
|
|
1206
|
+
return {
|
|
1207
|
+
...Re,
|
|
1208
|
+
limit: e
|
|
1209
|
+
};
|
|
1210
|
+
if (e.methods && !Array.isArray(e.methods))
|
|
1211
|
+
throw new Error("retry.methods must be an array");
|
|
1212
|
+
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1213
|
+
throw new Error("retry.statusCodes must be an array");
|
|
1214
|
+
return {
|
|
1215
|
+
...Re,
|
|
1216
|
+
...e,
|
|
1217
|
+
afterStatusCodes: ke
|
|
1218
|
+
};
|
|
1219
|
+
};
|
|
1220
|
+
async function kt(e, t, n, a) {
|
|
1221
|
+
return new Promise((s, r) => {
|
|
1222
|
+
const o = setTimeout(() => {
|
|
1223
|
+
n && n.abort(), r(new Ve(e));
|
|
1224
|
+
}, a.timeout);
|
|
1225
|
+
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1226
|
+
clearTimeout(o);
|
|
1227
|
+
});
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
async function Ft(e, { signal: t }) {
|
|
1231
|
+
return new Promise((n, a) => {
|
|
1232
|
+
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
|
|
1233
|
+
function s() {
|
|
1234
|
+
clearTimeout(r), a(t.reason);
|
|
1235
|
+
}
|
|
1236
|
+
const r = setTimeout(() => {
|
|
1237
|
+
t == null || t.removeEventListener("abort", s), n();
|
|
1238
|
+
}, e);
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
const Gt = (e, t) => {
|
|
1242
|
+
const n = {};
|
|
1243
|
+
for (const a in t)
|
|
1244
|
+
!(a in Lt) && !(a in Bt) && !(a in e) && (n[a] = t[a]);
|
|
1245
|
+
return n;
|
|
1246
|
+
};
|
|
1247
|
+
class te {
|
|
1248
|
+
static create(t, n) {
|
|
1249
|
+
const a = new te(t, n), s = async () => {
|
|
1250
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > pe)
|
|
1251
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${pe}`);
|
|
1252
|
+
await Promise.resolve();
|
|
1253
|
+
let o = await a._fetch();
|
|
1254
|
+
for (const p of a._options.hooks.afterResponse) {
|
|
1255
|
+
const d = await p(a.request, a._options, a._decorateResponse(o.clone()));
|
|
1256
|
+
d instanceof globalThis.Response && (o = d);
|
|
1257
|
+
}
|
|
1258
|
+
if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
|
|
1259
|
+
let p = new Ee(o, a.request, a._options);
|
|
1260
|
+
for (const d of a._options.hooks.beforeError)
|
|
1261
|
+
p = await d(p);
|
|
1262
|
+
throw p;
|
|
1263
|
+
}
|
|
1264
|
+
if (a._options.onDownloadProgress) {
|
|
1265
|
+
if (typeof a._options.onDownloadProgress != "function")
|
|
1266
|
+
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
1267
|
+
if (!xt)
|
|
1268
|
+
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1269
|
+
return a._stream(o.clone(), a._options.onDownloadProgress);
|
|
1270
|
+
}
|
|
1271
|
+
return o;
|
|
1272
|
+
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
|
|
1273
|
+
for (const [o, p] of Object.entries(Pt))
|
|
1274
|
+
r[o] = async () => {
|
|
1275
|
+
a.request.headers.set("accept", a.request.headers.get("accept") || p);
|
|
1276
|
+
const d = (await r).clone();
|
|
1277
|
+
if (o === "json") {
|
|
1278
|
+
if (d.status === 204 || (await d.clone().arrayBuffer()).byteLength === 0)
|
|
1279
|
+
return "";
|
|
1280
|
+
if (n.parseJson)
|
|
1281
|
+
return n.parseJson(await d.text());
|
|
1282
|
+
}
|
|
1283
|
+
return d[o]();
|
|
1284
|
+
};
|
|
1285
|
+
return r;
|
|
1286
|
+
}
|
|
1287
|
+
// eslint-disable-next-line complexity
|
|
1288
|
+
constructor(t, n = {}) {
|
|
1289
|
+
if (Object.defineProperty(this, "request", {
|
|
1290
|
+
enumerable: !0,
|
|
1291
|
+
configurable: !0,
|
|
1292
|
+
writable: !0,
|
|
1293
|
+
value: void 0
|
|
1294
|
+
}), Object.defineProperty(this, "abortController", {
|
|
1295
|
+
enumerable: !0,
|
|
1296
|
+
configurable: !0,
|
|
1297
|
+
writable: !0,
|
|
1298
|
+
value: void 0
|
|
1299
|
+
}), Object.defineProperty(this, "_retryCount", {
|
|
1300
|
+
enumerable: !0,
|
|
1301
|
+
configurable: !0,
|
|
1302
|
+
writable: !0,
|
|
1303
|
+
value: 0
|
|
1304
|
+
}), Object.defineProperty(this, "_input", {
|
|
1305
|
+
enumerable: !0,
|
|
1306
|
+
configurable: !0,
|
|
1307
|
+
writable: !0,
|
|
1308
|
+
value: void 0
|
|
1309
|
+
}), Object.defineProperty(this, "_options", {
|
|
1310
|
+
enumerable: !0,
|
|
1311
|
+
configurable: !0,
|
|
1312
|
+
writable: !0,
|
|
1313
|
+
value: void 0
|
|
1314
|
+
}), this._input = t, this._options = {
|
|
1315
|
+
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1316
|
+
credentials: this._input.credentials || "same-origin",
|
|
1317
|
+
...n,
|
|
1318
|
+
headers: Ue(this._input.headers, n.headers),
|
|
1319
|
+
hooks: we({
|
|
1320
|
+
beforeRequest: [],
|
|
1321
|
+
beforeRetry: [],
|
|
1322
|
+
beforeError: [],
|
|
1323
|
+
afterResponse: []
|
|
1324
|
+
}, n.hooks),
|
|
1325
|
+
method: Vt(n.method ?? this._input.method),
|
|
1326
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1327
|
+
prefixUrl: String(n.prefixUrl || ""),
|
|
1328
|
+
retry: $t(n.retry),
|
|
1329
|
+
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1330
|
+
timeout: n.timeout ?? 1e4,
|
|
1331
|
+
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
1332
|
+
}, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
|
|
1333
|
+
throw new TypeError("`input` must be a string, URL, or Request");
|
|
1334
|
+
if (this._options.prefixUrl && typeof this._input == "string") {
|
|
1335
|
+
if (this._input.startsWith("/"))
|
|
1336
|
+
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1337
|
+
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1338
|
+
}
|
|
1339
|
+
if (Nt) {
|
|
1340
|
+
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1341
|
+
const a = this._options.signal;
|
|
1342
|
+
this._options.signal.addEventListener("abort", () => {
|
|
1343
|
+
this.abortController.abort(a.reason);
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
this._options.signal = this.abortController.signal;
|
|
1347
|
+
}
|
|
1348
|
+
if (Mt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1349
|
+
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1350
|
+
(Dt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
|
|
1351
|
+
}
|
|
1352
|
+
this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
|
|
1353
|
+
}
|
|
1354
|
+
_calculateRetryDelay(t) {
|
|
1355
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof Ve)) {
|
|
1356
|
+
if (t instanceof Ee) {
|
|
1357
|
+
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1358
|
+
return 0;
|
|
1359
|
+
const a = t.response.headers.get("Retry-After");
|
|
1360
|
+
if (a && this._options.retry.afterStatusCodes.includes(t.response.status)) {
|
|
1361
|
+
let s = Number(a);
|
|
1362
|
+
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;
|
|
1363
|
+
}
|
|
1364
|
+
if (t.response.status === 413)
|
|
1365
|
+
return 0;
|
|
1366
|
+
}
|
|
1367
|
+
const n = this._options.retry.delay(this._retryCount);
|
|
1368
|
+
return Math.min(this._options.retry.backoffLimit, n);
|
|
1369
|
+
}
|
|
1370
|
+
return 0;
|
|
1371
|
+
}
|
|
1372
|
+
_decorateResponse(t) {
|
|
1373
|
+
return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
|
|
1374
|
+
}
|
|
1375
|
+
async _retry(t) {
|
|
1376
|
+
try {
|
|
1377
|
+
return await t();
|
|
1378
|
+
} catch (n) {
|
|
1379
|
+
const a = Math.min(this._calculateRetryDelay(n), pe);
|
|
1380
|
+
if (a !== 0 && this._retryCount > 0) {
|
|
1381
|
+
await Ft(a, { signal: this._options.signal });
|
|
1382
|
+
for (const s of this._options.hooks.beforeRetry)
|
|
1383
|
+
if (await s({
|
|
1384
|
+
request: this.request,
|
|
1385
|
+
options: this._options,
|
|
1386
|
+
error: n,
|
|
1387
|
+
retryCount: this._retryCount
|
|
1388
|
+
}) === $e)
|
|
1389
|
+
return;
|
|
1390
|
+
return this._retry(t);
|
|
1391
|
+
}
|
|
1392
|
+
throw n;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
async _fetch() {
|
|
1396
|
+
for (const n of this._options.hooks.beforeRequest) {
|
|
1397
|
+
const a = await n(this.request, this._options);
|
|
1398
|
+
if (a instanceof Request) {
|
|
1399
|
+
this.request = a;
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
if (a instanceof Response)
|
|
1403
|
+
return a;
|
|
1404
|
+
}
|
|
1405
|
+
const t = Gt(this.request, this._options);
|
|
1406
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : kt(this.request.clone(), t, this.abortController, this._options);
|
|
1407
|
+
}
|
|
1408
|
+
/* istanbul ignore next */
|
|
1409
|
+
_stream(t, n) {
|
|
1410
|
+
const a = Number(t.headers.get("content-length")) || 0;
|
|
1411
|
+
let s = 0;
|
|
1412
|
+
return t.status === 204 ? (n && n({ percent: 1, totalBytes: a, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
|
|
1413
|
+
status: t.status,
|
|
1414
|
+
statusText: t.statusText,
|
|
1415
|
+
headers: t.headers
|
|
1416
|
+
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
1417
|
+
async start(r) {
|
|
1418
|
+
const o = t.body.getReader();
|
|
1419
|
+
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1420
|
+
async function p() {
|
|
1421
|
+
const { done: d, value: y } = await o.read();
|
|
1422
|
+
if (d) {
|
|
1423
|
+
r.close();
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
if (n) {
|
|
1427
|
+
s += y.byteLength;
|
|
1428
|
+
const u = a === 0 ? 0 : s / a;
|
|
1429
|
+
n({ percent: u, transferredBytes: s, totalBytes: a }, y);
|
|
1430
|
+
}
|
|
1431
|
+
r.enqueue(y), await p();
|
|
1432
|
+
}
|
|
1433
|
+
await p();
|
|
1434
|
+
}
|
|
1435
|
+
}), {
|
|
1436
|
+
status: t.status,
|
|
1437
|
+
statusText: t.statusText,
|
|
1438
|
+
headers: t.headers
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
/*! MIT License © Sindre Sorhus */
|
|
1443
|
+
const ue = (e) => {
|
|
1444
|
+
const t = (n, a) => te.create(n, J(e, a));
|
|
1445
|
+
for (const n of He)
|
|
1446
|
+
t[n] = (a, s) => te.create(a, J(e, s, { method: n }));
|
|
1447
|
+
return t.create = (n) => ue(J(n)), t.extend = (n) => ue(J(e, n)), t.stop = $e, t;
|
|
1448
|
+
}, qt = ue(), Wt = qt, jt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, ge = Wt.create({ headers: jt }), Ae = {
|
|
1449
|
+
get: (e, t) => ge.get(e, t).json(),
|
|
1450
|
+
post: (e, t) => ge.post(e, t).json()
|
|
1451
|
+
}, Oe = Object.values(i), Kt = (e = "") => {
|
|
1096
1452
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1097
|
-
if (
|
|
1453
|
+
if (Oe.includes(n))
|
|
1098
1454
|
return !0;
|
|
1099
1455
|
const [a] = t.split("/");
|
|
1100
|
-
if (
|
|
1456
|
+
if (Oe.includes(a))
|
|
1101
1457
|
return !0;
|
|
1102
1458
|
throw new Error(
|
|
1103
1459
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1104
1460
|
);
|
|
1105
|
-
},
|
|
1106
|
-
|
|
1107
|
-
|
|
1461
|
+
}, j = 8, H = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1462
|
+
function re({
|
|
1463
|
+
value: e,
|
|
1464
|
+
bigIntDecimal: t = j,
|
|
1465
|
+
decimal: n = j
|
|
1466
|
+
}) {
|
|
1467
|
+
const a = e < 0n;
|
|
1468
|
+
let s = e.toString().substring(a ? 1 : 0);
|
|
1469
|
+
const r = n - (s.length - 1);
|
|
1470
|
+
r > 0 && (s = "0".repeat(r) + s);
|
|
1471
|
+
const o = s.length - n;
|
|
1472
|
+
let p = s.slice(-n);
|
|
1473
|
+
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(
|
|
1474
|
+
/\.?0*$/,
|
|
1475
|
+
""
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
var U, k, z, le, ye, Ie, ne, ce, $, q, ae, me;
|
|
1479
|
+
const Yt = class Fe {
|
|
1108
1480
|
constructor(t) {
|
|
1109
|
-
|
|
1110
|
-
const n =
|
|
1111
|
-
this.decimal =
|
|
1112
|
-
Math.max(
|
|
1113
|
-
),
|
|
1481
|
+
V(this, U), V(this, z), V(this, ye), V(this, ne), V(this, $), V(this, ae), C(this, "decimalMultiplier", 10n ** 8n), C(this, "bigIntValue", 0n), C(this, "decimal");
|
|
1482
|
+
const n = Z(t);
|
|
1483
|
+
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = H(
|
|
1484
|
+
Math.max(E(this, ae, me).call(this, E(this, $, q).call(this, n)), this.decimal || 0)
|
|
1485
|
+
), E(this, z, le).call(this, n);
|
|
1114
1486
|
}
|
|
1115
1487
|
static fromBigInt(t, n) {
|
|
1116
|
-
return new
|
|
1488
|
+
return new Fe({
|
|
1117
1489
|
decimal: n,
|
|
1118
|
-
value:
|
|
1490
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1119
1491
|
});
|
|
1120
1492
|
}
|
|
1121
1493
|
static shiftDecimals({
|
|
@@ -1123,40 +1495,25 @@ const Tt = class z {
|
|
|
1123
1495
|
from: n,
|
|
1124
1496
|
to: a
|
|
1125
1497
|
}) {
|
|
1126
|
-
return
|
|
1127
|
-
|
|
1498
|
+
return this.fromBigInt(
|
|
1499
|
+
t.getBaseValue("bigint") * H(a) / H(n),
|
|
1128
1500
|
a
|
|
1129
1501
|
);
|
|
1130
1502
|
}
|
|
1131
|
-
|
|
1132
|
-
return
|
|
1133
|
-
}
|
|
1134
|
-
get baseValue() {
|
|
1135
|
-
return R(this, k, Q).call(this, "string");
|
|
1136
|
-
}
|
|
1137
|
-
get baseValueNumber() {
|
|
1138
|
-
return R(this, k, Q).call(this, "number");
|
|
1139
|
-
}
|
|
1140
|
-
get baseValueBigInt() {
|
|
1141
|
-
return R(this, k, Q).call(this, "number");
|
|
1142
|
-
}
|
|
1143
|
-
get value() {
|
|
1144
|
-
return this.formatBigIntToSafeValue(
|
|
1145
|
-
this.bigIntValue,
|
|
1146
|
-
this.decimal || G(this.decimalMultiplier)
|
|
1147
|
-
);
|
|
1503
|
+
set(t) {
|
|
1504
|
+
return E(this, z, le).call(this, Z(t)), this;
|
|
1148
1505
|
}
|
|
1149
1506
|
add(...t) {
|
|
1150
|
-
return
|
|
1507
|
+
return E(this, U, k).call(this, "add", ...t);
|
|
1151
1508
|
}
|
|
1152
1509
|
sub(...t) {
|
|
1153
|
-
return
|
|
1510
|
+
return E(this, U, k).call(this, "sub", ...t);
|
|
1154
1511
|
}
|
|
1155
1512
|
mul(...t) {
|
|
1156
|
-
return
|
|
1513
|
+
return E(this, U, k).call(this, "mul", ...t);
|
|
1157
1514
|
}
|
|
1158
1515
|
div(...t) {
|
|
1159
|
-
return
|
|
1516
|
+
return E(this, U, k).call(this, "div", ...t);
|
|
1160
1517
|
}
|
|
1161
1518
|
gt(t) {
|
|
1162
1519
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1173,129 +1530,197 @@ const Tt = class z {
|
|
|
1173
1530
|
eqValue(t) {
|
|
1174
1531
|
return this.bigIntValue === this.getBigIntValue(t);
|
|
1175
1532
|
}
|
|
1533
|
+
getValue(t) {
|
|
1534
|
+
const n = this.formatBigIntToSafeValue(
|
|
1535
|
+
this.bigIntValue,
|
|
1536
|
+
this.decimal || G(this.decimalMultiplier)
|
|
1537
|
+
);
|
|
1538
|
+
switch (t) {
|
|
1539
|
+
case "number":
|
|
1540
|
+
return Number(n);
|
|
1541
|
+
case "string":
|
|
1542
|
+
return n;
|
|
1543
|
+
default:
|
|
1544
|
+
return this.bigIntValue * BigInt(this.decimal || 8n) / this.decimalMultiplier;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
getBaseValue(t) {
|
|
1548
|
+
const n = this.decimalMultiplier / H(this.decimal || A.THOR), a = this.bigIntValue / n;
|
|
1549
|
+
switch (t) {
|
|
1550
|
+
case "number":
|
|
1551
|
+
return Number(a);
|
|
1552
|
+
case "string":
|
|
1553
|
+
return a.toString();
|
|
1554
|
+
default:
|
|
1555
|
+
return a;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1176
1558
|
getBigIntValue(t, n) {
|
|
1177
|
-
|
|
1559
|
+
if (!n && typeof t == "object")
|
|
1560
|
+
return t.bigIntValue;
|
|
1561
|
+
const a = Z(t), s = E(this, $, q).call(this, a);
|
|
1562
|
+
return s === "0" || s === "undefined" ? 0n : E(this, ne, ce).call(this, s, n);
|
|
1178
1563
|
}
|
|
1179
1564
|
formatBigIntToSafeValue(t, n) {
|
|
1180
|
-
const a = n || this.decimal ||
|
|
1565
|
+
const a = n || this.decimal || j, s = Math.max(
|
|
1181
1566
|
a,
|
|
1182
1567
|
G(this.decimalMultiplier)
|
|
1183
|
-
), r = t < 0n;
|
|
1184
|
-
let
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
)
|
|
1568
|
+
), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, y = d.length - s;
|
|
1569
|
+
let u = d.slice(-s);
|
|
1570
|
+
return parseInt(u[a]) >= 5 ? u = `${u.substring(0, a - 1)}${(parseInt(u[a - 1]) + 1).toString()}` : u = u.substring(0, a), `${r ? "-" : ""}${d.slice(
|
|
1571
|
+
0,
|
|
1572
|
+
y
|
|
1573
|
+
)}.${u}`.replace(/\.?0*$/, "");
|
|
1574
|
+
}
|
|
1575
|
+
toSignificant(t = 6) {
|
|
1576
|
+
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
1577
|
+
if ((parseInt(s) ? s.length + r.length : r.length) <= t)
|
|
1578
|
+
return this.getValue("string");
|
|
1579
|
+
if (s.length >= t)
|
|
1580
|
+
return s.slice(0, t).padEnd(s.length, "0");
|
|
1581
|
+
if (parseInt(s))
|
|
1582
|
+
return `${s}.${r.slice(0, t - s.length)}`.padEnd(
|
|
1583
|
+
t - s.length,
|
|
1584
|
+
"0"
|
|
1585
|
+
);
|
|
1586
|
+
const o = parseInt(r), p = `${o}`.slice(0, t);
|
|
1587
|
+
return `0.${p.padStart(
|
|
1588
|
+
r.length - `${o}`.length + p.length,
|
|
1589
|
+
"0"
|
|
1590
|
+
)}`;
|
|
1591
|
+
}
|
|
1592
|
+
toFixed(t = 6) {
|
|
1593
|
+
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
1594
|
+
if (parseInt(s))
|
|
1595
|
+
return `${s}.${r.slice(0, t)}`.padEnd(t, "0");
|
|
1596
|
+
const o = parseInt(r), p = `${o}`.slice(0, t);
|
|
1597
|
+
return `0.${p.padStart(
|
|
1598
|
+
r.length - `${o}`.length + p.length,
|
|
1599
|
+
"0"
|
|
1600
|
+
)}`;
|
|
1193
1601
|
}
|
|
1194
|
-
|
|
1195
|
-
const n = this.
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1602
|
+
toAbbreviation(t = 2) {
|
|
1603
|
+
const n = this.getValue("number"), a = ["", "K", "M", "B", "T", "Q", "Qi", "S"], s = Math.floor(Math.log10(Math.abs(n)) / 3), r = a[s];
|
|
1604
|
+
if (!r)
|
|
1605
|
+
return this.getValue("string");
|
|
1606
|
+
const o = 10 ** (s * 3);
|
|
1607
|
+
return `${(n / o).toFixed(t)}${r}`;
|
|
1608
|
+
}
|
|
1609
|
+
toCurrency(t = "$", {
|
|
1610
|
+
currencyPosition: n = "start",
|
|
1611
|
+
decimal: a = 2,
|
|
1612
|
+
decimalSeparator: s = ".",
|
|
1613
|
+
thousandSeparator: r = ","
|
|
1614
|
+
} = {}) {
|
|
1615
|
+
const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."), y = p.replace(/\B(?=(\d{3})+(?!\d))/g, r), u = !p && !d ? "0.00" : p === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${y}${d ? `${s}${d.slice(0, a)}` : ""}`;
|
|
1616
|
+
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1200
1617
|
}
|
|
1201
1618
|
};
|
|
1202
|
-
|
|
1203
|
-
const n =
|
|
1204
|
-
(
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1619
|
+
U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1620
|
+
const n = E(this, ye, Ie).call(this, this, ...t), a = H(n), s = t.reduce(
|
|
1621
|
+
(o, p) => {
|
|
1622
|
+
const d = this.getBigIntValue(p, n);
|
|
1623
|
+
switch (e) {
|
|
1624
|
+
case "add":
|
|
1625
|
+
return o + d;
|
|
1626
|
+
case "sub":
|
|
1627
|
+
return o - d;
|
|
1628
|
+
case "mul":
|
|
1629
|
+
return o * d / a;
|
|
1630
|
+
case "div": {
|
|
1631
|
+
if (d === 0n)
|
|
1632
|
+
throw new RangeError("Division by zero");
|
|
1633
|
+
return o * a / d;
|
|
1634
|
+
}
|
|
1635
|
+
default:
|
|
1636
|
+
return o;
|
|
1637
|
+
}
|
|
1209
1638
|
},
|
|
1210
1639
|
//normalize is to precision multiplier base
|
|
1211
1640
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1212
|
-
), r =
|
|
1641
|
+
), r = re({
|
|
1213
1642
|
bigIntDecimal: n,
|
|
1214
1643
|
decimal: Math.max(n, G(this.decimalMultiplier)),
|
|
1215
|
-
value:
|
|
1644
|
+
value: s
|
|
1216
1645
|
});
|
|
1217
1646
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1218
|
-
},
|
|
1219
|
-
const
|
|
1220
|
-
this.bigIntValue =
|
|
1221
|
-
},
|
|
1647
|
+
}, z = /* @__PURE__ */ new WeakSet(), le = function(e) {
|
|
1648
|
+
const t = E(this, $, q).call(this, e) || "0";
|
|
1649
|
+
this.bigIntValue = E(this, ne, ce).call(this, t);
|
|
1650
|
+
}, ye = /* @__PURE__ */ new WeakSet(), Ie = function(...e) {
|
|
1222
1651
|
const t = e.map(
|
|
1223
|
-
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) :
|
|
1652
|
+
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : E(this, ae, me).call(this, E(this, $, q).call(this, n))
|
|
1224
1653
|
).filter(Boolean);
|
|
1225
|
-
return Math.max(...t,
|
|
1226
|
-
},
|
|
1227
|
-
const n = t ?
|
|
1228
|
-
return BigInt(`${
|
|
1229
|
-
},
|
|
1654
|
+
return Math.max(...t, j);
|
|
1655
|
+
}, ne = /* @__PURE__ */ new WeakSet(), ce = function(e, t) {
|
|
1656
|
+
const n = t ? H(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
|
|
1657
|
+
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1658
|
+
}, $ = /* @__PURE__ */ new WeakSet(), q = function(e) {
|
|
1230
1659
|
const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
|
|
1231
1660
|
useGrouping: !1,
|
|
1232
1661
|
maximumFractionDigits: 20
|
|
1233
|
-
}) : e}`.replaceAll(",", ".").split(".");
|
|
1662
|
+
}) : Z(e)}`.replaceAll(",", ".").split(".");
|
|
1234
1663
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1235
|
-
},
|
|
1664
|
+
}, ae = /* @__PURE__ */ new WeakSet(), me = function(e) {
|
|
1236
1665
|
var t;
|
|
1237
1666
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1238
|
-
return Math.max(n,
|
|
1239
|
-
}, k = /* @__PURE__ */ new WeakSet(), Q = function(e) {
|
|
1240
|
-
const t = this.decimalMultiplier / U(this.decimal || 0), n = this.bigIntValue / t;
|
|
1241
|
-
switch (e) {
|
|
1242
|
-
case "number":
|
|
1243
|
-
return Number(n);
|
|
1244
|
-
case "string":
|
|
1245
|
-
return n.toString();
|
|
1246
|
-
default:
|
|
1247
|
-
return n;
|
|
1248
|
-
}
|
|
1667
|
+
return Math.max(n, j);
|
|
1249
1668
|
};
|
|
1250
|
-
let
|
|
1251
|
-
|
|
1252
|
-
|
|
1669
|
+
let Te = Yt;
|
|
1670
|
+
function Z(e) {
|
|
1671
|
+
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1672
|
+
}
|
|
1673
|
+
const ee = (e, t) => typeof e == "bigint" ? re({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1674
|
+
let he;
|
|
1675
|
+
const Se = (e) => {
|
|
1676
|
+
if (!he)
|
|
1253
1677
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1254
|
-
return
|
|
1255
|
-
},
|
|
1256
|
-
|
|
1257
|
-
const n = await
|
|
1258
|
-
return new
|
|
1259
|
-
};
|
|
1260
|
-
class
|
|
1678
|
+
return he.get(e.toUpperCase()) || { decimal: A.THOR, identifier: "" };
|
|
1679
|
+
}, ve = async (e, t = 0) => {
|
|
1680
|
+
Kt(e);
|
|
1681
|
+
const n = await wt(_e(e)), a = ee(t, n);
|
|
1682
|
+
return new N({ decimal: n, value: a, identifier: e });
|
|
1683
|
+
}, Ce = /* @__PURE__ */ new Map();
|
|
1684
|
+
class N extends Te {
|
|
1261
1685
|
constructor(t) {
|
|
1686
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = Ce.get(n);
|
|
1687
|
+
if (a)
|
|
1688
|
+
return a.set(t.value);
|
|
1262
1689
|
super(
|
|
1263
|
-
t.value instanceof
|
|
1264
|
-
),
|
|
1265
|
-
const
|
|
1266
|
-
this.type =
|
|
1690
|
+
t.value instanceof Te ? t.value : { decimal: t.decimal, value: t.value }
|
|
1691
|
+
), C(this, "address"), C(this, "isSynthetic", !1), C(this, "isGasAsset", !1), C(this, "chain"), C(this, "symbol"), C(this, "ticker"), C(this, "type");
|
|
1692
|
+
const s = _e(n);
|
|
1693
|
+
this.type = Rt(s), this.chain = s.chain, this.ticker = s.ticker, this.symbol = s.symbol, this.address = s.address, this.isSynthetic = s.isSynthetic, this.isGasAsset = s.isGasAsset, Ce.set(n, this);
|
|
1694
|
+
}
|
|
1695
|
+
toString(t = !1) {
|
|
1696
|
+
const n = this.isSynthetic ? this.symbol.split("-")[0] : this.ticker;
|
|
1697
|
+
return t ? n : (
|
|
1698
|
+
// THOR.ETH/ETH | ETH.USDT-0x1234567890
|
|
1699
|
+
`${this.chain}.${this.symbol}`
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1702
|
+
eq({ chain: t, symbol: n }) {
|
|
1703
|
+
return this.chain === t && this.symbol === n;
|
|
1267
1704
|
}
|
|
1268
1705
|
static async fromString(t, n = 0) {
|
|
1269
|
-
return
|
|
1706
|
+
return ve(t, n);
|
|
1270
1707
|
}
|
|
1271
1708
|
static fromStringSync(t, n = 0) {
|
|
1272
|
-
const {
|
|
1709
|
+
const { isSynthetic: a } = _e(t), { decimal: s, identifier: r } = Se(
|
|
1273
1710
|
t
|
|
1274
|
-
);
|
|
1275
|
-
return
|
|
1711
|
+
), o = ee(n, s);
|
|
1712
|
+
return r ? new N({ decimal: s, identifier: r, value: o }) : a ? new N({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1276
1713
|
}
|
|
1277
1714
|
static async fromIdentifier(t, n = 0) {
|
|
1278
|
-
return
|
|
1715
|
+
return ve(t, n);
|
|
1279
1716
|
}
|
|
1280
1717
|
static fromIdentifierSync(t, n = 0) {
|
|
1281
|
-
const { decimal: a, identifier:
|
|
1282
|
-
return new
|
|
1718
|
+
const { decimal: a, identifier: s } = Se(t), r = ee(n, a);
|
|
1719
|
+
return new N({ decimal: a, identifier: s, value: r });
|
|
1283
1720
|
}
|
|
1284
1721
|
static fromChainOrSignature(t, n = 0) {
|
|
1285
|
-
const { decimal: a, identifier:
|
|
1286
|
-
return new
|
|
1287
|
-
}
|
|
1288
|
-
static async fromTCQuote(t, n = 0) {
|
|
1289
|
-
const a = await Se(ye(t)), i = this.shiftDecimals({ value: n, from: E.THOR, to: a });
|
|
1290
|
-
return new v({ value: i, identifier: t, decimal: a });
|
|
1291
|
-
}
|
|
1292
|
-
static fromTCQuoteStatic(t, n = 0) {
|
|
1293
|
-
const a = se(t), i = this.shiftDecimals({
|
|
1294
|
-
value: n,
|
|
1295
|
-
from: E.THOR,
|
|
1296
|
-
to: a.decimal
|
|
1297
|
-
});
|
|
1298
|
-
return new v({ ...a, value: i });
|
|
1722
|
+
const { decimal: a, identifier: s } = Et(t), r = ee(n, a);
|
|
1723
|
+
return new N({ value: r, decimal: a, identifier: s });
|
|
1299
1724
|
}
|
|
1300
1725
|
static async loadStaticAssets() {
|
|
1301
1726
|
return new Promise(
|
|
@@ -1305,14 +1730,14 @@ class v extends de {
|
|
|
1305
1730
|
// Omit ThorchainList from import to avoid decimals conflict (TC uses 8 for all)
|
|
1306
1731
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1307
1732
|
ThorchainList: a,
|
|
1308
|
-
NativeList:
|
|
1733
|
+
NativeList: s,
|
|
1309
1734
|
...r
|
|
1310
1735
|
} = await import("@swapkit/tokens");
|
|
1311
|
-
|
|
1312
|
-
(
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
}),
|
|
1736
|
+
he = [s, ...Object.values(r)].reduce(
|
|
1737
|
+
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: y, ...u }) => {
|
|
1738
|
+
const c = "decimals" in u ? u.decimals : A[y];
|
|
1739
|
+
o.set(d, { identifier: d, decimal: c });
|
|
1740
|
+
}), o),
|
|
1316
1741
|
/* @__PURE__ */ new Map()
|
|
1317
1742
|
), t({ ok: !0 });
|
|
1318
1743
|
} catch (a) {
|
|
@@ -1325,45 +1750,36 @@ class v extends de {
|
|
|
1325
1750
|
}
|
|
1326
1751
|
);
|
|
1327
1752
|
}
|
|
1328
|
-
get assetValue() {
|
|
1329
|
-
return `${this.value} ${this.ticker}`;
|
|
1330
|
-
}
|
|
1331
|
-
toString() {
|
|
1332
|
-
return `${this.chain}.${this.symbol}`;
|
|
1333
|
-
}
|
|
1334
|
-
eq({ chain: t, symbol: n }) {
|
|
1335
|
-
return this.chain === t && this.symbol === n;
|
|
1336
|
-
}
|
|
1337
1753
|
}
|
|
1338
|
-
const
|
|
1339
|
-
const t =
|
|
1754
|
+
const de = (e) => {
|
|
1755
|
+
const t = N.fromChainOrSignature(e);
|
|
1340
1756
|
switch (e) {
|
|
1341
|
-
case
|
|
1342
|
-
case
|
|
1343
|
-
case
|
|
1344
|
-
return t.
|
|
1345
|
-
case
|
|
1346
|
-
return t.
|
|
1347
|
-
case
|
|
1348
|
-
case
|
|
1349
|
-
return t.
|
|
1350
|
-
case
|
|
1351
|
-
case
|
|
1352
|
-
return t.
|
|
1757
|
+
case i.Bitcoin:
|
|
1758
|
+
case i.Litecoin:
|
|
1759
|
+
case i.BitcoinCash:
|
|
1760
|
+
return t.set(10001e-8);
|
|
1761
|
+
case i.Dogecoin:
|
|
1762
|
+
return t.set(1.00000001);
|
|
1763
|
+
case i.Avalanche:
|
|
1764
|
+
case i.Ethereum:
|
|
1765
|
+
return t.set(1e-8);
|
|
1766
|
+
case i.THORChain:
|
|
1767
|
+
case i.Maya:
|
|
1768
|
+
return t.set(0);
|
|
1353
1769
|
default:
|
|
1354
|
-
return t.
|
|
1770
|
+
return t.set(1e-8);
|
|
1355
1771
|
}
|
|
1356
|
-
},
|
|
1357
|
-
const t = e.slice(0, 14).includes("/"), n = e.includes(".") ? e : `${
|
|
1772
|
+
}, _e = (e) => {
|
|
1773
|
+
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".").pop().split("/"), s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
|
|
1358
1774
|
return {
|
|
1359
|
-
address:
|
|
1360
|
-
chain:
|
|
1361
|
-
isGasAsset:
|
|
1775
|
+
address: d == null ? void 0 : d.toLowerCase(),
|
|
1776
|
+
chain: r,
|
|
1777
|
+
isGasAsset: Le({ chain: r, symbol: o }),
|
|
1362
1778
|
isSynthetic: t,
|
|
1363
|
-
symbol:
|
|
1364
|
-
ticker:
|
|
1779
|
+
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1780
|
+
ticker: p
|
|
1365
1781
|
};
|
|
1366
|
-
},
|
|
1782
|
+
}, Xt = {
|
|
1367
1783
|
/**
|
|
1368
1784
|
* Core
|
|
1369
1785
|
*/
|
|
@@ -1420,20 +1836,23 @@ const fe = (e) => {
|
|
|
1420
1836
|
*/
|
|
1421
1837
|
helpers_number_different_decimals: 99101
|
|
1422
1838
|
};
|
|
1423
|
-
class
|
|
1839
|
+
class m extends Error {
|
|
1424
1840
|
constructor(t, n) {
|
|
1425
|
-
console.error(n), super(t, { cause: { code:
|
|
1841
|
+
console.error(n), super(t, { cause: { code: Xt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1426
1842
|
}
|
|
1427
1843
|
}
|
|
1428
|
-
class
|
|
1844
|
+
class D extends Te {
|
|
1429
1845
|
eq(t) {
|
|
1430
1846
|
return this.eqValue(t);
|
|
1431
1847
|
}
|
|
1432
|
-
|
|
1433
|
-
return
|
|
1848
|
+
static fromBigInt(t, n) {
|
|
1849
|
+
return new D({
|
|
1850
|
+
decimal: n,
|
|
1851
|
+
value: re({ value: t, bigIntDecimal: n, decimal: n })
|
|
1852
|
+
});
|
|
1434
1853
|
}
|
|
1435
1854
|
}
|
|
1436
|
-
const
|
|
1855
|
+
const Jt = [
|
|
1437
1856
|
{
|
|
1438
1857
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1439
1858
|
stateMutability: "nonpayable",
|
|
@@ -1524,7 +1943,7 @@ const ht = [
|
|
|
1524
1943
|
type: "function"
|
|
1525
1944
|
},
|
|
1526
1945
|
{ stateMutability: "payable", type: "receive" }
|
|
1527
|
-
],
|
|
1946
|
+
], Qt = [
|
|
1528
1947
|
{
|
|
1529
1948
|
inputs: [
|
|
1530
1949
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -1668,7 +2087,7 @@ const ht = [
|
|
|
1668
2087
|
type: "function"
|
|
1669
2088
|
},
|
|
1670
2089
|
{ stateMutability: "payable", type: "receive" }
|
|
1671
|
-
],
|
|
2090
|
+
], zt = [
|
|
1672
2091
|
{
|
|
1673
2092
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1674
2093
|
stateMutability: "nonpayable",
|
|
@@ -1773,7 +2192,7 @@ const ht = [
|
|
|
1773
2192
|
type: "function"
|
|
1774
2193
|
},
|
|
1775
2194
|
{ stateMutability: "payable", type: "receive" }
|
|
1776
|
-
],
|
|
2195
|
+
], Zt = [
|
|
1777
2196
|
{
|
|
1778
2197
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1779
2198
|
stateMutability: "nonpayable",
|
|
@@ -1864,7 +2283,7 @@ const ht = [
|
|
|
1864
2283
|
type: "function"
|
|
1865
2284
|
},
|
|
1866
2285
|
{ stateMutability: "payable", type: "receive" }
|
|
1867
|
-
],
|
|
2286
|
+
], en = [
|
|
1868
2287
|
{
|
|
1869
2288
|
inputs: [
|
|
1870
2289
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2008,7 +2427,7 @@ const ht = [
|
|
|
2008
2427
|
type: "function"
|
|
2009
2428
|
},
|
|
2010
2429
|
{ stateMutability: "payable", type: "receive" }
|
|
2011
|
-
],
|
|
2430
|
+
], tn = [
|
|
2012
2431
|
{
|
|
2013
2432
|
inputs: [
|
|
2014
2433
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2127,7 +2546,7 @@ const ht = [
|
|
|
2127
2546
|
type: "function"
|
|
2128
2547
|
},
|
|
2129
2548
|
{ stateMutability: "payable", type: "receive" }
|
|
2130
|
-
],
|
|
2549
|
+
], nn = [
|
|
2131
2550
|
{
|
|
2132
2551
|
inputs: [
|
|
2133
2552
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2246,7 +2665,7 @@ const ht = [
|
|
|
2246
2665
|
type: "function"
|
|
2247
2666
|
},
|
|
2248
2667
|
{ stateMutability: "payable", type: "receive" }
|
|
2249
|
-
],
|
|
2668
|
+
], an = [
|
|
2250
2669
|
{
|
|
2251
2670
|
inputs: [
|
|
2252
2671
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2365,7 +2784,7 @@ const ht = [
|
|
|
2365
2784
|
type: "function"
|
|
2366
2785
|
},
|
|
2367
2786
|
{ stateMutability: "payable", type: "receive" }
|
|
2368
|
-
],
|
|
2787
|
+
], sn = [
|
|
2369
2788
|
{
|
|
2370
2789
|
inputs: [
|
|
2371
2790
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2484,7 +2903,7 @@ const ht = [
|
|
|
2484
2903
|
type: "function"
|
|
2485
2904
|
},
|
|
2486
2905
|
{ stateMutability: "payable", type: "receive" }
|
|
2487
|
-
],
|
|
2906
|
+
], rn = [
|
|
2488
2907
|
{
|
|
2489
2908
|
inputs: [
|
|
2490
2909
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2611,7 +3030,7 @@ const ht = [
|
|
|
2611
3030
|
type: "function"
|
|
2612
3031
|
},
|
|
2613
3032
|
{ stateMutability: "payable", type: "receive" }
|
|
2614
|
-
],
|
|
3033
|
+
], on = [
|
|
2615
3034
|
{
|
|
2616
3035
|
inputs: [
|
|
2617
3036
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2738,7 +3157,7 @@ const ht = [
|
|
|
2738
3157
|
type: "function"
|
|
2739
3158
|
},
|
|
2740
3159
|
{ stateMutability: "payable", type: "receive" }
|
|
2741
|
-
],
|
|
3160
|
+
], pn = [
|
|
2742
3161
|
{
|
|
2743
3162
|
inputs: [
|
|
2744
3163
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2865,7 +3284,7 @@ const ht = [
|
|
|
2865
3284
|
type: "function"
|
|
2866
3285
|
},
|
|
2867
3286
|
{ stateMutability: "payable", type: "receive" }
|
|
2868
|
-
],
|
|
3287
|
+
], dn = [
|
|
2869
3288
|
{
|
|
2870
3289
|
inputs: [
|
|
2871
3290
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2992,7 +3411,7 @@ const ht = [
|
|
|
2992
3411
|
type: "function"
|
|
2993
3412
|
},
|
|
2994
3413
|
{ stateMutability: "payable", type: "receive" }
|
|
2995
|
-
],
|
|
3414
|
+
], un = [
|
|
2996
3415
|
{
|
|
2997
3416
|
inputs: [
|
|
2998
3417
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3119,279 +3538,287 @@ const ht = [
|
|
|
3119
3538
|
type: "function"
|
|
3120
3539
|
},
|
|
3121
3540
|
{ stateMutability: "payable", type: "receive" }
|
|
3122
|
-
],
|
|
3123
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3124
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3125
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3126
|
-
},
|
|
3127
|
-
...
|
|
3541
|
+
], Ge = {
|
|
3542
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Jt,
|
|
3543
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: zt,
|
|
3544
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Zt
|
|
3545
|
+
}, ln = {
|
|
3546
|
+
...Ge,
|
|
3128
3547
|
// AVAX
|
|
3129
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3130
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3131
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3548
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: tn,
|
|
3549
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Qt,
|
|
3550
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: an,
|
|
3132
3551
|
// BSC
|
|
3133
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3552
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: en,
|
|
3134
3553
|
// ETH
|
|
3135
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3136
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3137
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3138
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3139
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3140
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3141
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3142
|
-
},
|
|
3554
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: nn,
|
|
3555
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: sn,
|
|
3556
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: rn,
|
|
3557
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: on,
|
|
3558
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: pn,
|
|
3559
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: dn,
|
|
3560
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: un
|
|
3561
|
+
}, yn = ({
|
|
3143
3562
|
streamSwap: e,
|
|
3144
3563
|
contractAddress: t,
|
|
3145
3564
|
recipient: n,
|
|
3146
3565
|
toChecksumAddress: a,
|
|
3147
3566
|
calldata: {
|
|
3148
|
-
amount:
|
|
3567
|
+
amount: s,
|
|
3149
3568
|
amountOutMin: r = "",
|
|
3150
|
-
data:
|
|
3151
|
-
deadline:
|
|
3152
|
-
memo:
|
|
3153
|
-
router:
|
|
3154
|
-
memoStreamingSwap:
|
|
3155
|
-
tcMemo:
|
|
3156
|
-
tcRouter:
|
|
3157
|
-
tcVault:
|
|
3158
|
-
vault:
|
|
3159
|
-
token:
|
|
3569
|
+
data: o = "",
|
|
3570
|
+
deadline: p,
|
|
3571
|
+
memo: d,
|
|
3572
|
+
router: y,
|
|
3573
|
+
memoStreamingSwap: u,
|
|
3574
|
+
tcMemo: c,
|
|
3575
|
+
tcRouter: _,
|
|
3576
|
+
tcVault: b,
|
|
3577
|
+
vault: w,
|
|
3578
|
+
token: R
|
|
3160
3579
|
}
|
|
3161
3580
|
}) => {
|
|
3162
|
-
const
|
|
3163
|
-
if (
|
|
3581
|
+
const O = !!Ge[t.toLowerCase()];
|
|
3582
|
+
if (O && !y)
|
|
3164
3583
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3165
|
-
const
|
|
3166
|
-
if (!
|
|
3584
|
+
const I = c || d, S = e && u || I;
|
|
3585
|
+
if (!b && !w)
|
|
3167
3586
|
throw new Error("TC Vault is required on calldata");
|
|
3168
|
-
if (!
|
|
3587
|
+
if (!_ && !y)
|
|
3169
3588
|
throw new Error("TC Router is required on calldata");
|
|
3170
|
-
if (!
|
|
3589
|
+
if (!S)
|
|
3171
3590
|
throw new Error("TC Memo is required on calldata");
|
|
3172
|
-
if (!
|
|
3591
|
+
if (!R)
|
|
3173
3592
|
throw new Error("Token is required on calldata");
|
|
3174
|
-
const
|
|
3593
|
+
const P = [
|
|
3175
3594
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3176
|
-
a(
|
|
3177
|
-
a(
|
|
3178
|
-
|
|
3179
|
-
a(
|
|
3180
|
-
|
|
3181
|
-
],
|
|
3182
|
-
return [...
|
|
3183
|
-
},
|
|
3184
|
-
const n =
|
|
3595
|
+
a(_ || y),
|
|
3596
|
+
a(b || w),
|
|
3597
|
+
S.replace("{recipientAddress}", n),
|
|
3598
|
+
a(R),
|
|
3599
|
+
s
|
|
3600
|
+
], qe = O ? [a(y), o, p] : [r, p];
|
|
3601
|
+
return [...P, ...qe];
|
|
3602
|
+
}, cn = ({ chain: e, txHash: t }) => {
|
|
3603
|
+
const n = Pe[e];
|
|
3185
3604
|
switch (e) {
|
|
3186
|
-
case
|
|
3187
|
-
case
|
|
3188
|
-
case
|
|
3189
|
-
case
|
|
3190
|
-
case
|
|
3605
|
+
case i.Binance:
|
|
3606
|
+
case i.Bitcoin:
|
|
3607
|
+
case i.BitcoinCash:
|
|
3608
|
+
case i.Maya:
|
|
3609
|
+
case i.Kujira:
|
|
3610
|
+
case i.THORChain:
|
|
3191
3611
|
return `${n}/tx/${t}`;
|
|
3192
|
-
case
|
|
3193
|
-
case
|
|
3194
|
-
case
|
|
3195
|
-
case
|
|
3196
|
-
case
|
|
3197
|
-
case
|
|
3612
|
+
case i.Arbitrum:
|
|
3613
|
+
case i.Avalanche:
|
|
3614
|
+
case i.BinanceSmartChain:
|
|
3615
|
+
case i.Ethereum:
|
|
3616
|
+
case i.Optimism:
|
|
3617
|
+
case i.Polygon:
|
|
3198
3618
|
return `${n}/tx/${t.startsWith("0x") ? t : `0x${t}`}`;
|
|
3199
|
-
case
|
|
3619
|
+
case i.Cosmos:
|
|
3200
3620
|
return `${n}/transactions/${t}`;
|
|
3201
|
-
case
|
|
3621
|
+
case i.Dogecoin:
|
|
3202
3622
|
return `${n}/transaction/${t.toLowerCase()}`;
|
|
3203
|
-
case
|
|
3623
|
+
case i.Litecoin:
|
|
3204
3624
|
return `${n}/${t}`;
|
|
3205
3625
|
default:
|
|
3206
3626
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3207
3627
|
}
|
|
3208
|
-
},
|
|
3209
|
-
const n =
|
|
3628
|
+
}, mn = ({ chain: e, address: t }) => {
|
|
3629
|
+
const n = Pe[e];
|
|
3210
3630
|
switch (e) {
|
|
3211
|
-
case
|
|
3212
|
-
case
|
|
3213
|
-
case
|
|
3214
|
-
case
|
|
3215
|
-
case
|
|
3216
|
-
case
|
|
3217
|
-
case
|
|
3218
|
-
case
|
|
3219
|
-
case
|
|
3220
|
-
case
|
|
3221
|
-
case
|
|
3222
|
-
case
|
|
3631
|
+
case i.Arbitrum:
|
|
3632
|
+
case i.Avalanche:
|
|
3633
|
+
case i.Binance:
|
|
3634
|
+
case i.BinanceSmartChain:
|
|
3635
|
+
case i.Bitcoin:
|
|
3636
|
+
case i.BitcoinCash:
|
|
3637
|
+
case i.Dogecoin:
|
|
3638
|
+
case i.Ethereum:
|
|
3639
|
+
case i.Maya:
|
|
3640
|
+
case i.Optimism:
|
|
3641
|
+
case i.Polygon:
|
|
3642
|
+
case i.Kujira:
|
|
3643
|
+
case i.THORChain:
|
|
3223
3644
|
return `${n}/address/${t}`;
|
|
3224
|
-
case
|
|
3645
|
+
case i.Cosmos:
|
|
3225
3646
|
return `${n}/account/${t}`;
|
|
3226
|
-
case
|
|
3647
|
+
case i.Litecoin:
|
|
3227
3648
|
return `${n}/${t}`;
|
|
3228
3649
|
default:
|
|
3229
3650
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3230
3651
|
}
|
|
3231
|
-
},
|
|
3232
|
-
const t = e ?
|
|
3233
|
-
return
|
|
3234
|
-
},
|
|
3235
|
-
const t = e ?
|
|
3236
|
-
return
|
|
3237
|
-
},
|
|
3652
|
+
}, Tn = (e) => {
|
|
3653
|
+
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3654
|
+
return Ae.get(`${t}/thorchain/inbound_addresses`);
|
|
3655
|
+
}, hn = (e) => {
|
|
3656
|
+
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3657
|
+
return Ae.get(`${t}/thorchain/mimir`);
|
|
3658
|
+
}, Me = () => Object.values(i).reduce(
|
|
3238
3659
|
(e, t) => (e[t] = null, e),
|
|
3239
3660
|
{}
|
|
3240
3661
|
);
|
|
3241
|
-
var
|
|
3242
|
-
class
|
|
3662
|
+
var L, se, K, M, Y, X;
|
|
3663
|
+
class Ln {
|
|
3243
3664
|
constructor({ stagenet: t } = {}) {
|
|
3244
|
-
T(this, "connectedChains",
|
|
3245
|
-
T(this, "connectedWallets",
|
|
3665
|
+
T(this, "connectedChains", Me());
|
|
3666
|
+
T(this, "connectedWallets", Me());
|
|
3246
3667
|
T(this, "stagenet", !1);
|
|
3247
3668
|
T(this, "getAddress", (t) => {
|
|
3248
3669
|
var n;
|
|
3249
3670
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3250
3671
|
});
|
|
3251
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3672
|
+
T(this, "getExplorerTxUrl", (t, n) => cn({ chain: t, txHash: n }));
|
|
3252
3673
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3253
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3674
|
+
T(this, "getExplorerAddressUrl", (t, n) => mn({ chain: t, address: n }));
|
|
3254
3675
|
T(this, "getBalance", async (t, n) => {
|
|
3255
|
-
|
|
3256
|
-
if (!n)
|
|
3257
|
-
return ((i = this.connectedChains[t]) == null ? void 0 : i.balance) || [];
|
|
3258
|
-
const a = await this.getWalletByChain(t);
|
|
3676
|
+
const a = await this.getWalletByChain(t, n);
|
|
3259
3677
|
return (a == null ? void 0 : a.balance) || [];
|
|
3260
3678
|
});
|
|
3261
|
-
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey:
|
|
3262
|
-
var
|
|
3263
|
-
const { quoteMode: r } = a.meta,
|
|
3679
|
+
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: s }) => {
|
|
3680
|
+
var p, d;
|
|
3681
|
+
const { quoteMode: r } = a.meta, o = r.startsWith("ERC20-") ? i.Ethereum : r.startsWith("ARC20-") ? i.Avalanche : i.BinanceSmartChain;
|
|
3264
3682
|
if (!a.complete)
|
|
3265
|
-
throw new
|
|
3683
|
+
throw new m("core_swap_route_not_complete");
|
|
3266
3684
|
try {
|
|
3267
|
-
if (
|
|
3268
|
-
const
|
|
3269
|
-
if (!(
|
|
3270
|
-
throw new
|
|
3271
|
-
if (!(t ? (
|
|
3272
|
-
throw new
|
|
3273
|
-
const {
|
|
3274
|
-
data:
|
|
3275
|
-
from:
|
|
3276
|
-
to:
|
|
3277
|
-
chainId: BigInt(
|
|
3278
|
-
value:
|
|
3279
|
-
value: _(b) ? b : O(b, "wei").toString(16)
|
|
3280
|
-
}).baseValueBigInt : 0n
|
|
3685
|
+
if (et.includes(r)) {
|
|
3686
|
+
const y = this.connectedWallets[o];
|
|
3687
|
+
if (!(y != null && y.sendTransaction))
|
|
3688
|
+
throw new m("core_wallet_connection_not_found");
|
|
3689
|
+
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3690
|
+
throw new m("core_swap_route_transaction_not_found");
|
|
3691
|
+
const { data: c, from: _, to: b, value: w } = a.transaction, R = {
|
|
3692
|
+
data: c,
|
|
3693
|
+
from: _,
|
|
3694
|
+
to: b.toLowerCase(),
|
|
3695
|
+
chainId: BigInt(dt[o]),
|
|
3696
|
+
value: w ? BigInt(w) : 0n
|
|
3281
3697
|
};
|
|
3282
|
-
return
|
|
3698
|
+
return y.sendTransaction(R, s);
|
|
3283
3699
|
}
|
|
3284
|
-
if (
|
|
3700
|
+
if (nt.includes(r)) {
|
|
3285
3701
|
if (!a.calldata.fromAsset)
|
|
3286
|
-
throw new
|
|
3287
|
-
const
|
|
3288
|
-
if (!
|
|
3289
|
-
throw new
|
|
3290
|
-
const { address:
|
|
3291
|
-
contract:
|
|
3292
|
-
calldata: { amountIn:
|
|
3293
|
-
} = a,
|
|
3294
|
-
return this.deposit({
|
|
3702
|
+
throw new m("core_swap_asset_not_recognized");
|
|
3703
|
+
const y = await N.fromString(a.calldata.fromAsset);
|
|
3704
|
+
if (!y)
|
|
3705
|
+
throw new m("core_swap_asset_not_recognized");
|
|
3706
|
+
const { address: u } = await f(this, L).call(this, y.chain), {
|
|
3707
|
+
contract: c,
|
|
3708
|
+
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap: R }
|
|
3709
|
+
} = a, O = y.add(D.fromBigInt(BigInt(b), y.decimal)), I = t && R || w;
|
|
3710
|
+
return this.deposit({
|
|
3711
|
+
expiration: _,
|
|
3712
|
+
assetValue: O,
|
|
3713
|
+
memo: I,
|
|
3714
|
+
feeOptionKey: s,
|
|
3715
|
+
router: c,
|
|
3716
|
+
recipient: u
|
|
3717
|
+
});
|
|
3295
3718
|
}
|
|
3296
|
-
if (
|
|
3297
|
-
const { calldata:
|
|
3298
|
-
if (!
|
|
3299
|
-
throw new
|
|
3300
|
-
const
|
|
3301
|
-
if (!(
|
|
3302
|
-
throw new
|
|
3303
|
-
const { getProvider:
|
|
3304
|
-
if (!
|
|
3305
|
-
throw new
|
|
3306
|
-
const
|
|
3307
|
-
|
|
3308
|
-
...Dt({
|
|
3719
|
+
if (tt.includes(r)) {
|
|
3720
|
+
const { calldata: y, contract: u } = a;
|
|
3721
|
+
if (!u)
|
|
3722
|
+
throw new m("core_swap_contract_not_found");
|
|
3723
|
+
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3724
|
+
if (!(c != null && c.sendTransaction) || !_)
|
|
3725
|
+
throw new m("core_wallet_connection_not_found");
|
|
3726
|
+
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), R = b(o), O = ln[u.toLowerCase()];
|
|
3727
|
+
if (!O)
|
|
3728
|
+
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3729
|
+
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O, R))).getFunction("swapIn").populateTransaction(
|
|
3730
|
+
...yn({
|
|
3309
3731
|
streamSwap: t,
|
|
3310
|
-
toChecksumAddress:
|
|
3311
|
-
contractAddress:
|
|
3732
|
+
toChecksumAddress: w,
|
|
3733
|
+
contractAddress: u,
|
|
3312
3734
|
recipient: n,
|
|
3313
|
-
calldata:
|
|
3735
|
+
calldata: y
|
|
3314
3736
|
}),
|
|
3315
|
-
{ from:
|
|
3316
|
-
)
|
|
3317
|
-
return
|
|
3737
|
+
{ from: _ }
|
|
3738
|
+
);
|
|
3739
|
+
return c.sendTransaction(S, s);
|
|
3318
3740
|
}
|
|
3319
|
-
throw new
|
|
3320
|
-
} catch (
|
|
3321
|
-
throw new
|
|
3741
|
+
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3742
|
+
} catch (y) {
|
|
3743
|
+
throw new m("core_swap_transaction_error", y);
|
|
3322
3744
|
}
|
|
3323
3745
|
});
|
|
3324
|
-
T(this, "getWalletByChain", async (t) => {
|
|
3325
|
-
var
|
|
3326
|
-
const
|
|
3327
|
-
if (!
|
|
3746
|
+
T(this, "getWalletByChain", async (t, n) => {
|
|
3747
|
+
var o, p;
|
|
3748
|
+
const a = this.getAddress(t);
|
|
3749
|
+
if (!a)
|
|
3328
3750
|
return null;
|
|
3329
|
-
const
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3751
|
+
const s = [N.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3752
|
+
try {
|
|
3753
|
+
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3754
|
+
return this.connectedChains[t] = {
|
|
3755
|
+
address: a,
|
|
3756
|
+
balance: d != null && d.length ? d : s,
|
|
3757
|
+
walletType: r
|
|
3758
|
+
}, { ...this.connectedChains[t] };
|
|
3759
|
+
} catch (d) {
|
|
3760
|
+
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3761
|
+
}
|
|
3337
3762
|
});
|
|
3338
|
-
T(this, "approveAssetValue", (t, n) =>
|
|
3339
|
-
T(this, "isAssetValueApproved", (t, n) =>
|
|
3763
|
+
T(this, "approveAssetValue", (t, n) => f(this, K).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3764
|
+
T(this, "isAssetValueApproved", (t, n) => f(this, K).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3340
3765
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3341
|
-
var a,
|
|
3342
|
-
return (
|
|
3766
|
+
var a, s;
|
|
3767
|
+
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
3343
3768
|
});
|
|
3344
3769
|
T(this, "transfer", async (t) => {
|
|
3345
3770
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
3346
3771
|
if (!n)
|
|
3347
|
-
throw new
|
|
3772
|
+
throw new m("core_wallet_connection_not_found");
|
|
3348
3773
|
try {
|
|
3349
|
-
return await n.transfer(
|
|
3774
|
+
return await n.transfer(f(this, X).call(this, t));
|
|
3350
3775
|
} catch (a) {
|
|
3351
|
-
throw new
|
|
3776
|
+
throw new m("core_swap_transaction_error", a);
|
|
3352
3777
|
}
|
|
3353
3778
|
});
|
|
3354
3779
|
T(this, "deposit", async ({
|
|
3355
3780
|
assetValue: t,
|
|
3356
3781
|
recipient: n,
|
|
3357
3782
|
router: a,
|
|
3358
|
-
...
|
|
3783
|
+
...s
|
|
3359
3784
|
}) => {
|
|
3360
|
-
const { chain: r, symbol:
|
|
3361
|
-
if (!
|
|
3362
|
-
throw new
|
|
3363
|
-
const
|
|
3785
|
+
const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
|
|
3786
|
+
if (!d)
|
|
3787
|
+
throw new m("core_wallet_connection_not_found");
|
|
3788
|
+
const y = f(this, X).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3364
3789
|
try {
|
|
3365
3790
|
switch (r) {
|
|
3366
|
-
case
|
|
3367
|
-
const
|
|
3368
|
-
return await (n === "" ?
|
|
3791
|
+
case i.THORChain: {
|
|
3792
|
+
const u = d;
|
|
3793
|
+
return await (n === "" ? u.deposit(y) : u.transfer(y));
|
|
3369
3794
|
}
|
|
3370
|
-
case
|
|
3371
|
-
case
|
|
3372
|
-
case
|
|
3373
|
-
const { getChecksumAddressFromAsset:
|
|
3374
|
-
return await
|
|
3375
|
-
abi:
|
|
3376
|
-
contractAddress: a || (await
|
|
3795
|
+
case i.Ethereum:
|
|
3796
|
+
case i.BinanceSmartChain:
|
|
3797
|
+
case i.Avalanche: {
|
|
3798
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Qe : r === i.BinanceSmartChain ? ze : Je;
|
|
3799
|
+
return await d.call({
|
|
3800
|
+
abi: c,
|
|
3801
|
+
contractAddress: a || (await f(this, L).call(this, r)).router,
|
|
3377
3802
|
funcName: "depositWithExpiry",
|
|
3378
3803
|
funcParams: [
|
|
3379
3804
|
n,
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
i.expiration
|
|
3805
|
+
u({ chain: r, symbol: o, ticker: p }, r),
|
|
3806
|
+
t.getBaseValue("string"),
|
|
3807
|
+
y.memo,
|
|
3808
|
+
s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
3385
3809
|
],
|
|
3386
|
-
txOverrides: {
|
|
3810
|
+
txOverrides: {
|
|
3811
|
+
from: y.from,
|
|
3812
|
+
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
3813
|
+
}
|
|
3387
3814
|
});
|
|
3388
3815
|
}
|
|
3389
3816
|
default:
|
|
3390
|
-
return await
|
|
3817
|
+
return await d.transfer(y);
|
|
3391
3818
|
}
|
|
3392
|
-
} catch (
|
|
3393
|
-
const
|
|
3394
|
-
throw new
|
|
3819
|
+
} catch (u) {
|
|
3820
|
+
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), w = c == null ? void 0 : c.includes("server"), R = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : w ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3821
|
+
throw new m(R, u);
|
|
3395
3822
|
}
|
|
3396
3823
|
});
|
|
3397
3824
|
/**
|
|
@@ -3402,115 +3829,108 @@ class tn {
|
|
|
3402
3829
|
assetValue: n
|
|
3403
3830
|
}) => {
|
|
3404
3831
|
if (t.lte(0) || n.lte(0))
|
|
3405
|
-
throw new
|
|
3406
|
-
let a = "",
|
|
3832
|
+
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3833
|
+
let a = "", s = "";
|
|
3407
3834
|
try {
|
|
3408
|
-
a = await
|
|
3835
|
+
a = await f(this, M).call(this, {
|
|
3409
3836
|
assetValue: t,
|
|
3410
|
-
memo: x(
|
|
3837
|
+
memo: x(h.DEPOSIT, {
|
|
3411
3838
|
...n,
|
|
3412
3839
|
address: this.getAddress(n.chain)
|
|
3413
3840
|
})
|
|
3414
3841
|
});
|
|
3415
3842
|
} catch (r) {
|
|
3416
|
-
throw new
|
|
3843
|
+
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3417
3844
|
}
|
|
3418
3845
|
try {
|
|
3419
|
-
|
|
3846
|
+
s = await f(this, M).call(this, {
|
|
3420
3847
|
assetValue: n,
|
|
3421
|
-
memo: x(
|
|
3848
|
+
memo: x(h.DEPOSIT, {
|
|
3422
3849
|
...n,
|
|
3423
|
-
address: this.getAddress(
|
|
3850
|
+
address: this.getAddress(i.THORChain)
|
|
3424
3851
|
})
|
|
3425
3852
|
});
|
|
3426
3853
|
} catch (r) {
|
|
3427
|
-
throw new
|
|
3854
|
+
throw new m("core_transaction_create_liquidity_asset_error", r);
|
|
3428
3855
|
}
|
|
3429
|
-
return { runeTx: a, assetTx:
|
|
3856
|
+
return { runeTx: a, assetTx: s };
|
|
3430
3857
|
});
|
|
3431
3858
|
T(this, "addLiquidity", async ({
|
|
3432
3859
|
poolIdentifier: t,
|
|
3433
3860
|
runeAssetValue: n,
|
|
3434
3861
|
assetValue: a,
|
|
3435
|
-
runeAddr:
|
|
3862
|
+
runeAddr: s,
|
|
3436
3863
|
assetAddr: r,
|
|
3437
|
-
isPendingSymmAsset:
|
|
3438
|
-
mode:
|
|
3864
|
+
isPendingSymmAsset: o,
|
|
3865
|
+
mode: p = "sym"
|
|
3439
3866
|
}) => {
|
|
3440
|
-
const [
|
|
3441
|
-
if (!
|
|
3442
|
-
throw new
|
|
3443
|
-
if (
|
|
3444
|
-
throw new
|
|
3445
|
-
let
|
|
3446
|
-
const
|
|
3447
|
-
if (
|
|
3867
|
+
const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"), b = o || c, w = b ? s || this.getAddress(i.THORChain) : "", R = u || p === "asset" ? r || this.getAddress(d) : "";
|
|
3868
|
+
if (!c && !_)
|
|
3869
|
+
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3870
|
+
if (b && !w)
|
|
3871
|
+
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3872
|
+
let O, I;
|
|
3873
|
+
const S = { chain: d, symbol: y.join(".") };
|
|
3874
|
+
if (c && n)
|
|
3448
3875
|
try {
|
|
3449
|
-
|
|
3876
|
+
O = await f(this, M).call(this, {
|
|
3450
3877
|
assetValue: n,
|
|
3451
|
-
memo: x(
|
|
3878
|
+
memo: x(h.DEPOSIT, { ...S, address: R })
|
|
3452
3879
|
});
|
|
3453
|
-
} catch (
|
|
3454
|
-
throw new
|
|
3880
|
+
} catch (P) {
|
|
3881
|
+
throw new m("core_transaction_add_liquidity_rune_error", P);
|
|
3455
3882
|
}
|
|
3456
|
-
if (
|
|
3883
|
+
if (_ && a)
|
|
3457
3884
|
try {
|
|
3458
|
-
|
|
3885
|
+
I = await f(this, M).call(this, {
|
|
3459
3886
|
assetValue: a,
|
|
3460
|
-
memo: x(
|
|
3887
|
+
memo: x(h.DEPOSIT, { ...S, address: w })
|
|
3461
3888
|
});
|
|
3462
|
-
} catch (
|
|
3463
|
-
throw new
|
|
3889
|
+
} catch (P) {
|
|
3890
|
+
throw new m("core_transaction_add_liquidity_asset_error", P);
|
|
3464
3891
|
}
|
|
3465
|
-
return { runeTx:
|
|
3892
|
+
return { runeTx: O, assetTx: I };
|
|
3466
3893
|
});
|
|
3467
3894
|
T(this, "withdraw", async ({
|
|
3468
3895
|
memo: t,
|
|
3469
3896
|
assetValue: n,
|
|
3470
3897
|
percent: a,
|
|
3471
|
-
from:
|
|
3898
|
+
from: s,
|
|
3472
3899
|
to: r
|
|
3473
3900
|
}) => {
|
|
3474
|
-
const
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
targetAssetString: p == null ? void 0 : p.toString(),
|
|
3484
|
-
singleSide: !1
|
|
3485
|
-
})
|
|
3486
|
-
});
|
|
3487
|
-
} catch (d) {
|
|
3488
|
-
throw new c("core_transaction_withdraw_error", d);
|
|
3489
|
-
}
|
|
3901
|
+
const o = r === "rune" ? N.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = de(s === "asset" ? n.chain : i.THORChain), d = t || x(h.WITHDRAW, {
|
|
3902
|
+
symbol: n.symbol,
|
|
3903
|
+
chain: n.chain,
|
|
3904
|
+
ticker: n.ticker,
|
|
3905
|
+
basisPoints: Math.max(1e4, Math.round(a * 100)),
|
|
3906
|
+
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3907
|
+
singleSide: !1
|
|
3908
|
+
});
|
|
3909
|
+
return f(this, M).call(this, { assetValue: p, memo: d });
|
|
3490
3910
|
});
|
|
3491
3911
|
T(this, "savings", async ({
|
|
3492
3912
|
assetValue: t,
|
|
3493
3913
|
memo: n,
|
|
3494
3914
|
percent: a,
|
|
3495
|
-
type:
|
|
3915
|
+
type: s
|
|
3496
3916
|
}) => {
|
|
3497
|
-
const r =
|
|
3917
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || x(r, {
|
|
3498
3918
|
ticker: t.ticker,
|
|
3499
3919
|
symbol: t.symbol,
|
|
3500
3920
|
chain: t.chain,
|
|
3501
3921
|
singleSide: !0,
|
|
3502
|
-
basisPoints: a ? Math.
|
|
3503
|
-
});
|
|
3504
|
-
return
|
|
3922
|
+
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3923
|
+
}), p = r === h.DEPOSIT ? t : de(t.chain);
|
|
3924
|
+
return f(this, M).call(this, { memo: o, assetValue: p });
|
|
3505
3925
|
});
|
|
3506
3926
|
T(this, "loan", ({
|
|
3507
3927
|
assetValue: t,
|
|
3508
3928
|
memo: n,
|
|
3509
3929
|
minAmount: a,
|
|
3510
|
-
type:
|
|
3511
|
-
}) =>
|
|
3930
|
+
type: s
|
|
3931
|
+
}) => f(this, M).call(this, {
|
|
3512
3932
|
assetValue: t,
|
|
3513
|
-
memo: n || x(
|
|
3933
|
+
memo: n || x(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3514
3934
|
asset: t.toString(),
|
|
3515
3935
|
minAmount: a.toString(),
|
|
3516
3936
|
address: this.getAddress(t.chain)
|
|
@@ -3521,31 +3941,31 @@ class tn {
|
|
|
3521
3941
|
assetValue: n,
|
|
3522
3942
|
address: a
|
|
3523
3943
|
}) => {
|
|
3524
|
-
const
|
|
3944
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = x(s, {
|
|
3525
3945
|
address: a,
|
|
3526
|
-
unbondAmount: t === "unbond" ? n.
|
|
3946
|
+
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
3527
3947
|
});
|
|
3528
|
-
return
|
|
3948
|
+
return f(this, Y).call(this, {
|
|
3529
3949
|
memo: r,
|
|
3530
|
-
assetValue: t === "bond" ? n :
|
|
3950
|
+
assetValue: t === "bond" ? n : de(i.THORChain)
|
|
3531
3951
|
});
|
|
3532
3952
|
});
|
|
3533
3953
|
T(this, "registerThorname", ({
|
|
3534
3954
|
assetValue: t,
|
|
3535
3955
|
...n
|
|
3536
|
-
}) =>
|
|
3537
|
-
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls:
|
|
3956
|
+
}) => f(this, Y).call(this, { assetValue: t, memo: x(h.THORNAME_REGISTER, n) }));
|
|
3957
|
+
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3538
3958
|
try {
|
|
3539
3959
|
t.forEach((r) => {
|
|
3540
3960
|
this[r.connectMethodName] = r.connect({
|
|
3541
|
-
addChain:
|
|
3961
|
+
addChain: f(this, se),
|
|
3542
3962
|
config: n || {},
|
|
3543
3963
|
apis: a,
|
|
3544
|
-
rpcUrls:
|
|
3964
|
+
rpcUrls: s
|
|
3545
3965
|
});
|
|
3546
3966
|
});
|
|
3547
3967
|
} catch (r) {
|
|
3548
|
-
throw new
|
|
3968
|
+
throw new m("core_extend_error", r);
|
|
3549
3969
|
}
|
|
3550
3970
|
});
|
|
3551
3971
|
T(this, "estimateMaxSendableAmount", async ({
|
|
@@ -3554,132 +3974,132 @@ class tn {
|
|
|
3554
3974
|
}) => {
|
|
3555
3975
|
const a = this.getWallet(t);
|
|
3556
3976
|
switch (t) {
|
|
3557
|
-
case
|
|
3558
|
-
case
|
|
3559
|
-
case
|
|
3560
|
-
case
|
|
3561
|
-
case
|
|
3562
|
-
case
|
|
3563
|
-
const { estimateMaxSendableAmount:
|
|
3564
|
-
return
|
|
3977
|
+
case i.Arbitrum:
|
|
3978
|
+
case i.Avalanche:
|
|
3979
|
+
case i.BinanceSmartChain:
|
|
3980
|
+
case i.Ethereum:
|
|
3981
|
+
case i.Optimism:
|
|
3982
|
+
case i.Polygon: {
|
|
3983
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-evm");
|
|
3984
|
+
return s({
|
|
3565
3985
|
...n,
|
|
3566
3986
|
toolbox: a
|
|
3567
3987
|
});
|
|
3568
3988
|
}
|
|
3569
|
-
case
|
|
3570
|
-
case
|
|
3571
|
-
case
|
|
3572
|
-
case
|
|
3989
|
+
case i.Bitcoin:
|
|
3990
|
+
case i.BitcoinCash:
|
|
3991
|
+
case i.Dogecoin:
|
|
3992
|
+
case i.Litecoin:
|
|
3573
3993
|
return a.estimateMaxSendableAmount(n);
|
|
3574
|
-
case
|
|
3575
|
-
case
|
|
3576
|
-
case
|
|
3577
|
-
const { estimateMaxSendableAmount:
|
|
3578
|
-
return
|
|
3994
|
+
case i.Binance:
|
|
3995
|
+
case i.THORChain:
|
|
3996
|
+
case i.Cosmos: {
|
|
3997
|
+
const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-cosmos");
|
|
3998
|
+
return s({
|
|
3579
3999
|
...n,
|
|
3580
4000
|
toolbox: a
|
|
3581
4001
|
});
|
|
3582
4002
|
}
|
|
3583
4003
|
default:
|
|
3584
|
-
throw new
|
|
4004
|
+
throw new m("core_estimated_max_spendable_chain_not_supported");
|
|
3585
4005
|
}
|
|
3586
4006
|
});
|
|
3587
4007
|
/**
|
|
3588
4008
|
* Wallet connection methods
|
|
3589
4009
|
*/
|
|
3590
4010
|
T(this, "connectXDEFI", async (t) => {
|
|
3591
|
-
throw new
|
|
4011
|
+
throw new m("core_wallet_xdefi_not_installed");
|
|
3592
4012
|
});
|
|
3593
4013
|
T(this, "connectEVMWallet", async (t, n) => {
|
|
3594
|
-
throw new
|
|
4014
|
+
throw new m("core_wallet_evmwallet_not_installed");
|
|
3595
4015
|
});
|
|
3596
4016
|
T(this, "connectWalletconnect", async (t, n) => {
|
|
3597
|
-
throw new
|
|
4017
|
+
throw new m("core_wallet_walletconnect_not_installed");
|
|
3598
4018
|
});
|
|
3599
4019
|
T(this, "connectKeystore", async (t, n) => {
|
|
3600
|
-
throw new
|
|
4020
|
+
throw new m("core_wallet_keystore_not_installed");
|
|
3601
4021
|
});
|
|
3602
4022
|
T(this, "connectLedger", async (t, n) => {
|
|
3603
|
-
throw new
|
|
4023
|
+
throw new m("core_wallet_ledger_not_installed");
|
|
3604
4024
|
});
|
|
3605
4025
|
T(this, "connectTrezor", async (t, n) => {
|
|
3606
|
-
throw new
|
|
4026
|
+
throw new m("core_wallet_trezor_not_installed");
|
|
3607
4027
|
});
|
|
3608
|
-
T(this, "connectKeplr", async () => {
|
|
3609
|
-
throw new
|
|
4028
|
+
T(this, "connectKeplr", async (t) => {
|
|
4029
|
+
throw new m("core_wallet_keplr_not_installed");
|
|
3610
4030
|
});
|
|
3611
4031
|
T(this, "connectOkx", async (t) => {
|
|
3612
|
-
throw new
|
|
4032
|
+
throw new m("core_wallet_okx_not_installed");
|
|
3613
4033
|
});
|
|
3614
4034
|
T(this, "disconnectChain", (t) => {
|
|
3615
4035
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
3616
4036
|
});
|
|
3617
|
-
|
|
3618
|
-
if (t ===
|
|
4037
|
+
B(this, L, async (t) => {
|
|
4038
|
+
if (t === i.THORChain)
|
|
3619
4039
|
return {
|
|
3620
4040
|
gas_rate: "0",
|
|
3621
4041
|
router: "0",
|
|
3622
4042
|
address: "",
|
|
3623
4043
|
halted: !1,
|
|
3624
|
-
chain:
|
|
4044
|
+
chain: i.THORChain
|
|
3625
4045
|
};
|
|
3626
|
-
const a = (await
|
|
4046
|
+
const a = (await Tn(this.stagenet)).find((s) => s.chain === t);
|
|
3627
4047
|
if (!a)
|
|
3628
|
-
throw new
|
|
4048
|
+
throw new m("core_inbound_data_not_found");
|
|
3629
4049
|
if (a != null && a.halted)
|
|
3630
|
-
throw new
|
|
4050
|
+
throw new m("core_chain_halted");
|
|
3631
4051
|
return a;
|
|
3632
4052
|
});
|
|
3633
|
-
|
|
4053
|
+
B(this, se, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
3634
4054
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
3635
4055
|
});
|
|
3636
|
-
|
|
3637
|
-
assetValue:
|
|
3638
|
-
type:
|
|
3639
|
-
contractAddress:
|
|
4056
|
+
B(this, K, async ({
|
|
4057
|
+
assetValue: t,
|
|
4058
|
+
type: n = "checkOnly",
|
|
4059
|
+
contractAddress: a
|
|
3640
4060
|
}) => {
|
|
3641
|
-
const
|
|
3642
|
-
if (
|
|
4061
|
+
const { address: s, chain: r, isGasAsset: o, isSynthetic: p } = t, d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(r);
|
|
4062
|
+
if (d && o || !d || p)
|
|
3643
4063
|
return !0;
|
|
3644
|
-
const
|
|
3645
|
-
if (!
|
|
3646
|
-
throw new
|
|
3647
|
-
const
|
|
3648
|
-
if (!
|
|
3649
|
-
throw new
|
|
3650
|
-
const
|
|
3651
|
-
return
|
|
3652
|
-
amount: t,
|
|
3653
|
-
assetAddress:
|
|
3654
|
-
from:
|
|
3655
|
-
spenderAddress:
|
|
4064
|
+
const u = this.connectedWallets[r], c = n === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
|
|
4065
|
+
if (!c)
|
|
4066
|
+
throw new m("core_wallet_connection_not_found");
|
|
4067
|
+
const _ = this.getAddress(r);
|
|
4068
|
+
if (!s || !_)
|
|
4069
|
+
throw new m("core_approve_asset_address_or_from_not_found");
|
|
4070
|
+
const b = a || (await f(this, L).call(this, r)).router;
|
|
4071
|
+
return c({
|
|
4072
|
+
amount: t.getBaseValue("bigint"),
|
|
4073
|
+
assetAddress: s,
|
|
4074
|
+
from: _,
|
|
4075
|
+
spenderAddress: b
|
|
3656
4076
|
});
|
|
3657
4077
|
});
|
|
3658
|
-
|
|
4078
|
+
B(this, M, async ({
|
|
3659
4079
|
assetValue: t,
|
|
3660
4080
|
memo: n,
|
|
3661
4081
|
feeOptionKey: a = F.Fast
|
|
3662
4082
|
}) => {
|
|
3663
4083
|
const {
|
|
3664
|
-
gas_rate:
|
|
4084
|
+
gas_rate: s,
|
|
3665
4085
|
router: r,
|
|
3666
|
-
address:
|
|
3667
|
-
} = await
|
|
4086
|
+
address: o
|
|
4087
|
+
} = await f(this, L).call(this, t.chain), p = (parseInt(s) || 0) * At[a];
|
|
3668
4088
|
return this.deposit({
|
|
3669
4089
|
assetValue: t,
|
|
3670
|
-
recipient:
|
|
4090
|
+
recipient: o,
|
|
3671
4091
|
memo: n,
|
|
3672
4092
|
router: r,
|
|
3673
|
-
feeRate:
|
|
4093
|
+
feeRate: p
|
|
3674
4094
|
});
|
|
3675
4095
|
});
|
|
3676
|
-
|
|
3677
|
-
const a = await
|
|
4096
|
+
B(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
4097
|
+
const a = await hn(this.stagenet);
|
|
3678
4098
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
3679
|
-
throw new
|
|
4099
|
+
throw new m("core_chain_halted");
|
|
3680
4100
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
3681
4101
|
});
|
|
3682
|
-
|
|
4102
|
+
B(this, X, ({ assetValue: t, ...n }) => ({
|
|
3683
4103
|
...n,
|
|
3684
4104
|
memo: n.memo || "",
|
|
3685
4105
|
from: this.getAddress(t.chain),
|
|
@@ -3688,66 +4108,66 @@ class tn {
|
|
|
3688
4108
|
this.stagenet = !!t;
|
|
3689
4109
|
}
|
|
3690
4110
|
}
|
|
3691
|
-
|
|
4111
|
+
L = new WeakMap(), se = new WeakMap(), K = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
|
|
3692
4112
|
export {
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
4113
|
+
et as AGG_SWAP,
|
|
4114
|
+
bn as ApiError,
|
|
4115
|
+
W as ApiUrl,
|
|
4116
|
+
N as AssetValue,
|
|
4117
|
+
A as BaseDecimal,
|
|
4118
|
+
Te as BigIntArithmetics,
|
|
4119
|
+
i as Chain,
|
|
4120
|
+
fe as ChainId,
|
|
4121
|
+
On as ChainIdToChain,
|
|
4122
|
+
dt as ChainToChainId,
|
|
4123
|
+
Pe as ChainToExplorerUrl,
|
|
4124
|
+
gn as ChainToHexChainId,
|
|
4125
|
+
ut as ChainToRPC,
|
|
4126
|
+
it as ContractAddress,
|
|
4127
|
+
En as CosmosChainList,
|
|
4128
|
+
rt as DerivationPath,
|
|
4129
|
+
l as ERROR_CODE,
|
|
4130
|
+
at as ERROR_MODULE,
|
|
4131
|
+
Ne as ERROR_TYPE,
|
|
4132
|
+
ot as EVMChainList,
|
|
4133
|
+
lt as ErrorCode,
|
|
3714
4134
|
F as FeeOption,
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
4135
|
+
h as MemoType,
|
|
4136
|
+
wn as NetworkDerivationPath,
|
|
4137
|
+
Ze as QuoteMode,
|
|
4138
|
+
De as RPCUrl,
|
|
4139
|
+
Ae as RequestClient,
|
|
4140
|
+
tt as SWAP_IN,
|
|
4141
|
+
nt as SWAP_OUT,
|
|
4142
|
+
Ln as SwapKitCore,
|
|
4143
|
+
m as SwapKitError,
|
|
4144
|
+
D as SwapKitNumber,
|
|
4145
|
+
Qe as TCAvalancheDepositABI,
|
|
4146
|
+
ze as TCBscDepositABI,
|
|
4147
|
+
Je as TCEthereumVaultAbi,
|
|
4148
|
+
Rn as TCSupportedChainList,
|
|
4149
|
+
An as UTXOChainList,
|
|
4150
|
+
yt as WalletOption,
|
|
4151
|
+
In as assetFromString,
|
|
4152
|
+
Bn as derivationPathToString,
|
|
4153
|
+
fn as erc20ABI,
|
|
4154
|
+
Sn as filterAssets,
|
|
4155
|
+
re as formatBigIntToSafeValue,
|
|
4156
|
+
At as gasFeeMultiplier,
|
|
4157
|
+
Rt as getAssetType,
|
|
4158
|
+
St as getAsymmetricAssetShare,
|
|
4159
|
+
Cn as getAsymmetricAssetWithdrawAmount,
|
|
4160
|
+
It as getAsymmetricRuneShare,
|
|
4161
|
+
vn as getAsymmetricRuneWithdrawAmount,
|
|
4162
|
+
Et as getCommonAssetInfo,
|
|
4163
|
+
wt as getDecimal,
|
|
4164
|
+
Nn as getEstimatedPoolShare,
|
|
4165
|
+
xn as getLiquiditySlippage,
|
|
3744
4166
|
x as getMemoFor,
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
tt as postRequest,
|
|
3752
|
-
Xt as validateTHORName
|
|
4167
|
+
de as getMinAmountByChain,
|
|
4168
|
+
vt as getSymmetricPoolShare,
|
|
4169
|
+
Mn as getSymmetricWithdraw,
|
|
4170
|
+
Dn as getTHORNameCost,
|
|
4171
|
+
Le as isGasAsset,
|
|
4172
|
+
Pn as validateTHORName
|
|
3753
4173
|
};
|