@swapkit/core 1.0.0-rc.77 → 1.0.0-rc.79
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.cjs.map +1 -1
- package/dist/index.es.js +538 -521
- package/dist/index.es.js.map +1 -1
- package/package.json +11 -11
- package/src/client/index.ts +31 -4
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var T = (e, t, n) => (
|
|
1
|
+
var We = Object.defineProperty;
|
|
2
|
+
var je = (e, t, n) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var T = (e, t, n) => (je(e, typeof t != "symbol" ? t + "" : t, n), n), Ke = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var b = (e, t, n) => (Ke(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, Ye = (e, t, n) => t in e ? Xe(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
13
|
const fn = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
@@ -108,7 +108,7 @@ const fn = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Je = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const fn = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Qe = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const fn = [
|
|
|
447
447
|
stateMutability: "view",
|
|
448
448
|
type: "function"
|
|
449
449
|
}
|
|
450
|
-
],
|
|
450
|
+
], ze = [
|
|
451
451
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
452
452
|
{
|
|
453
453
|
anonymous: !1,
|
|
@@ -600,13 +600,13 @@ const fn = [
|
|
|
600
600
|
type: "function"
|
|
601
601
|
}
|
|
602
602
|
];
|
|
603
|
-
var
|
|
604
|
-
const
|
|
603
|
+
var Ze = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(Ze || {});
|
|
604
|
+
const et = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], tt = [
|
|
610
610
|
"ERC20-TC",
|
|
611
611
|
"ERC20-ARC20",
|
|
612
612
|
"ERC20-BEP20",
|
|
@@ -617,80 +617,80 @@ const Ze = [
|
|
|
617
617
|
"BEP20-ERC20",
|
|
618
618
|
"BEP20-ARC20"
|
|
619
619
|
/* BSC_TO_AVAX */
|
|
620
|
-
],
|
|
620
|
+
], nt = [
|
|
621
621
|
"TC-TC",
|
|
622
622
|
"TC-ERC20",
|
|
623
623
|
"TC-ARC20",
|
|
624
624
|
"TC-BEP20"
|
|
625
625
|
/* TC_SUPPORTED_TO_BSC */
|
|
626
626
|
];
|
|
627
|
-
var
|
|
628
|
-
const
|
|
629
|
-
[
|
|
630
|
-
[
|
|
631
|
-
[
|
|
632
|
-
[
|
|
633
|
-
[
|
|
634
|
-
[
|
|
635
|
-
[
|
|
636
|
-
[
|
|
637
|
-
[
|
|
638
|
-
[
|
|
639
|
-
[
|
|
640
|
-
[
|
|
641
|
-
[
|
|
642
|
-
[
|
|
643
|
-
[
|
|
644
|
-
[
|
|
645
|
-
[
|
|
646
|
-
[
|
|
647
|
-
[
|
|
648
|
-
[
|
|
649
|
-
[
|
|
650
|
-
[
|
|
651
|
-
[
|
|
652
|
-
[
|
|
653
|
-
[
|
|
654
|
-
[
|
|
655
|
-
[
|
|
656
|
-
[
|
|
657
|
-
[
|
|
658
|
-
[
|
|
659
|
-
[
|
|
660
|
-
[
|
|
661
|
-
[
|
|
662
|
-
[
|
|
663
|
-
[
|
|
664
|
-
[
|
|
665
|
-
[
|
|
666
|
-
[
|
|
667
|
-
[
|
|
668
|
-
[
|
|
669
|
-
[
|
|
670
|
-
[
|
|
671
|
-
[
|
|
672
|
-
[
|
|
673
|
-
[
|
|
674
|
-
[
|
|
675
|
-
[
|
|
676
|
-
[
|
|
677
|
-
[
|
|
678
|
-
[
|
|
627
|
+
var ve = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(ve || {}), at = /* @__PURE__ */ ((e) => (e.HEALTH_CONTROLLER = "1000", e.LIQUIDITY_CONTROLLER = "1001", e.PROVIDER_CONTROLLER = "1002", e.QUOTE_CONTROLLER = "1003", e.SWAP_CONTROLLER = "1004", e.UTIL_CONTROLLER = "1005", e.AIRDROP_CONTROLLER = "1006", e.PROVIDER = "2000", e.ASSET = "2001", e.TOKEN_LIST = "2002", e.QUOTE = "2100", e.QUOTE_TXN_DETAILS = "2101", e.THORCHAIN_PROVIDER = "3000", e.UNISWAPV2_ETH_PROVIDER = "3001", e.UNISWAPV3_ETH_PROVIDER = "3002", e.SUSHISWAP_ETH_PROVIDER = "3003", e.PANCAKESWAP_BSC_PROVIDER = "3004", e.PANCAKESWAP_ETH_PROVIDER = "3005", e.ONEINCH_ETH_PROVIDER = "3006", e.ONEINCH_BSC_PROVIDER = "3007", e.ONEINCH_AVAX_PROVIDER = "3008", e.ZEROX_ETH_PROVIDER = "3009", e.WOOFI_AVAX_PROVIDER = "3010", e.PANGOLIN_AVAX_PROVIDER = "3011", e.TRADERJOE_AVAX_PROVIDER = "3012", e.KYBER_ETH_PROVIDER = "3013", e.KYBER_AVAX_PROVIDER = "3014", e.WOOFI_BSC_PROVIDER = "3015", e.STARGATE_PROVIDER = "3016", e.PROVIDER_UTIL = "4000", e.TXN_DETAILS = "5000", e.AIRDROP_UTIL = "6000", e))(at || {}), l = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_MAX_500 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(l || {});
|
|
628
|
+
const st = {
|
|
629
|
+
[l.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
|
+
[l.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
|
+
[l.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
632
|
+
[l.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
|
|
633
|
+
[l.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
|
|
634
|
+
[l.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
|
|
635
|
+
[l.INVALID_TYPE_GENERIC]: "Invalid type",
|
|
636
|
+
[l.INVALID_NUMBER_STRING]: "Invalid number string.",
|
|
637
|
+
[l.INVALID_NUMBER]: "Invalid number.",
|
|
638
|
+
[l.INVALID_BOOLEAN]: "Invalid boolean.",
|
|
639
|
+
[l.INVALID_OBJECT]: "Invalid object.",
|
|
640
|
+
[l.INVALID_ARRAY]: "Invalid array.",
|
|
641
|
+
[l.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
|
|
642
|
+
[l.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
|
|
643
|
+
[l.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
|
|
644
|
+
[l.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
|
|
645
|
+
[l.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
|
|
646
|
+
[l.AFF_BPS_INTEGER_MAX_500]: "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_PROVIDER_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
679
|
}, pe = (e, t) => {
|
|
680
|
-
let n =
|
|
680
|
+
let n = st[e];
|
|
681
681
|
for (let a = 0; a < t.length; a++)
|
|
682
682
|
n = n.replace(`{${a}}`, t[a]);
|
|
683
683
|
return t.length === 0 ? n.replace("{0}", "") : n;
|
|
684
684
|
};
|
|
685
|
-
let bn = class
|
|
685
|
+
let bn = class Ce extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
689
689
|
module: a,
|
|
690
690
|
code: s,
|
|
691
691
|
message: r,
|
|
692
|
-
type:
|
|
693
|
-
options: { shouldLog:
|
|
692
|
+
type: p,
|
|
693
|
+
options: { shouldLog: o, shouldThrow: d, shouldTrace: y } = {
|
|
694
694
|
shouldLog: !0,
|
|
695
695
|
shouldThrow: !0,
|
|
696
696
|
shouldTrace: !0
|
|
@@ -698,14 +698,14 @@ let bn = class ve extends Error {
|
|
|
698
698
|
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
700
|
const m = r || pe(s, u || []) || "";
|
|
701
|
-
super(m), 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 = m, this.display = pe(s, u || []), this.code = s, this.type =
|
|
702
|
-
shouldLog:
|
|
703
|
-
shouldTrace:
|
|
701
|
+
super(m), 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 = m, this.display = pe(s, u || []), this.code = s, this.type = p || ve.UNHANDLED_ERROR, this.options = {
|
|
702
|
+
shouldLog: o || !0,
|
|
703
|
+
shouldTrace: y || !0,
|
|
704
704
|
shouldThrow: d || !1
|
|
705
705
|
}, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
707
707
|
static fromErrorInfo(t) {
|
|
708
|
-
return new
|
|
708
|
+
return new Ce(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -724,7 +724,7 @@ let bn = class ve extends Error {
|
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
726
|
};
|
|
727
|
-
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}),
|
|
727
|
+
var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), it = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(it || {}), rt = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(rt || {});
|
|
728
728
|
const wn = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
@@ -742,8 +742,8 @@ const wn = {
|
|
|
742
742
|
OP: [44, 60, 0, 0, 0],
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
|
-
var
|
|
746
|
-
const
|
|
745
|
+
var w = /* @__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))(w || {});
|
|
746
|
+
const ot = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
749
749
|
"BSC",
|
|
@@ -775,20 +775,20 @@ const rt = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var _e = /* @__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))(_e || {}),
|
|
779
|
-
const
|
|
778
|
+
var _e = /* @__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))(_e || {}), Me = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Me || {}), K = /* @__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.net", e.ThorswapStatic = "https://static.thorswap.net", e))(K || {});
|
|
779
|
+
const re = Object.values(i), pt = Object.keys(i), fe = re.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
|
-
const n =
|
|
781
|
+
const n = pt.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
785
|
+
), dt = re.reduce(
|
|
786
786
|
(e, t) => (e[t] = _e[fe[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), ut = re.reduce(
|
|
789
|
+
(e, t) => (e[t] = Me[fe[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
), gn =
|
|
791
|
+
), gn = re.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
793
|
const n = `${fe[t]}Hex`;
|
|
794
794
|
return e[t] = _e[n], e;
|
|
@@ -819,7 +819,7 @@ const ie = Object.values(i), ot = Object.keys(i), fe = ie.reduce(
|
|
|
819
819
|
"thorchain-stagenet-v2": "THOR",
|
|
820
820
|
"thorchain-mainnet-v1": "THOR"
|
|
821
821
|
/* THORChain */
|
|
822
|
-
},
|
|
822
|
+
}, Ne = {
|
|
823
823
|
ARB: "https://arbiscan.io",
|
|
824
824
|
AVAX: "https://snowtrace.io",
|
|
825
825
|
BSC: "https://bscscan.com",
|
|
@@ -836,17 +836,17 @@ const ie = Object.values(i), ot = Object.keys(i), fe = ie.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://runescan.io"
|
|
838
838
|
};
|
|
839
|
-
var
|
|
839
|
+
var lt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(lt || {}), _ = /* @__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))(_ || {}), G = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(G || {}), yt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.OKX_MOBILE = "OKX_MOBILE", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(yt || {}), ct = Object.defineProperty, mt = (e, t, n) => t in e ? ct(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, S = (e, t, n) => (mt(e, typeof t != "symbol" ? t + "" : t, n), n), Tt = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
|
-
},
|
|
842
|
+
}, k = (e, t, n) => {
|
|
843
843
|
if (t.has(e))
|
|
844
844
|
throw TypeError("Cannot add the same private member more than once");
|
|
845
845
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
846
|
-
},
|
|
847
|
-
const
|
|
846
|
+
}, g = (e, t, n) => (Tt(e, t, "access private method"), n);
|
|
847
|
+
const ht = "0x313ce567", xe = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await we.post(
|
|
849
|
+
const { result: n } = await we.post(ut[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -856,37 +856,37 @@ const Tt = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
856
856
|
id: 44,
|
|
857
857
|
jsonrpc: "2.0",
|
|
858
858
|
method: "eth_call",
|
|
859
|
-
params: [{ to: t.toLowerCase(), data:
|
|
859
|
+
params: [{ to: t.toLowerCase(), data: ht }, "latest"]
|
|
860
860
|
})
|
|
861
861
|
});
|
|
862
862
|
return parseInt(BigInt(n).toString());
|
|
863
863
|
} catch (n) {
|
|
864
|
-
return console.error(n),
|
|
864
|
+
return console.error(n), w[e];
|
|
865
865
|
}
|
|
866
|
-
},
|
|
866
|
+
}, _t = async (e) => {
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
|
-
return
|
|
868
|
+
return w.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
|
-
return t != null && t.startsWith("0x") ?
|
|
871
|
-
},
|
|
870
|
+
return t != null && t.startsWith("0x") ? xe({ chain: i.Ethereum, to: t }) : w.ETH;
|
|
871
|
+
}, ft = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ?
|
|
874
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? xe({ chain: i.Avalanche, to: t.toLowerCase() }) : w.AVAX;
|
|
874
|
+
}, bt = async (e) => (e === i.BinanceSmartChain, w.BSC), wt = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
|
-
return ht(t);
|
|
878
|
-
case i.Avalanche:
|
|
879
877
|
return _t(t);
|
|
880
|
-
case i.
|
|
878
|
+
case i.Avalanche:
|
|
881
879
|
return ft(t);
|
|
880
|
+
case i.BinanceSmartChain:
|
|
881
|
+
return bt(t);
|
|
882
882
|
default:
|
|
883
|
-
return
|
|
883
|
+
return w[e];
|
|
884
884
|
}
|
|
885
|
-
},
|
|
886
|
-
[
|
|
887
|
-
[
|
|
888
|
-
[
|
|
889
|
-
},
|
|
885
|
+
}, At = {
|
|
886
|
+
[G.Average]: 1.2,
|
|
887
|
+
[G.Fast]: 1.5,
|
|
888
|
+
[G.Fastest]: 2
|
|
889
|
+
}, De = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case i.Bitcoin:
|
|
892
892
|
case i.BitcoinCash:
|
|
@@ -912,20 +912,20 @@ const Tt = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
912
912
|
case i.THORChain:
|
|
913
913
|
return t === "RUNE";
|
|
914
914
|
}
|
|
915
|
-
},
|
|
915
|
+
}, Et = (e) => {
|
|
916
916
|
switch (e) {
|
|
917
917
|
case "ETH.THOR":
|
|
918
918
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
919
919
|
case "ETH.vTHOR":
|
|
920
920
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
921
921
|
case i.Cosmos:
|
|
922
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
922
|
+
return { identifier: "GAIA.ATOM", decimal: w[e] };
|
|
923
923
|
case i.THORChain:
|
|
924
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
924
|
+
return { identifier: "THOR.RUNE", decimal: w[e] };
|
|
925
925
|
case i.BinanceSmartChain:
|
|
926
|
-
return { identifier: "BSC.BNB", decimal:
|
|
926
|
+
return { identifier: "BSC.BNB", decimal: w[e] };
|
|
927
927
|
case i.Maya:
|
|
928
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
928
|
+
return { identifier: "MAYA.CACAO", decimal: w.MAYA };
|
|
929
929
|
case "MAYA.MAYA":
|
|
930
930
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
931
931
|
case i.Kujira:
|
|
@@ -939,9 +939,9 @@ const Tt = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
939
939
|
case i.Polygon:
|
|
940
940
|
case i.Bitcoin:
|
|
941
941
|
case i.Ethereum:
|
|
942
|
-
return { identifier: `${e}.${e}`, decimal:
|
|
942
|
+
return { identifier: `${e}.${e}`, decimal: w[e] };
|
|
943
943
|
}
|
|
944
|
-
},
|
|
944
|
+
}, Rt = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
946
946
|
return "Synth";
|
|
947
947
|
switch (e) {
|
|
@@ -973,35 +973,35 @@ const Tt = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
973
973
|
}
|
|
974
974
|
}, In = (e) => {
|
|
975
975
|
var t;
|
|
976
|
-
const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."),
|
|
977
|
-
return { chain: n, symbol: r, ticker:
|
|
978
|
-
},
|
|
976
|
+
const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."), p = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
977
|
+
return { chain: n, symbol: r, ticker: p, synth: s };
|
|
978
|
+
}, gt = new RegExp(
|
|
979
979
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
980
|
"gmi"
|
|
981
|
-
),
|
|
981
|
+
), Ot = (e) => {
|
|
982
982
|
const [t, n] = e.split(".");
|
|
983
|
-
if (!
|
|
983
|
+
if (!ot.includes(t))
|
|
984
984
|
return !0;
|
|
985
985
|
const [, a] = n.split("-");
|
|
986
|
-
return
|
|
986
|
+
return De({ chain: t, symbol: n }) || !!a;
|
|
987
987
|
}, Sn = (e) => e.filter((t) => {
|
|
988
988
|
const n = `${t.chain}.${t.symbol}`;
|
|
989
|
-
return !
|
|
989
|
+
return !gt.test(n) && Ot(n) && t.value !== "0";
|
|
990
990
|
});
|
|
991
|
-
function
|
|
991
|
+
function It({
|
|
992
992
|
liquidityUnits: e,
|
|
993
993
|
poolUnits: t,
|
|
994
994
|
runeDepth: n
|
|
995
995
|
}) {
|
|
996
|
-
const a =
|
|
997
|
-
return
|
|
996
|
+
const a = I(e), s = I(t), r = I(n), p = a.mul(r), o = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = s.mul(s).mul(s);
|
|
997
|
+
return p.mul(o.sub(d).add(y)).div(u);
|
|
998
998
|
}
|
|
999
|
-
function
|
|
999
|
+
function St({
|
|
1000
1000
|
liquidityUnits: e,
|
|
1001
1001
|
poolUnits: t,
|
|
1002
1002
|
assetDepth: n
|
|
1003
1003
|
}) {
|
|
1004
|
-
const a =
|
|
1004
|
+
const a = I(e), s = I(t), r = I(n), p = a.mul(r), o = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = p.mul(o.sub(d).add(y)), m = s.mul(s).mul(s);
|
|
1005
1005
|
return u.div(m);
|
|
1006
1006
|
}
|
|
1007
1007
|
function vn({
|
|
@@ -1010,7 +1010,7 @@ function vn({
|
|
|
1010
1010
|
liquidityUnits: n,
|
|
1011
1011
|
poolUnits: a
|
|
1012
1012
|
}) {
|
|
1013
|
-
return
|
|
1013
|
+
return It({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1014
1014
|
}
|
|
1015
1015
|
function Cn({
|
|
1016
1016
|
percent: e,
|
|
@@ -1018,20 +1018,20 @@ function Cn({
|
|
|
1018
1018
|
liquidityUnits: n,
|
|
1019
1019
|
poolUnits: a
|
|
1020
1020
|
}) {
|
|
1021
|
-
return
|
|
1021
|
+
return St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1022
1022
|
}
|
|
1023
|
-
function
|
|
1024
|
-
return
|
|
1023
|
+
function I(e) {
|
|
1024
|
+
return D.fromBigInt(BigInt(e), w.THOR);
|
|
1025
1025
|
}
|
|
1026
|
-
function
|
|
1026
|
+
function vt({
|
|
1027
1027
|
liquidityUnits: e,
|
|
1028
1028
|
poolUnits: t,
|
|
1029
1029
|
runeDepth: n,
|
|
1030
1030
|
assetDepth: a
|
|
1031
1031
|
}) {
|
|
1032
1032
|
return {
|
|
1033
|
-
assetAmount:
|
|
1034
|
-
runeAmount:
|
|
1033
|
+
assetAmount: I(a).mul(e).div(t),
|
|
1034
|
+
runeAmount: I(n).mul(e).div(t)
|
|
1035
1035
|
};
|
|
1036
1036
|
}
|
|
1037
1037
|
function Mn({
|
|
@@ -1042,8 +1042,8 @@ function Mn({
|
|
|
1042
1042
|
percent: s
|
|
1043
1043
|
}) {
|
|
1044
1044
|
return Object.fromEntries(
|
|
1045
|
-
Object.entries(
|
|
1046
|
-
([r,
|
|
1045
|
+
Object.entries(vt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1046
|
+
([r, p]) => [r, p.mul(s)]
|
|
1047
1047
|
)
|
|
1048
1048
|
);
|
|
1049
1049
|
}
|
|
@@ -1055,11 +1055,11 @@ function Nn({
|
|
|
1055
1055
|
runeAmount: s,
|
|
1056
1056
|
assetAmount: r
|
|
1057
1057
|
}) {
|
|
1058
|
-
const
|
|
1059
|
-
if (
|
|
1060
|
-
return
|
|
1061
|
-
const
|
|
1062
|
-
return
|
|
1058
|
+
const p = new D({ value: e, decimal: 8 }), o = new D({ value: n, decimal: 8 }), d = new D({ value: t, decimal: 8 }), y = new D({ value: s, decimal: 8 }), u = new D({ value: r, decimal: 8 }), m = y.mul(o), h = u.mul(p), f = y.mul(u), A = p.mul(o), E = d.mul(m.add(h.add(f.mul(2)))), O = m.add(h.add(A.mul(2))), R = E.div(O), x = I(a).add(R);
|
|
1059
|
+
if (R.getBaseValue("number") === 0)
|
|
1060
|
+
return x.div(d).getBaseValue("number");
|
|
1061
|
+
const $ = d.add(x);
|
|
1062
|
+
return x.div($).getBaseValue("number");
|
|
1063
1063
|
}
|
|
1064
1064
|
function xn({
|
|
1065
1065
|
runeAmount: e,
|
|
@@ -1069,28 +1069,28 @@ function xn({
|
|
|
1069
1069
|
}) {
|
|
1070
1070
|
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1071
1071
|
return 0;
|
|
1072
|
-
const s =
|
|
1073
|
-
return Math.abs(d.div(
|
|
1072
|
+
const s = I(n), r = I(a), p = I(t), o = I(e), d = p.mul(s).sub(r.mul(o)), y = r.mul(o).add(s.mul(r));
|
|
1073
|
+
return Math.abs(d.div(y).getBaseValue("number"));
|
|
1074
1074
|
}
|
|
1075
1075
|
const M = (e, t) => {
|
|
1076
1076
|
switch (e) {
|
|
1077
|
-
case
|
|
1078
|
-
case
|
|
1077
|
+
case _.LEAVE:
|
|
1078
|
+
case _.BOND: {
|
|
1079
1079
|
const { address: n } = t;
|
|
1080
1080
|
return `${e}:${n}`;
|
|
1081
1081
|
}
|
|
1082
|
-
case
|
|
1082
|
+
case _.UNBOND: {
|
|
1083
1083
|
const { address: n, unbondAmount: a } = t;
|
|
1084
1084
|
return `${e}:${n}:${a}`;
|
|
1085
1085
|
}
|
|
1086
|
-
case
|
|
1086
|
+
case _.THORNAME_REGISTER: {
|
|
1087
1087
|
const { name: n, chain: a, address: s, owner: r } = t;
|
|
1088
1088
|
return `${e}:${n}:${a}:${s}${r ? `:${r}` : ""}`;
|
|
1089
1089
|
}
|
|
1090
|
-
case
|
|
1090
|
+
case _.DEPOSIT: {
|
|
1091
1091
|
const { chain: n, symbol: a, address: s, singleSide: r } = t;
|
|
1092
|
-
return r ? `${e}:${n}/${a}::t:0` : `${e}:${((
|
|
1093
|
-
switch (
|
|
1092
|
+
return r ? `${e}:${n}/${a}::t:0` : `${e}:${((p, o) => {
|
|
1093
|
+
switch (p) {
|
|
1094
1094
|
case i.Litecoin:
|
|
1095
1095
|
return "l";
|
|
1096
1096
|
case i.Dogecoin:
|
|
@@ -1098,16 +1098,16 @@ const M = (e, t) => {
|
|
|
1098
1098
|
case i.BitcoinCash:
|
|
1099
1099
|
return "c";
|
|
1100
1100
|
default:
|
|
1101
|
-
return `${
|
|
1101
|
+
return `${p}.${o}`;
|
|
1102
1102
|
}
|
|
1103
1103
|
})(n, a)}:${s || ""}:t:0`;
|
|
1104
1104
|
}
|
|
1105
|
-
case
|
|
1106
|
-
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString:
|
|
1107
|
-
return `${e}:${n}${
|
|
1105
|
+
case _.WITHDRAW: {
|
|
1106
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: p, singleSide: o } = t, d = n === "ETH" && a !== "ETH" ? `${a}-${s.slice(-3)}` : s, y = !o && p ? `:${p}` : "";
|
|
1107
|
+
return `${e}:${n}${o ? "/" : "."}${d}:${r}${y}`;
|
|
1108
1108
|
}
|
|
1109
|
-
case
|
|
1110
|
-
case
|
|
1109
|
+
case _.OPEN_LOAN:
|
|
1110
|
+
case _.CLOSE_LOAN: {
|
|
1111
1111
|
const { asset: n, address: a } = t;
|
|
1112
1112
|
return `${e}:${n}:${a}`;
|
|
1113
1113
|
}
|
|
@@ -1131,8 +1131,8 @@ function Bn([e, t, n, a, s]) {
|
|
|
1131
1131
|
}
|
|
1132
1132
|
class Ae extends Error {
|
|
1133
1133
|
constructor(t, n, a) {
|
|
1134
|
-
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "",
|
|
1135
|
-
super(`Request failed with ${
|
|
1134
|
+
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", p = `${s} ${r}`.trim(), o = p ? `status code ${p}` : "an unknown error";
|
|
1135
|
+
super(`Request failed with ${o}`), Object.defineProperty(this, "response", {
|
|
1136
1136
|
enumerable: !0,
|
|
1137
1137
|
configurable: !0,
|
|
1138
1138
|
writable: !0,
|
|
@@ -1150,7 +1150,7 @@ class Ae extends Error {
|
|
|
1150
1150
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
|
-
class
|
|
1153
|
+
class Pe extends Error {
|
|
1154
1154
|
constructor(t) {
|
|
1155
1155
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1156
1156
|
enumerable: !0,
|
|
@@ -1160,28 +1160,28 @@ class De extends Error {
|
|
|
1160
1160
|
}), this.name = "TimeoutError", this.request = t;
|
|
1161
1161
|
}
|
|
1162
1162
|
}
|
|
1163
|
-
const
|
|
1163
|
+
const Z = (e) => e !== null && typeof e == "object", z = (...e) => {
|
|
1164
1164
|
for (const t of e)
|
|
1165
|
-
if ((!
|
|
1165
|
+
if ((!Z(t) || Array.isArray(t)) && t !== void 0)
|
|
1166
1166
|
throw new TypeError("The `options` argument must be an object");
|
|
1167
1167
|
return be({}, ...e);
|
|
1168
|
-
},
|
|
1168
|
+
}, Be = (e = {}, t = {}) => {
|
|
1169
1169
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1170
|
-
for (const [r,
|
|
1171
|
-
a &&
|
|
1170
|
+
for (const [r, p] of s.entries())
|
|
1171
|
+
a && p === "undefined" || p === void 0 ? n.delete(r) : n.set(r, p);
|
|
1172
1172
|
return n;
|
|
1173
1173
|
}, be = (...e) => {
|
|
1174
1174
|
let t = {}, n = {};
|
|
1175
1175
|
for (const a of e)
|
|
1176
1176
|
if (Array.isArray(a))
|
|
1177
1177
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1178
|
-
else if (
|
|
1178
|
+
else if (Z(a)) {
|
|
1179
1179
|
for (let [s, r] of Object.entries(a))
|
|
1180
|
-
|
|
1181
|
-
|
|
1180
|
+
Z(r) && s in t && (r = be(t[s], r)), t = { ...t, [s]: r };
|
|
1181
|
+
Z(a.headers) && (n = Be(n, a.headers), t.headers = n);
|
|
1182
1182
|
}
|
|
1183
1183
|
return t;
|
|
1184
|
-
},
|
|
1184
|
+
}, Ct = (() => {
|
|
1185
1185
|
let e = !1, t = !1;
|
|
1186
1186
|
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1187
1187
|
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
@@ -1192,13 +1192,13 @@ const z = (e) => e !== null && typeof e == "object", Q = (...e) => {
|
|
|
1192
1192
|
return e = !0, "half";
|
|
1193
1193
|
}
|
|
1194
1194
|
}).headers.has("Content-Type")), e && !t;
|
|
1195
|
-
})(),
|
|
1195
|
+
})(), Mt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", xt = typeof globalThis.FormData == "function", Le = ["get", "post", "put", "patch", "head", "delete"], Dt = {
|
|
1196
1196
|
json: "application/json",
|
|
1197
1197
|
text: "text/*",
|
|
1198
1198
|
formData: "multipart/form-data",
|
|
1199
1199
|
arrayBuffer: "*/*",
|
|
1200
1200
|
blob: "*/*"
|
|
1201
|
-
}, de = 2147483647,
|
|
1201
|
+
}, de = 2147483647, Ve = Symbol("stop"), Pt = {
|
|
1202
1202
|
json: !0,
|
|
1203
1203
|
parseJson: !0,
|
|
1204
1204
|
searchParams: !0,
|
|
@@ -1209,7 +1209,7 @@ const z = (e) => e !== null && typeof e == "object", Q = (...e) => {
|
|
|
1209
1209
|
throwHttpErrors: !0,
|
|
1210
1210
|
onDownloadProgress: !0,
|
|
1211
1211
|
fetch: !0
|
|
1212
|
-
},
|
|
1212
|
+
}, Bt = {
|
|
1213
1213
|
method: !0,
|
|
1214
1214
|
headers: !0,
|
|
1215
1215
|
body: !0,
|
|
@@ -1225,15 +1225,15 @@ const z = (e) => e !== null && typeof e == "object", Q = (...e) => {
|
|
|
1225
1225
|
window: !0,
|
|
1226
1226
|
dispatcher: !0,
|
|
1227
1227
|
duplex: !0
|
|
1228
|
-
},
|
|
1228
|
+
}, Lt = (e) => Le.includes(e) ? e.toUpperCase() : e, Vt = ["get", "put", "head", "delete", "options", "trace"], Ut = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], Ee = {
|
|
1229
1229
|
limit: 2,
|
|
1230
|
-
methods:
|
|
1231
|
-
statusCodes:
|
|
1232
|
-
afterStatusCodes:
|
|
1230
|
+
methods: Vt,
|
|
1231
|
+
statusCodes: Ut,
|
|
1232
|
+
afterStatusCodes: Ue,
|
|
1233
1233
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1234
1234
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1235
1235
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1236
|
-
},
|
|
1236
|
+
}, Ht = (e = {}) => {
|
|
1237
1237
|
if (typeof e == "number")
|
|
1238
1238
|
return {
|
|
1239
1239
|
...Ee,
|
|
@@ -1246,20 +1246,20 @@ const z = (e) => e !== null && typeof e == "object", Q = (...e) => {
|
|
|
1246
1246
|
return {
|
|
1247
1247
|
...Ee,
|
|
1248
1248
|
...e,
|
|
1249
|
-
afterStatusCodes:
|
|
1249
|
+
afterStatusCodes: Ue
|
|
1250
1250
|
};
|
|
1251
1251
|
};
|
|
1252
|
-
async function
|
|
1252
|
+
async function $t(e, t, n, a) {
|
|
1253
1253
|
return new Promise((s, r) => {
|
|
1254
|
-
const
|
|
1255
|
-
n && n.abort(), r(new
|
|
1254
|
+
const p = setTimeout(() => {
|
|
1255
|
+
n && n.abort(), r(new Pe(e));
|
|
1256
1256
|
}, a.timeout);
|
|
1257
1257
|
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1258
|
-
clearTimeout(
|
|
1258
|
+
clearTimeout(p);
|
|
1259
1259
|
});
|
|
1260
1260
|
});
|
|
1261
1261
|
}
|
|
1262
|
-
async function
|
|
1262
|
+
async function kt(e, { signal: t }) {
|
|
1263
1263
|
return new Promise((n, a) => {
|
|
1264
1264
|
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
|
|
1265
1265
|
function s() {
|
|
@@ -1270,49 +1270,49 @@ async function $t(e, { signal: t }) {
|
|
|
1270
1270
|
}, e);
|
|
1271
1271
|
});
|
|
1272
1272
|
}
|
|
1273
|
-
const
|
|
1273
|
+
const Ft = (e, t) => {
|
|
1274
1274
|
const n = {};
|
|
1275
1275
|
for (const a in t)
|
|
1276
|
-
!(a in
|
|
1276
|
+
!(a in Bt) && !(a in Pt) && !(a in e) && (n[a] = t[a]);
|
|
1277
1277
|
return n;
|
|
1278
1278
|
};
|
|
1279
|
-
class
|
|
1279
|
+
class ne {
|
|
1280
1280
|
static create(t, n) {
|
|
1281
|
-
const a = new
|
|
1281
|
+
const a = new ne(t, n), s = async () => {
|
|
1282
1282
|
if (typeof a._options.timeout == "number" && a._options.timeout > de)
|
|
1283
1283
|
throw new RangeError(`The \`timeout\` option cannot be greater than ${de}`);
|
|
1284
1284
|
await Promise.resolve();
|
|
1285
|
-
let
|
|
1286
|
-
for (const
|
|
1287
|
-
const d = await
|
|
1288
|
-
d instanceof globalThis.Response && (
|
|
1285
|
+
let p = await a._fetch();
|
|
1286
|
+
for (const o of a._options.hooks.afterResponse) {
|
|
1287
|
+
const d = await o(a.request, a._options, a._decorateResponse(p.clone()));
|
|
1288
|
+
d instanceof globalThis.Response && (p = d);
|
|
1289
1289
|
}
|
|
1290
|
-
if (a._decorateResponse(
|
|
1291
|
-
let
|
|
1290
|
+
if (a._decorateResponse(p), !p.ok && a._options.throwHttpErrors) {
|
|
1291
|
+
let o = new Ae(p, a.request, a._options);
|
|
1292
1292
|
for (const d of a._options.hooks.beforeError)
|
|
1293
|
-
|
|
1294
|
-
throw
|
|
1293
|
+
o = await d(o);
|
|
1294
|
+
throw o;
|
|
1295
1295
|
}
|
|
1296
1296
|
if (a._options.onDownloadProgress) {
|
|
1297
1297
|
if (typeof a._options.onDownloadProgress != "function")
|
|
1298
1298
|
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
1299
|
-
if (!
|
|
1299
|
+
if (!Nt)
|
|
1300
1300
|
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1301
|
-
return a._stream(
|
|
1301
|
+
return a._stream(p.clone(), a._options.onDownloadProgress);
|
|
1302
1302
|
}
|
|
1303
|
-
return
|
|
1303
|
+
return p;
|
|
1304
1304
|
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
|
|
1305
|
-
for (const [
|
|
1306
|
-
r[
|
|
1307
|
-
a.request.headers.set("accept", a.request.headers.get("accept") ||
|
|
1305
|
+
for (const [p, o] of Object.entries(Dt))
|
|
1306
|
+
r[p] = async () => {
|
|
1307
|
+
a.request.headers.set("accept", a.request.headers.get("accept") || o);
|
|
1308
1308
|
const d = (await r).clone();
|
|
1309
|
-
if (
|
|
1309
|
+
if (p === "json") {
|
|
1310
1310
|
if (d.status === 204 || (await d.clone().arrayBuffer()).byteLength === 0)
|
|
1311
1311
|
return "";
|
|
1312
1312
|
if (n.parseJson)
|
|
1313
1313
|
return n.parseJson(await d.text());
|
|
1314
1314
|
}
|
|
1315
|
-
return d[
|
|
1315
|
+
return d[p]();
|
|
1316
1316
|
};
|
|
1317
1317
|
return r;
|
|
1318
1318
|
}
|
|
@@ -1347,17 +1347,17 @@ class te {
|
|
|
1347
1347
|
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1348
1348
|
credentials: this._input.credentials || "same-origin",
|
|
1349
1349
|
...n,
|
|
1350
|
-
headers:
|
|
1350
|
+
headers: Be(this._input.headers, n.headers),
|
|
1351
1351
|
hooks: be({
|
|
1352
1352
|
beforeRequest: [],
|
|
1353
1353
|
beforeRetry: [],
|
|
1354
1354
|
beforeError: [],
|
|
1355
1355
|
afterResponse: []
|
|
1356
1356
|
}, n.hooks),
|
|
1357
|
-
method:
|
|
1357
|
+
method: Lt(n.method ?? this._input.method),
|
|
1358
1358
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1359
1359
|
prefixUrl: String(n.prefixUrl || ""),
|
|
1360
|
-
retry:
|
|
1360
|
+
retry: Ht(n.retry),
|
|
1361
1361
|
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1362
1362
|
timeout: n.timeout ?? 1e4,
|
|
1363
1363
|
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
@@ -1368,7 +1368,7 @@ class te {
|
|
|
1368
1368
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1369
1369
|
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1370
1370
|
}
|
|
1371
|
-
if (
|
|
1371
|
+
if (Mt) {
|
|
1372
1372
|
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1373
1373
|
const a = this._options.signal;
|
|
1374
1374
|
this._options.signal.addEventListener("abort", () => {
|
|
@@ -1377,14 +1377,14 @@ class te {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
this._options.signal = this.abortController.signal;
|
|
1379
1379
|
}
|
|
1380
|
-
if (
|
|
1380
|
+
if (Ct && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1381
1381
|
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1382
|
-
(
|
|
1382
|
+
(xt && 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);
|
|
1383
1383
|
}
|
|
1384
1384
|
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 }));
|
|
1385
1385
|
}
|
|
1386
1386
|
_calculateRetryDelay(t) {
|
|
1387
|
-
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof
|
|
1387
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof Pe)) {
|
|
1388
1388
|
if (t instanceof Ae) {
|
|
1389
1389
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1390
1390
|
return 0;
|
|
@@ -1410,14 +1410,14 @@ class te {
|
|
|
1410
1410
|
} catch (n) {
|
|
1411
1411
|
const a = Math.min(this._calculateRetryDelay(n), de);
|
|
1412
1412
|
if (a !== 0 && this._retryCount > 0) {
|
|
1413
|
-
await
|
|
1413
|
+
await kt(a, { signal: this._options.signal });
|
|
1414
1414
|
for (const s of this._options.hooks.beforeRetry)
|
|
1415
1415
|
if (await s({
|
|
1416
1416
|
request: this.request,
|
|
1417
1417
|
options: this._options,
|
|
1418
1418
|
error: n,
|
|
1419
1419
|
retryCount: this._retryCount
|
|
1420
|
-
}) ===
|
|
1420
|
+
}) === Ve)
|
|
1421
1421
|
return;
|
|
1422
1422
|
return this._retry(t);
|
|
1423
1423
|
}
|
|
@@ -1434,8 +1434,8 @@ class te {
|
|
|
1434
1434
|
if (a instanceof Response)
|
|
1435
1435
|
return a;
|
|
1436
1436
|
}
|
|
1437
|
-
const t =
|
|
1438
|
-
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) :
|
|
1437
|
+
const t = Ft(this.request, this._options);
|
|
1438
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : $t(this.request.clone(), t, this.abortController, this._options);
|
|
1439
1439
|
}
|
|
1440
1440
|
/* istanbul ignore next */
|
|
1441
1441
|
_stream(t, n) {
|
|
@@ -1447,22 +1447,22 @@ class te {
|
|
|
1447
1447
|
headers: t.headers
|
|
1448
1448
|
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
1449
1449
|
async start(r) {
|
|
1450
|
-
const
|
|
1450
|
+
const p = t.body.getReader();
|
|
1451
1451
|
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1452
|
-
async function
|
|
1453
|
-
const { done: d, value:
|
|
1452
|
+
async function o() {
|
|
1453
|
+
const { done: d, value: y } = await p.read();
|
|
1454
1454
|
if (d) {
|
|
1455
1455
|
r.close();
|
|
1456
1456
|
return;
|
|
1457
1457
|
}
|
|
1458
1458
|
if (n) {
|
|
1459
|
-
s +=
|
|
1459
|
+
s += y.byteLength;
|
|
1460
1460
|
const u = a === 0 ? 0 : s / a;
|
|
1461
|
-
n({ percent: u, transferredBytes: s, totalBytes: a },
|
|
1461
|
+
n({ percent: u, transferredBytes: s, totalBytes: a }, y);
|
|
1462
1462
|
}
|
|
1463
|
-
r.enqueue(
|
|
1463
|
+
r.enqueue(y), await o();
|
|
1464
1464
|
}
|
|
1465
|
-
await
|
|
1465
|
+
await o();
|
|
1466
1466
|
}
|
|
1467
1467
|
}), {
|
|
1468
1468
|
status: t.status,
|
|
@@ -1473,15 +1473,15 @@ class te {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
/*! MIT License © Sindre Sorhus */
|
|
1475
1475
|
const ce = (e) => {
|
|
1476
|
-
const t = (n, a) =>
|
|
1477
|
-
for (const n of
|
|
1478
|
-
t[n] = (a, s) =>
|
|
1479
|
-
return t.create = (n) => ce(
|
|
1480
|
-
},
|
|
1476
|
+
const t = (n, a) => ne.create(n, z(e, a));
|
|
1477
|
+
for (const n of Le)
|
|
1478
|
+
t[n] = (a, s) => ne.create(a, z(e, s, { method: n }));
|
|
1479
|
+
return t.create = (n) => ce(z(n)), t.extend = (n) => ce(z(e, n)), t.stop = Ve, t;
|
|
1480
|
+
}, Gt = ce(), qt = Gt, Wt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Re = qt.create({ headers: Wt }), we = {
|
|
1481
1481
|
get: (e, t) => Re.get(e, t).json(),
|
|
1482
1482
|
post: (e, t) => Re.post(e, t).json()
|
|
1483
1483
|
}, ge = [...Object.values(i), "TERRA"];
|
|
1484
|
-
function
|
|
1484
|
+
function jt(e = "") {
|
|
1485
1485
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1486
1486
|
if (ge.includes(n))
|
|
1487
1487
|
return !0;
|
|
@@ -1492,11 +1492,11 @@ function Wt(e = "") {
|
|
|
1492
1492
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1493
1493
|
);
|
|
1494
1494
|
}
|
|
1495
|
-
const
|
|
1496
|
-
function
|
|
1495
|
+
const X = 8, L = (e) => 10n ** BigInt(e), q = (e) => Math.log10(parseFloat(e.toString()));
|
|
1496
|
+
function oe({
|
|
1497
1497
|
value: e,
|
|
1498
|
-
bigIntDecimal: t =
|
|
1499
|
-
decimal: n =
|
|
1498
|
+
bigIntDecimal: t = X,
|
|
1499
|
+
decimal: n = X
|
|
1500
1500
|
}) {
|
|
1501
1501
|
if (n === 0)
|
|
1502
1502
|
return e.toString();
|
|
@@ -1504,24 +1504,24 @@ function re({
|
|
|
1504
1504
|
let s = e.toString().substring(a ? 1 : 0);
|
|
1505
1505
|
const r = n - (s.length - 1);
|
|
1506
1506
|
r > 0 && (s = "0".repeat(r) + s);
|
|
1507
|
-
const
|
|
1508
|
-
let
|
|
1509
|
-
return parseInt(
|
|
1507
|
+
const p = s.length - n;
|
|
1508
|
+
let o = s.slice(-n);
|
|
1509
|
+
return parseInt(o[t]) >= 5 ? o = `${o.substring(0, t - 1)}${(parseInt(o[t - 1]) + 1).toString()}` : o = o.substring(0, t), `${a ? "-" : ""}${s.slice(0, p)}.${o}`.replace(
|
|
1510
1510
|
/\.?0*$/,
|
|
1511
1511
|
""
|
|
1512
1512
|
);
|
|
1513
1513
|
}
|
|
1514
|
-
var U,
|
|
1515
|
-
const
|
|
1514
|
+
var U, F, B, H, me, He, ee, ue, ae, Te;
|
|
1515
|
+
const Kt = class $e {
|
|
1516
1516
|
constructor(t) {
|
|
1517
|
-
|
|
1517
|
+
k(this, U), k(this, B), k(this, me), k(this, ee), k(this, ae), S(this, "decimalMultiplier", 10n ** 8n), S(this, "bigIntValue", 0n), S(this, "decimal");
|
|
1518
1518
|
const n = he(t), a = typeof t == "object";
|
|
1519
|
-
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(
|
|
1519
|
+
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(Fe(se(n)), this.decimal || 0)), g(this, me, He).call(this, n);
|
|
1520
1520
|
}
|
|
1521
1521
|
static fromBigInt(t, n) {
|
|
1522
|
-
return new
|
|
1522
|
+
return new $e({
|
|
1523
1523
|
decimal: n,
|
|
1524
|
-
value:
|
|
1524
|
+
value: oe({ value: t, bigIntDecimal: n, decimal: n })
|
|
1525
1525
|
});
|
|
1526
1526
|
}
|
|
1527
1527
|
static shiftDecimals({
|
|
@@ -1538,37 +1538,37 @@ const jt = class He {
|
|
|
1538
1538
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1539
1539
|
}
|
|
1540
1540
|
add(...t) {
|
|
1541
|
-
return
|
|
1541
|
+
return g(this, U, F).call(this, "add", ...t);
|
|
1542
1542
|
}
|
|
1543
1543
|
sub(...t) {
|
|
1544
|
-
return
|
|
1544
|
+
return g(this, U, F).call(this, "sub", ...t);
|
|
1545
1545
|
}
|
|
1546
1546
|
mul(...t) {
|
|
1547
|
-
return
|
|
1547
|
+
return g(this, U, F).call(this, "mul", ...t);
|
|
1548
1548
|
}
|
|
1549
1549
|
div(...t) {
|
|
1550
|
-
return
|
|
1550
|
+
return g(this, U, F).call(this, "div", ...t);
|
|
1551
1551
|
}
|
|
1552
1552
|
gt(t) {
|
|
1553
|
-
return
|
|
1553
|
+
return g(this, B, H).call(this, "gt", t);
|
|
1554
1554
|
}
|
|
1555
1555
|
gte(t) {
|
|
1556
|
-
return
|
|
1556
|
+
return g(this, B, H).call(this, "gte", t);
|
|
1557
1557
|
}
|
|
1558
1558
|
lt(t) {
|
|
1559
|
-
return
|
|
1559
|
+
return g(this, B, H).call(this, "lt", t);
|
|
1560
1560
|
}
|
|
1561
1561
|
lte(t) {
|
|
1562
|
-
return
|
|
1562
|
+
return g(this, B, H).call(this, "lte", t);
|
|
1563
1563
|
}
|
|
1564
1564
|
eqValue(t) {
|
|
1565
|
-
return
|
|
1565
|
+
return g(this, B, H).call(this, "eqValue", t);
|
|
1566
1566
|
}
|
|
1567
1567
|
// @ts-expect-error False positive
|
|
1568
1568
|
getValue(t) {
|
|
1569
1569
|
const n = this.formatBigIntToSafeValue(
|
|
1570
1570
|
this.bigIntValue,
|
|
1571
|
-
this.decimal ||
|
|
1571
|
+
this.decimal || q(this.decimalMultiplier)
|
|
1572
1572
|
);
|
|
1573
1573
|
switch (t) {
|
|
1574
1574
|
case "number":
|
|
@@ -1581,7 +1581,7 @@ const jt = class He {
|
|
|
1581
1581
|
}
|
|
1582
1582
|
// @ts-expect-error
|
|
1583
1583
|
getBaseValue(t) {
|
|
1584
|
-
const n = this.decimalMultiplier / L(this.decimal ||
|
|
1584
|
+
const n = this.decimalMultiplier / L(this.decimal || w.THOR), a = this.bigIntValue / n;
|
|
1585
1585
|
switch (t) {
|
|
1586
1586
|
case "number":
|
|
1587
1587
|
return Number(a);
|
|
@@ -1594,8 +1594,8 @@ const jt = class He {
|
|
|
1594
1594
|
getBigIntValue(t, n) {
|
|
1595
1595
|
if (!n && typeof t == "object")
|
|
1596
1596
|
return t.bigIntValue;
|
|
1597
|
-
const a = he(t), s =
|
|
1598
|
-
return s === "0" || s === "undefined" ? 0n :
|
|
1597
|
+
const a = he(t), s = se(a);
|
|
1598
|
+
return s === "0" || s === "undefined" ? 0n : g(this, ae, Te).call(this, s, n);
|
|
1599
1599
|
}
|
|
1600
1600
|
toSignificant(t = 6) {
|
|
1601
1601
|
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
@@ -1608,9 +1608,9 @@ const jt = class He {
|
|
|
1608
1608
|
t - s.length,
|
|
1609
1609
|
"0"
|
|
1610
1610
|
);
|
|
1611
|
-
const
|
|
1612
|
-
return `0.${
|
|
1613
|
-
r.length - `${
|
|
1611
|
+
const p = parseInt(r), o = `${p}`.slice(0, t);
|
|
1612
|
+
return `0.${o.padStart(
|
|
1613
|
+
r.length - `${p}`.length + o.length,
|
|
1614
1614
|
"0"
|
|
1615
1615
|
)}`;
|
|
1616
1616
|
}
|
|
@@ -1618,9 +1618,9 @@ const jt = class He {
|
|
|
1618
1618
|
const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
|
|
1619
1619
|
if (parseInt(s))
|
|
1620
1620
|
return `${s}.${r.slice(0, t)}`.padEnd(t, "0");
|
|
1621
|
-
const
|
|
1622
|
-
return `0.${
|
|
1623
|
-
r.length - `${
|
|
1621
|
+
const p = parseInt(r), o = `${p}`.slice(0, t);
|
|
1622
|
+
return `0.${o.padStart(
|
|
1623
|
+
r.length - `${p}`.length + o.length,
|
|
1624
1624
|
"0"
|
|
1625
1625
|
)}`;
|
|
1626
1626
|
}
|
|
@@ -1628,8 +1628,8 @@ const jt = class He {
|
|
|
1628
1628
|
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];
|
|
1629
1629
|
if (!r)
|
|
1630
1630
|
return this.getValue("string");
|
|
1631
|
-
const
|
|
1632
|
-
return `${(n /
|
|
1631
|
+
const p = 10 ** (s * 3);
|
|
1632
|
+
return `${(n / p).toFixed(t)}${r}`;
|
|
1633
1633
|
}
|
|
1634
1634
|
toCurrency(t = "$", {
|
|
1635
1635
|
currencyPosition: n = "start",
|
|
@@ -1637,44 +1637,44 @@ const jt = class He {
|
|
|
1637
1637
|
decimalSeparator: s = ".",
|
|
1638
1638
|
thousandSeparator: r = ","
|
|
1639
1639
|
} = {}) {
|
|
1640
|
-
const
|
|
1640
|
+
const p = this.getValue("number"), [o, d = ""] = p.toFixed(6).split("."), y = o.replace(/\B(?=(\d{3})+(?!\d))/g, r), u = !o && !d ? "0.00" : o === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${y}${parseInt(d) ? `${s}${d.slice(0, a)}` : ""}`;
|
|
1641
1641
|
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1642
1642
|
}
|
|
1643
1643
|
formatBigIntToSafeValue(t, n) {
|
|
1644
|
-
const a = n || this.decimal ||
|
|
1644
|
+
const a = n || this.decimal || X, s = Math.max(
|
|
1645
1645
|
a,
|
|
1646
|
-
|
|
1647
|
-
), r = t < 0n,
|
|
1646
|
+
q(this.decimalMultiplier)
|
|
1647
|
+
), r = t < 0n, p = t.toString().substring(r ? 1 : 0), o = s - (p.length - 1), d = o > 0 ? "0".repeat(o) + p : p, y = d.length - s;
|
|
1648
1648
|
let u = d.slice(-s);
|
|
1649
1649
|
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(
|
|
1650
1650
|
0,
|
|
1651
|
-
|
|
1651
|
+
y
|
|
1652
1652
|
)}.${u}`.replace(/\.?0*$/, "");
|
|
1653
1653
|
}
|
|
1654
1654
|
};
|
|
1655
|
-
U = /* @__PURE__ */ new WeakSet(),
|
|
1656
|
-
const n =
|
|
1657
|
-
(
|
|
1658
|
-
const
|
|
1655
|
+
U = /* @__PURE__ */ new WeakSet(), F = function(e, ...t) {
|
|
1656
|
+
const n = g(this, ee, ue).call(this, this, ...t), a = Math.max(n, q(this.decimalMultiplier)), s = L(a), r = t.reduce(
|
|
1657
|
+
(o, d) => {
|
|
1658
|
+
const y = this.getBigIntValue(d, a);
|
|
1659
1659
|
switch (e) {
|
|
1660
1660
|
case "add":
|
|
1661
|
-
return
|
|
1661
|
+
return o + y;
|
|
1662
1662
|
case "sub":
|
|
1663
|
-
return
|
|
1663
|
+
return o - y;
|
|
1664
1664
|
case "mul":
|
|
1665
|
-
return
|
|
1665
|
+
return o * y / s;
|
|
1666
1666
|
case "div": {
|
|
1667
|
-
if (
|
|
1667
|
+
if (y === 0n)
|
|
1668
1668
|
throw new RangeError("Division by zero");
|
|
1669
|
-
return
|
|
1669
|
+
return o * s / y;
|
|
1670
1670
|
}
|
|
1671
1671
|
default:
|
|
1672
|
-
return
|
|
1672
|
+
return o;
|
|
1673
1673
|
}
|
|
1674
1674
|
},
|
|
1675
1675
|
//normalize is to precision multiplier base
|
|
1676
1676
|
this.bigIntValue * s / this.decimalMultiplier
|
|
1677
|
-
),
|
|
1677
|
+
), p = oe({
|
|
1678
1678
|
bigIntDecimal: a,
|
|
1679
1679
|
decimal: a,
|
|
1680
1680
|
value: r
|
|
@@ -1682,11 +1682,11 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1682
1682
|
return new this.constructor({
|
|
1683
1683
|
decimalMultiplier: L(a),
|
|
1684
1684
|
decimal: this.decimal,
|
|
1685
|
-
value:
|
|
1685
|
+
value: p,
|
|
1686
1686
|
identifier: this.toString()
|
|
1687
1687
|
});
|
|
1688
1688
|
}, B = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
|
|
1689
|
-
const n =
|
|
1689
|
+
const n = g(this, ee, ue).call(this, this, ...t), a = this.getBigIntValue(t[0], n), s = this.getBigIntValue(this, n);
|
|
1690
1690
|
switch (e) {
|
|
1691
1691
|
case "gt":
|
|
1692
1692
|
return s > a;
|
|
@@ -1699,46 +1699,46 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1699
1699
|
case "eqValue":
|
|
1700
1700
|
return s === a;
|
|
1701
1701
|
}
|
|
1702
|
-
}, me = /* @__PURE__ */ new WeakSet(),
|
|
1703
|
-
const t =
|
|
1704
|
-
this.bigIntValue =
|
|
1705
|
-
},
|
|
1706
|
-
const t = e.map((n) => typeof n == "object" ? n.decimal ||
|
|
1707
|
-
return Math.max(...t,
|
|
1708
|
-
},
|
|
1709
|
-
const n = t ? L(t) : this.decimalMultiplier, a =
|
|
1702
|
+
}, me = /* @__PURE__ */ new WeakSet(), He = function(e) {
|
|
1703
|
+
const t = se(e) || "0";
|
|
1704
|
+
this.bigIntValue = g(this, ae, Te).call(this, t);
|
|
1705
|
+
}, ee = /* @__PURE__ */ new WeakSet(), ue = function(...e) {
|
|
1706
|
+
const t = e.map((n) => typeof n == "object" ? n.decimal || q(n.decimalMultiplier) : Fe(se(n))).filter(Boolean);
|
|
1707
|
+
return Math.max(...t, X);
|
|
1708
|
+
}, ae = /* @__PURE__ */ new WeakSet(), Te = function(e, t) {
|
|
1709
|
+
const n = t ? L(t) : this.decimalMultiplier, a = q(n), [s = "", r = ""] = e.split(".");
|
|
1710
1710
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1711
1711
|
};
|
|
1712
|
-
let
|
|
1713
|
-
const
|
|
1712
|
+
let ke = Kt;
|
|
1713
|
+
const Xt = Intl.NumberFormat("fullwide", {
|
|
1714
1714
|
useGrouping: !1,
|
|
1715
1715
|
maximumFractionDigits: 20
|
|
1716
1716
|
});
|
|
1717
|
-
function
|
|
1718
|
-
const t = `${typeof e == "number" ?
|
|
1717
|
+
function se(e) {
|
|
1718
|
+
const t = `${typeof e == "number" ? Xt.format(e) : he(e)}`.replaceAll(",", ".").split(".");
|
|
1719
1719
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1720
1720
|
}
|
|
1721
|
-
function
|
|
1721
|
+
function Fe(e) {
|
|
1722
1722
|
var t;
|
|
1723
1723
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1724
|
-
return Math.max(n,
|
|
1724
|
+
return Math.max(n, X);
|
|
1725
1725
|
}
|
|
1726
1726
|
function he(e) {
|
|
1727
1727
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1728
1728
|
}
|
|
1729
|
-
const
|
|
1730
|
-
class N extends
|
|
1729
|
+
const W = /* @__PURE__ */ new Map();
|
|
1730
|
+
class N extends ke {
|
|
1731
1731
|
constructor({
|
|
1732
1732
|
value: t,
|
|
1733
1733
|
decimal: n,
|
|
1734
1734
|
tax: a,
|
|
1735
1735
|
chain: s,
|
|
1736
1736
|
symbol: r,
|
|
1737
|
-
identifier:
|
|
1737
|
+
identifier: p
|
|
1738
1738
|
}) {
|
|
1739
1739
|
super(typeof t == "object" ? t : { decimal: n, value: t }), S(this, "address"), S(this, "chain"), S(this, "isGasAsset", !1), S(this, "isSynthetic", !1), S(this, "symbol"), S(this, "tax"), S(this, "ticker"), S(this, "type");
|
|
1740
|
-
const
|
|
1741
|
-
this.type =
|
|
1740
|
+
const o = te(p || `${s}.${r}`);
|
|
1741
|
+
this.type = Rt(o), this.tax = a, this.chain = o.chain, this.ticker = o.ticker, this.symbol = o.symbol, this.address = o.address, this.isSynthetic = o.isSynthetic, this.isGasAsset = o.isGasAsset;
|
|
1742
1742
|
}
|
|
1743
1743
|
toString() {
|
|
1744
1744
|
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
@@ -1756,8 +1756,8 @@ class N extends $e {
|
|
|
1756
1756
|
const [a, s, r] = t.split(".");
|
|
1757
1757
|
if (!a || !s)
|
|
1758
1758
|
throw new Error("Invalid asset url");
|
|
1759
|
-
const
|
|
1760
|
-
return ye(
|
|
1759
|
+
const p = a === i.THORChain && r ? `${a}.${s}/${r}` : t;
|
|
1760
|
+
return ye(p, n);
|
|
1761
1761
|
}
|
|
1762
1762
|
static fromString(t, n = 0) {
|
|
1763
1763
|
return ye(t, n);
|
|
@@ -1766,33 +1766,33 @@ class N extends $e {
|
|
|
1766
1766
|
return ye(t, n);
|
|
1767
1767
|
}
|
|
1768
1768
|
static fromStringSync(t, n = 0) {
|
|
1769
|
-
const { chain: a, isSynthetic: s } =
|
|
1769
|
+
const { chain: a, isSynthetic: s } = te(t), r = W.get(t.toUpperCase());
|
|
1770
1770
|
if (s)
|
|
1771
1771
|
return Oe(t, n);
|
|
1772
|
-
const { tax:
|
|
1773
|
-
decimal:
|
|
1772
|
+
const { tax: p, decimal: o, identifier: d } = r || {
|
|
1773
|
+
decimal: w[a],
|
|
1774
1774
|
identifier: t
|
|
1775
1775
|
};
|
|
1776
1776
|
return new N({
|
|
1777
|
-
tax:
|
|
1778
|
-
value:
|
|
1777
|
+
tax: p,
|
|
1778
|
+
value: j(n, o),
|
|
1779
1779
|
identifier: s ? t : d,
|
|
1780
|
-
decimal: s ? 8 :
|
|
1780
|
+
decimal: s ? 8 : o
|
|
1781
1781
|
});
|
|
1782
1782
|
}
|
|
1783
1783
|
static fromIdentifierSync(t, n = 0) {
|
|
1784
|
-
const { chain: a, isSynthetic: s } =
|
|
1784
|
+
const { chain: a, isSynthetic: s } = te(t), r = W.get(t);
|
|
1785
1785
|
if (s)
|
|
1786
1786
|
return Oe(t, n);
|
|
1787
|
-
const { tax:
|
|
1788
|
-
decimal:
|
|
1787
|
+
const { tax: p, decimal: o, identifier: d } = r || {
|
|
1788
|
+
decimal: w[a],
|
|
1789
1789
|
identifier: t
|
|
1790
1790
|
};
|
|
1791
|
-
return new N({ tax:
|
|
1791
|
+
return new N({ tax: p, decimal: o, identifier: d, value: j(n, o) });
|
|
1792
1792
|
}
|
|
1793
1793
|
static fromChainOrSignature(t, n = 0) {
|
|
1794
|
-
const { decimal: a, identifier: s } =
|
|
1795
|
-
return new N({ value:
|
|
1794
|
+
const { decimal: a, identifier: s } = Et(t);
|
|
1795
|
+
return new N({ value: j(n, a), decimal: a, identifier: s });
|
|
1796
1796
|
}
|
|
1797
1797
|
static loadStaticAssets() {
|
|
1798
1798
|
return new Promise(
|
|
@@ -1801,10 +1801,10 @@ class N extends $e {
|
|
|
1801
1801
|
const a = await import("@swapkit/tokens");
|
|
1802
1802
|
Object.values(a).forEach((s) => {
|
|
1803
1803
|
var r;
|
|
1804
|
-
(r = s == null ? void 0 : s.tokens) == null || r.forEach(({ identifier:
|
|
1805
|
-
|
|
1806
|
-
identifier:
|
|
1807
|
-
decimal: "decimals" in d ? d.decimals :
|
|
1804
|
+
(r = s == null ? void 0 : s.tokens) == null || r.forEach(({ identifier: p, chain: o, ...d }) => {
|
|
1805
|
+
W.set(p.toUpperCase(), {
|
|
1806
|
+
identifier: p,
|
|
1807
|
+
decimal: "decimals" in d ? d.decimals : w[o]
|
|
1808
1808
|
});
|
|
1809
1809
|
});
|
|
1810
1810
|
}), t({ ok: !0 });
|
|
@@ -1841,9 +1841,9 @@ function le(e) {
|
|
|
1841
1841
|
}
|
|
1842
1842
|
}
|
|
1843
1843
|
async function ye(e, t = 0) {
|
|
1844
|
-
|
|
1845
|
-
const n =
|
|
1846
|
-
return n ||
|
|
1844
|
+
jt(e);
|
|
1845
|
+
const n = W.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await wt(te(e));
|
|
1846
|
+
return n || W.set(e.toUpperCase(), { identifier: e, decimal: a }), new N({ decimal: a, value: j(t, a), identifier: e });
|
|
1847
1847
|
}
|
|
1848
1848
|
function Oe(e, t = 0) {
|
|
1849
1849
|
const [n, a] = e.split(".")[0].toUpperCase() === i.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
@@ -1851,28 +1851,28 @@ function Oe(e, t = 0) {
|
|
|
1851
1851
|
throw new Error("Invalid asset identifier");
|
|
1852
1852
|
return new N({
|
|
1853
1853
|
decimal: 8,
|
|
1854
|
-
value:
|
|
1854
|
+
value: j(t, 8),
|
|
1855
1855
|
identifier: `${i.THORChain}.${n}/${a}`
|
|
1856
1856
|
});
|
|
1857
1857
|
}
|
|
1858
|
-
function
|
|
1859
|
-
return typeof e == "bigint" ?
|
|
1858
|
+
function j(e, t) {
|
|
1859
|
+
return typeof e == "bigint" ? oe({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1860
1860
|
}
|
|
1861
|
-
function
|
|
1861
|
+
function te(e) {
|
|
1862
1862
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".")[0].toUpperCase() === i.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1863
1863
|
if (t && (!n || !a))
|
|
1864
1864
|
throw new Error("Invalid asset identifier");
|
|
1865
|
-
const s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r,
|
|
1865
|
+
const s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, p] = s.split("."), [o, d] = (t ? a : p).split("-");
|
|
1866
1866
|
return {
|
|
1867
1867
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1868
1868
|
chain: r,
|
|
1869
|
-
isGasAsset:
|
|
1869
|
+
isGasAsset: De({ chain: r, symbol: p }),
|
|
1870
1870
|
isSynthetic: t,
|
|
1871
|
-
symbol: (t ? `${n}/` : "") + (d ? `${
|
|
1872
|
-
ticker:
|
|
1871
|
+
symbol: (t ? `${n}/` : "") + (d ? `${o}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : p),
|
|
1872
|
+
ticker: o
|
|
1873
1873
|
};
|
|
1874
1874
|
}
|
|
1875
|
-
const
|
|
1875
|
+
const Yt = {
|
|
1876
1876
|
/**
|
|
1877
1877
|
* Core
|
|
1878
1878
|
*/
|
|
@@ -1932,21 +1932,21 @@ const Xt = {
|
|
|
1932
1932
|
};
|
|
1933
1933
|
class c extends Error {
|
|
1934
1934
|
constructor(t, n) {
|
|
1935
|
-
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code:
|
|
1935
|
+
console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Yt[t], message: t } }), Object.setPrototypeOf(this, c.prototype);
|
|
1936
1936
|
}
|
|
1937
1937
|
}
|
|
1938
|
-
class
|
|
1938
|
+
class D extends ke {
|
|
1939
1939
|
eq(t) {
|
|
1940
1940
|
return this.eqValue(t);
|
|
1941
1941
|
}
|
|
1942
1942
|
static fromBigInt(t, n) {
|
|
1943
|
-
return new
|
|
1943
|
+
return new D({
|
|
1944
1944
|
decimal: n,
|
|
1945
|
-
value:
|
|
1945
|
+
value: oe({ value: t, bigIntDecimal: n, decimal: n })
|
|
1946
1946
|
});
|
|
1947
1947
|
}
|
|
1948
1948
|
}
|
|
1949
|
-
const
|
|
1949
|
+
const Jt = [
|
|
1950
1950
|
{
|
|
1951
1951
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1952
1952
|
stateMutability: "nonpayable",
|
|
@@ -2037,7 +2037,7 @@ const Yt = [
|
|
|
2037
2037
|
type: "function"
|
|
2038
2038
|
},
|
|
2039
2039
|
{ stateMutability: "payable", type: "receive" }
|
|
2040
|
-
],
|
|
2040
|
+
], Qt = [
|
|
2041
2041
|
{
|
|
2042
2042
|
inputs: [
|
|
2043
2043
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2181,7 +2181,7 @@ const Yt = [
|
|
|
2181
2181
|
type: "function"
|
|
2182
2182
|
},
|
|
2183
2183
|
{ stateMutability: "payable", type: "receive" }
|
|
2184
|
-
],
|
|
2184
|
+
], zt = [
|
|
2185
2185
|
{
|
|
2186
2186
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2187
2187
|
stateMutability: "nonpayable",
|
|
@@ -2286,7 +2286,7 @@ const Yt = [
|
|
|
2286
2286
|
type: "function"
|
|
2287
2287
|
},
|
|
2288
2288
|
{ stateMutability: "payable", type: "receive" }
|
|
2289
|
-
],
|
|
2289
|
+
], Zt = [
|
|
2290
2290
|
{
|
|
2291
2291
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2292
2292
|
stateMutability: "nonpayable",
|
|
@@ -2377,7 +2377,7 @@ const Yt = [
|
|
|
2377
2377
|
type: "function"
|
|
2378
2378
|
},
|
|
2379
2379
|
{ stateMutability: "payable", type: "receive" }
|
|
2380
|
-
],
|
|
2380
|
+
], en = [
|
|
2381
2381
|
{
|
|
2382
2382
|
inputs: [
|
|
2383
2383
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2521,7 +2521,7 @@ const Yt = [
|
|
|
2521
2521
|
type: "function"
|
|
2522
2522
|
},
|
|
2523
2523
|
{ stateMutability: "payable", type: "receive" }
|
|
2524
|
-
],
|
|
2524
|
+
], tn = [
|
|
2525
2525
|
{
|
|
2526
2526
|
inputs: [
|
|
2527
2527
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2640,7 +2640,7 @@ const Yt = [
|
|
|
2640
2640
|
type: "function"
|
|
2641
2641
|
},
|
|
2642
2642
|
{ stateMutability: "payable", type: "receive" }
|
|
2643
|
-
],
|
|
2643
|
+
], nn = [
|
|
2644
2644
|
{
|
|
2645
2645
|
inputs: [
|
|
2646
2646
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2759,7 +2759,7 @@ const Yt = [
|
|
|
2759
2759
|
type: "function"
|
|
2760
2760
|
},
|
|
2761
2761
|
{ stateMutability: "payable", type: "receive" }
|
|
2762
|
-
],
|
|
2762
|
+
], an = [
|
|
2763
2763
|
{
|
|
2764
2764
|
inputs: [
|
|
2765
2765
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2878,7 +2878,7 @@ const Yt = [
|
|
|
2878
2878
|
type: "function"
|
|
2879
2879
|
},
|
|
2880
2880
|
{ stateMutability: "payable", type: "receive" }
|
|
2881
|
-
],
|
|
2881
|
+
], sn = [
|
|
2882
2882
|
{
|
|
2883
2883
|
inputs: [
|
|
2884
2884
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2997,7 +2997,7 @@ const Yt = [
|
|
|
2997
2997
|
type: "function"
|
|
2998
2998
|
},
|
|
2999
2999
|
{ stateMutability: "payable", type: "receive" }
|
|
3000
|
-
],
|
|
3000
|
+
], rn = [
|
|
3001
3001
|
{
|
|
3002
3002
|
inputs: [
|
|
3003
3003
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3124,7 +3124,7 @@ const Yt = [
|
|
|
3124
3124
|
type: "function"
|
|
3125
3125
|
},
|
|
3126
3126
|
{ stateMutability: "payable", type: "receive" }
|
|
3127
|
-
],
|
|
3127
|
+
], on = [
|
|
3128
3128
|
{
|
|
3129
3129
|
inputs: [
|
|
3130
3130
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3251,7 +3251,7 @@ const Yt = [
|
|
|
3251
3251
|
type: "function"
|
|
3252
3252
|
},
|
|
3253
3253
|
{ stateMutability: "payable", type: "receive" }
|
|
3254
|
-
],
|
|
3254
|
+
], pn = [
|
|
3255
3255
|
{
|
|
3256
3256
|
inputs: [
|
|
3257
3257
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3378,7 +3378,7 @@ const Yt = [
|
|
|
3378
3378
|
type: "function"
|
|
3379
3379
|
},
|
|
3380
3380
|
{ stateMutability: "payable", type: "receive" }
|
|
3381
|
-
],
|
|
3381
|
+
], dn = [
|
|
3382
3382
|
{
|
|
3383
3383
|
inputs: [
|
|
3384
3384
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3505,7 +3505,7 @@ const Yt = [
|
|
|
3505
3505
|
type: "function"
|
|
3506
3506
|
},
|
|
3507
3507
|
{ stateMutability: "payable", type: "receive" }
|
|
3508
|
-
],
|
|
3508
|
+
], un = [
|
|
3509
3509
|
{
|
|
3510
3510
|
inputs: [
|
|
3511
3511
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3632,26 +3632,26 @@ const Yt = [
|
|
|
3632
3632
|
type: "function"
|
|
3633
3633
|
},
|
|
3634
3634
|
{ stateMutability: "payable", type: "receive" }
|
|
3635
|
-
],
|
|
3636
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3637
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3638
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3639
|
-
},
|
|
3640
|
-
...
|
|
3635
|
+
], Ge = {
|
|
3636
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Jt,
|
|
3637
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: zt,
|
|
3638
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Zt
|
|
3639
|
+
}, Ie = {
|
|
3640
|
+
...Ge,
|
|
3641
3641
|
// AVAX
|
|
3642
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3643
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3644
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3642
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: tn,
|
|
3643
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Qt,
|
|
3644
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: an,
|
|
3645
3645
|
// BSC
|
|
3646
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3646
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: en,
|
|
3647
3647
|
// ETH
|
|
3648
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3649
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3650
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3651
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3652
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3653
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3654
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3648
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: nn,
|
|
3649
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: sn,
|
|
3650
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: rn,
|
|
3651
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: on,
|
|
3652
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: pn,
|
|
3653
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: dn,
|
|
3654
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: un
|
|
3655
3655
|
}, ln = ({
|
|
3656
3656
|
streamSwap: e,
|
|
3657
3657
|
contractAddress: t,
|
|
@@ -3660,41 +3660,41 @@ const Yt = [
|
|
|
3660
3660
|
calldata: {
|
|
3661
3661
|
amount: s,
|
|
3662
3662
|
amountOutMin: r = "",
|
|
3663
|
-
data:
|
|
3664
|
-
deadline:
|
|
3663
|
+
data: p = "",
|
|
3664
|
+
deadline: o,
|
|
3665
3665
|
memo: d,
|
|
3666
|
-
router:
|
|
3666
|
+
router: y,
|
|
3667
3667
|
memoStreamingSwap: u,
|
|
3668
3668
|
tcMemo: m,
|
|
3669
|
-
tcRouter:
|
|
3670
|
-
tcVault:
|
|
3669
|
+
tcRouter: h,
|
|
3670
|
+
tcVault: f,
|
|
3671
3671
|
vault: A,
|
|
3672
3672
|
token: E
|
|
3673
3673
|
}
|
|
3674
3674
|
}) => {
|
|
3675
|
-
const O = !!
|
|
3676
|
-
if (O && !
|
|
3675
|
+
const O = !!Ge[t.toLowerCase()];
|
|
3676
|
+
if (O && !y)
|
|
3677
3677
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3678
|
-
const
|
|
3679
|
-
if (!
|
|
3678
|
+
const R = m || d, x = e && u || R;
|
|
3679
|
+
if (!f && !A)
|
|
3680
3680
|
throw new Error("TC Vault is required on calldata");
|
|
3681
|
-
if (!
|
|
3681
|
+
if (!h && !y)
|
|
3682
3682
|
throw new Error("TC Router is required on calldata");
|
|
3683
|
-
if (!
|
|
3683
|
+
if (!x)
|
|
3684
3684
|
throw new Error("TC Memo is required on calldata");
|
|
3685
3685
|
if (!E)
|
|
3686
3686
|
throw new Error("Token is required on calldata");
|
|
3687
|
-
const
|
|
3687
|
+
const $ = [
|
|
3688
3688
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3689
|
-
a(
|
|
3690
|
-
a(
|
|
3691
|
-
|
|
3689
|
+
a(h || y),
|
|
3690
|
+
a(f || A),
|
|
3691
|
+
x.replace("{recipientAddress}", n),
|
|
3692
3692
|
a(E),
|
|
3693
3693
|
s
|
|
3694
|
-
],
|
|
3695
|
-
return [
|
|
3694
|
+
], qe = O ? [a(y), p, o] : [r, o];
|
|
3695
|
+
return [...$, ...qe];
|
|
3696
3696
|
}, yn = ({ chain: e, txHash: t }) => {
|
|
3697
|
-
const n =
|
|
3697
|
+
const n = Ne[e];
|
|
3698
3698
|
switch (e) {
|
|
3699
3699
|
case i.Binance:
|
|
3700
3700
|
case i.Maya:
|
|
@@ -3719,7 +3719,7 @@ const Yt = [
|
|
|
3719
3719
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3720
3720
|
}
|
|
3721
3721
|
}, cn = ({ chain: e, address: t }) => {
|
|
3722
|
-
const n =
|
|
3722
|
+
const n = Ne[e];
|
|
3723
3723
|
switch (e) {
|
|
3724
3724
|
case i.Arbitrum:
|
|
3725
3725
|
case i.Avalanche:
|
|
@@ -3742,12 +3742,12 @@ const Yt = [
|
|
|
3742
3742
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3743
3743
|
}
|
|
3744
3744
|
}, mn = (e) => {
|
|
3745
|
-
const t = e ?
|
|
3745
|
+
const t = e ? K.ThornodeStagenet : K.ThornodeMainnet;
|
|
3746
3746
|
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3747
3747
|
}, Tn = (e) => {
|
|
3748
|
-
const t = e ?
|
|
3748
|
+
const t = e ? K.ThornodeStagenet : K.ThornodeMainnet;
|
|
3749
3749
|
return we.get(`${t}/thorchain/mimir`);
|
|
3750
|
-
},
|
|
3750
|
+
}, Se = () => Object.values(i).reduce(
|
|
3751
3751
|
(e, t) => (e[t] = null, e),
|
|
3752
3752
|
{}
|
|
3753
3753
|
), hn = async ({ chain: e, address: t }) => {
|
|
@@ -3760,11 +3760,11 @@ const Yt = [
|
|
|
3760
3760
|
return !0;
|
|
3761
3761
|
}
|
|
3762
3762
|
};
|
|
3763
|
-
var V,
|
|
3763
|
+
var V, ie, Y, v, J, Q;
|
|
3764
3764
|
class Ln {
|
|
3765
3765
|
constructor({ stagenet: t } = {}) {
|
|
3766
|
-
T(this, "connectedChains",
|
|
3767
|
-
T(this, "connectedWallets",
|
|
3766
|
+
T(this, "connectedChains", Se());
|
|
3767
|
+
T(this, "connectedWallets", Se());
|
|
3768
3768
|
T(this, "stagenet", !1);
|
|
3769
3769
|
T(this, "getAddress", (t) => {
|
|
3770
3770
|
var n;
|
|
@@ -3778,80 +3778,97 @@ class Ln {
|
|
|
3778
3778
|
return (a == null ? void 0 : a.balance) || [];
|
|
3779
3779
|
});
|
|
3780
3780
|
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: s }) => {
|
|
3781
|
-
var
|
|
3782
|
-
const {
|
|
3781
|
+
var d, y;
|
|
3782
|
+
const {
|
|
3783
|
+
meta: { quoteMode: r },
|
|
3784
|
+
evmTransactionDetails: p
|
|
3785
|
+
} = a, o = r.startsWith("ERC20-") ? i.Ethereum : r.startsWith("ARC20-") ? i.Avalanche : r.startsWith("BEP20-") ? i.BinanceSmartChain : void 0;
|
|
3783
3786
|
if (!a.complete)
|
|
3784
3787
|
throw new c("core_swap_route_not_complete");
|
|
3785
3788
|
try {
|
|
3786
|
-
if (
|
|
3787
|
-
const
|
|
3788
|
-
if (!(
|
|
3789
|
+
if (p && o) {
|
|
3790
|
+
const u = this.connectedWallets[o];
|
|
3791
|
+
if (!(u != null && u.call))
|
|
3792
|
+
throw new c("core_wallet_connection_not_found");
|
|
3793
|
+
const { contractAddress: m, contractMethod: h, contractParams: f, contractParamsStreaming: A } = p;
|
|
3794
|
+
if (!(t ? A : f))
|
|
3795
|
+
throw new c("core_swap_route_transaction_not_found");
|
|
3796
|
+
return await u.call({
|
|
3797
|
+
contractAddress: m,
|
|
3798
|
+
abi: Ie[m.toLowerCase()],
|
|
3799
|
+
funcName: h,
|
|
3800
|
+
funcParams: t ? A : f
|
|
3801
|
+
});
|
|
3802
|
+
}
|
|
3803
|
+
if (et.includes(r) && o) {
|
|
3804
|
+
const u = this.connectedWallets[o];
|
|
3805
|
+
if (!(u != null && u.sendTransaction))
|
|
3789
3806
|
throw new c("core_wallet_connection_not_found");
|
|
3790
|
-
if (!(t ? (
|
|
3807
|
+
if (!(t ? (d = a == null ? void 0 : a.streamingSwap) == null ? void 0 : d.transaction : a == null ? void 0 : a.transaction))
|
|
3791
3808
|
throw new c("core_swap_route_transaction_not_found");
|
|
3792
|
-
const { data:
|
|
3793
|
-
data:
|
|
3794
|
-
from:
|
|
3795
|
-
to:
|
|
3796
|
-
chainId: BigInt(
|
|
3797
|
-
value:
|
|
3809
|
+
const { data: h, from: f, to: A, value: E } = a.transaction, O = {
|
|
3810
|
+
data: h,
|
|
3811
|
+
from: f,
|
|
3812
|
+
to: A.toLowerCase(),
|
|
3813
|
+
chainId: BigInt(dt[o]),
|
|
3814
|
+
value: E ? BigInt(E) : 0n
|
|
3798
3815
|
};
|
|
3799
|
-
return
|
|
3816
|
+
return u.sendTransaction(O, s);
|
|
3800
3817
|
}
|
|
3801
|
-
if (
|
|
3818
|
+
if (nt.includes(r)) {
|
|
3802
3819
|
if (!a.calldata.fromAsset)
|
|
3803
3820
|
throw new c("core_swap_asset_not_recognized");
|
|
3804
|
-
const
|
|
3805
|
-
if (!
|
|
3821
|
+
const u = await N.fromString(a.calldata.fromAsset);
|
|
3822
|
+
if (!u)
|
|
3806
3823
|
throw new c("core_swap_asset_not_recognized");
|
|
3807
|
-
const { address:
|
|
3808
|
-
contract:
|
|
3809
|
-
calldata: { expiration:
|
|
3810
|
-
} = a,
|
|
3824
|
+
const { address: m } = await b(this, V).call(this, u.chain), {
|
|
3825
|
+
contract: h,
|
|
3826
|
+
calldata: { expiration: f, amountIn: A, memo: E, memoStreamingSwap: O }
|
|
3827
|
+
} = a, R = u.add(D.fromBigInt(BigInt(A), u.decimal)), x = t && O || E;
|
|
3811
3828
|
return this.deposit({
|
|
3812
|
-
expiration:
|
|
3813
|
-
assetValue:
|
|
3814
|
-
memo:
|
|
3829
|
+
expiration: f,
|
|
3830
|
+
assetValue: R,
|
|
3831
|
+
memo: x,
|
|
3815
3832
|
feeOptionKey: s,
|
|
3816
|
-
router:
|
|
3817
|
-
recipient:
|
|
3833
|
+
router: h,
|
|
3834
|
+
recipient: m
|
|
3818
3835
|
});
|
|
3819
3836
|
}
|
|
3820
|
-
if (
|
|
3821
|
-
const { calldata:
|
|
3822
|
-
if (!
|
|
3837
|
+
if (tt.includes(r) && o) {
|
|
3838
|
+
const { calldata: u, contract: m } = a;
|
|
3839
|
+
if (!m)
|
|
3823
3840
|
throw new c("core_swap_contract_not_found");
|
|
3824
|
-
const
|
|
3825
|
-
if (!(
|
|
3841
|
+
const h = this.connectedWallets[o], f = this.getAddress(o);
|
|
3842
|
+
if (!(h != null && h.sendTransaction) || !f)
|
|
3826
3843
|
throw new c("core_wallet_connection_not_found");
|
|
3827
|
-
const { getProvider:
|
|
3828
|
-
if (!
|
|
3829
|
-
throw new c("core_swap_contract_not_supported", { contractAddress:
|
|
3830
|
-
const
|
|
3844
|
+
const { getProvider: A, toChecksumAddress: E } = await import("@swapkit/toolbox-evm"), O = A(o), R = Ie[m.toLowerCase()];
|
|
3845
|
+
if (!R)
|
|
3846
|
+
throw new c("core_swap_contract_not_supported", { contractAddress: m });
|
|
3847
|
+
const $ = await (await ((y = h.createContract) == null ? void 0 : y.call(h, m, R, O))).getFunction("swapIn").populateTransaction(
|
|
3831
3848
|
...ln({
|
|
3832
3849
|
streamSwap: t,
|
|
3833
|
-
toChecksumAddress:
|
|
3834
|
-
contractAddress:
|
|
3850
|
+
toChecksumAddress: E,
|
|
3851
|
+
contractAddress: m,
|
|
3835
3852
|
recipient: n,
|
|
3836
|
-
calldata:
|
|
3853
|
+
calldata: u
|
|
3837
3854
|
}),
|
|
3838
|
-
{ from:
|
|
3855
|
+
{ from: f }
|
|
3839
3856
|
);
|
|
3840
|
-
return
|
|
3857
|
+
return h.sendTransaction($, s);
|
|
3841
3858
|
}
|
|
3842
3859
|
throw new c("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3843
|
-
} catch (
|
|
3844
|
-
throw new c("core_swap_transaction_error",
|
|
3860
|
+
} catch (u) {
|
|
3861
|
+
throw new c("core_swap_transaction_error", u);
|
|
3845
3862
|
}
|
|
3846
3863
|
});
|
|
3847
3864
|
T(this, "getWalletByChain", async (t, n) => {
|
|
3848
|
-
var
|
|
3865
|
+
var p, o;
|
|
3849
3866
|
const a = this.getAddress(t);
|
|
3850
3867
|
if (!a)
|
|
3851
3868
|
return null;
|
|
3852
|
-
const s = [N.fromChainOrSignature(t)], r = (
|
|
3869
|
+
const s = [N.fromChainOrSignature(t)], r = (p = this.connectedChains[t]) == null ? void 0 : p.walletType;
|
|
3853
3870
|
try {
|
|
3854
|
-
const d = await ((
|
|
3871
|
+
const d = await ((o = this.getWallet(t)) == null ? void 0 : o.getBalance(a, n));
|
|
3855
3872
|
return this.connectedChains[t] = {
|
|
3856
3873
|
address: a,
|
|
3857
3874
|
balance: d != null && d.length ? d : s,
|
|
@@ -3861,8 +3878,8 @@ class Ln {
|
|
|
3861
3878
|
return console.error(d), { address: a, balance: s, walletType: r };
|
|
3862
3879
|
}
|
|
3863
3880
|
});
|
|
3864
|
-
T(this, "approveAssetValue", (t, n) =>
|
|
3865
|
-
T(this, "isAssetValueApproved", (t, n) =>
|
|
3881
|
+
T(this, "approveAssetValue", (t, n) => b(this, Y).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3882
|
+
T(this, "isAssetValueApproved", (t, n) => b(this, Y).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3866
3883
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3867
3884
|
var a, s;
|
|
3868
3885
|
return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
|
|
@@ -3872,7 +3889,7 @@ class Ln {
|
|
|
3872
3889
|
if (!n)
|
|
3873
3890
|
throw new c("core_wallet_connection_not_found");
|
|
3874
3891
|
try {
|
|
3875
|
-
return await n.transfer(
|
|
3892
|
+
return await n.transfer(b(this, Q).call(this, t));
|
|
3876
3893
|
} catch (a) {
|
|
3877
3894
|
throw new c("core_swap_transaction_error", a);
|
|
3878
3895
|
}
|
|
@@ -3883,44 +3900,44 @@ class Ln {
|
|
|
3883
3900
|
router: a,
|
|
3884
3901
|
...s
|
|
3885
3902
|
}) => {
|
|
3886
|
-
const { chain: r, symbol:
|
|
3903
|
+
const { chain: r, symbol: p, ticker: o } = t, d = this.connectedWallets[r];
|
|
3887
3904
|
if (!await hn({ address: await (d == null ? void 0 : d.getAddress()), chain: r }))
|
|
3888
3905
|
throw new c("core_transaction_invalid_sender_address");
|
|
3889
3906
|
if (!d)
|
|
3890
3907
|
throw new c("core_wallet_connection_not_found");
|
|
3891
|
-
const
|
|
3908
|
+
const y = b(this, Q).call(this, { assetValue: t, recipient: n, router: a, ...s });
|
|
3892
3909
|
try {
|
|
3893
3910
|
switch (r) {
|
|
3894
3911
|
case i.THORChain: {
|
|
3895
3912
|
const u = d;
|
|
3896
|
-
return await (n === "" ? u.deposit(
|
|
3913
|
+
return await (n === "" ? u.deposit(y) : u.transfer(y));
|
|
3897
3914
|
}
|
|
3898
3915
|
case i.Ethereum:
|
|
3899
3916
|
case i.BinanceSmartChain:
|
|
3900
3917
|
case i.Avalanche: {
|
|
3901
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ?
|
|
3918
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ? Qe : r === i.BinanceSmartChain ? ze : Je;
|
|
3902
3919
|
return await d.call({
|
|
3903
3920
|
abi: m,
|
|
3904
|
-
contractAddress: a || (await
|
|
3921
|
+
contractAddress: a || (await b(this, V).call(this, r)).router,
|
|
3905
3922
|
funcName: "depositWithExpiry",
|
|
3906
3923
|
funcParams: [
|
|
3907
3924
|
n,
|
|
3908
|
-
u({ chain: r, symbol:
|
|
3925
|
+
u({ chain: r, symbol: p, ticker: o }, r),
|
|
3909
3926
|
t.getBaseValue("string"),
|
|
3910
|
-
|
|
3927
|
+
y.memo,
|
|
3911
3928
|
s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
3912
3929
|
],
|
|
3913
3930
|
txOverrides: {
|
|
3914
|
-
from:
|
|
3931
|
+
from: y.from,
|
|
3915
3932
|
value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
|
|
3916
3933
|
}
|
|
3917
3934
|
});
|
|
3918
3935
|
}
|
|
3919
3936
|
default:
|
|
3920
|
-
return await d.transfer(
|
|
3937
|
+
return await d.transfer(y);
|
|
3921
3938
|
}
|
|
3922
3939
|
} catch (u) {
|
|
3923
|
-
const m = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(),
|
|
3940
|
+
const m = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), h = m == null ? void 0 : m.includes("insufficient funds"), f = m == null ? void 0 : m.includes("gas"), A = m == null ? void 0 : m.includes("server"), E = h ? "core_transaction_deposit_insufficient_funds_error" : f ? "core_transaction_deposit_gas_error" : A ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3924
3941
|
throw new c(E, u);
|
|
3925
3942
|
}
|
|
3926
3943
|
});
|
|
@@ -3935,9 +3952,9 @@ class Ln {
|
|
|
3935
3952
|
throw new c("core_transaction_create_liquidity_invalid_params");
|
|
3936
3953
|
let a = "", s = "";
|
|
3937
3954
|
try {
|
|
3938
|
-
a = await
|
|
3955
|
+
a = await b(this, v).call(this, {
|
|
3939
3956
|
assetValue: t,
|
|
3940
|
-
memo: M(
|
|
3957
|
+
memo: M(_.DEPOSIT, {
|
|
3941
3958
|
...n,
|
|
3942
3959
|
address: this.getAddress(n.chain)
|
|
3943
3960
|
})
|
|
@@ -3946,9 +3963,9 @@ class Ln {
|
|
|
3946
3963
|
throw new c("core_transaction_create_liquidity_rune_error", r);
|
|
3947
3964
|
}
|
|
3948
3965
|
try {
|
|
3949
|
-
s = await
|
|
3966
|
+
s = await b(this, v).call(this, {
|
|
3950
3967
|
assetValue: n,
|
|
3951
|
-
memo: M(
|
|
3968
|
+
memo: M(_.DEPOSIT, {
|
|
3952
3969
|
...n,
|
|
3953
3970
|
address: this.getAddress(i.THORChain)
|
|
3954
3971
|
})
|
|
@@ -3964,31 +3981,31 @@ class Ln {
|
|
|
3964
3981
|
runeAddr: a,
|
|
3965
3982
|
assetAddr: s,
|
|
3966
3983
|
isPendingSymmAsset: r,
|
|
3967
|
-
mode:
|
|
3984
|
+
mode: p = "sym"
|
|
3968
3985
|
}) => {
|
|
3969
|
-
const { chain:
|
|
3986
|
+
const { chain: o, symbol: d } = n, y = p === "sym", u = (t == null ? void 0 : t.gt(0)) && (y || p === "rune"), m = (n == null ? void 0 : n.gt(0)) && (y || p === "asset"), h = r || u, f = h ? a || this.getAddress(i.THORChain) : "", A = y || p === "asset" ? s || this.getAddress(o) : "";
|
|
3970
3987
|
if (!u && !m)
|
|
3971
3988
|
throw new c("core_transaction_add_liquidity_invalid_params");
|
|
3972
|
-
if (
|
|
3989
|
+
if (h && !f)
|
|
3973
3990
|
throw new c("core_transaction_add_liquidity_no_rune_address");
|
|
3974
3991
|
let E, O;
|
|
3975
3992
|
if (u && t)
|
|
3976
3993
|
try {
|
|
3977
|
-
E = await
|
|
3994
|
+
E = await b(this, v).call(this, {
|
|
3978
3995
|
assetValue: t,
|
|
3979
|
-
memo: M(
|
|
3996
|
+
memo: M(_.DEPOSIT, { chain: o, symbol: d, address: A })
|
|
3980
3997
|
});
|
|
3981
|
-
} catch (
|
|
3982
|
-
throw new c("core_transaction_add_liquidity_rune_error",
|
|
3998
|
+
} catch (R) {
|
|
3999
|
+
throw new c("core_transaction_add_liquidity_rune_error", R);
|
|
3983
4000
|
}
|
|
3984
4001
|
if (m && n)
|
|
3985
4002
|
try {
|
|
3986
|
-
O = await
|
|
4003
|
+
O = await b(this, v).call(this, {
|
|
3987
4004
|
assetValue: n,
|
|
3988
|
-
memo: M(
|
|
4005
|
+
memo: M(_.DEPOSIT, { chain: o, symbol: d, address: f })
|
|
3989
4006
|
});
|
|
3990
|
-
} catch (
|
|
3991
|
-
throw new c("core_transaction_add_liquidity_asset_error",
|
|
4007
|
+
} catch (R) {
|
|
4008
|
+
throw new c("core_transaction_add_liquidity_asset_error", R);
|
|
3992
4009
|
}
|
|
3993
4010
|
return { runeTx: E, assetTx: O };
|
|
3994
4011
|
});
|
|
@@ -4000,12 +4017,12 @@ class Ln {
|
|
|
4000
4017
|
}) => {
|
|
4001
4018
|
if (s && !a)
|
|
4002
4019
|
throw new c("core_transaction_add_liquidity_invalid_params");
|
|
4003
|
-
const r = M(
|
|
4020
|
+
const r = M(_.DEPOSIT, {
|
|
4004
4021
|
chain: n.split(".")[0],
|
|
4005
4022
|
symbol: n.split(".")[1],
|
|
4006
4023
|
address: s ? a : ""
|
|
4007
4024
|
});
|
|
4008
|
-
return
|
|
4025
|
+
return b(this, v).call(this, { assetValue: t, memo: r });
|
|
4009
4026
|
});
|
|
4010
4027
|
T(this, "withdraw", async ({
|
|
4011
4028
|
memo: t,
|
|
@@ -4014,15 +4031,15 @@ class Ln {
|
|
|
4014
4031
|
from: s,
|
|
4015
4032
|
to: r
|
|
4016
4033
|
}) => {
|
|
4017
|
-
const
|
|
4034
|
+
const p = r === "rune" && s !== "rune" ? N.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, o = le(s === "asset" ? n.chain : i.THORChain), d = t || M(_.WITHDRAW, {
|
|
4018
4035
|
symbol: n.symbol,
|
|
4019
4036
|
chain: n.chain,
|
|
4020
4037
|
ticker: n.ticker,
|
|
4021
4038
|
basisPoints: Math.min(1e4, Math.round(a * 100)),
|
|
4022
|
-
targetAssetString:
|
|
4039
|
+
targetAssetString: p == null ? void 0 : p.toString(),
|
|
4023
4040
|
singleSide: !1
|
|
4024
4041
|
});
|
|
4025
|
-
return
|
|
4042
|
+
return b(this, v).call(this, { assetValue: o, memo: d });
|
|
4026
4043
|
});
|
|
4027
4044
|
T(this, "savings", async ({
|
|
4028
4045
|
assetValue: t,
|
|
@@ -4030,23 +4047,23 @@ class Ln {
|
|
|
4030
4047
|
percent: a,
|
|
4031
4048
|
type: s
|
|
4032
4049
|
}) => {
|
|
4033
|
-
const r = s === "add" ?
|
|
4050
|
+
const r = s === "add" ? _.DEPOSIT : _.WITHDRAW, p = n || M(r, {
|
|
4034
4051
|
ticker: t.ticker,
|
|
4035
4052
|
symbol: t.symbol,
|
|
4036
4053
|
chain: t.chain,
|
|
4037
4054
|
singleSide: !0,
|
|
4038
4055
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
4039
|
-
}),
|
|
4040
|
-
return
|
|
4056
|
+
}), o = r === _.DEPOSIT ? t : le(t.chain);
|
|
4057
|
+
return b(this, v).call(this, { memo: p, assetValue: o });
|
|
4041
4058
|
});
|
|
4042
4059
|
T(this, "loan", ({
|
|
4043
4060
|
assetValue: t,
|
|
4044
4061
|
memo: n,
|
|
4045
4062
|
minAmount: a,
|
|
4046
4063
|
type: s
|
|
4047
|
-
}) =>
|
|
4064
|
+
}) => b(this, v).call(this, {
|
|
4048
4065
|
assetValue: t,
|
|
4049
|
-
memo: n || M(s === "open" ?
|
|
4066
|
+
memo: n || M(s === "open" ? _.OPEN_LOAN : _.CLOSE_LOAN, {
|
|
4050
4067
|
asset: t.toString(),
|
|
4051
4068
|
minAmount: a.toString(),
|
|
4052
4069
|
address: this.getAddress(t.chain)
|
|
@@ -4057,11 +4074,11 @@ class Ln {
|
|
|
4057
4074
|
assetValue: n,
|
|
4058
4075
|
address: a
|
|
4059
4076
|
}) => {
|
|
4060
|
-
const s = t === "bond" ?
|
|
4077
|
+
const s = t === "bond" ? _.BOND : t === "unbond" ? _.UNBOND : _.LEAVE, r = M(s, {
|
|
4061
4078
|
address: a,
|
|
4062
4079
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
4063
4080
|
});
|
|
4064
|
-
return
|
|
4081
|
+
return b(this, J).call(this, {
|
|
4065
4082
|
memo: r,
|
|
4066
4083
|
assetValue: t === "bond" ? n : le(i.THORChain)
|
|
4067
4084
|
});
|
|
@@ -4069,12 +4086,12 @@ class Ln {
|
|
|
4069
4086
|
T(this, "registerThorname", ({
|
|
4070
4087
|
assetValue: t,
|
|
4071
4088
|
...n
|
|
4072
|
-
}) =>
|
|
4089
|
+
}) => b(this, J).call(this, { assetValue: t, memo: M(_.THORNAME_REGISTER, n) }));
|
|
4073
4090
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
4074
4091
|
try {
|
|
4075
4092
|
t.forEach((r) => {
|
|
4076
4093
|
this[r.connectMethodName] = r.connect({
|
|
4077
|
-
addChain:
|
|
4094
|
+
addChain: b(this, ie),
|
|
4078
4095
|
config: n || {},
|
|
4079
4096
|
apis: a,
|
|
4080
4097
|
rpcUrls: s
|
|
@@ -4166,56 +4183,56 @@ class Ln {
|
|
|
4166
4183
|
throw new c("core_chain_halted");
|
|
4167
4184
|
return a;
|
|
4168
4185
|
});
|
|
4169
|
-
P(this,
|
|
4186
|
+
P(this, ie, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4170
4187
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4171
4188
|
});
|
|
4172
|
-
P(this,
|
|
4189
|
+
P(this, Y, async ({
|
|
4173
4190
|
assetValue: t,
|
|
4174
4191
|
type: n = "checkOnly",
|
|
4175
4192
|
contractAddress: a
|
|
4176
4193
|
}) => {
|
|
4177
|
-
const { address: s, chain: r, isGasAsset:
|
|
4178
|
-
if (d &&
|
|
4194
|
+
const { address: s, chain: r, isGasAsset: p, isSynthetic: o } = t, d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(r);
|
|
4195
|
+
if (d && p || !d || o)
|
|
4179
4196
|
return !0;
|
|
4180
4197
|
const u = this.connectedWallets[r], m = n === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
|
|
4181
4198
|
if (!m)
|
|
4182
4199
|
throw new c("core_wallet_connection_not_found");
|
|
4183
|
-
const
|
|
4184
|
-
if (!s || !
|
|
4200
|
+
const h = this.getAddress(r);
|
|
4201
|
+
if (!s || !h)
|
|
4185
4202
|
throw new c("core_approve_asset_address_or_from_not_found");
|
|
4186
|
-
const
|
|
4203
|
+
const f = a || (await b(this, V).call(this, r)).router;
|
|
4187
4204
|
return m({
|
|
4188
4205
|
amount: t.getBaseValue("bigint"),
|
|
4189
4206
|
assetAddress: s,
|
|
4190
|
-
from:
|
|
4191
|
-
spenderAddress:
|
|
4207
|
+
from: h,
|
|
4208
|
+
spenderAddress: f
|
|
4192
4209
|
});
|
|
4193
4210
|
});
|
|
4194
4211
|
P(this, v, async ({
|
|
4195
4212
|
assetValue: t,
|
|
4196
4213
|
memo: n,
|
|
4197
|
-
feeOptionKey: a =
|
|
4214
|
+
feeOptionKey: a = G.Fast
|
|
4198
4215
|
}) => {
|
|
4199
4216
|
const {
|
|
4200
4217
|
gas_rate: s,
|
|
4201
4218
|
router: r,
|
|
4202
|
-
address:
|
|
4203
|
-
} = await
|
|
4219
|
+
address: p
|
|
4220
|
+
} = await b(this, V).call(this, t.chain), o = (parseInt(s) || 0) * At[a];
|
|
4204
4221
|
return this.deposit({
|
|
4205
4222
|
assetValue: t,
|
|
4206
|
-
recipient:
|
|
4223
|
+
recipient: p,
|
|
4207
4224
|
memo: n,
|
|
4208
4225
|
router: r,
|
|
4209
|
-
feeRate:
|
|
4226
|
+
feeRate: o
|
|
4210
4227
|
});
|
|
4211
4228
|
});
|
|
4212
|
-
P(this,
|
|
4229
|
+
P(this, J, async ({ memo: t, assetValue: n }) => {
|
|
4213
4230
|
const a = await Tn(this.stagenet);
|
|
4214
4231
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4215
4232
|
throw new c("core_chain_halted");
|
|
4216
4233
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
4217
4234
|
});
|
|
4218
|
-
P(this,
|
|
4235
|
+
P(this, Q, ({ assetValue: t, ...n }) => ({
|
|
4219
4236
|
...n,
|
|
4220
4237
|
memo: n.memo || "",
|
|
4221
4238
|
from: this.getAddress(t.chain),
|
|
@@ -4224,67 +4241,67 @@ class Ln {
|
|
|
4224
4241
|
this.stagenet = !!t;
|
|
4225
4242
|
}
|
|
4226
4243
|
}
|
|
4227
|
-
V = new WeakMap(),
|
|
4244
|
+
V = new WeakMap(), ie = new WeakMap(), Y = new WeakMap(), v = new WeakMap(), J = new WeakMap(), Q = new WeakMap();
|
|
4228
4245
|
export {
|
|
4229
|
-
|
|
4246
|
+
et as AGG_SWAP,
|
|
4230
4247
|
bn as ApiError,
|
|
4231
|
-
|
|
4248
|
+
K as ApiUrl,
|
|
4232
4249
|
N as AssetValue,
|
|
4233
|
-
|
|
4234
|
-
|
|
4250
|
+
w as BaseDecimal,
|
|
4251
|
+
ke as BigIntArithmetics,
|
|
4235
4252
|
i as Chain,
|
|
4236
4253
|
_e as ChainId,
|
|
4237
4254
|
On as ChainIdToChain,
|
|
4238
|
-
|
|
4239
|
-
|
|
4255
|
+
dt as ChainToChainId,
|
|
4256
|
+
Ne as ChainToExplorerUrl,
|
|
4240
4257
|
gn as ChainToHexChainId,
|
|
4241
|
-
|
|
4242
|
-
|
|
4258
|
+
ut as ChainToRPC,
|
|
4259
|
+
it as ContractAddress,
|
|
4243
4260
|
En as CosmosChainList,
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4261
|
+
rt as DerivationPath,
|
|
4262
|
+
l as ERROR_CODE,
|
|
4263
|
+
at as ERROR_MODULE,
|
|
4264
|
+
ve as ERROR_TYPE,
|
|
4265
|
+
ot as EVMChainList,
|
|
4266
|
+
lt as ErrorCode,
|
|
4267
|
+
G as FeeOption,
|
|
4268
|
+
_ as MemoType,
|
|
4252
4269
|
wn as NetworkDerivationPath,
|
|
4253
|
-
|
|
4254
|
-
|
|
4270
|
+
Ze as QuoteMode,
|
|
4271
|
+
Me as RPCUrl,
|
|
4255
4272
|
we as RequestClient,
|
|
4256
|
-
|
|
4257
|
-
|
|
4273
|
+
tt as SWAP_IN,
|
|
4274
|
+
nt as SWAP_OUT,
|
|
4258
4275
|
Ln as SwapKitCore,
|
|
4259
4276
|
c as SwapKitError,
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4277
|
+
D as SwapKitNumber,
|
|
4278
|
+
Qe as TCAvalancheDepositABI,
|
|
4279
|
+
ze as TCBscDepositABI,
|
|
4280
|
+
Je as TCEthereumVaultAbi,
|
|
4264
4281
|
Rn as TCSupportedChainList,
|
|
4265
4282
|
An as UTXOChainList,
|
|
4266
|
-
|
|
4283
|
+
yt as WalletOption,
|
|
4267
4284
|
In as assetFromString,
|
|
4268
4285
|
Bn as derivationPathToString,
|
|
4269
4286
|
fn as erc20ABI,
|
|
4270
4287
|
Sn as filterAssets,
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4288
|
+
oe as formatBigIntToSafeValue,
|
|
4289
|
+
At as gasFeeMultiplier,
|
|
4290
|
+
Rt as getAssetType,
|
|
4291
|
+
St as getAsymmetricAssetShare,
|
|
4275
4292
|
Cn as getAsymmetricAssetWithdrawAmount,
|
|
4276
|
-
|
|
4293
|
+
It as getAsymmetricRuneShare,
|
|
4277
4294
|
vn as getAsymmetricRuneWithdrawAmount,
|
|
4278
|
-
|
|
4279
|
-
|
|
4295
|
+
Et as getCommonAssetInfo,
|
|
4296
|
+
wt as getDecimal,
|
|
4280
4297
|
Nn as getEstimatedPoolShare,
|
|
4281
4298
|
xn as getLiquiditySlippage,
|
|
4282
4299
|
M as getMemoFor,
|
|
4283
4300
|
le as getMinAmountByChain,
|
|
4284
|
-
|
|
4301
|
+
vt as getSymmetricPoolShare,
|
|
4285
4302
|
Mn as getSymmetricWithdraw,
|
|
4286
4303
|
Dn as getTHORNameCost,
|
|
4287
|
-
|
|
4304
|
+
De as isGasAsset,
|
|
4288
4305
|
Pn as validateTHORName
|
|
4289
4306
|
};
|
|
4290
4307
|
//# sourceMappingURL=index.es.js.map
|