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