@swapkit/core 1.0.0-rc.23 → 1.0.0-rc.26
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 +283 -298
- package/package.json +8 -8
- package/src/client/index.ts +7 -12
- package/dist/index-9e36735e.cjs +0 -1
- package/dist/index-cf1865cd.js +0 -649
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
|
-
},
|
|
847
|
-
const
|
|
846
|
+
}, R = (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("/"))
|
|
@@ -985,14 +985,14 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
|
|
|
985
985
|
poolUnits: t,
|
|
986
986
|
runeDepth: n
|
|
987
987
|
}) => {
|
|
988
|
-
const a =
|
|
988
|
+
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = s.mul(s).mul(s);
|
|
989
989
|
return o.mul(p.sub(d).add(y)).div(u);
|
|
990
990
|
}, gt = ({
|
|
991
991
|
liquidityUnits: e,
|
|
992
992
|
poolUnits: t,
|
|
993
993
|
assetDepth: n
|
|
994
994
|
}) => {
|
|
995
|
-
const a =
|
|
995
|
+
const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = o.mul(p.sub(d).add(y)), c = s.mul(s).mul(s);
|
|
996
996
|
return u.div(c);
|
|
997
997
|
}, In = ({
|
|
998
998
|
percent: e,
|
|
@@ -1004,14 +1004,14 @@ 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),
|
|
1007
|
+
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => D.fromBigInt(BigInt(e), A.THOR), Ot = ({
|
|
1008
1008
|
liquidityUnits: e,
|
|
1009
1009
|
poolUnits: t,
|
|
1010
1010
|
runeDepth: n,
|
|
1011
1011
|
assetDepth: a
|
|
1012
1012
|
}) => ({
|
|
1013
|
-
assetAmount:
|
|
1014
|
-
runeAmount:
|
|
1013
|
+
assetAmount: g(a).mul(e).div(t),
|
|
1014
|
+
runeAmount: g(n).mul(e).div(t)
|
|
1015
1015
|
}), vn = ({
|
|
1016
1016
|
liquidityUnits: e,
|
|
1017
1017
|
poolUnits: t,
|
|
@@ -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
|
|
1034
|
-
if (
|
|
1035
|
-
return
|
|
1036
|
-
const P = d.add(
|
|
1037
|
-
return
|
|
1033
|
+
const o = new D({ value: e, decimal: 8 }), p = new D({ value: n, decimal: 8 }), d = new D({ value: t, decimal: 8 }), y = new D({ value: s, decimal: 8 }), u = new D({ value: r, decimal: 8 }), c = y.mul(p), _ = u.mul(o), b = y.mul(u), w = o.mul(p), E = d.mul(c.add(_.add(b.mul(2)))), O = c.add(_.add(w.mul(2))), I = E.div(O), S = g(a).add(I);
|
|
1034
|
+
if (I.getBaseValue("number") === 0)
|
|
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,
|
|
@@ -1043,13 +1043,13 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
|
|
|
1043
1043
|
}) => {
|
|
1044
1044
|
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1045
1045
|
return 0;
|
|
1046
|
-
const s =
|
|
1046
|
+
const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), y = r.mul(p).add(s.mul(r));
|
|
1047
1047
|
return Math.abs(d.div(y).getBaseValue("number"));
|
|
1048
1048
|
}, It = ({
|
|
1049
1049
|
symbol: e,
|
|
1050
1050
|
ticker: t,
|
|
1051
1051
|
chain: n
|
|
1052
|
-
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e,
|
|
1052
|
+
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, x = (e, t) => {
|
|
1053
1053
|
switch (e) {
|
|
1054
1054
|
case h.LEAVE:
|
|
1055
1055
|
case h.BOND: {
|
|
@@ -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(
|
|
1478
|
-
),
|
|
1477
|
+
Math.max(R(this, te, le).call(this, R(this, $, W).call(this, n)), this.decimal || 0)
|
|
1478
|
+
), R(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
|
}
|
|
@@ -1515,16 +1515,16 @@ const Wt = class me {
|
|
|
1515
1515
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1516
1516
|
}
|
|
1517
1517
|
add(...t) {
|
|
1518
|
-
return
|
|
1518
|
+
return R(this, U, k).call(this, "add", ...t);
|
|
1519
1519
|
}
|
|
1520
1520
|
sub(...t) {
|
|
1521
|
-
return
|
|
1521
|
+
return R(this, U, k).call(this, "sub", ...t);
|
|
1522
1522
|
}
|
|
1523
1523
|
mul(...t) {
|
|
1524
|
-
return
|
|
1524
|
+
return R(this, U, k).call(this, "mul", ...t);
|
|
1525
1525
|
}
|
|
1526
1526
|
div(...t) {
|
|
1527
|
-
return
|
|
1527
|
+
return R(this, U, k).call(this, "div", ...t);
|
|
1528
1528
|
}
|
|
1529
1529
|
gt(t) {
|
|
1530
1530
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -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 :
|
|
1572
|
+
const a = ce(t), s = R(this, $, W).call(this, a);
|
|
1573
|
+
return s === "0" || s === "undefined" ? 0n : R(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 =
|
|
1622
|
+
const n = R(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 =
|
|
1651
|
-
this.bigIntValue =
|
|
1652
|
-
},
|
|
1649
|
+
}, pe = /* @__PURE__ */ new WeakSet(), He = function(e) {
|
|
1650
|
+
const t = R(this, $, W).call(this, e) || "0";
|
|
1651
|
+
this.bigIntValue = R(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) :
|
|
1654
|
+
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : R(this, te, le).call(this, R(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 N({ decimal: n, value: a, identifier: e });
|
|
1685
1685
|
};
|
|
1686
|
-
class
|
|
1686
|
+
class N 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 N({ decimal: s, identifier: r, value: o }) : a ? new N({ 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 N({ 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 N({ 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 = N.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 D 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 D({
|
|
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:
|
|
3591
|
-
vault:
|
|
3592
|
-
token:
|
|
3578
|
+
tcVault: b,
|
|
3579
|
+
vault: w,
|
|
3580
|
+
token: E
|
|
3593
3581
|
}
|
|
3594
3582
|
}) => {
|
|
3595
|
-
const
|
|
3596
|
-
if (
|
|
3583
|
+
const O = !!ke[t.toLowerCase()];
|
|
3584
|
+
if (O && !y)
|
|
3597
3585
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3598
|
-
const
|
|
3599
|
-
if (!
|
|
3586
|
+
const I = c || d, S = e && u || I;
|
|
3587
|
+
if (!b && !w)
|
|
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
|
-
if (!
|
|
3593
|
+
if (!E)
|
|
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
|
-
|
|
3612
|
-
a(
|
|
3598
|
+
a(b || w),
|
|
3599
|
+
S.replace("{recipientAddress}", n),
|
|
3600
|
+
a(E),
|
|
3613
3601
|
s
|
|
3614
|
-
],
|
|
3615
|
-
return [...P, ...
|
|
3602
|
+
], Fe = O ? [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,63 +3684,61 @@ 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 {
|
|
3706
|
-
data:
|
|
3707
|
-
from:
|
|
3708
|
-
to:
|
|
3709
|
-
chainId: BigInt(
|
|
3710
|
-
value:
|
|
3711
|
-
value: c(A) ? A : _(A, "wei").toString(16)
|
|
3712
|
-
}).getBaseValue("bigint") : 0n
|
|
3693
|
+
const { data: c, from: _, to: b, value: w } = a.transaction, E = {
|
|
3694
|
+
data: c,
|
|
3695
|
+
from: _,
|
|
3696
|
+
to: b.toLowerCase(),
|
|
3697
|
+
chainId: BigInt(rt[o]),
|
|
3698
|
+
value: w ? BigInt(w) : 0n
|
|
3713
3699
|
};
|
|
3714
|
-
return y.sendTransaction(
|
|
3700
|
+
return y.sendTransaction(E, s);
|
|
3715
3701
|
}
|
|
3716
|
-
if (
|
|
3702
|
+
if (et.includes(r)) {
|
|
3717
3703
|
if (!a.calldata.fromAsset)
|
|
3718
3704
|
throw new m("core_swap_asset_not_recognized");
|
|
3719
|
-
const y = await
|
|
3705
|
+
const y = await N.fromString(a.calldata.fromAsset);
|
|
3720
3706
|
if (!y)
|
|
3721
3707
|
throw new m("core_swap_asset_not_recognized");
|
|
3722
3708
|
const { address: u } = await f(this, V).call(this, y.chain), {
|
|
3723
3709
|
contract: c,
|
|
3724
|
-
calldata: { expiration: _, amountIn:
|
|
3725
|
-
} = a,
|
|
3710
|
+
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap: E }
|
|
3711
|
+
} = a, O = y.add(D.fromBigInt(BigInt(b), y.decimal)), I = t && E || w;
|
|
3726
3712
|
return this.deposit({
|
|
3727
3713
|
expiration: _,
|
|
3728
|
-
assetValue:
|
|
3729
|
-
memo:
|
|
3714
|
+
assetValue: O,
|
|
3715
|
+
memo: I,
|
|
3730
3716
|
feeOptionKey: s,
|
|
3731
3717
|
router: c,
|
|
3732
3718
|
recipient: u
|
|
3733
3719
|
});
|
|
3734
3720
|
}
|
|
3735
|
-
if (
|
|
3721
|
+
if (Ze.includes(r)) {
|
|
3736
3722
|
const { calldata: y, contract: u } = a;
|
|
3737
3723
|
if (!u)
|
|
3738
3724
|
throw new m("core_swap_contract_not_found");
|
|
3739
3725
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3740
3726
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3741
3727
|
throw new m("core_wallet_connection_not_found");
|
|
3742
|
-
const { getProvider:
|
|
3743
|
-
if (!
|
|
3728
|
+
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), E = b(o), O = pn[u.toLowerCase()];
|
|
3729
|
+
if (!O)
|
|
3744
3730
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3745
|
-
const
|
|
3731
|
+
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O, E))).getFunction("swapIn").populateTransaction(
|
|
3746
3732
|
...dn({
|
|
3747
3733
|
streamSwap: t,
|
|
3748
|
-
toChecksumAddress:
|
|
3734
|
+
toChecksumAddress: w,
|
|
3749
3735
|
contractAddress: u,
|
|
3750
3736
|
recipient: n,
|
|
3751
3737
|
calldata: y
|
|
3752
3738
|
}),
|
|
3753
3739
|
{ from: _ }
|
|
3754
3740
|
);
|
|
3755
|
-
return c.sendTransaction(
|
|
3741
|
+
return c.sendTransaction(S, s);
|
|
3756
3742
|
}
|
|
3757
3743
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3758
3744
|
} catch (y) {
|
|
@@ -3764,7 +3750,7 @@ class Pn {
|
|
|
3764
3750
|
const a = this.getAddress(t);
|
|
3765
3751
|
if (!a)
|
|
3766
3752
|
return null;
|
|
3767
|
-
const s = [
|
|
3753
|
+
const s = [N.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3768
3754
|
try {
|
|
3769
3755
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3770
3756
|
return this.connectedChains[t] = {
|
|
@@ -3811,7 +3797,7 @@ class Pn {
|
|
|
3811
3797
|
case i.Ethereum:
|
|
3812
3798
|
case i.BinanceSmartChain:
|
|
3813
3799
|
case i.Avalanche: {
|
|
3814
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ?
|
|
3800
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Xe : r === i.BinanceSmartChain ? Je : Ye;
|
|
3815
3801
|
return await d.call({
|
|
3816
3802
|
abi: c,
|
|
3817
3803
|
contractAddress: a || (await f(this, V).call(this, r)).router,
|
|
@@ -3819,10 +3805,9 @@ class Pn {
|
|
|
3819
3805
|
funcParams: [
|
|
3820
3806
|
n,
|
|
3821
3807
|
u({ chain: r, symbol: o, ticker: p }, r),
|
|
3822
|
-
|
|
3823
|
-
t.getBaseValue("bigint").toString(),
|
|
3808
|
+
t.getBaseValue("string"),
|
|
3824
3809
|
y.memo,
|
|
3825
|
-
s.expiration
|
|
3810
|
+
s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
3826
3811
|
],
|
|
3827
3812
|
txOverrides: {
|
|
3828
3813
|
from: y.from,
|
|
@@ -3834,8 +3819,8 @@ class Pn {
|
|
|
3834
3819
|
return await d.transfer(y);
|
|
3835
3820
|
}
|
|
3836
3821
|
} 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"),
|
|
3838
|
-
throw new m(
|
|
3822
|
+
const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), w = c == null ? void 0 : c.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : w ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3823
|
+
throw new m(E, u);
|
|
3839
3824
|
}
|
|
3840
3825
|
});
|
|
3841
3826
|
/**
|
|
@@ -3849,9 +3834,9 @@ class Pn {
|
|
|
3849
3834
|
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3850
3835
|
let a = "", s = "";
|
|
3851
3836
|
try {
|
|
3852
|
-
a = await f(this,
|
|
3837
|
+
a = await f(this, M).call(this, {
|
|
3853
3838
|
assetValue: t,
|
|
3854
|
-
memo:
|
|
3839
|
+
memo: x(h.DEPOSIT, {
|
|
3855
3840
|
...n,
|
|
3856
3841
|
address: this.getAddress(n.chain)
|
|
3857
3842
|
})
|
|
@@ -3860,9 +3845,9 @@ class Pn {
|
|
|
3860
3845
|
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3861
3846
|
}
|
|
3862
3847
|
try {
|
|
3863
|
-
s = await f(this,
|
|
3848
|
+
s = await f(this, M).call(this, {
|
|
3864
3849
|
assetValue: n,
|
|
3865
|
-
memo:
|
|
3850
|
+
memo: x(h.DEPOSIT, {
|
|
3866
3851
|
...n,
|
|
3867
3852
|
address: this.getAddress(i.THORChain)
|
|
3868
3853
|
})
|
|
@@ -3881,32 +3866,32 @@ class Pn {
|
|
|
3881
3866
|
isPendingSymmAsset: o,
|
|
3882
3867
|
mode: p = "sym"
|
|
3883
3868
|
}) => {
|
|
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"),
|
|
3869
|
+
const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"), b = o || c, w = b ? s || this.getAddress(i.THORChain) : "", E = u || p === "asset" ? r || this.getAddress(d) : "";
|
|
3885
3870
|
if (!c && !_)
|
|
3886
3871
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3887
|
-
if (
|
|
3872
|
+
if (b && !w)
|
|
3888
3873
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3889
|
-
let
|
|
3890
|
-
const
|
|
3874
|
+
let O, I;
|
|
3875
|
+
const S = { chain: d, symbol: y.join(".") };
|
|
3891
3876
|
if (c && n)
|
|
3892
3877
|
try {
|
|
3893
|
-
|
|
3878
|
+
O = await f(this, M).call(this, {
|
|
3894
3879
|
assetValue: n,
|
|
3895
|
-
memo:
|
|
3880
|
+
memo: x(h.DEPOSIT, { ...S, address: E })
|
|
3896
3881
|
});
|
|
3897
3882
|
} catch (P) {
|
|
3898
3883
|
throw new m("core_transaction_add_liquidity_rune_error", P);
|
|
3899
3884
|
}
|
|
3900
3885
|
if (_ && a)
|
|
3901
3886
|
try {
|
|
3902
|
-
|
|
3887
|
+
I = await f(this, M).call(this, {
|
|
3903
3888
|
assetValue: a,
|
|
3904
|
-
memo:
|
|
3889
|
+
memo: x(h.DEPOSIT, { ...S, address: w })
|
|
3905
3890
|
});
|
|
3906
3891
|
} catch (P) {
|
|
3907
3892
|
throw new m("core_transaction_add_liquidity_asset_error", P);
|
|
3908
3893
|
}
|
|
3909
|
-
return { runeTx:
|
|
3894
|
+
return { runeTx: O, assetTx: I };
|
|
3910
3895
|
});
|
|
3911
3896
|
T(this, "withdraw", async ({
|
|
3912
3897
|
memo: t,
|
|
@@ -3915,11 +3900,11 @@ class Pn {
|
|
|
3915
3900
|
from: s,
|
|
3916
3901
|
to: r
|
|
3917
3902
|
}) => {
|
|
3918
|
-
const o = r === "rune" ?
|
|
3903
|
+
const o = r === "rune" ? N.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n;
|
|
3919
3904
|
try {
|
|
3920
|
-
return await f(this,
|
|
3921
|
-
assetValue:
|
|
3922
|
-
memo: t ||
|
|
3905
|
+
return await f(this, M).call(this, {
|
|
3906
|
+
assetValue: Se(s === "asset" ? n.chain : i.THORChain),
|
|
3907
|
+
memo: t || x(h.WITHDRAW, {
|
|
3923
3908
|
symbol: n.symbol,
|
|
3924
3909
|
chain: n.chain,
|
|
3925
3910
|
ticker: n.ticker,
|
|
@@ -3938,23 +3923,23 @@ class Pn {
|
|
|
3938
3923
|
percent: a,
|
|
3939
3924
|
type: s
|
|
3940
3925
|
}) => {
|
|
3941
|
-
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n ||
|
|
3926
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || x(r, {
|
|
3942
3927
|
ticker: t.ticker,
|
|
3943
3928
|
symbol: t.symbol,
|
|
3944
3929
|
chain: t.chain,
|
|
3945
3930
|
singleSide: !0,
|
|
3946
|
-
basisPoints: a ? Math.
|
|
3931
|
+
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3947
3932
|
});
|
|
3948
|
-
return f(this,
|
|
3933
|
+
return f(this, M).call(this, { assetValue: t, memo: o });
|
|
3949
3934
|
});
|
|
3950
3935
|
T(this, "loan", ({
|
|
3951
3936
|
assetValue: t,
|
|
3952
3937
|
memo: n,
|
|
3953
3938
|
minAmount: a,
|
|
3954
3939
|
type: s
|
|
3955
|
-
}) => f(this,
|
|
3940
|
+
}) => f(this, M).call(this, {
|
|
3956
3941
|
assetValue: t,
|
|
3957
|
-
memo: n ||
|
|
3942
|
+
memo: n || x(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3958
3943
|
asset: t.toString(),
|
|
3959
3944
|
minAmount: a.toString(),
|
|
3960
3945
|
address: this.getAddress(t.chain)
|
|
@@ -3965,24 +3950,24 @@ class Pn {
|
|
|
3965
3950
|
assetValue: n,
|
|
3966
3951
|
address: a
|
|
3967
3952
|
}) => {
|
|
3968
|
-
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r =
|
|
3953
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = x(s, {
|
|
3969
3954
|
address: a,
|
|
3970
3955
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
3971
3956
|
});
|
|
3972
3957
|
return f(this, Y).call(this, {
|
|
3973
3958
|
memo: r,
|
|
3974
|
-
assetValue: t === "bond" ? n :
|
|
3959
|
+
assetValue: t === "bond" ? n : Se(i.THORChain)
|
|
3975
3960
|
});
|
|
3976
3961
|
});
|
|
3977
3962
|
T(this, "registerThorname", ({
|
|
3978
3963
|
assetValue: t,
|
|
3979
3964
|
...n
|
|
3980
|
-
}) => f(this, Y).call(this, { assetValue: t, memo:
|
|
3965
|
+
}) => f(this, Y).call(this, { assetValue: t, memo: x(h.THORNAME_REGISTER, n) }));
|
|
3981
3966
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3982
3967
|
try {
|
|
3983
3968
|
t.forEach((r) => {
|
|
3984
3969
|
this[r.connectMethodName] = r.connect({
|
|
3985
|
-
addChain: f(this,
|
|
3970
|
+
addChain: f(this, ne),
|
|
3986
3971
|
config: n || {},
|
|
3987
3972
|
apis: a,
|
|
3988
3973
|
rpcUrls: s
|
|
@@ -4074,32 +4059,32 @@ class Pn {
|
|
|
4074
4059
|
throw new m("core_chain_halted");
|
|
4075
4060
|
return a;
|
|
4076
4061
|
});
|
|
4077
|
-
B(this,
|
|
4062
|
+
B(this, ne, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4078
4063
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4079
4064
|
});
|
|
4080
4065
|
B(this, K, async ({
|
|
4081
|
-
assetValue:
|
|
4082
|
-
type:
|
|
4083
|
-
contractAddress:
|
|
4066
|
+
assetValue: t,
|
|
4067
|
+
type: n = "checkOnly",
|
|
4068
|
+
contractAddress: a
|
|
4084
4069
|
}) => {
|
|
4085
|
-
const d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(
|
|
4086
|
-
if (d &&
|
|
4070
|
+
const { address: s, chain: r, isGasAsset: o, isSynthetic: p } = t, d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(r);
|
|
4071
|
+
if (d && o || !d || p)
|
|
4087
4072
|
return !0;
|
|
4088
|
-
const u = this.connectedWallets[
|
|
4073
|
+
const u = this.connectedWallets[r], c = n === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
|
|
4089
4074
|
if (!c)
|
|
4090
4075
|
throw new m("core_wallet_connection_not_found");
|
|
4091
|
-
const _ = this.getAddress(
|
|
4092
|
-
if (!
|
|
4076
|
+
const _ = this.getAddress(r);
|
|
4077
|
+
if (!s || !_)
|
|
4093
4078
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
4094
|
-
const
|
|
4079
|
+
const b = a || (await f(this, V).call(this, r)).router;
|
|
4095
4080
|
return c({
|
|
4096
|
-
amount: t("bigint"),
|
|
4097
|
-
assetAddress:
|
|
4081
|
+
amount: t.getBaseValue("bigint"),
|
|
4082
|
+
assetAddress: s,
|
|
4098
4083
|
from: _,
|
|
4099
|
-
spenderAddress:
|
|
4084
|
+
spenderAddress: b
|
|
4100
4085
|
});
|
|
4101
4086
|
});
|
|
4102
|
-
B(this,
|
|
4087
|
+
B(this, M, async ({
|
|
4103
4088
|
assetValue: t,
|
|
4104
4089
|
memo: n,
|
|
4105
4090
|
feeOptionKey: a = F.Fast
|
|
@@ -4132,51 +4117,51 @@ class Pn {
|
|
|
4132
4117
|
this.stagenet = !!t;
|
|
4133
4118
|
}
|
|
4134
4119
|
}
|
|
4135
|
-
V = new WeakMap(),
|
|
4120
|
+
V = new WeakMap(), ne = new WeakMap(), K = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
|
|
4136
4121
|
export {
|
|
4137
|
-
|
|
4122
|
+
ze as AGG_SWAP,
|
|
4138
4123
|
hn as ApiError,
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4124
|
+
q as ApiUrl,
|
|
4125
|
+
N as AssetValue,
|
|
4126
|
+
A as BaseDecimal,
|
|
4127
|
+
ye as BigIntArithmetics,
|
|
4143
4128
|
i as Chain,
|
|
4144
|
-
|
|
4129
|
+
he as ChainId,
|
|
4145
4130
|
Rn as ChainIdToChain,
|
|
4146
|
-
|
|
4147
|
-
|
|
4131
|
+
rt as ChainToChainId,
|
|
4132
|
+
xe as ChainToExplorerUrl,
|
|
4148
4133
|
En as ChainToHexChainId,
|
|
4149
|
-
|
|
4150
|
-
|
|
4134
|
+
ot as ChainToRPC,
|
|
4135
|
+
at as ContractAddress,
|
|
4151
4136
|
wn as CosmosChainList,
|
|
4152
|
-
|
|
4137
|
+
st as DerivationPath,
|
|
4153
4138
|
l as ERROR_CODE,
|
|
4154
|
-
|
|
4155
|
-
|
|
4139
|
+
tt as ERROR_MODULE,
|
|
4140
|
+
Ce as ERROR_TYPE,
|
|
4156
4141
|
fn as EVMChainList,
|
|
4157
|
-
|
|
4142
|
+
pt as ErrorCode,
|
|
4158
4143
|
F as FeeOption,
|
|
4159
4144
|
h as MemoType,
|
|
4160
4145
|
_n as NetworkDerivationPath,
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4146
|
+
Qe as QuoteMode,
|
|
4147
|
+
Ne as RPCUrl,
|
|
4148
|
+
be as RequestClient,
|
|
4149
|
+
Ze as SWAP_IN,
|
|
4150
|
+
et as SWAP_OUT,
|
|
4166
4151
|
Pn as SwapKitCore,
|
|
4167
4152
|
m as SwapKitError,
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4153
|
+
D as SwapKitNumber,
|
|
4154
|
+
Xe as TCAvalancheDepositABI,
|
|
4155
|
+
Je as TCBscDepositABI,
|
|
4156
|
+
Ye as TCEthereumVaultAbi,
|
|
4172
4157
|
An as TCSupportedChainList,
|
|
4173
4158
|
bn as UTXOChainList,
|
|
4174
|
-
|
|
4159
|
+
dt as WalletOption,
|
|
4175
4160
|
gn as assetFromString,
|
|
4176
4161
|
Dn as derivationPathToString,
|
|
4177
4162
|
Tn as erc20ABI,
|
|
4178
4163
|
On as filterAssets,
|
|
4179
|
-
|
|
4164
|
+
se as formatBigIntToSafeValue,
|
|
4180
4165
|
ft as gasFeeMultiplier,
|
|
4181
4166
|
At as getAssetType,
|
|
4182
4167
|
gt as getAsymmetricAssetShare,
|
|
@@ -4184,11 +4169,11 @@ export {
|
|
|
4184
4169
|
Rt as getAsymmetricRuneShare,
|
|
4185
4170
|
In as getAsymmetricRuneWithdrawAmount,
|
|
4186
4171
|
wt as getCommonAssetInfo,
|
|
4187
|
-
|
|
4172
|
+
_t as getDecimal,
|
|
4188
4173
|
Cn as getEstimatedPoolShare,
|
|
4189
4174
|
Mn as getLiquiditySlippage,
|
|
4190
|
-
|
|
4191
|
-
|
|
4175
|
+
x as getMemoFor,
|
|
4176
|
+
Se as getMinAmountByChain,
|
|
4192
4177
|
Ot as getSymmetricPoolShare,
|
|
4193
4178
|
vn as getSymmetricWithdraw,
|
|
4194
4179
|
Nn as getTHORNameCost,
|