@swapkit/core 1.0.0-rc.23 → 1.0.0-rc.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.es.js +242 -254
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var We = (e, t, n) => t in e ?
|
|
3
|
-
var T = (e, t, n) => (We(e, typeof t != "symbol" ? t + "" : t, n), n),
|
|
1
|
+
var Ge = Object.defineProperty;
|
|
2
|
+
var We = (e, t, n) => t in e ? Ge(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var T = (e, t, n) => (We(e, typeof t != "symbol" ? t + "" : t, n), n), qe = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var f = (e, t, n) => (
|
|
7
|
+
var f = (e, t, n) => (qe(e, t, "read from private field"), n ? n.call(e) : t.get(e)), B = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
12
|
+
var je = Object.defineProperty, Ke = (e, t, n) => t in e ? je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (Ke(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
13
|
const Tn = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
@@ -108,7 +108,7 @@ const Tn = [
|
|
|
108
108
|
stateMutability: "nonpayable",
|
|
109
109
|
type: "function"
|
|
110
110
|
}
|
|
111
|
-
],
|
|
111
|
+
], Ye = [
|
|
112
112
|
{
|
|
113
113
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
114
114
|
stateMutability: "nonpayable",
|
|
@@ -283,7 +283,7 @@ const Tn = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Xe = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -447,7 +447,7 @@ const Tn = [
|
|
|
447
447
|
stateMutability: "view",
|
|
448
448
|
type: "function"
|
|
449
449
|
}
|
|
450
|
-
],
|
|
450
|
+
], Je = [
|
|
451
451
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
452
452
|
{
|
|
453
453
|
anonymous: !1,
|
|
@@ -600,13 +600,13 @@ const Tn = [
|
|
|
600
600
|
type: "function"
|
|
601
601
|
}
|
|
602
602
|
];
|
|
603
|
-
var
|
|
604
|
-
const
|
|
603
|
+
var Qe = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(Qe || {});
|
|
604
|
+
const ze = [
|
|
605
605
|
"ERC20-ERC20",
|
|
606
606
|
"ARC20-ARC20",
|
|
607
607
|
"BEP20-BEP20"
|
|
608
608
|
/* BSC_TO_BSC */
|
|
609
|
-
],
|
|
609
|
+
], Ze = [
|
|
610
610
|
"ERC20-TC",
|
|
611
611
|
"ERC20-ARC20",
|
|
612
612
|
"ERC20-BEP20",
|
|
@@ -617,15 +617,15 @@ const Ze = [
|
|
|
617
617
|
"BEP20-ERC20",
|
|
618
618
|
"BEP20-ARC20"
|
|
619
619
|
/* BSC_TO_AVAX */
|
|
620
|
-
],
|
|
620
|
+
], et = [
|
|
621
621
|
"TC-TC",
|
|
622
622
|
"TC-ERC20",
|
|
623
623
|
"TC-ARC20",
|
|
624
624
|
"TC-BEP20"
|
|
625
625
|
/* TC_SUPPORTED_TO_BSC */
|
|
626
626
|
];
|
|
627
|
-
var
|
|
628
|
-
const
|
|
627
|
+
var Ce = /* @__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))(Ce || {}), tt = /* @__PURE__ */ ((e) => (e.HEALTH_CONTROLLER = "1000", e.LIQUIDITY_CONTROLLER = "1001", e.PROVIDER_CONTROLLER = "1002", e.QUOTE_CONTROLLER = "1003", e.SWAP_CONTROLLER = "1004", e.UTIL_CONTROLLER = "1005", e.AIRDROP_CONTROLLER = "1006", e.PROVIDER = "2000", e.ASSET = "2001", e.TOKEN_LIST = "2002", e.QUOTE = "2100", e.QUOTE_TXN_DETAILS = "2101", e.THORCHAIN_PROVIDER = "3000", e.UNISWAPV2_ETH_PROVIDER = "3001", e.UNISWAPV3_ETH_PROVIDER = "3002", e.SUSHISWAP_ETH_PROVIDER = "3003", e.PANCAKESWAP_BSC_PROVIDER = "3004", e.PANCAKESWAP_ETH_PROVIDER = "3005", e.ONEINCH_ETH_PROVIDER = "3006", e.ONEINCH_BSC_PROVIDER = "3007", e.ONEINCH_AVAX_PROVIDER = "3008", e.ZEROX_ETH_PROVIDER = "3009", e.WOOFI_AVAX_PROVIDER = "3010", e.PANGOLIN_AVAX_PROVIDER = "3011", e.TRADERJOE_AVAX_PROVIDER = "3012", e.KYBER_ETH_PROVIDER = "3013", e.KYBER_AVAX_PROVIDER = "3014", e.WOOFI_BSC_PROVIDER = "3015", e.STARGATE_PROVIDER = "3016", e.PROVIDER_UTIL = "4000", e.TXN_DETAILS = "5000", e.AIRDROP_UTIL = "6000", e))(tt || {}), l = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(l || {});
|
|
628
|
+
const nt = {
|
|
629
629
|
[l.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
630
|
[l.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
631
631
|
[l.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
@@ -676,13 +676,13 @@ const at = {
|
|
|
676
676
|
[l.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
677
|
[l.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
678
|
[l.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
|
-
},
|
|
680
|
-
let n =
|
|
679
|
+
}, ie = (e, t) => {
|
|
680
|
+
let n = nt[e];
|
|
681
681
|
for (let a = 0; a < t.length; a++)
|
|
682
682
|
n = n.replace(`{${a}}`, t[a]);
|
|
683
683
|
return t.length === 0 ? n.replace("{0}", "") : n;
|
|
684
684
|
};
|
|
685
|
-
let hn = class
|
|
685
|
+
let hn = class Me extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -697,15 +697,15 @@ let hn = class Ne extends Error {
|
|
|
697
697
|
},
|
|
698
698
|
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
|
-
const c = r ||
|
|
701
|
-
super(c),
|
|
700
|
+
const c = r || ie(s, u || []) || "";
|
|
701
|
+
super(c), v(this, "status"), v(this, "revision"), v(this, "type"), v(this, "module"), v(this, "code"), v(this, "message"), v(this, "display"), v(this, "stack"), v(this, "options"), v(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = ie(s, u || []), this.code = s, this.type = o || Ce.UNHANDLED_ERROR, this.options = {
|
|
702
702
|
shouldLog: p || !0,
|
|
703
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 Me(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ let hn = class Ne extends Error {
|
|
|
714
714
|
return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
|
|
715
715
|
}
|
|
716
716
|
get displayMessage() {
|
|
717
|
-
return
|
|
717
|
+
return ie(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -724,7 +724,7 @@ let hn = class Ne 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 || {}), at = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(at || {}), st = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(st || {});
|
|
728
728
|
const _n = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
@@ -742,7 +742,7 @@ const _n = {
|
|
|
742
742
|
OP: [44, 60, 0, 0, 0],
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
|
-
var
|
|
745
|
+
var A = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(A || {});
|
|
746
746
|
const fn = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
@@ -775,23 +775,23 @@ const fn = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var
|
|
779
|
-
const
|
|
778
|
+
var he = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(he || {}), Ne = /* @__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))(Ne || {}), q = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(q || {});
|
|
779
|
+
const ae = Object.values(i), it = Object.keys(i), _e = ae.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
|
-
const n =
|
|
781
|
+
const n = it.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
786
|
-
(e, t) => (e[t] =
|
|
785
|
+
), rt = ae.reduce(
|
|
786
|
+
(e, t) => (e[t] = he[_e[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), ot = ae.reduce(
|
|
789
|
+
(e, t) => (e[t] = Ne[_e[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
), En =
|
|
791
|
+
), En = ae.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
|
-
const n = `${
|
|
794
|
-
return e[t] =
|
|
793
|
+
const n = `${_e[t]}Hex`;
|
|
794
|
+
return e[t] = he[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
797
|
), Rn = {
|
|
@@ -819,7 +819,7 @@ const se = Object.values(i), rt = Object.keys(i), be = se.reduce(
|
|
|
819
819
|
"thorchain-stagenet-v2": "THOR",
|
|
820
820
|
"thorchain-mainnet-v1": "THOR"
|
|
821
821
|
/* THORChain */
|
|
822
|
-
},
|
|
822
|
+
}, xe = {
|
|
823
823
|
ARB: "https://arbiscan.io",
|
|
824
824
|
AVAX: "https://snowtrace.io",
|
|
825
825
|
BSC: "https://bscscan.com",
|
|
@@ -836,17 +836,17 @@ const se = Object.values(i), rt = Object.keys(i), be = se.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://viewblock.io/thorchain"
|
|
838
838
|
};
|
|
839
|
-
var
|
|
839
|
+
var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), dt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(dt || {}), ut = Object.defineProperty, lt = (e, t, n) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (lt(e, typeof t != "symbol" ? t + "" : t, n), n), yt = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
842
|
}, L = (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
|
-
}, g = (e, t, n) => (
|
|
847
|
-
const
|
|
846
|
+
}, g = (e, t, n) => (yt(e, t, "access private method"), n);
|
|
847
|
+
const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await
|
|
849
|
+
const { result: n } = await be.post(ot[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -856,31 +856,31 @@ const mt = "0x313ce567", Pe = 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: ct }, "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), A[e];
|
|
865
865
|
}
|
|
866
|
-
},
|
|
866
|
+
}, mt = async (e) => {
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
|
-
return
|
|
868
|
+
return A.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
|
-
return t != null && t.startsWith("0x") ?
|
|
871
|
-
},
|
|
870
|
+
return t != null && t.startsWith("0x") ? De({ chain: i.Ethereum, to: t }) : A.ETH;
|
|
871
|
+
}, Tt = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ?
|
|
874
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? De({ chain: i.Avalanche, to: t.toLowerCase() }) : A.AVAX;
|
|
874
|
+
}, ht = async (e) => (e === i.BinanceSmartChain, A.BSC), _t = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
|
-
return
|
|
877
|
+
return mt(t);
|
|
878
878
|
case i.Avalanche:
|
|
879
|
-
return
|
|
879
|
+
return Tt(t);
|
|
880
880
|
case i.BinanceSmartChain:
|
|
881
|
-
return
|
|
881
|
+
return ht(t);
|
|
882
882
|
default:
|
|
883
|
-
return
|
|
883
|
+
return A[e];
|
|
884
884
|
}
|
|
885
885
|
}, ft = {
|
|
886
886
|
[F.Average]: 1.2,
|
|
@@ -919,13 +919,13 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
|
|
|
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: A[e] };
|
|
923
923
|
case i.THORChain:
|
|
924
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
924
|
+
return { identifier: "THOR.RUNE", decimal: A[e] };
|
|
925
925
|
case i.BinanceSmartChain:
|
|
926
|
-
return { identifier: "BSC.BNB", decimal:
|
|
926
|
+
return { identifier: "BSC.BNB", decimal: A[e] };
|
|
927
927
|
case i.Maya:
|
|
928
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
928
|
+
return { identifier: "MAYA.CACAO", decimal: A.MAYA };
|
|
929
929
|
case "MAYA.MAYA":
|
|
930
930
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
931
931
|
case i.Kujira:
|
|
@@ -939,7 +939,7 @@ const mt = "0x313ce567", Pe = 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: A[e] };
|
|
943
943
|
}
|
|
944
944
|
}, At = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
@@ -1004,7 +1004,7 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
|
|
|
1004
1004
|
assetDepth: t,
|
|
1005
1005
|
liquidityUnits: n,
|
|
1006
1006
|
poolUnits: a
|
|
1007
|
-
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), I = (e) =>
|
|
1007
|
+
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), I = (e) => N.fromBigInt(BigInt(e), A.THOR), Ot = ({
|
|
1008
1008
|
liquidityUnits: e,
|
|
1009
1009
|
poolUnits: t,
|
|
1010
1010
|
runeDepth: n,
|
|
@@ -1030,11 +1030,11 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
|
|
|
1030
1030
|
runeAmount: s,
|
|
1031
1031
|
assetAmount: r
|
|
1032
1032
|
}) => {
|
|
1033
|
-
const o = new
|
|
1033
|
+
const o = new N({ value: e, decimal: 8 }), p = new N({ value: n, decimal: 8 }), d = new N({ value: t, decimal: 8 }), y = new N({ value: s, decimal: 8 }), u = new N({ value: r, decimal: 8 }), c = y.mul(p), _ = u.mul(o), b = y.mul(u), E = o.mul(p), R = d.mul(c.add(_.add(b.mul(2)))), w = c.add(_.add(E.mul(2))), O = R.div(w), S = I(a).add(O);
|
|
1034
1034
|
if (O.getBaseValue("number") === 0)
|
|
1035
|
-
return
|
|
1036
|
-
const P = d.add(
|
|
1037
|
-
return
|
|
1035
|
+
return S.div(d).getBaseValue("number");
|
|
1036
|
+
const P = d.add(S);
|
|
1037
|
+
return S.div(P).getBaseValue("number");
|
|
1038
1038
|
}, Mn = ({
|
|
1039
1039
|
runeAmount: e,
|
|
1040
1040
|
assetAmount: t,
|
|
@@ -1090,7 +1090,7 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
|
|
|
1090
1090
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1091
1091
|
return !!e.match(t);
|
|
1092
1092
|
}, Dn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1093
|
-
class
|
|
1093
|
+
class we extends Error {
|
|
1094
1094
|
constructor(t, n, a) {
|
|
1095
1095
|
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
|
|
1096
1096
|
super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
|
|
@@ -1111,7 +1111,7 @@ class Ee extends Error {
|
|
|
1111
1111
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
|
-
class
|
|
1114
|
+
class Pe extends Error {
|
|
1115
1115
|
constructor(t) {
|
|
1116
1116
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1117
1117
|
enumerable: !0,
|
|
@@ -1125,21 +1125,21 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1125
1125
|
for (const t of e)
|
|
1126
1126
|
if ((!Q(t) || Array.isArray(t)) && t !== void 0)
|
|
1127
1127
|
throw new TypeError("The `options` argument must be an object");
|
|
1128
|
-
return
|
|
1129
|
-
},
|
|
1128
|
+
return fe({}, ...e);
|
|
1129
|
+
}, Be = (e = {}, t = {}) => {
|
|
1130
1130
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1131
1131
|
for (const [r, o] of s.entries())
|
|
1132
1132
|
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
1133
1133
|
return n;
|
|
1134
|
-
},
|
|
1134
|
+
}, fe = (...e) => {
|
|
1135
1135
|
let t = {}, n = {};
|
|
1136
1136
|
for (const a of e)
|
|
1137
1137
|
if (Array.isArray(a))
|
|
1138
1138
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1139
1139
|
else if (Q(a)) {
|
|
1140
1140
|
for (let [s, r] of Object.entries(a))
|
|
1141
|
-
Q(r) && s in t && (r =
|
|
1142
|
-
Q(a.headers) && (n =
|
|
1141
|
+
Q(r) && s in t && (r = fe(t[s], r)), t = { ...t, [s]: r };
|
|
1142
|
+
Q(a.headers) && (n = Be(n, a.headers), t.headers = n);
|
|
1143
1143
|
}
|
|
1144
1144
|
return t;
|
|
1145
1145
|
}, St = (() => {
|
|
@@ -1153,13 +1153,13 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1153
1153
|
return e = !0, "half";
|
|
1154
1154
|
}
|
|
1155
1155
|
}).headers.has("Content-Type")), e && !t;
|
|
1156
|
-
})(), vt = typeof globalThis.AbortController == "function", Ct = typeof globalThis.ReadableStream == "function", Mt = typeof globalThis.FormData == "function",
|
|
1156
|
+
})(), vt = typeof globalThis.AbortController == "function", Ct = typeof globalThis.ReadableStream == "function", Mt = typeof globalThis.FormData == "function", Ve = ["get", "post", "put", "patch", "head", "delete"], Nt = {
|
|
1157
1157
|
json: "application/json",
|
|
1158
1158
|
text: "text/*",
|
|
1159
1159
|
formData: "multipart/form-data",
|
|
1160
1160
|
arrayBuffer: "*/*",
|
|
1161
1161
|
blob: "*/*"
|
|
1162
|
-
},
|
|
1162
|
+
}, re = 2147483647, Le = Symbol("stop"), xt = {
|
|
1163
1163
|
json: !0,
|
|
1164
1164
|
parseJson: !0,
|
|
1165
1165
|
searchParams: !0,
|
|
@@ -1186,18 +1186,18 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1186
1186
|
window: !0,
|
|
1187
1187
|
dispatcher: !0,
|
|
1188
1188
|
duplex: !0
|
|
1189
|
-
}, Pt = (e) =>
|
|
1189
|
+
}, Pt = (e) => Ve.includes(e) ? e.toUpperCase() : e, Bt = ["get", "put", "head", "delete", "options", "trace"], Vt = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], Ae = {
|
|
1190
1190
|
limit: 2,
|
|
1191
1191
|
methods: Bt,
|
|
1192
1192
|
statusCodes: Vt,
|
|
1193
|
-
afterStatusCodes:
|
|
1193
|
+
afterStatusCodes: Ue,
|
|
1194
1194
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1195
1195
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1196
1196
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1197
1197
|
}, Lt = (e = {}) => {
|
|
1198
1198
|
if (typeof e == "number")
|
|
1199
1199
|
return {
|
|
1200
|
-
...
|
|
1200
|
+
...Ae,
|
|
1201
1201
|
limit: e
|
|
1202
1202
|
};
|
|
1203
1203
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -1205,15 +1205,15 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1205
1205
|
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1206
1206
|
throw new Error("retry.statusCodes must be an array");
|
|
1207
1207
|
return {
|
|
1208
|
-
...
|
|
1208
|
+
...Ae,
|
|
1209
1209
|
...e,
|
|
1210
|
-
afterStatusCodes:
|
|
1210
|
+
afterStatusCodes: Ue
|
|
1211
1211
|
};
|
|
1212
1212
|
};
|
|
1213
1213
|
async function Ut(e, t, n, a) {
|
|
1214
1214
|
return new Promise((s, r) => {
|
|
1215
1215
|
const o = setTimeout(() => {
|
|
1216
|
-
n && n.abort(), r(new
|
|
1216
|
+
n && n.abort(), r(new Pe(e));
|
|
1217
1217
|
}, a.timeout);
|
|
1218
1218
|
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1219
1219
|
clearTimeout(o);
|
|
@@ -1237,11 +1237,11 @@ const $t = (e, t) => {
|
|
|
1237
1237
|
!(a in Dt) && !(a in xt) && !(a in e) && (n[a] = t[a]);
|
|
1238
1238
|
return n;
|
|
1239
1239
|
};
|
|
1240
|
-
class
|
|
1240
|
+
class Z {
|
|
1241
1241
|
static create(t, n) {
|
|
1242
|
-
const a = new
|
|
1243
|
-
if (typeof a._options.timeout == "number" && a._options.timeout >
|
|
1244
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
1242
|
+
const a = new Z(t, n), s = async () => {
|
|
1243
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > re)
|
|
1244
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${re}`);
|
|
1245
1245
|
await Promise.resolve();
|
|
1246
1246
|
let o = await a._fetch();
|
|
1247
1247
|
for (const p of a._options.hooks.afterResponse) {
|
|
@@ -1249,7 +1249,7 @@ class ee {
|
|
|
1249
1249
|
d instanceof globalThis.Response && (o = d);
|
|
1250
1250
|
}
|
|
1251
1251
|
if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
|
|
1252
|
-
let p = new
|
|
1252
|
+
let p = new we(o, a.request, a._options);
|
|
1253
1253
|
for (const d of a._options.hooks.beforeError)
|
|
1254
1254
|
p = await d(p);
|
|
1255
1255
|
throw p;
|
|
@@ -1308,8 +1308,8 @@ class ee {
|
|
|
1308
1308
|
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1309
1309
|
credentials: this._input.credentials || "same-origin",
|
|
1310
1310
|
...n,
|
|
1311
|
-
headers:
|
|
1312
|
-
hooks:
|
|
1311
|
+
headers: Be(this._input.headers, n.headers),
|
|
1312
|
+
hooks: fe({
|
|
1313
1313
|
beforeRequest: [],
|
|
1314
1314
|
beforeRetry: [],
|
|
1315
1315
|
beforeError: [],
|
|
@@ -1345,8 +1345,8 @@ class ee {
|
|
|
1345
1345
|
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 }));
|
|
1346
1346
|
}
|
|
1347
1347
|
_calculateRetryDelay(t) {
|
|
1348
|
-
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof
|
|
1349
|
-
if (t instanceof
|
|
1348
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof Pe)) {
|
|
1349
|
+
if (t instanceof we) {
|
|
1350
1350
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1351
1351
|
return 0;
|
|
1352
1352
|
const a = t.response.headers.get("Retry-After");
|
|
@@ -1369,7 +1369,7 @@ class ee {
|
|
|
1369
1369
|
try {
|
|
1370
1370
|
return await t();
|
|
1371
1371
|
} catch (n) {
|
|
1372
|
-
const a = Math.min(this._calculateRetryDelay(n),
|
|
1372
|
+
const a = Math.min(this._calculateRetryDelay(n), re);
|
|
1373
1373
|
if (a !== 0 && this._retryCount > 0) {
|
|
1374
1374
|
await Ht(a, { signal: this._options.signal });
|
|
1375
1375
|
for (const s of this._options.hooks.beforeRetry)
|
|
@@ -1378,7 +1378,7 @@ class ee {
|
|
|
1378
1378
|
options: this._options,
|
|
1379
1379
|
error: n,
|
|
1380
1380
|
retryCount: this._retryCount
|
|
1381
|
-
}) ===
|
|
1381
|
+
}) === Le)
|
|
1382
1382
|
return;
|
|
1383
1383
|
return this._retry(t);
|
|
1384
1384
|
}
|
|
@@ -1433,26 +1433,26 @@ class ee {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
1435
|
/*! MIT License © Sindre Sorhus */
|
|
1436
|
-
const
|
|
1437
|
-
const t = (n, a) =>
|
|
1438
|
-
for (const n of
|
|
1439
|
-
t[n] = (a, s) =>
|
|
1440
|
-
return t.create = (n) =>
|
|
1441
|
-
}, kt =
|
|
1442
|
-
get: (e, t) =>
|
|
1443
|
-
post: (e, t) =>
|
|
1444
|
-
},
|
|
1436
|
+
const oe = (e) => {
|
|
1437
|
+
const t = (n, a) => Z.create(n, J(e, a));
|
|
1438
|
+
for (const n of Ve)
|
|
1439
|
+
t[n] = (a, s) => Z.create(a, J(e, s, { method: n }));
|
|
1440
|
+
return t.create = (n) => oe(J(n)), t.extend = (n) => oe(J(e, n)), t.stop = Le, t;
|
|
1441
|
+
}, kt = oe(), Ft = kt, Gt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Ee = Ft.create({ headers: Gt }), be = {
|
|
1442
|
+
get: (e, t) => Ee.get(e, t).json(),
|
|
1443
|
+
post: (e, t) => Ee.post(e, t).json()
|
|
1444
|
+
}, Re = Object.values(i), Wt = (e = "") => {
|
|
1445
1445
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1446
|
-
if (
|
|
1446
|
+
if (Re.includes(n))
|
|
1447
1447
|
return !0;
|
|
1448
1448
|
const [a] = t.split("/");
|
|
1449
|
-
if (
|
|
1449
|
+
if (Re.includes(a))
|
|
1450
1450
|
return !0;
|
|
1451
1451
|
throw new Error(
|
|
1452
1452
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1453
1453
|
);
|
|
1454
1454
|
}, j = 8, H = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1455
|
-
function
|
|
1455
|
+
function se({
|
|
1456
1456
|
value: e,
|
|
1457
1457
|
bigIntDecimal: t = j,
|
|
1458
1458
|
decimal: n = j
|
|
@@ -1468,19 +1468,19 @@ function ie({
|
|
|
1468
1468
|
""
|
|
1469
1469
|
);
|
|
1470
1470
|
}
|
|
1471
|
-
var U, k,
|
|
1472
|
-
const
|
|
1471
|
+
var U, k, pe, He, de, ge, ee, ue, $, W, te, le;
|
|
1472
|
+
const qt = class $e {
|
|
1473
1473
|
constructor(t) {
|
|
1474
|
-
L(this, U), L(this,
|
|
1475
|
-
const n =
|
|
1474
|
+
L(this, U), L(this, pe), L(this, de), L(this, ee), L(this, $), L(this, te), C(this, "decimalMultiplier", 10n ** 8n), C(this, "bigIntValue", 0n), C(this, "decimal");
|
|
1475
|
+
const n = ce(t);
|
|
1476
1476
|
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = H(
|
|
1477
|
-
Math.max(g(this,
|
|
1478
|
-
), g(this,
|
|
1477
|
+
Math.max(g(this, te, le).call(this, g(this, $, W).call(this, n)), this.decimal || 0)
|
|
1478
|
+
), g(this, pe, He).call(this, n);
|
|
1479
1479
|
}
|
|
1480
1480
|
static fromBigInt(t, n) {
|
|
1481
|
-
return new
|
|
1481
|
+
return new $e({
|
|
1482
1482
|
decimal: n,
|
|
1483
|
-
value:
|
|
1483
|
+
value: se({ value: t, bigIntDecimal: n, decimal: n })
|
|
1484
1484
|
});
|
|
1485
1485
|
}
|
|
1486
1486
|
static shiftDecimals({
|
|
@@ -1489,7 +1489,7 @@ const Wt = class me {
|
|
|
1489
1489
|
to: a
|
|
1490
1490
|
}) {
|
|
1491
1491
|
return this.fromBigInt(
|
|
1492
|
-
|
|
1492
|
+
t.getBaseValue("bigint") * H(a) / H(n),
|
|
1493
1493
|
a
|
|
1494
1494
|
);
|
|
1495
1495
|
}
|
|
@@ -1556,7 +1556,7 @@ const Wt = class me {
|
|
|
1556
1556
|
}
|
|
1557
1557
|
}
|
|
1558
1558
|
getBaseValue(t) {
|
|
1559
|
-
const n = this.decimalMultiplier / H(this.decimal ||
|
|
1559
|
+
const n = this.decimalMultiplier / H(this.decimal || A.THOR), a = this.bigIntValue / n;
|
|
1560
1560
|
switch (t) {
|
|
1561
1561
|
case "number":
|
|
1562
1562
|
return Number(a);
|
|
@@ -1569,8 +1569,8 @@ const Wt = class me {
|
|
|
1569
1569
|
getBigIntValue(t, n) {
|
|
1570
1570
|
if (!n && typeof t == "object")
|
|
1571
1571
|
return t.bigIntValue;
|
|
1572
|
-
const a =
|
|
1573
|
-
return s === "0" || s === "undefined" ? 0n : g(this,
|
|
1572
|
+
const a = ce(t), s = g(this, $, W).call(this, a);
|
|
1573
|
+
return s === "0" || s === "undefined" ? 0n : g(this, ee, ue).call(this, s, n);
|
|
1574
1574
|
}
|
|
1575
1575
|
formatBigIntToSafeValue(t, n) {
|
|
1576
1576
|
const a = n || this.decimal || j, s = Math.max(
|
|
@@ -1619,7 +1619,7 @@ const Wt = class me {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
};
|
|
1621
1621
|
U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1622
|
-
const n = g(this,
|
|
1622
|
+
const n = g(this, de, ge).call(this, this, ...t), a = H(n), s = t.reduce(
|
|
1623
1623
|
(o, p) => {
|
|
1624
1624
|
const d = this.getBigIntValue(p, n);
|
|
1625
1625
|
switch (e) {
|
|
@@ -1640,55 +1640,55 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1640
1640
|
},
|
|
1641
1641
|
//normalize is to precision multiplier base
|
|
1642
1642
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1643
|
-
), r =
|
|
1643
|
+
), r = se({
|
|
1644
1644
|
bigIntDecimal: n,
|
|
1645
1645
|
decimal: Math.max(n, G(this.decimalMultiplier)),
|
|
1646
1646
|
value: s
|
|
1647
1647
|
});
|
|
1648
1648
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1649
|
-
},
|
|
1650
|
-
const t = g(this, $,
|
|
1651
|
-
this.bigIntValue = g(this,
|
|
1652
|
-
},
|
|
1649
|
+
}, pe = /* @__PURE__ */ new WeakSet(), He = function(e) {
|
|
1650
|
+
const t = g(this, $, W).call(this, e) || "0";
|
|
1651
|
+
this.bigIntValue = g(this, ee, ue).call(this, t);
|
|
1652
|
+
}, de = /* @__PURE__ */ new WeakSet(), ge = function(...e) {
|
|
1653
1653
|
const t = e.map(
|
|
1654
|
-
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : g(this,
|
|
1654
|
+
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : g(this, te, le).call(this, g(this, $, W).call(this, n))
|
|
1655
1655
|
).filter(Boolean);
|
|
1656
1656
|
return Math.max(...t, j);
|
|
1657
|
-
},
|
|
1657
|
+
}, ee = /* @__PURE__ */ new WeakSet(), ue = function(e, t) {
|
|
1658
1658
|
const n = t ? H(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
|
|
1659
1659
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1660
|
-
}, $ = /* @__PURE__ */ new WeakSet(),
|
|
1660
|
+
}, $ = /* @__PURE__ */ new WeakSet(), W = function(e) {
|
|
1661
1661
|
const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
|
|
1662
1662
|
useGrouping: !1,
|
|
1663
1663
|
maximumFractionDigits: 20
|
|
1664
|
-
}) :
|
|
1664
|
+
}) : ce(e)}`.replaceAll(",", ".").split(".");
|
|
1665
1665
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1666
|
-
},
|
|
1666
|
+
}, te = /* @__PURE__ */ new WeakSet(), le = function(e) {
|
|
1667
1667
|
var t;
|
|
1668
1668
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1669
1669
|
return Math.max(n, j);
|
|
1670
1670
|
};
|
|
1671
|
-
let
|
|
1672
|
-
function
|
|
1671
|
+
let ye = qt;
|
|
1672
|
+
function ce(e) {
|
|
1673
1673
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1674
1674
|
}
|
|
1675
|
-
const z = (e, t) => typeof e == "bigint" ?
|
|
1676
|
-
let
|
|
1677
|
-
const
|
|
1678
|
-
if (!
|
|
1675
|
+
const z = (e, t) => typeof e == "bigint" ? se({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1676
|
+
let me;
|
|
1677
|
+
const Oe = (e) => {
|
|
1678
|
+
if (!me)
|
|
1679
1679
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1680
|
-
return
|
|
1681
|
-
},
|
|
1682
|
-
|
|
1683
|
-
const n = await
|
|
1684
|
-
return new
|
|
1680
|
+
return me.get(e.toUpperCase()) || { decimal: A.THOR, identifier: "" };
|
|
1681
|
+
}, Ie = async (e, t = 0) => {
|
|
1682
|
+
Wt(e);
|
|
1683
|
+
const n = await _t(Te(e)), a = z(t, n);
|
|
1684
|
+
return new x({ decimal: n, value: a, identifier: e });
|
|
1685
1685
|
};
|
|
1686
|
-
class
|
|
1686
|
+
class x extends ye {
|
|
1687
1687
|
constructor(t) {
|
|
1688
1688
|
super(
|
|
1689
|
-
t.value instanceof
|
|
1690
|
-
),
|
|
1691
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a =
|
|
1689
|
+
t.value instanceof ye ? t.value : { decimal: t.decimal, value: t.value }
|
|
1690
|
+
), C(this, "address"), C(this, "chain"), C(this, "isSynthetic", !1), C(this, "isGasAsset", !1), C(this, "symbol"), C(this, "ticker"), C(this, "type");
|
|
1691
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = Te(n);
|
|
1692
1692
|
this.type = At(a), this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset;
|
|
1693
1693
|
}
|
|
1694
1694
|
get assetValue() {
|
|
@@ -1705,36 +1705,24 @@ class S extends Te {
|
|
|
1705
1705
|
return this.chain === t && this.symbol === n;
|
|
1706
1706
|
}
|
|
1707
1707
|
static async fromString(t, n = 0) {
|
|
1708
|
-
return
|
|
1708
|
+
return Ie(t, n);
|
|
1709
1709
|
}
|
|
1710
1710
|
static fromStringSync(t, n = 0) {
|
|
1711
|
-
const { isSynthetic: a } =
|
|
1711
|
+
const { isSynthetic: a } = Te(t), { decimal: s, identifier: r } = Oe(
|
|
1712
1712
|
t
|
|
1713
1713
|
), o = z(n, s);
|
|
1714
|
-
return r ? new
|
|
1714
|
+
return r ? new x({ decimal: s, identifier: r, value: o }) : a ? new x({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1715
1715
|
}
|
|
1716
1716
|
static async fromIdentifier(t, n = 0) {
|
|
1717
|
-
return
|
|
1717
|
+
return Ie(t, n);
|
|
1718
1718
|
}
|
|
1719
1719
|
static fromIdentifierSync(t, n = 0) {
|
|
1720
|
-
const { decimal: a, identifier: s } =
|
|
1721
|
-
return new
|
|
1720
|
+
const { decimal: a, identifier: s } = Oe(t), r = z(n, a);
|
|
1721
|
+
return new x({ decimal: a, identifier: s, value: r });
|
|
1722
1722
|
}
|
|
1723
1723
|
static fromChainOrSignature(t, n = 0) {
|
|
1724
1724
|
const { decimal: a, identifier: s } = wt(t), r = z(n, a);
|
|
1725
|
-
return new
|
|
1726
|
-
}
|
|
1727
|
-
static async fromTCQuote(t, n = 0) {
|
|
1728
|
-
const a = await Be(Z(t)), s = this.shiftDecimals({ value: n, from: b.THOR, to: a });
|
|
1729
|
-
return new S({ value: s, identifier: t, decimal: a });
|
|
1730
|
-
}
|
|
1731
|
-
static fromTCQuoteStatic(t, n = 0) {
|
|
1732
|
-
const a = pe(t), s = this.shiftDecimals({
|
|
1733
|
-
value: n,
|
|
1734
|
-
from: b.THOR,
|
|
1735
|
-
to: a.decimal
|
|
1736
|
-
});
|
|
1737
|
-
return new S({ ...a, value: s });
|
|
1725
|
+
return new x({ value: r, decimal: a, identifier: s });
|
|
1738
1726
|
}
|
|
1739
1727
|
static async loadStaticAssets() {
|
|
1740
1728
|
return new Promise(
|
|
@@ -1747,9 +1735,9 @@ class S extends Te {
|
|
|
1747
1735
|
NativeList: s,
|
|
1748
1736
|
...r
|
|
1749
1737
|
} = await import("@swapkit/tokens");
|
|
1750
|
-
|
|
1738
|
+
me = [s, ...Object.values(r)].reduce(
|
|
1751
1739
|
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: y, ...u }) => {
|
|
1752
|
-
const c = "decimals" in u ? u.decimals :
|
|
1740
|
+
const c = "decimals" in u ? u.decimals : A[y];
|
|
1753
1741
|
o.set(d, { identifier: d, decimal: c });
|
|
1754
1742
|
}), o),
|
|
1755
1743
|
/* @__PURE__ */ new Map()
|
|
@@ -1765,8 +1753,8 @@ class S extends Te {
|
|
|
1765
1753
|
);
|
|
1766
1754
|
}
|
|
1767
1755
|
}
|
|
1768
|
-
const
|
|
1769
|
-
const t =
|
|
1756
|
+
const Se = (e) => {
|
|
1757
|
+
const t = x.fromChainOrSignature(e);
|
|
1770
1758
|
switch (e) {
|
|
1771
1759
|
case i.Bitcoin:
|
|
1772
1760
|
case i.Litecoin:
|
|
@@ -1783,7 +1771,7 @@ const ve = (e) => {
|
|
|
1783
1771
|
default:
|
|
1784
1772
|
return t.add(1);
|
|
1785
1773
|
}
|
|
1786
|
-
},
|
|
1774
|
+
}, Te = (e) => {
|
|
1787
1775
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".").pop().split("/"), s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
|
|
1788
1776
|
return {
|
|
1789
1777
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
@@ -1855,14 +1843,14 @@ class m extends Error {
|
|
|
1855
1843
|
console.error(n), super(t, { cause: { code: jt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1856
1844
|
}
|
|
1857
1845
|
}
|
|
1858
|
-
class
|
|
1846
|
+
class N extends ye {
|
|
1859
1847
|
eq(t) {
|
|
1860
1848
|
return this.eqValue(t);
|
|
1861
1849
|
}
|
|
1862
1850
|
static fromBigInt(t, n) {
|
|
1863
|
-
return new
|
|
1851
|
+
return new N({
|
|
1864
1852
|
decimal: n,
|
|
1865
|
-
value:
|
|
1853
|
+
value: se({ value: t, bigIntDecimal: n, decimal: n })
|
|
1866
1854
|
});
|
|
1867
1855
|
}
|
|
1868
1856
|
}
|
|
@@ -3552,12 +3540,12 @@ const Kt = [
|
|
|
3552
3540
|
type: "function"
|
|
3553
3541
|
},
|
|
3554
3542
|
{ stateMutability: "payable", type: "receive" }
|
|
3555
|
-
],
|
|
3543
|
+
], ke = {
|
|
3556
3544
|
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Kt,
|
|
3557
3545
|
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Xt,
|
|
3558
3546
|
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Jt
|
|
3559
3547
|
}, pn = {
|
|
3560
|
-
...
|
|
3548
|
+
...ke,
|
|
3561
3549
|
// AVAX
|
|
3562
3550
|
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: zt,
|
|
3563
3551
|
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Yt,
|
|
@@ -3587,34 +3575,34 @@ const Kt = [
|
|
|
3587
3575
|
memoStreamingSwap: u,
|
|
3588
3576
|
tcMemo: c,
|
|
3589
3577
|
tcRouter: _,
|
|
3590
|
-
tcVault:
|
|
3578
|
+
tcVault: b,
|
|
3591
3579
|
vault: E,
|
|
3592
3580
|
token: R
|
|
3593
3581
|
}
|
|
3594
3582
|
}) => {
|
|
3595
|
-
const
|
|
3596
|
-
if (
|
|
3583
|
+
const w = !!ke[t.toLowerCase()];
|
|
3584
|
+
if (w && !y)
|
|
3597
3585
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3598
|
-
const O = c || d,
|
|
3599
|
-
if (!
|
|
3586
|
+
const O = c || d, S = e && u || O;
|
|
3587
|
+
if (!b && !E)
|
|
3600
3588
|
throw new Error("TC Vault is required on calldata");
|
|
3601
3589
|
if (!_ && !y)
|
|
3602
3590
|
throw new Error("TC Router is required on calldata");
|
|
3603
|
-
if (!
|
|
3591
|
+
if (!S)
|
|
3604
3592
|
throw new Error("TC Memo is required on calldata");
|
|
3605
3593
|
if (!R)
|
|
3606
3594
|
throw new Error("Token is required on calldata");
|
|
3607
3595
|
const P = [
|
|
3608
3596
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3609
3597
|
a(_ || y),
|
|
3610
|
-
a(
|
|
3611
|
-
|
|
3598
|
+
a(b || E),
|
|
3599
|
+
S.replace("{recipientAddress}", n),
|
|
3612
3600
|
a(R),
|
|
3613
3601
|
s
|
|
3614
|
-
],
|
|
3615
|
-
return [...P, ...
|
|
3602
|
+
], Fe = w ? [a(y), o, p] : [r, p];
|
|
3603
|
+
return [...P, ...Fe];
|
|
3616
3604
|
}, un = ({ chain: e, txHash: t }) => {
|
|
3617
|
-
const n =
|
|
3605
|
+
const n = xe[e];
|
|
3618
3606
|
switch (e) {
|
|
3619
3607
|
case i.Binance:
|
|
3620
3608
|
case i.Bitcoin:
|
|
@@ -3640,7 +3628,7 @@ const Kt = [
|
|
|
3640
3628
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3641
3629
|
}
|
|
3642
3630
|
}, ln = ({ chain: e, address: t }) => {
|
|
3643
|
-
const n =
|
|
3631
|
+
const n = xe[e];
|
|
3644
3632
|
switch (e) {
|
|
3645
3633
|
case i.Arbitrum:
|
|
3646
3634
|
case i.Avalanche:
|
|
@@ -3664,20 +3652,20 @@ const Kt = [
|
|
|
3664
3652
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3665
3653
|
}
|
|
3666
3654
|
}, yn = (e) => {
|
|
3667
|
-
const t = e ?
|
|
3668
|
-
return
|
|
3655
|
+
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3656
|
+
return be.get(`${t}/thorchain/inbound_addresses`);
|
|
3669
3657
|
}, cn = (e) => {
|
|
3670
|
-
const t = e ?
|
|
3671
|
-
return
|
|
3672
|
-
},
|
|
3658
|
+
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3659
|
+
return be.get(`${t}/thorchain/mimir`);
|
|
3660
|
+
}, ve = () => Object.values(i).reduce(
|
|
3673
3661
|
(e, t) => (e[t] = null, e),
|
|
3674
3662
|
{}
|
|
3675
3663
|
);
|
|
3676
|
-
var V,
|
|
3664
|
+
var V, ne, K, M, Y, X;
|
|
3677
3665
|
class Pn {
|
|
3678
3666
|
constructor({ stagenet: t } = {}) {
|
|
3679
|
-
T(this, "connectedChains",
|
|
3680
|
-
T(this, "connectedWallets",
|
|
3667
|
+
T(this, "connectedChains", ve());
|
|
3668
|
+
T(this, "connectedWallets", ve());
|
|
3681
3669
|
T(this, "stagenet", !1);
|
|
3682
3670
|
T(this, "getAddress", (t) => {
|
|
3683
3671
|
var n;
|
|
@@ -3696,53 +3684,53 @@ class Pn {
|
|
|
3696
3684
|
if (!a.complete)
|
|
3697
3685
|
throw new m("core_swap_route_not_complete");
|
|
3698
3686
|
try {
|
|
3699
|
-
if (
|
|
3687
|
+
if (ze.includes(r)) {
|
|
3700
3688
|
const y = this.connectedWallets[o];
|
|
3701
3689
|
if (!(y != null && y.sendTransaction))
|
|
3702
3690
|
throw new m("core_wallet_connection_not_found");
|
|
3703
3691
|
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3704
3692
|
throw new m("core_swap_route_transaction_not_found");
|
|
3705
|
-
const { isHexString: c, parseUnits: _ } = await import("./index-cf1865cd.js"), { data:
|
|
3706
|
-
data:
|
|
3693
|
+
const { isHexString: c, parseUnits: _ } = await import("./index-cf1865cd.js"), { data: b, from: E, to: R, value: w } = a.transaction, O = {
|
|
3694
|
+
data: b,
|
|
3707
3695
|
from: E,
|
|
3708
3696
|
to: R.toLowerCase(),
|
|
3709
|
-
chainId: BigInt(
|
|
3710
|
-
value:
|
|
3711
|
-
value: c(
|
|
3697
|
+
chainId: BigInt(rt[o]),
|
|
3698
|
+
value: w ? new N({
|
|
3699
|
+
value: c(w) ? w : _(w, "wei").toString(16)
|
|
3712
3700
|
}).getBaseValue("bigint") : 0n
|
|
3713
3701
|
};
|
|
3714
3702
|
return y.sendTransaction(O, s);
|
|
3715
3703
|
}
|
|
3716
|
-
if (
|
|
3704
|
+
if (et.includes(r)) {
|
|
3717
3705
|
if (!a.calldata.fromAsset)
|
|
3718
3706
|
throw new m("core_swap_asset_not_recognized");
|
|
3719
|
-
const y = await
|
|
3707
|
+
const y = await x.fromString(a.calldata.fromAsset);
|
|
3720
3708
|
if (!y)
|
|
3721
3709
|
throw new m("core_swap_asset_not_recognized");
|
|
3722
3710
|
const { address: u } = await f(this, V).call(this, y.chain), {
|
|
3723
3711
|
contract: c,
|
|
3724
|
-
calldata: { expiration: _, amountIn:
|
|
3725
|
-
} = a,
|
|
3712
|
+
calldata: { expiration: _, amountIn: b, memo: E, memoStreamingSwap: R }
|
|
3713
|
+
} = a, w = y.add(N.fromBigInt(BigInt(b), y.decimal)), O = t && R || E;
|
|
3726
3714
|
return this.deposit({
|
|
3727
3715
|
expiration: _,
|
|
3728
|
-
assetValue:
|
|
3716
|
+
assetValue: w,
|
|
3729
3717
|
memo: O,
|
|
3730
3718
|
feeOptionKey: s,
|
|
3731
3719
|
router: c,
|
|
3732
3720
|
recipient: u
|
|
3733
3721
|
});
|
|
3734
3722
|
}
|
|
3735
|
-
if (
|
|
3723
|
+
if (Ze.includes(r)) {
|
|
3736
3724
|
const { calldata: y, contract: u } = a;
|
|
3737
3725
|
if (!u)
|
|
3738
3726
|
throw new m("core_swap_contract_not_found");
|
|
3739
3727
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3740
3728
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3741
3729
|
throw new m("core_wallet_connection_not_found");
|
|
3742
|
-
const { getProvider:
|
|
3743
|
-
if (!
|
|
3730
|
+
const { getProvider: b, toChecksumAddress: E } = await import("@swapkit/toolbox-evm"), R = b(o), w = pn[u.toLowerCase()];
|
|
3731
|
+
if (!w)
|
|
3744
3732
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3745
|
-
const
|
|
3733
|
+
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, w, R))).getFunction("swapIn").populateTransaction(
|
|
3746
3734
|
...dn({
|
|
3747
3735
|
streamSwap: t,
|
|
3748
3736
|
toChecksumAddress: E,
|
|
@@ -3752,7 +3740,7 @@ class Pn {
|
|
|
3752
3740
|
}),
|
|
3753
3741
|
{ from: _ }
|
|
3754
3742
|
);
|
|
3755
|
-
return c.sendTransaction(
|
|
3743
|
+
return c.sendTransaction(S, s);
|
|
3756
3744
|
}
|
|
3757
3745
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3758
3746
|
} catch (y) {
|
|
@@ -3764,7 +3752,7 @@ class Pn {
|
|
|
3764
3752
|
const a = this.getAddress(t);
|
|
3765
3753
|
if (!a)
|
|
3766
3754
|
return null;
|
|
3767
|
-
const s = [
|
|
3755
|
+
const s = [x.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3768
3756
|
try {
|
|
3769
3757
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3770
3758
|
return this.connectedChains[t] = {
|
|
@@ -3811,7 +3799,7 @@ class Pn {
|
|
|
3811
3799
|
case i.Ethereum:
|
|
3812
3800
|
case i.BinanceSmartChain:
|
|
3813
3801
|
case i.Avalanche: {
|
|
3814
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ?
|
|
3802
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Xe : r === i.BinanceSmartChain ? Je : Ye;
|
|
3815
3803
|
return await d.call({
|
|
3816
3804
|
abi: c,
|
|
3817
3805
|
contractAddress: a || (await f(this, V).call(this, r)).router,
|
|
@@ -3834,7 +3822,7 @@ class Pn {
|
|
|
3834
3822
|
return await d.transfer(y);
|
|
3835
3823
|
}
|
|
3836
3824
|
} catch (u) {
|
|
3837
|
-
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"),
|
|
3825
|
+
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), E = c == null ? void 0 : c.includes("server"), R = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : E ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3838
3826
|
throw new m(R, u);
|
|
3839
3827
|
}
|
|
3840
3828
|
});
|
|
@@ -3849,7 +3837,7 @@ class Pn {
|
|
|
3849
3837
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3850
3838
|
let a = "", s = "";
|
|
3851
3839
|
try {
|
|
3852
|
-
a = await f(this,
|
|
3840
|
+
a = await f(this, M).call(this, {
|
|
3853
3841
|
assetValue: t,
|
|
3854
3842
|
memo: D(h.DEPOSIT, {
|
|
3855
3843
|
...n,
|
|
@@ -3860,7 +3848,7 @@ class Pn {
|
|
|
3860
3848
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3861
3849
|
}
|
|
3862
3850
|
try {
|
|
3863
|
-
s = await f(this,
|
|
3851
|
+
s = await f(this, M).call(this, {
|
|
3864
3852
|
assetValue: n,
|
|
3865
3853
|
memo: D(h.DEPOSIT, {
|
|
3866
3854
|
...n,
|
|
@@ -3881,32 +3869,32 @@ class Pn {
|
|
|
3881
3869
|
isPendingSymmAsset: o,
|
|
3882
3870
|
mode: p = "sym"
|
|
3883
3871
|
}) => {
|
|
3884
|
-
const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"),
|
|
3872
|
+
const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"), b = o || c, E = b ? s || this.getAddress(i.THORChain) : "", R = u || p === "asset" ? r || this.getAddress(d) : "";
|
|
3885
3873
|
if (!c && !_)
|
|
3886
3874
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3887
|
-
if (
|
|
3875
|
+
if (b && !E)
|
|
3888
3876
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3889
|
-
let
|
|
3890
|
-
const
|
|
3877
|
+
let w, O;
|
|
3878
|
+
const S = { chain: d, symbol: y.join(".") };
|
|
3891
3879
|
if (c && n)
|
|
3892
3880
|
try {
|
|
3893
|
-
|
|
3881
|
+
w = await f(this, M).call(this, {
|
|
3894
3882
|
assetValue: n,
|
|
3895
|
-
memo: D(h.DEPOSIT, { ...
|
|
3883
|
+
memo: D(h.DEPOSIT, { ...S, address: R })
|
|
3896
3884
|
});
|
|
3897
3885
|
} catch (P) {
|
|
3898
3886
|
throw new m("core_transaction_add_liquidity_rune_error", P);
|
|
3899
3887
|
}
|
|
3900
3888
|
if (_ && a)
|
|
3901
3889
|
try {
|
|
3902
|
-
O = await f(this,
|
|
3890
|
+
O = await f(this, M).call(this, {
|
|
3903
3891
|
assetValue: a,
|
|
3904
|
-
memo: D(h.DEPOSIT, { ...
|
|
3892
|
+
memo: D(h.DEPOSIT, { ...S, address: E })
|
|
3905
3893
|
});
|
|
3906
3894
|
} catch (P) {
|
|
3907
3895
|
throw new m("core_transaction_add_liquidity_asset_error", P);
|
|
3908
3896
|
}
|
|
3909
|
-
return { runeTx:
|
|
3897
|
+
return { runeTx: w, assetTx: O };
|
|
3910
3898
|
});
|
|
3911
3899
|
T(this, "withdraw", async ({
|
|
3912
3900
|
memo: t,
|
|
@@ -3915,10 +3903,10 @@ class Pn {
|
|
|
3915
3903
|
from: s,
|
|
3916
3904
|
to: r
|
|
3917
3905
|
}) => {
|
|
3918
|
-
const o = r === "rune" ?
|
|
3906
|
+
const o = r === "rune" ? x.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n;
|
|
3919
3907
|
try {
|
|
3920
|
-
return await f(this,
|
|
3921
|
-
assetValue:
|
|
3908
|
+
return await f(this, M).call(this, {
|
|
3909
|
+
assetValue: Se(s === "asset" ? n.chain : i.THORChain),
|
|
3922
3910
|
memo: t || D(h.WITHDRAW, {
|
|
3923
3911
|
symbol: n.symbol,
|
|
3924
3912
|
chain: n.chain,
|
|
@@ -3945,14 +3933,14 @@ class Pn {
|
|
|
3945
3933
|
singleSide: !0,
|
|
3946
3934
|
basisPoints: a ? Math.max(1e4, Math.round(a * 100)) : void 0
|
|
3947
3935
|
});
|
|
3948
|
-
return f(this,
|
|
3936
|
+
return f(this, M).call(this, { assetValue: t, memo: o });
|
|
3949
3937
|
});
|
|
3950
3938
|
T(this, "loan", ({
|
|
3951
3939
|
assetValue: t,
|
|
3952
3940
|
memo: n,
|
|
3953
3941
|
minAmount: a,
|
|
3954
3942
|
type: s
|
|
3955
|
-
}) => f(this,
|
|
3943
|
+
}) => f(this, M).call(this, {
|
|
3956
3944
|
assetValue: t,
|
|
3957
3945
|
memo: n || D(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3958
3946
|
asset: t.toString(),
|
|
@@ -3971,7 +3959,7 @@ class Pn {
|
|
|
3971
3959
|
});
|
|
3972
3960
|
return f(this, Y).call(this, {
|
|
3973
3961
|
memo: r,
|
|
3974
|
-
assetValue: t === "bond" ? n :
|
|
3962
|
+
assetValue: t === "bond" ? n : Se(i.THORChain)
|
|
3975
3963
|
});
|
|
3976
3964
|
});
|
|
3977
3965
|
T(this, "registerThorname", ({
|
|
@@ -3982,7 +3970,7 @@ class Pn {
|
|
|
3982
3970
|
try {
|
|
3983
3971
|
t.forEach((r) => {
|
|
3984
3972
|
this[r.connectMethodName] = r.connect({
|
|
3985
|
-
addChain: f(this,
|
|
3973
|
+
addChain: f(this, ne),
|
|
3986
3974
|
config: n || {},
|
|
3987
3975
|
apis: a,
|
|
3988
3976
|
rpcUrls: s
|
|
@@ -4074,7 +4062,7 @@ class Pn {
|
|
|
4074
4062
|
throw new m("core_chain_halted");
|
|
4075
4063
|
return a;
|
|
4076
4064
|
});
|
|
4077
|
-
B(this,
|
|
4065
|
+
B(this, ne, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4078
4066
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4079
4067
|
});
|
|
4080
4068
|
B(this, K, async ({
|
|
@@ -4091,15 +4079,15 @@ class Pn {
|
|
|
4091
4079
|
const _ = this.getAddress(a);
|
|
4092
4080
|
if (!n || !_)
|
|
4093
4081
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
4094
|
-
const
|
|
4082
|
+
const b = p || (await f(this, V).call(this, a)).router;
|
|
4095
4083
|
return c({
|
|
4096
4084
|
amount: t("bigint"),
|
|
4097
4085
|
assetAddress: n,
|
|
4098
4086
|
from: _,
|
|
4099
|
-
spenderAddress:
|
|
4087
|
+
spenderAddress: b
|
|
4100
4088
|
});
|
|
4101
4089
|
});
|
|
4102
|
-
B(this,
|
|
4090
|
+
B(this, M, async ({
|
|
4103
4091
|
assetValue: t,
|
|
4104
4092
|
memo: n,
|
|
4105
4093
|
feeOptionKey: a = F.Fast
|
|
@@ -4132,51 +4120,51 @@ class Pn {
|
|
|
4132
4120
|
this.stagenet = !!t;
|
|
4133
4121
|
}
|
|
4134
4122
|
}
|
|
4135
|
-
V = new WeakMap(),
|
|
4123
|
+
V = new WeakMap(), ne = new WeakMap(), K = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
|
|
4136
4124
|
export {
|
|
4137
|
-
|
|
4125
|
+
ze as AGG_SWAP,
|
|
4138
4126
|
hn as ApiError,
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4127
|
+
q as ApiUrl,
|
|
4128
|
+
x as AssetValue,
|
|
4129
|
+
A as BaseDecimal,
|
|
4130
|
+
ye as BigIntArithmetics,
|
|
4143
4131
|
i as Chain,
|
|
4144
|
-
|
|
4132
|
+
he as ChainId,
|
|
4145
4133
|
Rn as ChainIdToChain,
|
|
4146
|
-
|
|
4147
|
-
|
|
4134
|
+
rt as ChainToChainId,
|
|
4135
|
+
xe as ChainToExplorerUrl,
|
|
4148
4136
|
En as ChainToHexChainId,
|
|
4149
|
-
|
|
4150
|
-
|
|
4137
|
+
ot as ChainToRPC,
|
|
4138
|
+
at as ContractAddress,
|
|
4151
4139
|
wn as CosmosChainList,
|
|
4152
|
-
|
|
4140
|
+
st as DerivationPath,
|
|
4153
4141
|
l as ERROR_CODE,
|
|
4154
|
-
|
|
4155
|
-
|
|
4142
|
+
tt as ERROR_MODULE,
|
|
4143
|
+
Ce as ERROR_TYPE,
|
|
4156
4144
|
fn as EVMChainList,
|
|
4157
|
-
|
|
4145
|
+
pt as ErrorCode,
|
|
4158
4146
|
F as FeeOption,
|
|
4159
4147
|
h as MemoType,
|
|
4160
4148
|
_n as NetworkDerivationPath,
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4149
|
+
Qe as QuoteMode,
|
|
4150
|
+
Ne as RPCUrl,
|
|
4151
|
+
be as RequestClient,
|
|
4152
|
+
Ze as SWAP_IN,
|
|
4153
|
+
et as SWAP_OUT,
|
|
4166
4154
|
Pn as SwapKitCore,
|
|
4167
4155
|
m as SwapKitError,
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4156
|
+
N as SwapKitNumber,
|
|
4157
|
+
Xe as TCAvalancheDepositABI,
|
|
4158
|
+
Je as TCBscDepositABI,
|
|
4159
|
+
Ye as TCEthereumVaultAbi,
|
|
4172
4160
|
An as TCSupportedChainList,
|
|
4173
4161
|
bn as UTXOChainList,
|
|
4174
|
-
|
|
4162
|
+
dt as WalletOption,
|
|
4175
4163
|
gn as assetFromString,
|
|
4176
4164
|
Dn as derivationPathToString,
|
|
4177
4165
|
Tn as erc20ABI,
|
|
4178
4166
|
On as filterAssets,
|
|
4179
|
-
|
|
4167
|
+
se as formatBigIntToSafeValue,
|
|
4180
4168
|
ft as gasFeeMultiplier,
|
|
4181
4169
|
At as getAssetType,
|
|
4182
4170
|
gt as getAsymmetricAssetShare,
|
|
@@ -4184,11 +4172,11 @@ export {
|
|
|
4184
4172
|
Rt as getAsymmetricRuneShare,
|
|
4185
4173
|
In as getAsymmetricRuneWithdrawAmount,
|
|
4186
4174
|
wt as getCommonAssetInfo,
|
|
4187
|
-
|
|
4175
|
+
_t as getDecimal,
|
|
4188
4176
|
Cn as getEstimatedPoolShare,
|
|
4189
4177
|
Mn as getLiquiditySlippage,
|
|
4190
4178
|
D as getMemoFor,
|
|
4191
|
-
|
|
4179
|
+
Se as getMinAmountByChain,
|
|
4192
4180
|
Ot as getSymmetricPoolShare,
|
|
4193
4181
|
vn as getSymmetricWithdraw,
|
|
4194
4182
|
Nn as getTHORNameCost,
|