@swapkit/core 1.0.0-rc.0 → 1.0.0-rc.10
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 +4 -2
- package/dist/index.es.js +556 -483
- package/package.json +15 -9
- package/src/client/explorerUrls.ts +2 -0
- package/src/client/index.ts +2 -2
- package/src/client/types.ts +2 -0
- package/dist/index.es-320ea117.js +0 -13836
- package/dist/index.es-66e7d15a.js +0 -11436
- package/dist/index.es-8503fb04-8503fb04.js +0 -34669
- package/dist/index.es-8503fb04-903b9173.cjs +0 -1
- package/dist/index.es-c82b553a.cjs +0 -14
- package/dist/index.es-e22f22e9.cjs +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Me = Object.defineProperty;
|
|
2
|
+
var Ce = (e, t, n) => t in e ? Me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var m = (e, t, n) => (Ce(e, typeof t != "symbol" ? t + "" : t, n), n), Ne = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var A = (e, t, n) => (
|
|
7
|
+
var A = (e, t, n) => (Ne(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
|
|
12
|
+
var xe = Object.defineProperty, De = (e, t, n) => t in e ? xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (De(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
13
|
const Lt = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
@@ -108,7 +108,7 @@ const Lt = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Pe = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const Lt = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Be = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const Lt = [
|
|
|
447
447
|
stateMutability: "view",
|
|
448
448
|
type: "function"
|
|
449
449
|
}
|
|
450
|
-
],
|
|
450
|
+
], Ve = [
|
|
451
451
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
452
452
|
{
|
|
453
453
|
anonymous: !1,
|
|
@@ -600,13 +600,13 @@ const Lt = [
|
|
|
600
600
|
type: "function"
|
|
601
601
|
}
|
|
602
602
|
];
|
|
603
|
-
var
|
|
604
|
-
const
|
|
603
|
+
var Le = /* @__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))(Le || {});
|
|
604
|
+
const Ue = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], He = [
|
|
610
610
|
"ERC20-TC",
|
|
611
611
|
"ERC20-ARC20",
|
|
612
612
|
"ERC20-BEP20",
|
|
@@ -617,72 +617,72 @@ const He = [
|
|
|
617
617
|
"BEP20-ERC20",
|
|
618
618
|
"BEP20-ARC20"
|
|
619
619
|
/* BSC_TO_AVAX */
|
|
620
|
-
],
|
|
620
|
+
], $e = [
|
|
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 be = /* @__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))(be || {}), ke = /* @__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))(ke || {}), d = /* @__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))(d || {});
|
|
628
|
+
const Fe = {
|
|
629
|
+
[d.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
|
+
[d.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
|
+
[d.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
632
|
+
[d.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
|
|
633
|
+
[d.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
|
|
634
|
+
[d.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
|
|
635
|
+
[d.INVALID_TYPE_GENERIC]: "Invalid type",
|
|
636
|
+
[d.INVALID_NUMBER_STRING]: "Invalid number string.",
|
|
637
|
+
[d.INVALID_NUMBER]: "Invalid number.",
|
|
638
|
+
[d.INVALID_BOOLEAN]: "Invalid boolean.",
|
|
639
|
+
[d.INVALID_OBJECT]: "Invalid object.",
|
|
640
|
+
[d.INVALID_ARRAY]: "Invalid array.",
|
|
641
|
+
[d.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
|
|
642
|
+
[d.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
|
|
643
|
+
[d.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
|
|
644
|
+
[d.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
|
|
645
|
+
[d.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
|
|
646
|
+
[d.AFF_BPS_INTEGER_0_100]: "affiliateBasisPoints must be an integer between 0 and 100.",
|
|
647
|
+
[d.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
|
|
648
|
+
[d.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
|
|
649
|
+
[d.PREFERRED_PROFVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
|
|
650
|
+
[d.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
|
|
651
|
+
[d.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
|
|
652
|
+
[d.INVALID_PROVIDER]: "Invalid provider {0}.",
|
|
653
|
+
[d.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
|
|
654
|
+
[d.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
|
|
655
|
+
[d.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
|
|
656
|
+
[d.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
|
|
657
|
+
[d.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
|
|
658
|
+
[d.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
|
|
659
|
+
[d.INVALID_CHAIN]: "Invalid chain {0}.",
|
|
660
|
+
[d.INVALID_ASSET]: "Invalid asset {0}.",
|
|
661
|
+
[d.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
|
|
662
|
+
[d.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
|
|
663
|
+
[d.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
|
|
664
|
+
[d.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
|
|
665
|
+
[d.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
|
|
666
|
+
[d.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
|
|
667
|
+
[d.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
|
|
668
|
+
[d.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
|
|
669
|
+
[d.INVALID_QUOTE_MODE]: "Invalid quote mode.",
|
|
670
|
+
[d.NO_QUOTES]: "No quotes to service this request.",
|
|
671
|
+
[d.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
|
|
672
|
+
[d.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
|
|
673
|
+
[d.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
|
|
674
|
+
[d.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
|
|
675
|
+
[d.NO_PRICE]: "No price for asset {0}.",
|
|
676
|
+
[d.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
|
+
[d.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
|
+
[d.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
|
+
}, te = (e, t) => {
|
|
680
|
+
let n = Fe[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
|
-
|
|
685
|
+
class Ae extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -690,22 +690,22 @@ let Ut = class we extends Error {
|
|
|
690
690
|
code: i,
|
|
691
691
|
message: r,
|
|
692
692
|
type: p,
|
|
693
|
-
options: { shouldLog:
|
|
693
|
+
options: { shouldLog: o, shouldThrow: y, shouldTrace: T } = {
|
|
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 l = r || te(i, u || []) || "";
|
|
701
|
+
super(l), 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 = l, this.display = te(i, u || []), this.code = i, this.type = p || be.UNHANDLED_ERROR, this.options = {
|
|
702
|
+
shouldLog: o || !0,
|
|
703
|
+
shouldTrace: T || !0,
|
|
704
|
+
shouldThrow: y || !1
|
|
705
|
+
}, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new Ae(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ let Ut = 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 te(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -723,9 +723,9 @@ let Ut = class we extends Error {
|
|
|
723
723
|
throw Error(t, { cause: this.stack });
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
|
-
}
|
|
727
|
-
var s = /* @__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.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(s || {}),
|
|
728
|
-
const
|
|
726
|
+
}
|
|
727
|
+
var s = /* @__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))(s || {}), Ge = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(Ge || {}), We = /* @__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))(We || {});
|
|
728
|
+
const Ut = {
|
|
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,6 +735,7 @@ const Ht = {
|
|
|
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],
|
|
@@ -742,7 +743,7 @@ const Ht = {
|
|
|
742
743
|
THOR: [44, 931, 0, 0, 0]
|
|
743
744
|
};
|
|
744
745
|
var E = /* @__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))(E || {});
|
|
745
|
-
const
|
|
746
|
+
const Ht = [
|
|
746
747
|
"ETH",
|
|
747
748
|
"AVAX",
|
|
748
749
|
"BSC",
|
|
@@ -750,38 +751,38 @@ const $t = [
|
|
|
750
751
|
"OP",
|
|
751
752
|
"MATIC"
|
|
752
753
|
/* Polygon */
|
|
753
|
-
],
|
|
754
|
+
], $t = [
|
|
754
755
|
"BTC",
|
|
755
756
|
"BCH",
|
|
756
757
|
"DOGE",
|
|
757
758
|
"LTC"
|
|
758
759
|
/* Litecoin */
|
|
759
|
-
],
|
|
760
|
+
], kt = [
|
|
760
761
|
"GAIA",
|
|
761
762
|
"THOR",
|
|
762
763
|
"BNB"
|
|
763
764
|
/* Binance */
|
|
764
765
|
];
|
|
765
|
-
var
|
|
766
|
-
const
|
|
766
|
+
var le = /* @__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))(le || {}), we = /* @__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))(we || {}), 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 Z = Object.values(s), qe = Object.keys(s), ce = Z.reduce(
|
|
767
768
|
(e, t) => {
|
|
768
|
-
const n =
|
|
769
|
+
const n = qe.find((a) => s[a] === t);
|
|
769
770
|
return n && (e[t] = n), e;
|
|
770
771
|
},
|
|
771
772
|
{}
|
|
772
|
-
), Ke =
|
|
773
|
-
(e, t) => (e[t] =
|
|
773
|
+
), Ke = Z.reduce(
|
|
774
|
+
(e, t) => (e[t] = le[ce[t]], e),
|
|
774
775
|
{}
|
|
775
|
-
),
|
|
776
|
-
(e, t) => (e[t] =
|
|
776
|
+
), Ye = Z.reduce(
|
|
777
|
+
(e, t) => (e[t] = we[ce[t]], e),
|
|
777
778
|
{}
|
|
778
|
-
),
|
|
779
|
+
), Ft = Z.reduce(
|
|
779
780
|
(e, t) => {
|
|
780
781
|
const n = `${ce[t]}Hex`;
|
|
781
|
-
return e[t] =
|
|
782
|
+
return e[t] = le[n], e;
|
|
782
783
|
},
|
|
783
784
|
{}
|
|
784
|
-
),
|
|
785
|
+
), Gt = {
|
|
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
|
+
}, Ee = {
|
|
809
811
|
ARB: "https://arbiscan.io",
|
|
810
812
|
AVAX: "https://snowtrace.io",
|
|
811
813
|
BSC: "https://bscscan.com",
|
|
@@ -814,54 +816,63 @@ 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
|
-
MAYA: "https://
|
|
822
|
+
MAYA: "https://www.mayascan.org",
|
|
820
823
|
OP: "https://optimistic.etherscan.io",
|
|
821
824
|
MATIC: "https://polygonscan.com",
|
|
822
825
|
THOR: "https://viewblock.io/thorchain"
|
|
823
826
|
};
|
|
824
|
-
var
|
|
827
|
+
var Xe = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(Xe || {}), f = /* @__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))(f || {}), k = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(k || {}), je = /* @__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))(je || {}), Qe = Object.defineProperty, Je = (e, t, n) => t in e ? Qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, N = (e, t, n) => (Je(e, typeof t != "symbol" ? t + "" : t, n), n), ze = (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
|
|
834
|
+
}, g = (e, t, n) => (ze(e, t, "access private method"), n);
|
|
835
|
+
const Wt = (e) => {
|
|
833
836
|
if (e < 0)
|
|
834
837
|
throw new Error("Invalid number of year");
|
|
835
838
|
return 10 + e;
|
|
836
|
-
},
|
|
839
|
+
}, qt = (e) => {
|
|
837
840
|
if (e.length > 30)
|
|
838
841
|
return !1;
|
|
839
842
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
840
843
|
return !!e.match(t);
|
|
841
|
-
},
|
|
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 }) => {
|
|
844
|
+
}, Kt = ([e, t, n, a, i]) => `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`, Re = async (e, t) => {
|
|
859
845
|
try {
|
|
860
|
-
const n =
|
|
861
|
-
|
|
846
|
+
const n = Object.entries(t || {}).reduce(
|
|
847
|
+
(a, [i, r]) => (r && (a[i] = r), a),
|
|
848
|
+
{}
|
|
849
|
+
);
|
|
850
|
+
return (await fetch(
|
|
851
|
+
`${e}${t ? `?${new URLSearchParams(n).toString()}` : ""}`,
|
|
852
|
+
{ method: "GET", mode: "cors", credentials: "omit", referrer: "https://sk.thorswap.net" }
|
|
853
|
+
)).json();
|
|
854
|
+
} catch (n) {
|
|
855
|
+
return console.error(n), {};
|
|
856
|
+
}
|
|
857
|
+
}, Ze = async (e, t, n, a = !1) => {
|
|
858
|
+
try {
|
|
859
|
+
const i = await fetch(`${e}`, {
|
|
860
|
+
body: t,
|
|
861
|
+
headers: n,
|
|
862
|
+
method: "POST",
|
|
863
|
+
referrer: "https://sk.thorswap.net"
|
|
864
|
+
});
|
|
865
|
+
return a ? i.text() : i.json();
|
|
866
|
+
} catch {
|
|
867
|
+
return {};
|
|
868
|
+
}
|
|
869
|
+
}, et = "0x313ce567", Oe = async ({ chain: e, to: t }) => {
|
|
870
|
+
try {
|
|
871
|
+
const n = await Ze(
|
|
872
|
+
Ye[e],
|
|
862
873
|
JSON.stringify({
|
|
863
874
|
method: "eth_call",
|
|
864
|
-
params: [{ to: t.toLowerCase(), data:
|
|
875
|
+
params: [{ to: t.toLowerCase(), data: et }, "latest"],
|
|
865
876
|
id: 44,
|
|
866
877
|
jsonrpc: "2.0"
|
|
867
878
|
}),
|
|
@@ -872,30 +883,30 @@ const qt = (e) => {
|
|
|
872
883
|
} catch (n) {
|
|
873
884
|
return console.error(n), E[e];
|
|
874
885
|
}
|
|
875
|
-
},
|
|
886
|
+
}, tt = async (e) => {
|
|
876
887
|
if (e === s.Ethereum)
|
|
877
888
|
return E.ETH;
|
|
878
889
|
const [, t] = e.split("-");
|
|
879
|
-
return t != null && t.startsWith("0x") ?
|
|
880
|
-
},
|
|
890
|
+
return t != null && t.startsWith("0x") ? Oe({ chain: s.Ethereum, to: t }) : E.ETH;
|
|
891
|
+
}, nt = async (e) => {
|
|
881
892
|
const [, t] = e.split("-");
|
|
882
|
-
return t != null && t.startsWith("0x") ?
|
|
883
|
-
},
|
|
893
|
+
return t != null && t.startsWith("0x") ? Oe({ chain: s.Avalanche, to: t.toLowerCase() }) : E.AVAX;
|
|
894
|
+
}, at = async (e) => (e === s.BinanceSmartChain, E.BSC), Ie = async ({ chain: e, symbol: t }) => {
|
|
884
895
|
switch (e) {
|
|
885
896
|
case s.Ethereum:
|
|
886
|
-
return
|
|
897
|
+
return tt(t);
|
|
887
898
|
case s.Avalanche:
|
|
888
|
-
return
|
|
899
|
+
return nt(t);
|
|
889
900
|
case s.BinanceSmartChain:
|
|
890
|
-
return
|
|
901
|
+
return at(t);
|
|
891
902
|
default:
|
|
892
903
|
return E[e];
|
|
893
904
|
}
|
|
894
|
-
},
|
|
895
|
-
[
|
|
896
|
-
[
|
|
897
|
-
[
|
|
898
|
-
},
|
|
905
|
+
}, st = {
|
|
906
|
+
[k.Average]: 1.2,
|
|
907
|
+
[k.Fast]: 1.5,
|
|
908
|
+
[k.Fastest]: 2
|
|
909
|
+
}, it = ({ chain: e, symbol: t }) => {
|
|
899
910
|
switch (e) {
|
|
900
911
|
case s.Bitcoin:
|
|
901
912
|
case s.BitcoinCash:
|
|
@@ -910,6 +921,8 @@ const qt = (e) => {
|
|
|
910
921
|
return t === "ETH";
|
|
911
922
|
case s.Maya:
|
|
912
923
|
return t === "CACAO";
|
|
924
|
+
case s.Kujira:
|
|
925
|
+
return t === "KUJI";
|
|
913
926
|
case s.Cosmos:
|
|
914
927
|
return t === "ATOM";
|
|
915
928
|
case s.Polygon:
|
|
@@ -919,7 +932,7 @@ const qt = (e) => {
|
|
|
919
932
|
case s.THORChain:
|
|
920
933
|
return t === "RUNE";
|
|
921
934
|
}
|
|
922
|
-
},
|
|
935
|
+
}, rt = (e) => {
|
|
923
936
|
switch (e) {
|
|
924
937
|
case "ETH.THOR":
|
|
925
938
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
@@ -935,6 +948,7 @@ const qt = (e) => {
|
|
|
935
948
|
return { identifier: "MAYA.CACAO", decimal: E.MAYA };
|
|
936
949
|
case "MAYA.MAYA":
|
|
937
950
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
951
|
+
case s.Kujira:
|
|
938
952
|
case s.Arbitrum:
|
|
939
953
|
case s.Optimism:
|
|
940
954
|
case s.BitcoinCash:
|
|
@@ -947,7 +961,7 @@ const qt = (e) => {
|
|
|
947
961
|
case s.Ethereum:
|
|
948
962
|
return { identifier: `${e}.${e}`, decimal: E[e] };
|
|
949
963
|
}
|
|
950
|
-
},
|
|
964
|
+
}, pt = ({ chain: e, symbol: t }) => {
|
|
951
965
|
if (t.includes("/"))
|
|
952
966
|
return "Synth";
|
|
953
967
|
switch (e) {
|
|
@@ -960,6 +974,8 @@ const qt = (e) => {
|
|
|
960
974
|
return "Native";
|
|
961
975
|
case s.Cosmos:
|
|
962
976
|
return t === "ATOM" ? "Native" : "GAIA";
|
|
977
|
+
case s.Kujira:
|
|
978
|
+
return t === "KUJI" ? "Native" : "KUJI";
|
|
963
979
|
case s.Binance:
|
|
964
980
|
return t === s.Binance ? "Native" : "BEP2";
|
|
965
981
|
case s.BinanceSmartChain:
|
|
@@ -975,44 +991,56 @@ const qt = (e) => {
|
|
|
975
991
|
case s.Optimism:
|
|
976
992
|
return [s.Ethereum, s.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
977
993
|
}
|
|
978
|
-
},
|
|
994
|
+
}, Yt = (e) => {
|
|
979
995
|
var t;
|
|
980
996
|
const [n, ...a] = e.split("."), i = e.includes("/"), r = a.join("."), p = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
981
997
|
return { chain: n, symbol: r, ticker: p, synth: i };
|
|
982
|
-
},
|
|
998
|
+
}, ot = new RegExp(
|
|
999
|
+
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
1000
|
+
"gmi"
|
|
1001
|
+
), Xt = (e) => e.filter((t) => !ot.test(t.toString())), dt = ({
|
|
983
1002
|
liquidityUnits: e,
|
|
984
1003
|
poolUnits: t,
|
|
985
1004
|
runeDepth: n
|
|
986
1005
|
}) => {
|
|
987
|
-
const a = w(e), i = w(t), r = w(n), p = a.mul(r),
|
|
988
|
-
return p.mul(
|
|
989
|
-
},
|
|
1006
|
+
const a = w(e), i = w(t), r = w(n), p = a.mul(r), o = i.mul(i).mul(2), y = i.mul(a).mul(2), T = a.mul(a), u = i.mul(i).mul(i);
|
|
1007
|
+
return p.mul(o.sub(y).add(T)).div(u);
|
|
1008
|
+
}, ut = ({
|
|
990
1009
|
liquidityUnits: e,
|
|
991
1010
|
poolUnits: t,
|
|
992
1011
|
assetDepth: n
|
|
993
1012
|
}) => {
|
|
994
|
-
const a = w(e), i = w(t), r = w(n), p = a.mul(r),
|
|
995
|
-
return
|
|
1013
|
+
const a = w(e), i = w(t), r = w(n), p = a.mul(r), o = i.mul(i).mul(2), y = i.mul(a).mul(2), T = a.mul(a), u = p.mul(o.sub(y).add(T)), l = i.mul(i).mul(i);
|
|
1014
|
+
return u.div(l);
|
|
996
1015
|
}, jt = ({
|
|
997
1016
|
percent: e,
|
|
998
1017
|
runeDepth: t,
|
|
999
1018
|
liquidityUnits: n,
|
|
1000
1019
|
poolUnits: a
|
|
1001
|
-
}) =>
|
|
1020
|
+
}) => dt({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), Qt = ({
|
|
1002
1021
|
percent: e,
|
|
1003
1022
|
assetDepth: t,
|
|
1004
1023
|
liquidityUnits: n,
|
|
1005
1024
|
poolUnits: a
|
|
1006
|
-
}) =>
|
|
1025
|
+
}) => ut({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), w = (e) => new ye({ value: e, decimal: E.THOR }), yt = ({
|
|
1007
1026
|
liquidityUnits: e,
|
|
1008
1027
|
poolUnits: t,
|
|
1009
1028
|
runeDepth: n,
|
|
1010
|
-
assetDepth: a
|
|
1011
|
-
percent: i
|
|
1029
|
+
assetDepth: a
|
|
1012
1030
|
}) => ({
|
|
1013
|
-
assetAmount: w(a).mul(e).div(t)
|
|
1014
|
-
runeAmount: w(n).mul(e).div(t)
|
|
1031
|
+
assetAmount: w(a).mul(e).div(t),
|
|
1032
|
+
runeAmount: w(n).mul(e).div(t)
|
|
1015
1033
|
}), Jt = ({
|
|
1034
|
+
liquidityUnits: e,
|
|
1035
|
+
poolUnits: t,
|
|
1036
|
+
runeDepth: n,
|
|
1037
|
+
assetDepth: a,
|
|
1038
|
+
percent: i
|
|
1039
|
+
}) => Object.fromEntries(
|
|
1040
|
+
Object.entries(yt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1041
|
+
([r, p]) => [r, p.mul(i)]
|
|
1042
|
+
)
|
|
1043
|
+
), zt = ({
|
|
1016
1044
|
runeDepth: e,
|
|
1017
1045
|
poolUnits: t,
|
|
1018
1046
|
assetDepth: n,
|
|
@@ -1020,10 +1048,10 @@ const qt = (e) => {
|
|
|
1020
1048
|
runeAmount: i,
|
|
1021
1049
|
assetAmount: r
|
|
1022
1050
|
}) => {
|
|
1023
|
-
const p = w(e),
|
|
1024
|
-
if (
|
|
1025
|
-
return b.div(
|
|
1026
|
-
const M =
|
|
1051
|
+
const p = w(e), o = w(n), y = w(t), T = w(i), u = w(r), l = T.mul(o), h = u.mul(p), _ = T.mul(u), R = p.mul(o), O = y.mul(l.add(h.add(_.mul(2)))), S = l.add(h.add(R.mul(2))), I = O.div(S), b = w(a).add(I);
|
|
1052
|
+
if (I.baseValueNumber === 0)
|
|
1053
|
+
return b.div(y).baseValueNumber;
|
|
1054
|
+
const M = y.add(b);
|
|
1027
1055
|
return b.div(M).baseValueNumber;
|
|
1028
1056
|
}, Zt = ({
|
|
1029
1057
|
runeAmount: e,
|
|
@@ -1031,8 +1059,8 @@ const qt = (e) => {
|
|
|
1031
1059
|
runeDepth: n,
|
|
1032
1060
|
assetDepth: a
|
|
1033
1061
|
}) => {
|
|
1034
|
-
const i = w(n), r = w(a), p = w(t),
|
|
1035
|
-
return Math.abs(
|
|
1062
|
+
const i = w(n), r = w(a), p = w(t), o = w(e), y = p.mul(i).sub(r.mul(o)), T = r.mul(o).add(i.mul(r));
|
|
1063
|
+
return Math.abs(y.div(T).baseValueNumber);
|
|
1036
1064
|
}, lt = ({
|
|
1037
1065
|
symbol: e,
|
|
1038
1066
|
ticker: t,
|
|
@@ -1057,8 +1085,8 @@ const qt = (e) => {
|
|
|
1057
1085
|
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${i || ""}:t:0`;
|
|
1058
1086
|
}
|
|
1059
1087
|
case f.WITHDRAW: {
|
|
1060
|
-
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide:
|
|
1061
|
-
return `${e}:${n}${
|
|
1088
|
+
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: o } = t, y = !o && p ? `:${p}` : "", T = lt({ chain: n, symbol: i, ticker: a });
|
|
1089
|
+
return `${e}:${n}${o ? "/" : "."}${T}:${r}${y}`;
|
|
1062
1090
|
}
|
|
1063
1091
|
case f.OPEN_LOAN:
|
|
1064
1092
|
case f.CLOSE_LOAN: {
|
|
@@ -1068,43 +1096,44 @@ const qt = (e) => {
|
|
|
1068
1096
|
default:
|
|
1069
1097
|
return "";
|
|
1070
1098
|
}
|
|
1071
|
-
},
|
|
1099
|
+
}, me = Object.values(s), ct = (e = "") => {
|
|
1100
|
+
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1101
|
+
if (me.includes(n))
|
|
1102
|
+
return !0;
|
|
1103
|
+
const [a] = t.split("/");
|
|
1104
|
+
if (me.includes(a))
|
|
1105
|
+
return !0;
|
|
1106
|
+
throw new Error(
|
|
1107
|
+
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1108
|
+
);
|
|
1109
|
+
}, q = 8, U = (e) => 10n ** BigInt(e), F = (e) => Math.log10(parseFloat(e.toString()));
|
|
1110
|
+
function ge({
|
|
1072
1111
|
value: e,
|
|
1073
|
-
bigIntDecimal: t =
|
|
1074
|
-
decimal: n =
|
|
1075
|
-
})
|
|
1112
|
+
bigIntDecimal: t = q,
|
|
1113
|
+
decimal: n = q
|
|
1114
|
+
}) {
|
|
1076
1115
|
const a = e < 0n;
|
|
1077
1116
|
let i = e.toString().substring(a ? 1 : 0);
|
|
1078
1117
|
const r = n - (i.length - 1);
|
|
1079
1118
|
r > 0 && (i = "0".repeat(r) + i);
|
|
1080
1119
|
const p = i.length - n;
|
|
1081
|
-
let
|
|
1082
|
-
return parseInt(
|
|
1120
|
+
let o = i.slice(-n);
|
|
1121
|
+
return parseInt(o[t]) >= 5 ? o = `${o.substring(0, t - 1)}${(parseInt(o[t - 1]) + 1).toString()}` : o = o.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${o}`.replace(
|
|
1083
1122
|
/\.?0*$/,
|
|
1084
1123
|
""
|
|
1085
1124
|
);
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
return !0;
|
|
1090
|
-
const [a] = t.split("/");
|
|
1091
|
-
if (Te.includes(a))
|
|
1092
|
-
return !0;
|
|
1093
|
-
throw new Error(
|
|
1094
|
-
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1095
|
-
);
|
|
1096
|
-
}, U = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1097
|
-
var L, $, ie, ve, re, _e, J, pe, H, W, Z, oe, k, Q;
|
|
1098
|
-
const ct = class z {
|
|
1125
|
+
}
|
|
1126
|
+
var L, $, ae, Se, se, Te, Q, ie, H, G, J, re;
|
|
1127
|
+
const mt = class j {
|
|
1099
1128
|
constructor(t) {
|
|
1100
|
-
|
|
1101
|
-
const n =
|
|
1102
|
-
this.decimal =
|
|
1103
|
-
Math.max(
|
|
1104
|
-
),
|
|
1129
|
+
V(this, L), V(this, ae), V(this, se), V(this, Q), V(this, H), V(this, J), N(this, "decimalMultiplier", 10n ** 8n), N(this, "bigIntValue", 0n), N(this, "decimal");
|
|
1130
|
+
const n = oe(t);
|
|
1131
|
+
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = U(
|
|
1132
|
+
Math.max(g(this, J, re).call(this, g(this, H, G).call(this, n)), this.decimal || 0)
|
|
1133
|
+
), g(this, ae, Se).call(this, n);
|
|
1105
1134
|
}
|
|
1106
1135
|
static fromBigInt(t, n) {
|
|
1107
|
-
return new
|
|
1136
|
+
return new j({
|
|
1108
1137
|
decimal: n,
|
|
1109
1138
|
value: ge({ value: t, bigIntDecimal: n, decimal: n })
|
|
1110
1139
|
});
|
|
@@ -1114,40 +1143,43 @@ const ct = class z {
|
|
|
1114
1143
|
from: n,
|
|
1115
1144
|
to: a
|
|
1116
1145
|
}) {
|
|
1117
|
-
return
|
|
1118
|
-
new
|
|
1146
|
+
return j.fromBigInt(
|
|
1147
|
+
new j(t).bigIntValue * U(a) / U(n),
|
|
1119
1148
|
a
|
|
1120
1149
|
);
|
|
1121
1150
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1151
|
+
/**
|
|
1152
|
+
* @deprecated Use `getBaseValue('string')` instead
|
|
1153
|
+
*/
|
|
1125
1154
|
get baseValue() {
|
|
1126
|
-
return
|
|
1155
|
+
return this.getBaseValue("string");
|
|
1127
1156
|
}
|
|
1157
|
+
/**
|
|
1158
|
+
* @deprecated Use `getBaseValue('number')` instead
|
|
1159
|
+
*/
|
|
1128
1160
|
get baseValueNumber() {
|
|
1129
|
-
return
|
|
1161
|
+
return this.getBaseValue("number");
|
|
1130
1162
|
}
|
|
1163
|
+
/**
|
|
1164
|
+
* @deprecated Use `getBaseValue('bigint')` instead
|
|
1165
|
+
*/
|
|
1131
1166
|
get baseValueBigInt() {
|
|
1132
|
-
return
|
|
1167
|
+
return this.getBaseValue("bigint");
|
|
1133
1168
|
}
|
|
1134
|
-
|
|
1135
|
-
return this.
|
|
1136
|
-
this.bigIntValue,
|
|
1137
|
-
this.decimal || G(this.decimalMultiplier)
|
|
1138
|
-
);
|
|
1169
|
+
set(t) {
|
|
1170
|
+
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1139
1171
|
}
|
|
1140
1172
|
add(...t) {
|
|
1141
|
-
return
|
|
1173
|
+
return g(this, L, $).call(this, "add", ...t);
|
|
1142
1174
|
}
|
|
1143
1175
|
sub(...t) {
|
|
1144
|
-
return
|
|
1176
|
+
return g(this, L, $).call(this, "sub", ...t);
|
|
1145
1177
|
}
|
|
1146
1178
|
mul(...t) {
|
|
1147
|
-
return
|
|
1179
|
+
return g(this, L, $).call(this, "mul", ...t);
|
|
1148
1180
|
}
|
|
1149
1181
|
div(...t) {
|
|
1150
|
-
return
|
|
1182
|
+
return g(this, L, $).call(this, "div", ...t);
|
|
1151
1183
|
}
|
|
1152
1184
|
gt(t) {
|
|
1153
1185
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1164,124 +1196,174 @@ const ct = class z {
|
|
|
1164
1196
|
eqValue(t) {
|
|
1165
1197
|
return this.bigIntValue === this.getBigIntValue(t);
|
|
1166
1198
|
}
|
|
1199
|
+
getValue(t) {
|
|
1200
|
+
const n = this.formatBigIntToSafeValue(
|
|
1201
|
+
this.bigIntValue,
|
|
1202
|
+
this.decimal || F(this.decimalMultiplier)
|
|
1203
|
+
);
|
|
1204
|
+
switch (t) {
|
|
1205
|
+
case "number":
|
|
1206
|
+
return Number(n);
|
|
1207
|
+
case "string":
|
|
1208
|
+
return n;
|
|
1209
|
+
default:
|
|
1210
|
+
return this.bigIntValue;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
getBaseValue(t) {
|
|
1214
|
+
const n = this.decimalMultiplier / U(this.decimal || 0), a = this.bigIntValue / n;
|
|
1215
|
+
switch (t) {
|
|
1216
|
+
case "number":
|
|
1217
|
+
return Number(a);
|
|
1218
|
+
case "string":
|
|
1219
|
+
return a.toString();
|
|
1220
|
+
default:
|
|
1221
|
+
return this.bigIntValue;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1167
1224
|
getBigIntValue(t, n) {
|
|
1168
|
-
return !n && typeof t == "object" ? t.bigIntValue : (
|
|
1225
|
+
return !n && typeof t == "object" ? t.bigIntValue : g(this, Q, ie).call(this, g(this, H, G).call(this, oe(t)), n);
|
|
1169
1226
|
}
|
|
1170
1227
|
formatBigIntToSafeValue(t, n) {
|
|
1171
|
-
const a = n || this.decimal ||
|
|
1228
|
+
const a = n || this.decimal || q, i = Math.max(
|
|
1172
1229
|
a,
|
|
1173
|
-
|
|
1174
|
-
), r = t < 0n;
|
|
1175
|
-
let
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
return parseInt(m[a]) >= 5 ? m = `${m.substring(0, a - 1)}${(parseInt(m[a - 1]) + 1).toString()}` : m = m.substring(0, a), `${r ? "-" : ""}${p.slice(0, l)}.${m}`.replace(
|
|
1181
|
-
/\.?0*$/,
|
|
1182
|
-
""
|
|
1183
|
-
);
|
|
1230
|
+
F(this.decimalMultiplier)
|
|
1231
|
+
), r = t < 0n, p = t.toString().substring(r ? 1 : 0), o = i - (p.length - 1), y = o > 0 ? "0".repeat(o) + p : p, T = y.length - i;
|
|
1232
|
+
let u = y.slice(-i);
|
|
1233
|
+
return parseInt(u[a]) >= 5 ? u = `${u.substring(0, a - 1)}${(parseInt(u[a - 1]) + 1).toString()}` : u = u.substring(0, a), `${r ? "-" : ""}${y.slice(
|
|
1234
|
+
0,
|
|
1235
|
+
T
|
|
1236
|
+
)}.${u}`.replace(/\.?0*$/, "");
|
|
1184
1237
|
}
|
|
1185
|
-
toSignificant(t) {
|
|
1186
|
-
const n = this.
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1238
|
+
toSignificant(t = 6) {
|
|
1239
|
+
const [n, a] = this.getValue("string").split("."), i = n || "", r = a || "", p = parseInt(i) ? i.length + r.length : r.length;
|
|
1240
|
+
if (p <= t)
|
|
1241
|
+
return this.getValue("string");
|
|
1242
|
+
if (i.length >= t)
|
|
1243
|
+
return i.slice(0, t).padEnd(i.length, "0");
|
|
1244
|
+
if (parseInt(i))
|
|
1245
|
+
return `${i}.${r.slice(0, t - i.length)}`.padEnd(
|
|
1246
|
+
p - t,
|
|
1247
|
+
"0"
|
|
1248
|
+
);
|
|
1249
|
+
const o = parseInt(r), y = `${o}`.slice(0, t);
|
|
1250
|
+
return `0.${y.padStart(
|
|
1251
|
+
r.length - `${o}`.length + y.length,
|
|
1252
|
+
"0"
|
|
1253
|
+
)}`;
|
|
1191
1254
|
}
|
|
1192
1255
|
};
|
|
1193
1256
|
L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
1194
|
-
const n =
|
|
1195
|
-
(p,
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1257
|
+
const n = g(this, se, Te).call(this, this, ...t), a = U(n), i = t.reduce(
|
|
1258
|
+
(p, o) => {
|
|
1259
|
+
const y = this.getBigIntValue(o, n);
|
|
1260
|
+
switch (e) {
|
|
1261
|
+
case "add":
|
|
1262
|
+
return p + y;
|
|
1263
|
+
case "sub":
|
|
1264
|
+
return p - y;
|
|
1265
|
+
case "mul":
|
|
1266
|
+
return p * y / a;
|
|
1267
|
+
case "div": {
|
|
1268
|
+
if (y === 0n)
|
|
1269
|
+
throw new RangeError("Division by zero");
|
|
1270
|
+
return p * a / y;
|
|
1271
|
+
}
|
|
1272
|
+
default:
|
|
1273
|
+
return p;
|
|
1274
|
+
}
|
|
1200
1275
|
},
|
|
1201
1276
|
//normalize is to precision multiplier base
|
|
1202
1277
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1203
1278
|
), r = ge({
|
|
1204
1279
|
bigIntDecimal: n,
|
|
1205
|
-
decimal: Math.max(n,
|
|
1280
|
+
decimal: Math.max(n, F(this.decimalMultiplier)),
|
|
1206
1281
|
value: i
|
|
1207
1282
|
});
|
|
1208
1283
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1209
|
-
},
|
|
1210
|
-
const
|
|
1211
|
-
this.bigIntValue =
|
|
1212
|
-
},
|
|
1284
|
+
}, ae = /* @__PURE__ */ new WeakSet(), Se = function(e) {
|
|
1285
|
+
const t = g(this, H, G).call(this, e) || "0";
|
|
1286
|
+
this.bigIntValue = g(this, Q, ie).call(this, t);
|
|
1287
|
+
}, se = /* @__PURE__ */ new WeakSet(), Te = function(...e) {
|
|
1213
1288
|
const t = e.map(
|
|
1214
|
-
(n) => typeof n == "object" ? n.decimal ||
|
|
1289
|
+
(n) => typeof n == "object" ? n.decimal || F(n.decimalMultiplier) : g(this, J, re).call(this, g(this, H, G).call(this, n))
|
|
1215
1290
|
).filter(Boolean);
|
|
1216
|
-
return Math.max(...t,
|
|
1217
|
-
},
|
|
1218
|
-
const n = t ? U(t) : this.decimalMultiplier, a =
|
|
1291
|
+
return Math.max(...t, q);
|
|
1292
|
+
}, Q = /* @__PURE__ */ new WeakSet(), ie = function(e, t) {
|
|
1293
|
+
const n = t ? U(t) : this.decimalMultiplier, a = F(n), [i, r = ""] = e.split(".");
|
|
1219
1294
|
return BigInt(`${i}${r.padEnd(a, "0")}`);
|
|
1220
|
-
}, H = /* @__PURE__ */ new WeakSet(),
|
|
1295
|
+
}, H = /* @__PURE__ */ new WeakSet(), G = function(e) {
|
|
1221
1296
|
const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
|
|
1222
1297
|
useGrouping: !1,
|
|
1223
1298
|
maximumFractionDigits: 20
|
|
1224
|
-
}) : e}`.replaceAll(",", ".").split(".");
|
|
1299
|
+
}) : oe(e)}`.replaceAll(",", ".").split(".");
|
|
1225
1300
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1226
|
-
},
|
|
1301
|
+
}, J = /* @__PURE__ */ new WeakSet(), re = function(e) {
|
|
1227
1302
|
var t;
|
|
1228
1303
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1229
|
-
return Math.max(n,
|
|
1230
|
-
}, k = /* @__PURE__ */ new WeakSet(), Q = function(e) {
|
|
1231
|
-
const t = this.decimalMultiplier / U(this.decimal || 0), n = this.bigIntValue / t;
|
|
1232
|
-
switch (e) {
|
|
1233
|
-
case "number":
|
|
1234
|
-
return Number(n);
|
|
1235
|
-
case "string":
|
|
1236
|
-
return n.toString();
|
|
1237
|
-
default:
|
|
1238
|
-
return n;
|
|
1239
|
-
}
|
|
1304
|
+
return Math.max(n, q);
|
|
1240
1305
|
};
|
|
1241
|
-
let
|
|
1242
|
-
|
|
1243
|
-
|
|
1306
|
+
let pe = mt;
|
|
1307
|
+
function oe(e) {
|
|
1308
|
+
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1309
|
+
}
|
|
1310
|
+
let de;
|
|
1311
|
+
const ne = (e) => {
|
|
1312
|
+
if (!de)
|
|
1244
1313
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1245
|
-
return
|
|
1246
|
-
},
|
|
1247
|
-
|
|
1248
|
-
const n = await
|
|
1314
|
+
return de.get(e.toUpperCase()) || { decimal: E.THOR, identifier: "" };
|
|
1315
|
+
}, _e = async (e, t = 0) => {
|
|
1316
|
+
ct(e);
|
|
1317
|
+
const n = await Ie(ue(e));
|
|
1249
1318
|
return new v({ decimal: n, value: t, identifier: e });
|
|
1250
1319
|
};
|
|
1251
|
-
class v extends
|
|
1320
|
+
class v extends pe {
|
|
1252
1321
|
constructor(t) {
|
|
1253
1322
|
super(
|
|
1254
|
-
t.value instanceof
|
|
1323
|
+
t.value instanceof pe ? t.value : { decimal: t.decimal, value: t.value }
|
|
1255
1324
|
), N(this, "address"), N(this, "chain"), N(this, "isSynthetic", !1), N(this, "isGasAsset", !1), N(this, "symbol"), N(this, "ticker"), N(this, "type");
|
|
1256
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a =
|
|
1257
|
-
this.type =
|
|
1325
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = ue(n);
|
|
1326
|
+
this.type = pt(a), this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset;
|
|
1327
|
+
}
|
|
1328
|
+
get assetValue() {
|
|
1329
|
+
return `${this.getValue("string")} ${this.ticker}`;
|
|
1330
|
+
}
|
|
1331
|
+
toString(t = !1) {
|
|
1332
|
+
const n = this.isSynthetic ? this.ticker : `${this.chain}.${this.ticker}`;
|
|
1333
|
+
return t ? n : (
|
|
1334
|
+
// THOR.ETH/ETH | ETH.USDT-0x1234567890
|
|
1335
|
+
`${this.chain}.${this.symbol}`
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
eq({ chain: t, symbol: n }) {
|
|
1339
|
+
return this.chain === t && this.symbol === n;
|
|
1258
1340
|
}
|
|
1259
1341
|
static async fromString(t, n = 0) {
|
|
1260
|
-
return
|
|
1342
|
+
return _e(t, n);
|
|
1261
1343
|
}
|
|
1262
1344
|
static fromStringSync(t, n = 0) {
|
|
1263
|
-
const { decimal: a, identifier: i } =
|
|
1345
|
+
const { decimal: a, identifier: i } = ne(
|
|
1264
1346
|
t
|
|
1265
1347
|
);
|
|
1266
1348
|
return i ? new v({ decimal: a, identifier: i, value: n }) : void 0;
|
|
1267
1349
|
}
|
|
1268
1350
|
static async fromIdentifier(t, n = 0) {
|
|
1269
|
-
return
|
|
1351
|
+
return _e(t, n);
|
|
1270
1352
|
}
|
|
1271
1353
|
static fromIdentifierSync(t, n = 0) {
|
|
1272
|
-
const { decimal: a, identifier: i } =
|
|
1354
|
+
const { decimal: a, identifier: i } = ne(t);
|
|
1273
1355
|
return new v({ decimal: a, identifier: i, value: n });
|
|
1274
1356
|
}
|
|
1275
1357
|
static fromChainOrSignature(t, n = 0) {
|
|
1276
|
-
const { decimal: a, identifier: i } =
|
|
1358
|
+
const { decimal: a, identifier: i } = rt(t);
|
|
1277
1359
|
return new v({ value: n, decimal: a, identifier: i });
|
|
1278
1360
|
}
|
|
1279
1361
|
static async fromTCQuote(t, n = 0) {
|
|
1280
|
-
const a = await
|
|
1362
|
+
const a = await Ie(ue(t)), i = this.shiftDecimals({ value: n, from: E.THOR, to: a });
|
|
1281
1363
|
return new v({ value: i, identifier: t, decimal: a });
|
|
1282
1364
|
}
|
|
1283
1365
|
static fromTCQuoteStatic(t, n = 0) {
|
|
1284
|
-
const a =
|
|
1366
|
+
const a = ne(t), i = this.shiftDecimals({
|
|
1285
1367
|
value: n,
|
|
1286
1368
|
from: E.THOR,
|
|
1287
1369
|
to: a.decimal
|
|
@@ -1298,11 +1380,11 @@ class v extends de {
|
|
|
1298
1380
|
ThorchainList: a,
|
|
1299
1381
|
NativeList: i,
|
|
1300
1382
|
...r
|
|
1301
|
-
} = await import("
|
|
1302
|
-
|
|
1303
|
-
(p, { tokens:
|
|
1304
|
-
const
|
|
1305
|
-
p.set(
|
|
1383
|
+
} = await import("@swapkit/tokens");
|
|
1384
|
+
de = [i, ...Object.values(r)].reduce(
|
|
1385
|
+
(p, { tokens: o }) => (o.forEach(({ identifier: y, chain: T, ...u }) => {
|
|
1386
|
+
const l = "decimals" in u ? u.decimals : E[T];
|
|
1387
|
+
p.set(y, { identifier: y, decimal: l });
|
|
1306
1388
|
}), p),
|
|
1307
1389
|
/* @__PURE__ */ new Map()
|
|
1308
1390
|
), t({ ok: !0 });
|
|
@@ -1316,17 +1398,8 @@ class v extends de {
|
|
|
1316
1398
|
}
|
|
1317
1399
|
);
|
|
1318
1400
|
}
|
|
1319
|
-
get assetValue() {
|
|
1320
|
-
return `${this.value} ${this.ticker}`;
|
|
1321
|
-
}
|
|
1322
|
-
toString() {
|
|
1323
|
-
return `${this.chain}.${this.symbol}`;
|
|
1324
|
-
}
|
|
1325
|
-
eq({ chain: t, symbol: n }) {
|
|
1326
|
-
return this.chain === t && this.symbol === n;
|
|
1327
|
-
}
|
|
1328
1401
|
}
|
|
1329
|
-
const
|
|
1402
|
+
const he = (e) => {
|
|
1330
1403
|
const t = v.fromChainOrSignature(e);
|
|
1331
1404
|
switch (e) {
|
|
1332
1405
|
case s.Bitcoin:
|
|
@@ -1344,12 +1417,12 @@ const fe = (e) => {
|
|
|
1344
1417
|
default:
|
|
1345
1418
|
return t.add(1);
|
|
1346
1419
|
}
|
|
1347
|
-
},
|
|
1420
|
+
}, ue = (e) => {
|
|
1348
1421
|
const t = e.slice(0, 14).includes("/"), n = e.includes(".") ? e : `${s.THORChain}.${e}`, [a, i] = n.split("."), [r, p] = i.split("-");
|
|
1349
1422
|
return {
|
|
1350
1423
|
address: p == null ? void 0 : p.toLowerCase(),
|
|
1351
1424
|
chain: a,
|
|
1352
|
-
isGasAsset:
|
|
1425
|
+
isGasAsset: it({ chain: a, symbol: i }),
|
|
1353
1426
|
isSynthetic: t,
|
|
1354
1427
|
symbol: p ? `${r}-${(p == null ? void 0 : p.toLowerCase()) ?? ""}` : i,
|
|
1355
1428
|
ticker: t ? i : r
|
|
@@ -1416,13 +1489,10 @@ class c extends Error {
|
|
|
1416
1489
|
console.error(n), super(t, { cause: { code: Tt[t], message: t } }), Object.setPrototypeOf(this, c.prototype);
|
|
1417
1490
|
}
|
|
1418
1491
|
}
|
|
1419
|
-
class
|
|
1492
|
+
class ye extends pe {
|
|
1420
1493
|
eq(t) {
|
|
1421
1494
|
return this.eqValue(t);
|
|
1422
1495
|
}
|
|
1423
|
-
toString() {
|
|
1424
|
-
return this.value;
|
|
1425
|
-
}
|
|
1426
1496
|
}
|
|
1427
1497
|
const _t = [
|
|
1428
1498
|
{
|
|
@@ -2602,7 +2672,7 @@ const _t = [
|
|
|
2602
2672
|
type: "function"
|
|
2603
2673
|
},
|
|
2604
2674
|
{ stateMutability: "payable", type: "receive" }
|
|
2605
|
-
],
|
|
2675
|
+
], gt = [
|
|
2606
2676
|
{
|
|
2607
2677
|
inputs: [
|
|
2608
2678
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2729,7 +2799,7 @@ const _t = [
|
|
|
2729
2799
|
type: "function"
|
|
2730
2800
|
},
|
|
2731
2801
|
{ stateMutability: "payable", type: "receive" }
|
|
2732
|
-
],
|
|
2802
|
+
], St = [
|
|
2733
2803
|
{
|
|
2734
2804
|
inputs: [
|
|
2735
2805
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3110,12 +3180,12 @@ const _t = [
|
|
|
3110
3180
|
type: "function"
|
|
3111
3181
|
},
|
|
3112
3182
|
{ stateMutability: "payable", type: "receive" }
|
|
3113
|
-
],
|
|
3183
|
+
], ve = {
|
|
3114
3184
|
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: _t,
|
|
3115
3185
|
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: ft,
|
|
3116
3186
|
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: bt
|
|
3117
3187
|
}, Ct = {
|
|
3118
|
-
...
|
|
3188
|
+
...ve,
|
|
3119
3189
|
// AVAX
|
|
3120
3190
|
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: wt,
|
|
3121
3191
|
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: ht,
|
|
@@ -3126,8 +3196,8 @@ const _t = [
|
|
|
3126
3196
|
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Et,
|
|
3127
3197
|
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Ot,
|
|
3128
3198
|
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: It,
|
|
3129
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3130
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3199
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: gt,
|
|
3200
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: St,
|
|
3131
3201
|
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: vt,
|
|
3132
3202
|
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: Mt
|
|
3133
3203
|
}, Nt = ({
|
|
@@ -3139,45 +3209,46 @@ const _t = [
|
|
|
3139
3209
|
amount: i,
|
|
3140
3210
|
amountOutMin: r = "",
|
|
3141
3211
|
data: p = "",
|
|
3142
|
-
deadline:
|
|
3143
|
-
memo:
|
|
3144
|
-
router:
|
|
3145
|
-
memoStreamingSwap:
|
|
3146
|
-
tcMemo:
|
|
3212
|
+
deadline: o,
|
|
3213
|
+
memo: y,
|
|
3214
|
+
router: T,
|
|
3215
|
+
memoStreamingSwap: u,
|
|
3216
|
+
tcMemo: l,
|
|
3147
3217
|
tcRouter: h,
|
|
3148
3218
|
tcVault: _,
|
|
3149
|
-
vault:
|
|
3150
|
-
token:
|
|
3219
|
+
vault: R,
|
|
3220
|
+
token: O
|
|
3151
3221
|
}
|
|
3152
3222
|
}) => {
|
|
3153
|
-
const
|
|
3154
|
-
if (
|
|
3223
|
+
const S = !!ve[t.toLowerCase()];
|
|
3224
|
+
if (S && !T)
|
|
3155
3225
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3156
|
-
const
|
|
3157
|
-
if (!_ && !
|
|
3226
|
+
const I = l || y, b = e && u || I;
|
|
3227
|
+
if (!_ && !R)
|
|
3158
3228
|
throw new Error("TC Vault is required on calldata");
|
|
3159
|
-
if (!h && !
|
|
3229
|
+
if (!h && !T)
|
|
3160
3230
|
throw new Error("TC Router is required on calldata");
|
|
3161
3231
|
if (!b)
|
|
3162
3232
|
throw new Error("TC Memo is required on calldata");
|
|
3163
|
-
if (!
|
|
3233
|
+
if (!O)
|
|
3164
3234
|
throw new Error("Token is required on calldata");
|
|
3165
3235
|
const M = [
|
|
3166
3236
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3167
|
-
a(h ||
|
|
3168
|
-
a(_ ||
|
|
3237
|
+
a(h || T),
|
|
3238
|
+
a(_ || R),
|
|
3169
3239
|
b.replace("{recipientAddress}", n),
|
|
3170
|
-
a(
|
|
3240
|
+
a(O),
|
|
3171
3241
|
i
|
|
3172
|
-
],
|
|
3173
|
-
return [...M, ...
|
|
3242
|
+
], ee = S ? [a(T), p, o] : [r, o];
|
|
3243
|
+
return [...M, ...ee];
|
|
3174
3244
|
}, xt = ({ chain: e, txHash: t }) => {
|
|
3175
|
-
const n =
|
|
3245
|
+
const n = Ee[e];
|
|
3176
3246
|
switch (e) {
|
|
3177
3247
|
case s.Binance:
|
|
3178
3248
|
case s.Bitcoin:
|
|
3179
3249
|
case s.BitcoinCash:
|
|
3180
3250
|
case s.Maya:
|
|
3251
|
+
case s.Kujira:
|
|
3181
3252
|
case s.THORChain:
|
|
3182
3253
|
return `${n}/tx/${t}`;
|
|
3183
3254
|
case s.Arbitrum:
|
|
@@ -3197,7 +3268,7 @@ const _t = [
|
|
|
3197
3268
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3198
3269
|
}
|
|
3199
3270
|
}, Dt = ({ chain: e, address: t }) => {
|
|
3200
|
-
const n =
|
|
3271
|
+
const n = Ee[e];
|
|
3201
3272
|
switch (e) {
|
|
3202
3273
|
case s.Arbitrum:
|
|
3203
3274
|
case s.Avalanche:
|
|
@@ -3210,6 +3281,7 @@ const _t = [
|
|
|
3210
3281
|
case s.Maya:
|
|
3211
3282
|
case s.Optimism:
|
|
3212
3283
|
case s.Polygon:
|
|
3284
|
+
case s.Kujira:
|
|
3213
3285
|
case s.THORChain:
|
|
3214
3286
|
return `${n}/address/${t}`;
|
|
3215
3287
|
case s.Cosmos:
|
|
@@ -3220,99 +3292,99 @@ const _t = [
|
|
|
3220
3292
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3221
3293
|
}
|
|
3222
3294
|
}, Pt = (e) => {
|
|
3223
|
-
const t = e ?
|
|
3224
|
-
return
|
|
3295
|
+
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3296
|
+
return Re(`${t}/thorchain/inbound_addresses`);
|
|
3225
3297
|
}, Bt = (e) => {
|
|
3226
|
-
const t = e ?
|
|
3227
|
-
return
|
|
3228
|
-
},
|
|
3298
|
+
const t = e ? W.ThornodeStagenet : W.ThornodeMainnet;
|
|
3299
|
+
return Re(`${t}/thorchain/mimir`);
|
|
3300
|
+
}, fe = () => Object.values(s).reduce(
|
|
3229
3301
|
(e, t) => (e[t] = null, e),
|
|
3230
3302
|
{}
|
|
3231
3303
|
);
|
|
3232
|
-
var
|
|
3304
|
+
var B, z, K, x, Y, X;
|
|
3233
3305
|
class en {
|
|
3234
3306
|
constructor({ stagenet: t } = {}) {
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3307
|
+
m(this, "connectedChains", fe());
|
|
3308
|
+
m(this, "connectedWallets", fe());
|
|
3309
|
+
m(this, "stagenet", !1);
|
|
3310
|
+
m(this, "getAddress", (t) => {
|
|
3239
3311
|
var n;
|
|
3240
3312
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3241
3313
|
});
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3314
|
+
m(this, "getExplorerTxUrl", (t, n) => xt({ chain: t, txHash: n }));
|
|
3315
|
+
m(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3316
|
+
m(this, "getExplorerAddressUrl", (t, n) => Dt({ chain: t, address: n }));
|
|
3317
|
+
m(this, "getBalance", async (t, n) => {
|
|
3246
3318
|
var i;
|
|
3247
3319
|
if (!n)
|
|
3248
3320
|
return ((i = this.connectedChains[t]) == null ? void 0 : i.balance) || [];
|
|
3249
3321
|
const a = await this.getWalletByChain(t);
|
|
3250
3322
|
return (a == null ? void 0 : a.balance) || [];
|
|
3251
3323
|
});
|
|
3252
|
-
|
|
3253
|
-
var
|
|
3324
|
+
m(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: i }) => {
|
|
3325
|
+
var o, y, T, u;
|
|
3254
3326
|
const { quoteMode: r } = a.meta, p = r.startsWith("ERC20-") ? s.Ethereum : r.startsWith("ARC20-") ? s.Avalanche : s.BinanceSmartChain;
|
|
3255
3327
|
if (!a.complete)
|
|
3256
3328
|
throw new c("core_swap_route_not_complete");
|
|
3257
3329
|
try {
|
|
3258
|
-
if (
|
|
3259
|
-
const
|
|
3260
|
-
if (!(
|
|
3330
|
+
if (Ue.includes(r)) {
|
|
3331
|
+
const l = this.connectedWallets[p];
|
|
3332
|
+
if (!(l != null && l.sendTransaction))
|
|
3261
3333
|
throw new c("core_wallet_connection_not_found");
|
|
3262
|
-
if (!(t ? (
|
|
3334
|
+
if (!(t ? (o = a == null ? void 0 : a.streamingSwap) == null ? void 0 : o.transaction : a == null ? void 0 : a.transaction))
|
|
3263
3335
|
throw new c("core_swap_route_transaction_not_found");
|
|
3264
|
-
const { isHexString: _, parseUnits:
|
|
3265
|
-
data:
|
|
3266
|
-
from:
|
|
3267
|
-
to:
|
|
3336
|
+
const { isHexString: _, parseUnits: R } = await import("./index-cf1865cd.js"), { data: O, from: S, to: I, value: b } = a.transaction, M = {
|
|
3337
|
+
data: O,
|
|
3338
|
+
from: S,
|
|
3339
|
+
to: I.toLowerCase(),
|
|
3268
3340
|
chainId: BigInt(Ke[p]),
|
|
3269
|
-
value: b ? new
|
|
3270
|
-
value: _(b) ? b :
|
|
3341
|
+
value: b ? new ye({
|
|
3342
|
+
value: _(b) ? b : R(b, "wei").toString(16)
|
|
3271
3343
|
}).baseValueBigInt : 0n
|
|
3272
3344
|
};
|
|
3273
|
-
return
|
|
3345
|
+
return l.sendTransaction(M, i);
|
|
3274
3346
|
}
|
|
3275
|
-
if (
|
|
3347
|
+
if ($e.includes(r)) {
|
|
3276
3348
|
if (!a.calldata.fromAsset)
|
|
3277
3349
|
throw new c("core_swap_asset_not_recognized");
|
|
3278
|
-
const
|
|
3279
|
-
if (!
|
|
3350
|
+
const l = await v.fromString(a.calldata.fromAsset);
|
|
3351
|
+
if (!l)
|
|
3280
3352
|
throw new c("core_swap_asset_not_recognized");
|
|
3281
|
-
const { address: h } = await A(this,
|
|
3353
|
+
const { address: h } = await A(this, B).call(this, l.chain), {
|
|
3282
3354
|
contract: _,
|
|
3283
|
-
calldata: { amountIn:
|
|
3284
|
-
} = a,
|
|
3285
|
-
return this.deposit({ assetValue:
|
|
3355
|
+
calldata: { amountIn: R, memo: O, memoStreamingSwap: S }
|
|
3356
|
+
} = a, I = l.add(ye.fromBigInt(BigInt(R), l.decimal)), b = t && S || O;
|
|
3357
|
+
return this.deposit({ assetValue: I, memo: b, feeOptionKey: i, router: _, recipient: h });
|
|
3286
3358
|
}
|
|
3287
|
-
if (
|
|
3288
|
-
const { calldata:
|
|
3359
|
+
if (He.includes(r)) {
|
|
3360
|
+
const { calldata: l, contract: h } = a;
|
|
3289
3361
|
if (!h)
|
|
3290
3362
|
throw new c("core_swap_contract_not_found");
|
|
3291
|
-
const _ = this.connectedWallets[p],
|
|
3292
|
-
if (!(_ != null && _.sendTransaction) || !
|
|
3363
|
+
const _ = this.connectedWallets[p], R = this.getAddress(p);
|
|
3364
|
+
if (!(_ != null && _.sendTransaction) || !R)
|
|
3293
3365
|
throw new c("core_wallet_connection_not_found");
|
|
3294
|
-
const { getProvider:
|
|
3366
|
+
const { getProvider: O, toChecksumAddress: S } = await import("@swapkit/toolbox-evm"), I = O(p), b = Ct[h.toLowerCase()];
|
|
3295
3367
|
if (!b)
|
|
3296
3368
|
throw new c("core_swap_contract_not_supported", { contractAddress: h });
|
|
3297
|
-
const
|
|
3298
|
-
|
|
3369
|
+
const ee = await ((u = (T = (await ((y = _.createContract) == null ? void 0 : y.call(_, h, b, I))).populateTransaction).swapIn) == null ? void 0 : u.call(
|
|
3370
|
+
T,
|
|
3299
3371
|
...Nt({
|
|
3300
3372
|
streamSwap: t,
|
|
3301
|
-
toChecksumAddress:
|
|
3373
|
+
toChecksumAddress: S,
|
|
3302
3374
|
contractAddress: h,
|
|
3303
3375
|
recipient: n,
|
|
3304
|
-
calldata:
|
|
3376
|
+
calldata: l
|
|
3305
3377
|
}),
|
|
3306
|
-
{ from:
|
|
3378
|
+
{ from: R }
|
|
3307
3379
|
));
|
|
3308
|
-
return _.sendTransaction(
|
|
3380
|
+
return _.sendTransaction(ee, i);
|
|
3309
3381
|
}
|
|
3310
3382
|
throw new c("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3311
|
-
} catch (
|
|
3312
|
-
throw new c("core_swap_transaction_error",
|
|
3383
|
+
} catch (l) {
|
|
3384
|
+
throw new c("core_swap_transaction_error", l);
|
|
3313
3385
|
}
|
|
3314
3386
|
});
|
|
3315
|
-
|
|
3387
|
+
m(this, "getWalletByChain", async (t) => {
|
|
3316
3388
|
var i, r;
|
|
3317
3389
|
const n = this.getAddress(t);
|
|
3318
3390
|
if (!n)
|
|
@@ -3326,69 +3398,69 @@ class en {
|
|
|
3326
3398
|
walletType: (r = this.connectedChains[t]) == null ? void 0 : r.walletType
|
|
3327
3399
|
}, { ...this.connectedChains[t] };
|
|
3328
3400
|
});
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3401
|
+
m(this, "approveAssetValue", (t, n) => A(this, K).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3402
|
+
m(this, "isAssetValueApproved", (t, n) => A(this, K).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3403
|
+
m(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3332
3404
|
var a, i;
|
|
3333
3405
|
return (i = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : i.call(a, t);
|
|
3334
3406
|
});
|
|
3335
|
-
|
|
3407
|
+
m(this, "transfer", async (t) => {
|
|
3336
3408
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
3337
3409
|
if (!n)
|
|
3338
3410
|
throw new c("core_wallet_connection_not_found");
|
|
3339
3411
|
try {
|
|
3340
|
-
return await n.transfer(A(this,
|
|
3412
|
+
return await n.transfer(A(this, X).call(this, t));
|
|
3341
3413
|
} catch (a) {
|
|
3342
3414
|
throw new c("core_swap_transaction_error", a);
|
|
3343
3415
|
}
|
|
3344
3416
|
});
|
|
3345
|
-
|
|
3417
|
+
m(this, "deposit", async ({
|
|
3346
3418
|
assetValue: t,
|
|
3347
3419
|
recipient: n,
|
|
3348
3420
|
router: a,
|
|
3349
3421
|
...i
|
|
3350
3422
|
}) => {
|
|
3351
|
-
const { chain: r, symbol: p, ticker:
|
|
3352
|
-
if (!
|
|
3423
|
+
const { chain: r, symbol: p, ticker: o } = t, y = this.connectedWallets[r];
|
|
3424
|
+
if (!y)
|
|
3353
3425
|
throw new c("core_wallet_connection_not_found");
|
|
3354
|
-
const
|
|
3426
|
+
const T = A(this, X).call(this, { assetValue: t, recipient: n, router: a, ...i });
|
|
3355
3427
|
try {
|
|
3356
3428
|
switch (r) {
|
|
3357
3429
|
case s.THORChain: {
|
|
3358
|
-
const
|
|
3359
|
-
return await (n === "" ?
|
|
3430
|
+
const u = y;
|
|
3431
|
+
return await (n === "" ? u.deposit(T) : u.transfer(T));
|
|
3360
3432
|
}
|
|
3361
3433
|
case s.Ethereum:
|
|
3362
3434
|
case s.BinanceSmartChain:
|
|
3363
3435
|
case s.Avalanche: {
|
|
3364
|
-
const { getChecksumAddressFromAsset:
|
|
3365
|
-
return await
|
|
3366
|
-
abi:
|
|
3367
|
-
contractAddress: a || (await A(this,
|
|
3436
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), l = r === s.Avalanche ? Be : r === s.BinanceSmartChain ? Ve : Pe;
|
|
3437
|
+
return await y.call({
|
|
3438
|
+
abi: l,
|
|
3439
|
+
contractAddress: a || (await A(this, B).call(this, r)).router,
|
|
3368
3440
|
funcName: "depositWithExpiry",
|
|
3369
3441
|
funcParams: [
|
|
3370
3442
|
n,
|
|
3371
|
-
|
|
3443
|
+
u({ chain: r, symbol: p, ticker: o }, r),
|
|
3372
3444
|
// TODO: (@Towan) Re-Check on that conversion 🙏
|
|
3373
3445
|
t.baseValueBigInt.toString(),
|
|
3374
|
-
|
|
3446
|
+
T.memo,
|
|
3375
3447
|
i.expiration
|
|
3376
3448
|
],
|
|
3377
|
-
txOverrides: { from:
|
|
3449
|
+
txOverrides: { from: T.from, value: t.baseValueBigInt }
|
|
3378
3450
|
});
|
|
3379
3451
|
}
|
|
3380
3452
|
default:
|
|
3381
|
-
return await
|
|
3453
|
+
return await y.transfer(T);
|
|
3382
3454
|
}
|
|
3383
|
-
} catch (
|
|
3384
|
-
const
|
|
3385
|
-
throw new c(
|
|
3455
|
+
} catch (u) {
|
|
3456
|
+
const l = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), h = l == null ? void 0 : l.includes("insufficient funds"), _ = l == null ? void 0 : l.includes("gas"), R = l == null ? void 0 : l.includes("server"), O = h ? "core_transaction_deposit_insufficient_funds_error" : _ ? "core_transaction_deposit_gas_error" : R ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3457
|
+
throw new c(O, u);
|
|
3386
3458
|
}
|
|
3387
3459
|
});
|
|
3388
3460
|
/**
|
|
3389
3461
|
* TC related Methods
|
|
3390
3462
|
*/
|
|
3391
|
-
|
|
3463
|
+
m(this, "createLiquidity", async ({
|
|
3392
3464
|
runeAssetValue: t,
|
|
3393
3465
|
assetValue: n
|
|
3394
3466
|
}) => {
|
|
@@ -3419,43 +3491,43 @@ class en {
|
|
|
3419
3491
|
}
|
|
3420
3492
|
return { runeTx: a, assetTx: i };
|
|
3421
3493
|
});
|
|
3422
|
-
|
|
3494
|
+
m(this, "addLiquidity", async ({
|
|
3423
3495
|
poolIdentifier: t,
|
|
3424
3496
|
runeAssetValue: n,
|
|
3425
3497
|
assetValue: a,
|
|
3426
3498
|
runeAddr: i,
|
|
3427
3499
|
assetAddr: r,
|
|
3428
3500
|
isPendingSymmAsset: p,
|
|
3429
|
-
mode:
|
|
3501
|
+
mode: o = "sym"
|
|
3430
3502
|
}) => {
|
|
3431
|
-
const [
|
|
3432
|
-
if (!
|
|
3503
|
+
const [y, ...T] = t.split("."), u = o === "sym", l = (n == null ? void 0 : n.gt(0)) && (u || o === "rune"), h = (a == null ? void 0 : a.gt(0)) && (u || o === "asset"), _ = p || l, R = _ ? i || this.getAddress(s.THORChain) : "", O = u || o === "asset" ? r || this.getAddress(y) : "";
|
|
3504
|
+
if (!l && !h)
|
|
3433
3505
|
throw new c("core_transaction_add_liquidity_invalid_params");
|
|
3434
|
-
if (_ && !
|
|
3506
|
+
if (_ && !R)
|
|
3435
3507
|
throw new c("core_transaction_add_liquidity_no_rune_address");
|
|
3436
|
-
let
|
|
3437
|
-
const b = { chain:
|
|
3438
|
-
if (
|
|
3508
|
+
let S, I;
|
|
3509
|
+
const b = { chain: y, symbol: T.join(".") };
|
|
3510
|
+
if (l && n)
|
|
3439
3511
|
try {
|
|
3440
|
-
|
|
3512
|
+
S = await A(this, x).call(this, {
|
|
3441
3513
|
assetValue: n,
|
|
3442
|
-
memo: D(f.DEPOSIT, { ...b, address:
|
|
3514
|
+
memo: D(f.DEPOSIT, { ...b, address: O })
|
|
3443
3515
|
});
|
|
3444
3516
|
} catch (M) {
|
|
3445
3517
|
throw new c("core_transaction_add_liquidity_rune_error", M);
|
|
3446
3518
|
}
|
|
3447
3519
|
if (h && a)
|
|
3448
3520
|
try {
|
|
3449
|
-
|
|
3521
|
+
I = await A(this, x).call(this, {
|
|
3450
3522
|
assetValue: a,
|
|
3451
|
-
memo: D(f.DEPOSIT, { ...b, address:
|
|
3523
|
+
memo: D(f.DEPOSIT, { ...b, address: R })
|
|
3452
3524
|
});
|
|
3453
3525
|
} catch (M) {
|
|
3454
3526
|
throw new c("core_transaction_add_liquidity_asset_error", M);
|
|
3455
3527
|
}
|
|
3456
|
-
return { runeTx:
|
|
3528
|
+
return { runeTx: S, assetTx: I };
|
|
3457
3529
|
});
|
|
3458
|
-
|
|
3530
|
+
m(this, "withdraw", async ({
|
|
3459
3531
|
memo: t,
|
|
3460
3532
|
assetValue: n,
|
|
3461
3533
|
percent: a,
|
|
@@ -3465,7 +3537,7 @@ class en {
|
|
|
3465
3537
|
const p = r === "rune" ? v.fromChainOrSignature(s.THORChain) : i === "sym" && r === "sym" || i === "rune" || i === "asset" ? void 0 : n;
|
|
3466
3538
|
try {
|
|
3467
3539
|
return await A(this, x).call(this, {
|
|
3468
|
-
assetValue:
|
|
3540
|
+
assetValue: he(i === "asset" ? n.chain : s.THORChain),
|
|
3469
3541
|
memo: t || D(f.WITHDRAW, {
|
|
3470
3542
|
symbol: n.symbol,
|
|
3471
3543
|
chain: n.chain,
|
|
@@ -3475,11 +3547,11 @@ class en {
|
|
|
3475
3547
|
singleSide: !1
|
|
3476
3548
|
})
|
|
3477
3549
|
});
|
|
3478
|
-
} catch (
|
|
3479
|
-
throw new c("core_transaction_withdraw_error",
|
|
3550
|
+
} catch (o) {
|
|
3551
|
+
throw new c("core_transaction_withdraw_error", o);
|
|
3480
3552
|
}
|
|
3481
3553
|
});
|
|
3482
|
-
|
|
3554
|
+
m(this, "savings", async ({
|
|
3483
3555
|
assetValue: t,
|
|
3484
3556
|
memo: n,
|
|
3485
3557
|
percent: a,
|
|
@@ -3494,7 +3566,7 @@ class en {
|
|
|
3494
3566
|
});
|
|
3495
3567
|
return A(this, x).call(this, { assetValue: t, memo: p });
|
|
3496
3568
|
});
|
|
3497
|
-
|
|
3569
|
+
m(this, "loan", ({
|
|
3498
3570
|
assetValue: t,
|
|
3499
3571
|
memo: n,
|
|
3500
3572
|
minAmount: a,
|
|
@@ -3507,7 +3579,7 @@ class en {
|
|
|
3507
3579
|
address: this.getAddress(t.chain)
|
|
3508
3580
|
})
|
|
3509
3581
|
}));
|
|
3510
|
-
|
|
3582
|
+
m(this, "nodeAction", ({
|
|
3511
3583
|
type: t,
|
|
3512
3584
|
assetValue: n,
|
|
3513
3585
|
address: a
|
|
@@ -3516,20 +3588,20 @@ class en {
|
|
|
3516
3588
|
address: a,
|
|
3517
3589
|
unbondAmount: t === "unbond" ? n.baseValueNumber : void 0
|
|
3518
3590
|
});
|
|
3519
|
-
return A(this,
|
|
3591
|
+
return A(this, Y).call(this, {
|
|
3520
3592
|
memo: r,
|
|
3521
|
-
assetValue: t === "bond" ? n :
|
|
3593
|
+
assetValue: t === "bond" ? n : he(s.THORChain)
|
|
3522
3594
|
});
|
|
3523
3595
|
});
|
|
3524
|
-
|
|
3596
|
+
m(this, "registerThorname", ({
|
|
3525
3597
|
assetValue: t,
|
|
3526
3598
|
...n
|
|
3527
|
-
}) => A(this,
|
|
3528
|
-
|
|
3599
|
+
}) => A(this, Y).call(this, { assetValue: t, memo: D(f.THORNAME_REGISTER, n) }));
|
|
3600
|
+
m(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: i = {} }) => {
|
|
3529
3601
|
try {
|
|
3530
3602
|
t.forEach((r) => {
|
|
3531
3603
|
this[r.connectMethodName] = r.connect({
|
|
3532
|
-
addChain: A(this,
|
|
3604
|
+
addChain: A(this, z),
|
|
3533
3605
|
config: n || {},
|
|
3534
3606
|
apis: a,
|
|
3535
3607
|
rpcUrls: i
|
|
@@ -3539,7 +3611,7 @@ class en {
|
|
|
3539
3611
|
throw new c("core_extend_error", r);
|
|
3540
3612
|
}
|
|
3541
3613
|
});
|
|
3542
|
-
|
|
3614
|
+
m(this, "estimateMaxSendableAmount", async ({
|
|
3543
3615
|
chain: t,
|
|
3544
3616
|
params: n
|
|
3545
3617
|
}) => {
|
|
@@ -3551,7 +3623,7 @@ class en {
|
|
|
3551
3623
|
case s.Ethereum:
|
|
3552
3624
|
case s.Optimism:
|
|
3553
3625
|
case s.Polygon: {
|
|
3554
|
-
const { estimateMaxSendableAmount: i } = await import("
|
|
3626
|
+
const { estimateMaxSendableAmount: i } = await import("@swapkit/toolbox-evm");
|
|
3555
3627
|
return i({
|
|
3556
3628
|
...n,
|
|
3557
3629
|
toolbox: a
|
|
@@ -3565,7 +3637,7 @@ class en {
|
|
|
3565
3637
|
case s.Binance:
|
|
3566
3638
|
case s.THORChain:
|
|
3567
3639
|
case s.Cosmos: {
|
|
3568
|
-
const { estimateMaxSendableAmount: i } = await import("
|
|
3640
|
+
const { estimateMaxSendableAmount: i } = await import("@swapkit/toolbox-cosmos");
|
|
3569
3641
|
return i({
|
|
3570
3642
|
...n,
|
|
3571
3643
|
toolbox: a
|
|
@@ -3578,34 +3650,34 @@ class en {
|
|
|
3578
3650
|
/**
|
|
3579
3651
|
* Wallet connection methods
|
|
3580
3652
|
*/
|
|
3581
|
-
|
|
3653
|
+
m(this, "connectXDEFI", async (t) => {
|
|
3582
3654
|
throw new c("core_wallet_xdefi_not_installed");
|
|
3583
3655
|
});
|
|
3584
|
-
|
|
3656
|
+
m(this, "connectEVMWallet", async (t, n) => {
|
|
3585
3657
|
throw new c("core_wallet_evmwallet_not_installed");
|
|
3586
3658
|
});
|
|
3587
|
-
|
|
3659
|
+
m(this, "connectWalletconnect", async (t, n) => {
|
|
3588
3660
|
throw new c("core_wallet_walletconnect_not_installed");
|
|
3589
3661
|
});
|
|
3590
|
-
|
|
3662
|
+
m(this, "connectKeystore", async (t, n) => {
|
|
3591
3663
|
throw new c("core_wallet_keystore_not_installed");
|
|
3592
3664
|
});
|
|
3593
|
-
|
|
3665
|
+
m(this, "connectLedger", async (t, n) => {
|
|
3594
3666
|
throw new c("core_wallet_ledger_not_installed");
|
|
3595
3667
|
});
|
|
3596
|
-
|
|
3668
|
+
m(this, "connectTrezor", async (t, n) => {
|
|
3597
3669
|
throw new c("core_wallet_trezor_not_installed");
|
|
3598
3670
|
});
|
|
3599
|
-
|
|
3671
|
+
m(this, "connectKeplr", async (t) => {
|
|
3600
3672
|
throw new c("core_wallet_keplr_not_installed");
|
|
3601
3673
|
});
|
|
3602
|
-
|
|
3674
|
+
m(this, "connectOkx", async (t) => {
|
|
3603
3675
|
throw new c("core_wallet_okx_not_installed");
|
|
3604
3676
|
});
|
|
3605
|
-
|
|
3677
|
+
m(this, "disconnectChain", (t) => {
|
|
3606
3678
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
3607
3679
|
});
|
|
3608
|
-
P(this,
|
|
3680
|
+
P(this, B, async (t) => {
|
|
3609
3681
|
if (t === s.THORChain)
|
|
3610
3682
|
return {
|
|
3611
3683
|
gas_rate: "0",
|
|
@@ -3621,25 +3693,25 @@ class en {
|
|
|
3621
3693
|
throw new c("core_chain_halted");
|
|
3622
3694
|
return a;
|
|
3623
3695
|
});
|
|
3624
|
-
P(this,
|
|
3696
|
+
P(this, z, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
3625
3697
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
3626
3698
|
});
|
|
3627
|
-
P(this,
|
|
3699
|
+
P(this, K, async ({
|
|
3628
3700
|
assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset: i, isSynthetic: r },
|
|
3629
3701
|
type: p = "checkOnly",
|
|
3630
|
-
contractAddress:
|
|
3702
|
+
contractAddress: o
|
|
3631
3703
|
}) => {
|
|
3632
|
-
const
|
|
3633
|
-
if (
|
|
3704
|
+
const y = [s.Ethereum, s.Avalanche, s.BinanceSmartChain].includes(a);
|
|
3705
|
+
if (y && i || !y || r)
|
|
3634
3706
|
return !0;
|
|
3635
|
-
const
|
|
3636
|
-
if (!
|
|
3707
|
+
const u = this.connectedWallets[a], l = p === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
|
|
3708
|
+
if (!l)
|
|
3637
3709
|
throw new c("core_wallet_connection_not_found");
|
|
3638
3710
|
const h = this.getAddress(a);
|
|
3639
3711
|
if (!n || !h)
|
|
3640
3712
|
throw new c("core_approve_asset_address_or_from_not_found");
|
|
3641
|
-
const _ =
|
|
3642
|
-
return
|
|
3713
|
+
const _ = o || (await A(this, B).call(this, a)).router;
|
|
3714
|
+
return l({
|
|
3643
3715
|
amount: t,
|
|
3644
3716
|
assetAddress: n,
|
|
3645
3717
|
from: h,
|
|
@@ -3649,28 +3721,28 @@ class en {
|
|
|
3649
3721
|
P(this, x, async ({
|
|
3650
3722
|
assetValue: t,
|
|
3651
3723
|
memo: n,
|
|
3652
|
-
feeOptionKey: a =
|
|
3724
|
+
feeOptionKey: a = k.Fast
|
|
3653
3725
|
}) => {
|
|
3654
3726
|
const {
|
|
3655
3727
|
gas_rate: i,
|
|
3656
3728
|
router: r,
|
|
3657
3729
|
address: p
|
|
3658
|
-
} = await A(this,
|
|
3730
|
+
} = await A(this, B).call(this, t.chain), o = (parseInt(i) || 0) * st[a];
|
|
3659
3731
|
return this.deposit({
|
|
3660
3732
|
assetValue: t,
|
|
3661
3733
|
recipient: p,
|
|
3662
3734
|
memo: n,
|
|
3663
3735
|
router: r,
|
|
3664
|
-
feeRate:
|
|
3736
|
+
feeRate: o
|
|
3665
3737
|
});
|
|
3666
3738
|
});
|
|
3667
|
-
P(this,
|
|
3739
|
+
P(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
3668
3740
|
const a = await Bt(this.stagenet);
|
|
3669
3741
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
3670
3742
|
throw new c("core_chain_halted");
|
|
3671
3743
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
3672
3744
|
});
|
|
3673
|
-
P(this,
|
|
3745
|
+
P(this, X, ({ assetValue: t, ...n }) => ({
|
|
3674
3746
|
...n,
|
|
3675
3747
|
memo: n.memo || "",
|
|
3676
3748
|
from: this.getAddress(t.chain),
|
|
@@ -3679,65 +3751,66 @@ class en {
|
|
|
3679
3751
|
this.stagenet = !!t;
|
|
3680
3752
|
}
|
|
3681
3753
|
}
|
|
3682
|
-
|
|
3754
|
+
B = new WeakMap(), z = new WeakMap(), K = new WeakMap(), x = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
|
|
3683
3755
|
export {
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3756
|
+
Ue as AGG_SWAP,
|
|
3757
|
+
Ae as ApiError,
|
|
3758
|
+
W as ApiUrl,
|
|
3687
3759
|
v as AssetValue,
|
|
3688
3760
|
E as BaseDecimal,
|
|
3761
|
+
pe as BigIntArithmetics,
|
|
3689
3762
|
s as Chain,
|
|
3690
|
-
|
|
3691
|
-
|
|
3763
|
+
le as ChainId,
|
|
3764
|
+
Gt as ChainIdToChain,
|
|
3692
3765
|
Ke as ChainToChainId,
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
F as FeeOption,
|
|
3766
|
+
Ee as ChainToExplorerUrl,
|
|
3767
|
+
Ft as ChainToHexChainId,
|
|
3768
|
+
Ye as ChainToRPC,
|
|
3769
|
+
Ge as ContractAddress,
|
|
3770
|
+
kt as CosmosChainList,
|
|
3771
|
+
We as DerivationPath,
|
|
3772
|
+
d as ERROR_CODE,
|
|
3773
|
+
ke as ERROR_MODULE,
|
|
3774
|
+
be as ERROR_TYPE,
|
|
3775
|
+
Ht as EVMChainList,
|
|
3776
|
+
Xe as ErrorCode,
|
|
3777
|
+
k as FeeOption,
|
|
3706
3778
|
f as MemoType,
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
$e as
|
|
3712
|
-
ke as SWAP_OUT,
|
|
3779
|
+
Ut as NetworkDerivationPath,
|
|
3780
|
+
Le as QuoteMode,
|
|
3781
|
+
we as RPCUrl,
|
|
3782
|
+
He as SWAP_IN,
|
|
3783
|
+
$e as SWAP_OUT,
|
|
3713
3784
|
en as SwapKitCore,
|
|
3714
3785
|
c as SwapKitError,
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3786
|
+
ye as SwapKitNumber,
|
|
3787
|
+
Be as TCAvalancheDepositABI,
|
|
3788
|
+
Ve as TCBscDepositABI,
|
|
3789
|
+
Pe as TCEthereumVaultAbi,
|
|
3790
|
+
$t as UTXOChainList,
|
|
3791
|
+
je as WalletOption,
|
|
3792
|
+
Yt as assetFromString,
|
|
3793
|
+
Kt as derivationPathToString,
|
|
3723
3794
|
Lt as erc20ABI,
|
|
3795
|
+
Xt as filterAssets,
|
|
3724
3796
|
ge as formatBigIntToSafeValue,
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3797
|
+
st as gasFeeMultiplier,
|
|
3798
|
+
pt as getAssetType,
|
|
3799
|
+
ut as getAsymmetricAssetShare,
|
|
3728
3800
|
Qt as getAsymmetricAssetWithdrawAmount,
|
|
3729
|
-
|
|
3801
|
+
dt as getAsymmetricRuneShare,
|
|
3730
3802
|
jt as getAsymmetricRuneWithdrawAmount,
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3803
|
+
rt as getCommonAssetInfo,
|
|
3804
|
+
Ie as getDecimal,
|
|
3805
|
+
zt as getEstimatedPoolShare,
|
|
3734
3806
|
Zt as getLiquiditySlippage,
|
|
3735
3807
|
D as getMemoFor,
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3808
|
+
he as getMinAmountByChain,
|
|
3809
|
+
Re as getRequest,
|
|
3810
|
+
yt as getSymmetricPoolShare,
|
|
3811
|
+
Jt as getSymmetricWithdraw,
|
|
3812
|
+
Wt as getTHORNameCost,
|
|
3813
|
+
it as isGasAsset,
|
|
3814
|
+
Ze as postRequest,
|
|
3815
|
+
qt as validateTHORName
|
|
3743
3816
|
};
|