@swapkit/core 1.0.0-rc.36 → 1.0.0-rc.38
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 +160 -160
- package/package.json +13 -13
package/dist/index.es.js
CHANGED
|
@@ -108,7 +108,7 @@ const hn = [
|
|
|
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 hn = [
|
|
|
283
283
|
stateMutability: "view",
|
|
284
284
|
type: "function"
|
|
285
285
|
}
|
|
286
|
-
],
|
|
286
|
+
], Ke = [
|
|
287
287
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
288
288
|
{
|
|
289
289
|
anonymous: !1,
|
|
@@ -624,7 +624,7 @@ const Qe = [
|
|
|
624
624
|
"TC-BEP20"
|
|
625
625
|
/* TC_SUPPORTED_TO_BSC */
|
|
626
626
|
];
|
|
627
|
-
var
|
|
627
|
+
var Ie = /* @__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))(Ie || {}), et = /* @__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))(et || {}), y = /* @__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))(y || {});
|
|
628
628
|
const tt = {
|
|
629
629
|
[y.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
630
630
|
[y.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
@@ -676,13 +676,13 @@ const tt = {
|
|
|
676
676
|
[y.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
677
677
|
[y.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
678
678
|
[y.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
679
|
-
},
|
|
679
|
+
}, ae = (e, t) => {
|
|
680
680
|
let n = tt[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
|
-
class
|
|
685
|
+
class Se extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -697,15 +697,15 @@ class ve extends Error {
|
|
|
697
697
|
},
|
|
698
698
|
displayMessageParams: u
|
|
699
699
|
}) {
|
|
700
|
-
const c = r ||
|
|
701
|
-
super(c), S(this, "status"), S(this, "revision"), S(this, "type"), S(this, "module"), S(this, "code"), S(this, "message"), S(this, "display"), S(this, "stack"), S(this, "options"), S(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display =
|
|
700
|
+
const c = r || ae(s, u || []) || "";
|
|
701
|
+
super(c), S(this, "status"), S(this, "revision"), S(this, "type"), S(this, "module"), S(this, "code"), S(this, "message"), S(this, "display"), S(this, "stack"), S(this, "options"), S(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = ae(s, u || []), this.code = s, this.type = o || Ie.UNHANDLED_ERROR, this.options = {
|
|
702
702
|
shouldLog: p || !0,
|
|
703
703
|
shouldTrace: l || !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 Se(t);
|
|
709
709
|
}
|
|
710
710
|
toErrorInfo() {
|
|
711
711
|
return { ...this, identifier: this.identifier };
|
|
@@ -714,7 +714,7 @@ class ve 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 ae(this.code, this.displayMessageParams || []);
|
|
718
718
|
}
|
|
719
719
|
handle() {
|
|
720
720
|
const t = `[${this.identifier}]: ${this.message}`;
|
|
@@ -775,23 +775,23 @@ const st = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var
|
|
779
|
-
const
|
|
778
|
+
var me = /* @__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))(me || {}), ve = /* @__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))(ve || {}), k = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(k || {});
|
|
779
|
+
const ee = Object.values(i), it = Object.keys(i), Te = ee.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
781
|
const n = it.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
), rt =
|
|
786
|
-
(e, t) => (e[t] = Te[
|
|
785
|
+
), rt = ee.reduce(
|
|
786
|
+
(e, t) => (e[t] = me[Te[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
), ot =
|
|
789
|
-
(e, t) => (e[t] =
|
|
788
|
+
), ot = ee.reduce(
|
|
789
|
+
(e, t) => (e[t] = ve[Te[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
), An =
|
|
791
|
+
), An = ee.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
|
-
const n = `${
|
|
794
|
-
return e[t] =
|
|
793
|
+
const n = `${Te[t]}Hex`;
|
|
794
|
+
return e[t] = me[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
797
|
), En = {
|
|
@@ -819,7 +819,7 @@ const ne = Object.values(i), it = Object.keys(i), he = ne.reduce(
|
|
|
819
819
|
"thorchain-stagenet-v2": "THOR",
|
|
820
820
|
"thorchain-mainnet-v1": "THOR"
|
|
821
821
|
/* THORChain */
|
|
822
|
-
},
|
|
822
|
+
}, Ce = {
|
|
823
823
|
ARB: "https://arbiscan.io",
|
|
824
824
|
AVAX: "https://snowtrace.io",
|
|
825
825
|
BSC: "https://bscscan.com",
|
|
@@ -843,10 +843,10 @@ var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}
|
|
|
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 ct = "0x313ce567",
|
|
846
|
+
}, D = (e, t, n) => (yt(e, t, "access private method"), n);
|
|
847
|
+
const ct = "0x313ce567", Me = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await
|
|
849
|
+
const { result: n } = await _e.post(ot[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -867,10 +867,10 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
868
|
return w.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
|
-
return t != null && t.startsWith("0x") ?
|
|
870
|
+
return t != null && t.startsWith("0x") ? Me({ chain: i.Ethereum, to: t }) : w.ETH;
|
|
871
871
|
}, Tt = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ?
|
|
873
|
+
return t != null && t.startsWith("0x") ? Me({ chain: i.Avalanche, to: t.toLowerCase() }) : w.AVAX;
|
|
874
874
|
}, ht = async (e) => (e === i.BinanceSmartChain, w.BSC), _t = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
@@ -886,7 +886,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
886
886
|
[H.Average]: 1.2,
|
|
887
887
|
[H.Fast]: 1.5,
|
|
888
888
|
[H.Fastest]: 2
|
|
889
|
-
},
|
|
889
|
+
}, Ne = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case i.Bitcoin:
|
|
892
892
|
case i.BitcoinCash:
|
|
@@ -983,7 +983,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
983
983
|
if (!st.includes(t))
|
|
984
984
|
return !0;
|
|
985
985
|
const [, a] = n.split("-");
|
|
986
|
-
return
|
|
986
|
+
return Ne({ chain: t, symbol: n }) || !!a;
|
|
987
987
|
}, gn = (e) => e.filter((t) => {
|
|
988
988
|
const n = `${t.chain}.${t.symbol}`;
|
|
989
989
|
return !At.test(n) && Et(n) && t.value !== "0";
|
|
@@ -1011,7 +1011,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1011
1011
|
assetDepth: t,
|
|
1012
1012
|
liquidityUnits: n,
|
|
1013
1013
|
poolUnits: a
|
|
1014
|
-
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), R = (e) =>
|
|
1014
|
+
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), R = (e) => N.fromBigInt(BigInt(e), w.THOR), Ot = ({
|
|
1015
1015
|
liquidityUnits: e,
|
|
1016
1016
|
poolUnits: t,
|
|
1017
1017
|
runeDepth: n,
|
|
@@ -1037,11 +1037,11 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1037
1037
|
runeAmount: s,
|
|
1038
1038
|
assetAmount: r
|
|
1039
1039
|
}) => {
|
|
1040
|
-
const o = new
|
|
1040
|
+
const o = new N({ value: e, decimal: 8 }), p = new N({ value: n, decimal: 8 }), d = new N({ value: t, decimal: 8 }), l = new N({ value: s, decimal: 8 }), u = new N({ value: r, decimal: 8 }), c = l.mul(p), _ = u.mul(o), b = l.mul(u), A = o.mul(p), E = d.mul(c.add(_.add(b.mul(2)))), g = c.add(_.add(A.mul(2))), O = E.div(g), x = R(a).add(O);
|
|
1041
1041
|
if (O.getBaseValue("number") === 0)
|
|
1042
|
-
return
|
|
1043
|
-
const
|
|
1044
|
-
return
|
|
1042
|
+
return x.div(d).getBaseValue("number");
|
|
1043
|
+
const ne = d.add(x);
|
|
1044
|
+
return x.div(ne).getBaseValue("number");
|
|
1045
1045
|
}, Cn = ({
|
|
1046
1046
|
runeAmount: e,
|
|
1047
1047
|
assetAmount: t,
|
|
@@ -1097,7 +1097,7 @@ const ct = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
1097
1097
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1098
1098
|
return !!e.match(t);
|
|
1099
1099
|
}, xn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1100
|
-
class
|
|
1100
|
+
class fe extends Error {
|
|
1101
1101
|
constructor(t, n, a) {
|
|
1102
1102
|
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
|
|
1103
1103
|
super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
|
|
@@ -1118,7 +1118,7 @@ class be extends Error {
|
|
|
1118
1118
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
class
|
|
1121
|
+
class xe extends Error {
|
|
1122
1122
|
constructor(t) {
|
|
1123
1123
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
1124
1124
|
enumerable: !0,
|
|
@@ -1128,25 +1128,25 @@ class De extends Error {
|
|
|
1128
1128
|
}), this.name = "TimeoutError", this.request = t;
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
|
-
const
|
|
1131
|
+
const K = (e) => e !== null && typeof e == "object", Y = (...e) => {
|
|
1132
1132
|
for (const t of e)
|
|
1133
|
-
if ((!
|
|
1133
|
+
if ((!K(t) || Array.isArray(t)) && t !== void 0)
|
|
1134
1134
|
throw new TypeError("The `options` argument must be an object");
|
|
1135
|
-
return
|
|
1136
|
-
},
|
|
1135
|
+
return he({}, ...e);
|
|
1136
|
+
}, De = (e = {}, t = {}) => {
|
|
1137
1137
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1138
1138
|
for (const [r, o] of s.entries())
|
|
1139
1139
|
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
1140
1140
|
return n;
|
|
1141
|
-
},
|
|
1141
|
+
}, he = (...e) => {
|
|
1142
1142
|
let t = {}, n = {};
|
|
1143
1143
|
for (const a of e)
|
|
1144
1144
|
if (Array.isArray(a))
|
|
1145
1145
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1146
|
-
else if (
|
|
1146
|
+
else if (K(a)) {
|
|
1147
1147
|
for (let [s, r] of Object.entries(a))
|
|
1148
|
-
|
|
1149
|
-
|
|
1148
|
+
K(r) && s in t && (r = he(t[s], r)), t = { ...t, [s]: r };
|
|
1149
|
+
K(a.headers) && (n = De(n, a.headers), t.headers = n);
|
|
1150
1150
|
}
|
|
1151
1151
|
return t;
|
|
1152
1152
|
}, St = (() => {
|
|
@@ -1160,13 +1160,13 @@ const Y = (e) => e !== null && typeof e == "object", K = (...e) => {
|
|
|
1160
1160
|
return e = !0, "half";
|
|
1161
1161
|
}
|
|
1162
1162
|
}).headers.has("Content-Type")), e && !t;
|
|
1163
|
-
})(), vt = typeof globalThis.AbortController == "function", Ct = typeof globalThis.ReadableStream == "function", Mt = typeof globalThis.FormData == "function",
|
|
1163
|
+
})(), vt = typeof globalThis.AbortController == "function", Ct = typeof globalThis.ReadableStream == "function", Mt = typeof globalThis.FormData == "function", Pe = ["get", "post", "put", "patch", "head", "delete"], Nt = {
|
|
1164
1164
|
json: "application/json",
|
|
1165
1165
|
text: "text/*",
|
|
1166
1166
|
formData: "multipart/form-data",
|
|
1167
1167
|
arrayBuffer: "*/*",
|
|
1168
1168
|
blob: "*/*"
|
|
1169
|
-
},
|
|
1169
|
+
}, se = 2147483647, Be = Symbol("stop"), xt = {
|
|
1170
1170
|
json: !0,
|
|
1171
1171
|
parseJson: !0,
|
|
1172
1172
|
searchParams: !0,
|
|
@@ -1193,18 +1193,18 @@ const Y = (e) => e !== null && typeof e == "object", K = (...e) => {
|
|
|
1193
1193
|
window: !0,
|
|
1194
1194
|
dispatcher: !0,
|
|
1195
1195
|
duplex: !0
|
|
1196
|
-
}, Pt = (e) =>
|
|
1196
|
+
}, Pt = (e) => Pe.includes(e) ? e.toUpperCase() : e, Bt = ["get", "put", "head", "delete", "options", "trace"], Lt = [408, 413, 429, 500, 502, 503, 504], Le = [413, 429, 503], be = {
|
|
1197
1197
|
limit: 2,
|
|
1198
1198
|
methods: Bt,
|
|
1199
1199
|
statusCodes: Lt,
|
|
1200
|
-
afterStatusCodes:
|
|
1200
|
+
afterStatusCodes: Le,
|
|
1201
1201
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1202
1202
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1203
1203
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1204
1204
|
}, Vt = (e = {}) => {
|
|
1205
1205
|
if (typeof e == "number")
|
|
1206
1206
|
return {
|
|
1207
|
-
...
|
|
1207
|
+
...be,
|
|
1208
1208
|
limit: e
|
|
1209
1209
|
};
|
|
1210
1210
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -1212,15 +1212,15 @@ const Y = (e) => e !== null && typeof e == "object", K = (...e) => {
|
|
|
1212
1212
|
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1213
1213
|
throw new Error("retry.statusCodes must be an array");
|
|
1214
1214
|
return {
|
|
1215
|
-
...
|
|
1215
|
+
...be,
|
|
1216
1216
|
...e,
|
|
1217
|
-
afterStatusCodes:
|
|
1217
|
+
afterStatusCodes: Le
|
|
1218
1218
|
};
|
|
1219
1219
|
};
|
|
1220
1220
|
async function Ut(e, t, n, a) {
|
|
1221
1221
|
return new Promise((s, r) => {
|
|
1222
1222
|
const o = setTimeout(() => {
|
|
1223
|
-
n && n.abort(), r(new
|
|
1223
|
+
n && n.abort(), r(new xe(e));
|
|
1224
1224
|
}, a.timeout);
|
|
1225
1225
|
a.fetch(e, t).then(s).catch(r).then(() => {
|
|
1226
1226
|
clearTimeout(o);
|
|
@@ -1244,11 +1244,11 @@ const $t = (e, t) => {
|
|
|
1244
1244
|
!(a in Dt) && !(a in xt) && !(a in e) && (n[a] = t[a]);
|
|
1245
1245
|
return n;
|
|
1246
1246
|
};
|
|
1247
|
-
class
|
|
1247
|
+
class J {
|
|
1248
1248
|
static create(t, n) {
|
|
1249
|
-
const a = new
|
|
1250
|
-
if (typeof a._options.timeout == "number" && a._options.timeout >
|
|
1251
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
1249
|
+
const a = new J(t, n), s = async () => {
|
|
1250
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > se)
|
|
1251
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${se}`);
|
|
1252
1252
|
await Promise.resolve();
|
|
1253
1253
|
let o = await a._fetch();
|
|
1254
1254
|
for (const p of a._options.hooks.afterResponse) {
|
|
@@ -1256,7 +1256,7 @@ class z {
|
|
|
1256
1256
|
d instanceof globalThis.Response && (o = d);
|
|
1257
1257
|
}
|
|
1258
1258
|
if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
|
|
1259
|
-
let p = new
|
|
1259
|
+
let p = new fe(o, a.request, a._options);
|
|
1260
1260
|
for (const d of a._options.hooks.beforeError)
|
|
1261
1261
|
p = await d(p);
|
|
1262
1262
|
throw p;
|
|
@@ -1315,8 +1315,8 @@ class z {
|
|
|
1315
1315
|
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
1316
1316
|
credentials: this._input.credentials || "same-origin",
|
|
1317
1317
|
...n,
|
|
1318
|
-
headers:
|
|
1319
|
-
hooks:
|
|
1318
|
+
headers: De(this._input.headers, n.headers),
|
|
1319
|
+
hooks: he({
|
|
1320
1320
|
beforeRequest: [],
|
|
1321
1321
|
beforeRetry: [],
|
|
1322
1322
|
beforeError: [],
|
|
@@ -1352,8 +1352,8 @@ class z {
|
|
|
1352
1352
|
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 }));
|
|
1353
1353
|
}
|
|
1354
1354
|
_calculateRetryDelay(t) {
|
|
1355
|
-
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof
|
|
1356
|
-
if (t instanceof
|
|
1355
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof xe)) {
|
|
1356
|
+
if (t instanceof fe) {
|
|
1357
1357
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1358
1358
|
return 0;
|
|
1359
1359
|
const a = t.response.headers.get("Retry-After");
|
|
@@ -1376,7 +1376,7 @@ class z {
|
|
|
1376
1376
|
try {
|
|
1377
1377
|
return await t();
|
|
1378
1378
|
} catch (n) {
|
|
1379
|
-
const a = Math.min(this._calculateRetryDelay(n),
|
|
1379
|
+
const a = Math.min(this._calculateRetryDelay(n), se);
|
|
1380
1380
|
if (a !== 0 && this._retryCount > 0) {
|
|
1381
1381
|
await Ht(a, { signal: this._options.signal });
|
|
1382
1382
|
for (const s of this._options.hooks.beforeRetry)
|
|
@@ -1385,7 +1385,7 @@ class z {
|
|
|
1385
1385
|
options: this._options,
|
|
1386
1386
|
error: n,
|
|
1387
1387
|
retryCount: this._retryCount
|
|
1388
|
-
}) ===
|
|
1388
|
+
}) === Be)
|
|
1389
1389
|
return;
|
|
1390
1390
|
return this._retry(t);
|
|
1391
1391
|
}
|
|
@@ -1440,26 +1440,26 @@ class z {
|
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
1442
1442
|
/*! MIT License © Sindre Sorhus */
|
|
1443
|
-
const
|
|
1444
|
-
const t = (n, a) =>
|
|
1445
|
-
for (const n of
|
|
1446
|
-
t[n] = (a, s) =>
|
|
1447
|
-
return t.create = (n) =>
|
|
1448
|
-
}, kt =
|
|
1449
|
-
get: (e, t) =>
|
|
1450
|
-
post: (e, t) =>
|
|
1451
|
-
},
|
|
1443
|
+
const re = (e) => {
|
|
1444
|
+
const t = (n, a) => J.create(n, Y(e, a));
|
|
1445
|
+
for (const n of Pe)
|
|
1446
|
+
t[n] = (a, s) => J.create(a, Y(e, s, { method: n }));
|
|
1447
|
+
return t.create = (n) => re(Y(n)), t.extend = (n) => re(Y(e, n)), t.stop = Be, t;
|
|
1448
|
+
}, kt = re(), Ft = kt, Gt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, we = Ft.create({ headers: Gt }), _e = {
|
|
1449
|
+
get: (e, t) => we.get(e, t).json(),
|
|
1450
|
+
post: (e, t) => we.post(e, t).json()
|
|
1451
|
+
}, Ae = Object.values(i), qt = (e = "") => {
|
|
1452
1452
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1453
|
-
if (
|
|
1453
|
+
if (Ae.includes(n))
|
|
1454
1454
|
return !0;
|
|
1455
1455
|
const [a] = t.split("/");
|
|
1456
|
-
if (
|
|
1456
|
+
if (Ae.includes(a))
|
|
1457
1457
|
return !0;
|
|
1458
1458
|
throw new Error(
|
|
1459
1459
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1460
1460
|
);
|
|
1461
1461
|
}, F = 8, V = (e) => 10n ** BigInt(e), $ = (e) => Math.log10(parseFloat(e.toString()));
|
|
1462
|
-
function
|
|
1462
|
+
function te({
|
|
1463
1463
|
value: e,
|
|
1464
1464
|
bigIntDecimal: t = F,
|
|
1465
1465
|
decimal: n = F
|
|
@@ -1475,19 +1475,19 @@ function ae({
|
|
|
1475
1475
|
""
|
|
1476
1476
|
);
|
|
1477
1477
|
}
|
|
1478
|
-
var L, U,
|
|
1478
|
+
var L, U, oe, Ve, pe, Ee, Q, de;
|
|
1479
1479
|
const Wt = class Ue {
|
|
1480
1480
|
constructor(t) {
|
|
1481
|
-
j(this, L), j(this,
|
|
1482
|
-
const n =
|
|
1481
|
+
j(this, L), j(this, oe), j(this, pe), j(this, Q), v(this, "decimalMultiplier", 10n ** 8n), v(this, "bigIntValue", 0n), v(this, "decimal");
|
|
1482
|
+
const n = le(t);
|
|
1483
1483
|
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = V(
|
|
1484
|
-
Math.max(He(
|
|
1485
|
-
),
|
|
1484
|
+
Math.max(He(z(n)), this.decimal || 0)
|
|
1485
|
+
), D(this, oe, Ve).call(this, n);
|
|
1486
1486
|
}
|
|
1487
1487
|
static fromBigInt(t, n) {
|
|
1488
1488
|
return new Ue({
|
|
1489
1489
|
decimal: n,
|
|
1490
|
-
value:
|
|
1490
|
+
value: te({ value: t, bigIntDecimal: n, decimal: n })
|
|
1491
1491
|
});
|
|
1492
1492
|
}
|
|
1493
1493
|
static shiftDecimals({
|
|
@@ -1501,19 +1501,19 @@ const Wt = class Ue {
|
|
|
1501
1501
|
);
|
|
1502
1502
|
}
|
|
1503
1503
|
set(t) {
|
|
1504
|
-
return
|
|
1504
|
+
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1505
1505
|
}
|
|
1506
1506
|
add(...t) {
|
|
1507
|
-
return
|
|
1507
|
+
return D(this, L, U).call(this, "add", ...t);
|
|
1508
1508
|
}
|
|
1509
1509
|
sub(...t) {
|
|
1510
|
-
return
|
|
1510
|
+
return D(this, L, U).call(this, "sub", ...t);
|
|
1511
1511
|
}
|
|
1512
1512
|
mul(...t) {
|
|
1513
|
-
return
|
|
1513
|
+
return D(this, L, U).call(this, "mul", ...t);
|
|
1514
1514
|
}
|
|
1515
1515
|
div(...t) {
|
|
1516
|
-
return
|
|
1516
|
+
return D(this, L, U).call(this, "div", ...t);
|
|
1517
1517
|
}
|
|
1518
1518
|
gt(t) {
|
|
1519
1519
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1558,8 +1558,8 @@ const Wt = class Ue {
|
|
|
1558
1558
|
getBigIntValue(t, n) {
|
|
1559
1559
|
if (!n && typeof t == "object")
|
|
1560
1560
|
return t.bigIntValue;
|
|
1561
|
-
const a =
|
|
1562
|
-
return s === "0" || s === "undefined" ? 0n :
|
|
1561
|
+
const a = le(t), s = z(a);
|
|
1562
|
+
return s === "0" || s === "undefined" ? 0n : D(this, Q, de).call(this, s, n);
|
|
1563
1563
|
}
|
|
1564
1564
|
formatBigIntToSafeValue(t, n) {
|
|
1565
1565
|
const a = n || this.decimal || F, s = Math.max(
|
|
@@ -1617,7 +1617,7 @@ const Wt = class Ue {
|
|
|
1617
1617
|
}
|
|
1618
1618
|
};
|
|
1619
1619
|
L = /* @__PURE__ */ new WeakSet(), U = function(e, ...t) {
|
|
1620
|
-
const n =
|
|
1620
|
+
const n = D(this, pe, Ee).call(this, this, ...t), a = V(n), s = t.reduce(
|
|
1621
1621
|
(o, p) => {
|
|
1622
1622
|
const d = this.getBigIntValue(p, n);
|
|
1623
1623
|
switch (e) {
|
|
@@ -1638,31 +1638,31 @@ L = /* @__PURE__ */ new WeakSet(), U = function(e, ...t) {
|
|
|
1638
1638
|
},
|
|
1639
1639
|
//normalize is to precision multiplier base
|
|
1640
1640
|
this.bigIntValue * a / this.decimalMultiplier
|
|
1641
|
-
), r =
|
|
1641
|
+
), r = te({
|
|
1642
1642
|
bigIntDecimal: n,
|
|
1643
1643
|
decimal: Math.max(n, $(this.decimalMultiplier)),
|
|
1644
1644
|
value: s
|
|
1645
1645
|
});
|
|
1646
1646
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1647
|
-
},
|
|
1648
|
-
const t =
|
|
1649
|
-
this.bigIntValue =
|
|
1650
|
-
},
|
|
1647
|
+
}, oe = /* @__PURE__ */ new WeakSet(), Ve = function(e) {
|
|
1648
|
+
const t = z(e) || "0";
|
|
1649
|
+
this.bigIntValue = D(this, Q, de).call(this, t);
|
|
1650
|
+
}, pe = /* @__PURE__ */ new WeakSet(), Ee = function(...e) {
|
|
1651
1651
|
const t = e.map(
|
|
1652
|
-
(n) => typeof n == "object" ? n.decimal || $(n.decimalMultiplier) : He(
|
|
1652
|
+
(n) => typeof n == "object" ? n.decimal || $(n.decimalMultiplier) : He(z(n))
|
|
1653
1653
|
).filter(Boolean);
|
|
1654
1654
|
return Math.max(...t, F);
|
|
1655
|
-
},
|
|
1655
|
+
}, Q = /* @__PURE__ */ new WeakSet(), de = function(e, t) {
|
|
1656
1656
|
const n = t ? V(t) : this.decimalMultiplier, a = $(n), [s = "", r = ""] = e.split(".");
|
|
1657
1657
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1658
1658
|
};
|
|
1659
|
-
let
|
|
1659
|
+
let ue = Wt;
|
|
1660
1660
|
const jt = Intl.NumberFormat("fullwide", {
|
|
1661
1661
|
useGrouping: !1,
|
|
1662
1662
|
maximumFractionDigits: 20
|
|
1663
1663
|
});
|
|
1664
|
-
function
|
|
1665
|
-
const t = `${typeof e == "number" ? jt.format(e) :
|
|
1664
|
+
function z(e) {
|
|
1665
|
+
const t = `${typeof e == "number" ? jt.format(e) : le(e)}`.replaceAll(",", ".").split(".");
|
|
1666
1666
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1667
1667
|
}
|
|
1668
1668
|
function He(e) {
|
|
@@ -1670,27 +1670,27 @@ function He(e) {
|
|
|
1670
1670
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1671
1671
|
return Math.max(n, F);
|
|
1672
1672
|
}
|
|
1673
|
-
function
|
|
1673
|
+
function le(e) {
|
|
1674
1674
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1675
1675
|
}
|
|
1676
|
-
const
|
|
1677
|
-
let
|
|
1678
|
-
const
|
|
1679
|
-
if (!
|
|
1676
|
+
const X = (e, t) => typeof e == "bigint" ? te({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1677
|
+
let ye;
|
|
1678
|
+
const Re = (e) => {
|
|
1679
|
+
if (!ye)
|
|
1680
1680
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1681
|
-
return
|
|
1682
|
-
},
|
|
1681
|
+
return ye.get(e.toUpperCase()) || { decimal: w.THOR, identifier: "" };
|
|
1682
|
+
}, ge = async (e, t = 0) => {
|
|
1683
1683
|
qt(e);
|
|
1684
|
-
const n = await _t(
|
|
1684
|
+
const n = await _t(ce(e)), a = X(t, n);
|
|
1685
1685
|
return new C({ decimal: n, value: a, identifier: e });
|
|
1686
1686
|
};
|
|
1687
|
-
class C extends
|
|
1687
|
+
class C extends ue {
|
|
1688
1688
|
constructor(t) {
|
|
1689
1689
|
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`;
|
|
1690
1690
|
super(
|
|
1691
|
-
t.value instanceof
|
|
1691
|
+
t.value instanceof ue ? t.value : { decimal: t.decimal, value: t.value }
|
|
1692
1692
|
), v(this, "address"), v(this, "isSynthetic", !1), v(this, "isGasAsset", !1), v(this, "chain"), v(this, "symbol"), v(this, "ticker"), v(this, "type");
|
|
1693
|
-
const a =
|
|
1693
|
+
const a = ce(n);
|
|
1694
1694
|
this.type = wt(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;
|
|
1695
1695
|
}
|
|
1696
1696
|
toString(t = !1) {
|
|
@@ -1704,23 +1704,23 @@ class C extends ye {
|
|
|
1704
1704
|
return this.chain === t && this.symbol === n;
|
|
1705
1705
|
}
|
|
1706
1706
|
static async fromString(t, n = 0) {
|
|
1707
|
-
return
|
|
1707
|
+
return ge(t, n);
|
|
1708
1708
|
}
|
|
1709
1709
|
static fromStringSync(t, n = 0) {
|
|
1710
|
-
const { isSynthetic: a } =
|
|
1710
|
+
const { isSynthetic: a } = ce(t), { decimal: s, identifier: r } = Re(
|
|
1711
1711
|
t
|
|
1712
|
-
), o =
|
|
1712
|
+
), o = X(n, s);
|
|
1713
1713
|
return r ? new C({ decimal: s, identifier: r, value: o }) : a ? new C({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1714
1714
|
}
|
|
1715
1715
|
static async fromIdentifier(t, n = 0) {
|
|
1716
|
-
return
|
|
1716
|
+
return ge(t, n);
|
|
1717
1717
|
}
|
|
1718
1718
|
static fromIdentifierSync(t, n = 0) {
|
|
1719
|
-
const { decimal: a, identifier: s } =
|
|
1719
|
+
const { decimal: a, identifier: s } = Re(t), r = X(n, a);
|
|
1720
1720
|
return new C({ decimal: a, identifier: s, value: r });
|
|
1721
1721
|
}
|
|
1722
1722
|
static fromChainOrSignature(t, n = 0) {
|
|
1723
|
-
const { decimal: a, identifier: s } = bt(t), r =
|
|
1723
|
+
const { decimal: a, identifier: s } = bt(t), r = X(n, a);
|
|
1724
1724
|
return new C({ value: r, decimal: a, identifier: s });
|
|
1725
1725
|
}
|
|
1726
1726
|
static async loadStaticAssets() {
|
|
@@ -1734,7 +1734,7 @@ class C extends ye {
|
|
|
1734
1734
|
NativeList: s,
|
|
1735
1735
|
...r
|
|
1736
1736
|
} = await import("@swapkit/tokens");
|
|
1737
|
-
|
|
1737
|
+
ye = [s, ...Object.values(r)].reduce(
|
|
1738
1738
|
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: l, ...u }) => {
|
|
1739
1739
|
const c = "decimals" in u ? u.decimals : w[l];
|
|
1740
1740
|
o.set(d, { identifier: d, decimal: c });
|
|
@@ -1752,7 +1752,7 @@ class C extends ye {
|
|
|
1752
1752
|
);
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
|
-
const
|
|
1755
|
+
const ie = (e) => {
|
|
1756
1756
|
const t = C.fromChainOrSignature(e);
|
|
1757
1757
|
switch (e) {
|
|
1758
1758
|
case i.Bitcoin:
|
|
@@ -1770,17 +1770,17 @@ const oe = (e) => {
|
|
|
1770
1770
|
default:
|
|
1771
1771
|
return t.set(1e-8);
|
|
1772
1772
|
}
|
|
1773
|
-
},
|
|
1773
|
+
}, ce = (e) => {
|
|
1774
1774
|
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("-");
|
|
1775
1775
|
return {
|
|
1776
1776
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1777
1777
|
chain: r,
|
|
1778
|
-
isGasAsset:
|
|
1778
|
+
isGasAsset: Ne({ chain: r, symbol: o }),
|
|
1779
1779
|
isSynthetic: t,
|
|
1780
1780
|
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1781
1781
|
ticker: p
|
|
1782
1782
|
};
|
|
1783
|
-
},
|
|
1783
|
+
}, Yt = {
|
|
1784
1784
|
/**
|
|
1785
1785
|
* Core
|
|
1786
1786
|
*/
|
|
@@ -1839,21 +1839,21 @@ const oe = (e) => {
|
|
|
1839
1839
|
};
|
|
1840
1840
|
class m extends Error {
|
|
1841
1841
|
constructor(t, n) {
|
|
1842
|
-
console.error(n), super(t, { cause: { code:
|
|
1842
|
+
console.error(n), super(t, { cause: { code: Yt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1843
1843
|
}
|
|
1844
1844
|
}
|
|
1845
|
-
class
|
|
1845
|
+
class N extends ue {
|
|
1846
1846
|
eq(t) {
|
|
1847
1847
|
return this.eqValue(t);
|
|
1848
1848
|
}
|
|
1849
1849
|
static fromBigInt(t, n) {
|
|
1850
|
-
return new
|
|
1850
|
+
return new N({
|
|
1851
1851
|
decimal: n,
|
|
1852
|
-
value:
|
|
1852
|
+
value: te({ value: t, bigIntDecimal: n, decimal: n })
|
|
1853
1853
|
});
|
|
1854
1854
|
}
|
|
1855
1855
|
}
|
|
1856
|
-
const
|
|
1856
|
+
const Kt = [
|
|
1857
1857
|
{
|
|
1858
1858
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1859
1859
|
stateMutability: "nonpayable",
|
|
@@ -3540,7 +3540,7 @@ const Yt = [
|
|
|
3540
3540
|
},
|
|
3541
3541
|
{ stateMutability: "payable", type: "receive" }
|
|
3542
3542
|
], $e = {
|
|
3543
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3543
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Kt,
|
|
3544
3544
|
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Jt,
|
|
3545
3545
|
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Qt
|
|
3546
3546
|
}, dn = {
|
|
@@ -3582,26 +3582,26 @@ const Yt = [
|
|
|
3582
3582
|
const g = !!$e[t.toLowerCase()];
|
|
3583
3583
|
if (g && !l)
|
|
3584
3584
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3585
|
-
const O = c || d,
|
|
3585
|
+
const O = c || d, x = e && u || O;
|
|
3586
3586
|
if (!b && !A)
|
|
3587
3587
|
throw new Error("TC Vault is required on calldata");
|
|
3588
3588
|
if (!_ && !l)
|
|
3589
3589
|
throw new Error("TC Router is required on calldata");
|
|
3590
|
-
if (!
|
|
3590
|
+
if (!x)
|
|
3591
3591
|
throw new Error("TC Memo is required on calldata");
|
|
3592
3592
|
if (!E)
|
|
3593
3593
|
throw new Error("Token is required on calldata");
|
|
3594
|
-
const
|
|
3594
|
+
const ne = [
|
|
3595
3595
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3596
3596
|
a(_ || l),
|
|
3597
3597
|
a(b || A),
|
|
3598
|
-
|
|
3598
|
+
x.replace("{recipientAddress}", n),
|
|
3599
3599
|
a(E),
|
|
3600
3600
|
s
|
|
3601
3601
|
], ke = g ? [a(l), o, p] : [r, p];
|
|
3602
|
-
return [...
|
|
3602
|
+
return [...ne, ...ke];
|
|
3603
3603
|
}, ln = ({ chain: e, txHash: t }) => {
|
|
3604
|
-
const n =
|
|
3604
|
+
const n = Ce[e];
|
|
3605
3605
|
switch (e) {
|
|
3606
3606
|
case i.Binance:
|
|
3607
3607
|
case i.Bitcoin:
|
|
@@ -3627,7 +3627,7 @@ const Yt = [
|
|
|
3627
3627
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3628
3628
|
}
|
|
3629
3629
|
}, yn = ({ chain: e, address: t }) => {
|
|
3630
|
-
const n =
|
|
3630
|
+
const n = Ce[e];
|
|
3631
3631
|
switch (e) {
|
|
3632
3632
|
case i.Arbitrum:
|
|
3633
3633
|
case i.Avalanche:
|
|
@@ -3652,19 +3652,19 @@ const Yt = [
|
|
|
3652
3652
|
}
|
|
3653
3653
|
}, cn = (e) => {
|
|
3654
3654
|
const t = e ? k.ThornodeStagenet : k.ThornodeMainnet;
|
|
3655
|
-
return
|
|
3655
|
+
return _e.get(`${t}/thorchain/inbound_addresses`);
|
|
3656
3656
|
}, mn = (e) => {
|
|
3657
3657
|
const t = e ? k.ThornodeStagenet : k.ThornodeMainnet;
|
|
3658
|
-
return
|
|
3659
|
-
},
|
|
3658
|
+
return _e.get(`${t}/thorchain/mimir`);
|
|
3659
|
+
}, Oe = () => Object.values(i).reduce(
|
|
3660
3660
|
(e, t) => (e[t] = null, e),
|
|
3661
3661
|
{}
|
|
3662
3662
|
);
|
|
3663
|
-
var B,
|
|
3663
|
+
var B, Z, G, I, q, W;
|
|
3664
3664
|
class Dn {
|
|
3665
3665
|
constructor({ stagenet: t } = {}) {
|
|
3666
|
-
T(this, "connectedChains",
|
|
3667
|
-
T(this, "connectedWallets",
|
|
3666
|
+
T(this, "connectedChains", Oe());
|
|
3667
|
+
T(this, "connectedWallets", Oe());
|
|
3668
3668
|
T(this, "stagenet", !1);
|
|
3669
3669
|
T(this, "getAddress", (t) => {
|
|
3670
3670
|
var n;
|
|
@@ -3707,7 +3707,7 @@ class Dn {
|
|
|
3707
3707
|
const { address: u } = await f(this, B).call(this, l.chain), {
|
|
3708
3708
|
contract: c,
|
|
3709
3709
|
calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
|
|
3710
|
-
} = a, g = l.add(
|
|
3710
|
+
} = a, g = l.add(N.fromBigInt(BigInt(b), l.decimal)), O = t && E || A;
|
|
3711
3711
|
return this.deposit({
|
|
3712
3712
|
expiration: _,
|
|
3713
3713
|
assetValue: g,
|
|
@@ -3727,7 +3727,7 @@ class Dn {
|
|
|
3727
3727
|
const { getProvider: b, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = b(o), g = dn[u.toLowerCase()];
|
|
3728
3728
|
if (!g)
|
|
3729
3729
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3730
|
-
const
|
|
3730
|
+
const x = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, g, E))).getFunction("swapIn").populateTransaction(
|
|
3731
3731
|
...un({
|
|
3732
3732
|
streamSwap: t,
|
|
3733
3733
|
toChecksumAddress: A,
|
|
@@ -3737,7 +3737,7 @@ class Dn {
|
|
|
3737
3737
|
}),
|
|
3738
3738
|
{ from: _ }
|
|
3739
3739
|
);
|
|
3740
|
-
return c.sendTransaction(
|
|
3740
|
+
return c.sendTransaction(x, s);
|
|
3741
3741
|
}
|
|
3742
3742
|
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3743
3743
|
} catch (l) {
|
|
@@ -3796,7 +3796,7 @@ class Dn {
|
|
|
3796
3796
|
case i.Ethereum:
|
|
3797
3797
|
case i.BinanceSmartChain:
|
|
3798
3798
|
case i.Avalanche: {
|
|
3799
|
-
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ?
|
|
3799
|
+
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Ke : r === i.BinanceSmartChain ? Xe : Ye;
|
|
3800
3800
|
return await d.call({
|
|
3801
3801
|
abi: c,
|
|
3802
3802
|
contractAddress: a || (await f(this, B).call(this, r)).router,
|
|
@@ -3907,7 +3907,7 @@ class Dn {
|
|
|
3907
3907
|
from: s,
|
|
3908
3908
|
to: r
|
|
3909
3909
|
}) => {
|
|
3910
|
-
const o = r === "rune" ? C.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p =
|
|
3910
|
+
const o = r === "rune" ? C.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = ie(s === "asset" ? n.chain : i.THORChain), d = t || M(h.WITHDRAW, {
|
|
3911
3911
|
symbol: n.symbol,
|
|
3912
3912
|
chain: n.chain,
|
|
3913
3913
|
ticker: n.ticker,
|
|
@@ -3929,7 +3929,7 @@ class Dn {
|
|
|
3929
3929
|
chain: t.chain,
|
|
3930
3930
|
singleSide: !0,
|
|
3931
3931
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3932
|
-
}), p = r === h.DEPOSIT ? t :
|
|
3932
|
+
}), p = r === h.DEPOSIT ? t : ie(t.chain);
|
|
3933
3933
|
return f(this, I).call(this, { memo: o, assetValue: p });
|
|
3934
3934
|
});
|
|
3935
3935
|
T(this, "loan", ({
|
|
@@ -3956,7 +3956,7 @@ class Dn {
|
|
|
3956
3956
|
});
|
|
3957
3957
|
return f(this, q).call(this, {
|
|
3958
3958
|
memo: r,
|
|
3959
|
-
assetValue: t === "bond" ? n :
|
|
3959
|
+
assetValue: t === "bond" ? n : ie(i.THORChain)
|
|
3960
3960
|
});
|
|
3961
3961
|
});
|
|
3962
3962
|
T(this, "registerThorname", ({
|
|
@@ -3967,7 +3967,7 @@ class Dn {
|
|
|
3967
3967
|
try {
|
|
3968
3968
|
t.forEach((r) => {
|
|
3969
3969
|
this[r.connectMethodName] = r.connect({
|
|
3970
|
-
addChain: f(this,
|
|
3970
|
+
addChain: f(this, Z),
|
|
3971
3971
|
config: n || {},
|
|
3972
3972
|
apis: a,
|
|
3973
3973
|
rpcUrls: s
|
|
@@ -4059,7 +4059,7 @@ class Dn {
|
|
|
4059
4059
|
throw new m("core_chain_halted");
|
|
4060
4060
|
return a;
|
|
4061
4061
|
});
|
|
4062
|
-
P(this,
|
|
4062
|
+
P(this, Z, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
4063
4063
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4064
4064
|
});
|
|
4065
4065
|
P(this, G, async ({
|
|
@@ -4117,19 +4117,19 @@ class Dn {
|
|
|
4117
4117
|
this.stagenet = !!t;
|
|
4118
4118
|
}
|
|
4119
4119
|
}
|
|
4120
|
-
B = new WeakMap(),
|
|
4120
|
+
B = new WeakMap(), Z = new WeakMap(), G = new WeakMap(), I = new WeakMap(), q = new WeakMap(), W = new WeakMap();
|
|
4121
4121
|
export {
|
|
4122
4122
|
Qe as AGG_SWAP,
|
|
4123
|
-
|
|
4123
|
+
Se as ApiError,
|
|
4124
4124
|
k as ApiUrl,
|
|
4125
4125
|
C as AssetValue,
|
|
4126
4126
|
w as BaseDecimal,
|
|
4127
|
-
|
|
4127
|
+
ue as BigIntArithmetics,
|
|
4128
4128
|
i as Chain,
|
|
4129
|
-
|
|
4129
|
+
me as ChainId,
|
|
4130
4130
|
En as ChainIdToChain,
|
|
4131
4131
|
rt as ChainToChainId,
|
|
4132
|
-
|
|
4132
|
+
Ce as ChainToExplorerUrl,
|
|
4133
4133
|
An as ChainToHexChainId,
|
|
4134
4134
|
ot as ChainToRPC,
|
|
4135
4135
|
nt as ContractAddress,
|
|
@@ -4137,23 +4137,23 @@ export {
|
|
|
4137
4137
|
at as DerivationPath,
|
|
4138
4138
|
y as ERROR_CODE,
|
|
4139
4139
|
et as ERROR_MODULE,
|
|
4140
|
-
|
|
4140
|
+
Ie as ERROR_TYPE,
|
|
4141
4141
|
st as EVMChainList,
|
|
4142
4142
|
pt as ErrorCode,
|
|
4143
4143
|
H as FeeOption,
|
|
4144
4144
|
h as MemoType,
|
|
4145
4145
|
_n as NetworkDerivationPath,
|
|
4146
4146
|
Je as QuoteMode,
|
|
4147
|
-
|
|
4148
|
-
|
|
4147
|
+
ve as RPCUrl,
|
|
4148
|
+
_e as RequestClient,
|
|
4149
4149
|
ze as SWAP_IN,
|
|
4150
4150
|
Ze as SWAP_OUT,
|
|
4151
4151
|
Dn as SwapKitCore,
|
|
4152
4152
|
m as SwapKitError,
|
|
4153
|
-
|
|
4154
|
-
|
|
4153
|
+
N as SwapKitNumber,
|
|
4154
|
+
Ke as TCAvalancheDepositABI,
|
|
4155
4155
|
Xe as TCBscDepositABI,
|
|
4156
|
-
|
|
4156
|
+
Ye as TCEthereumVaultAbi,
|
|
4157
4157
|
wn as TCSupportedChainList,
|
|
4158
4158
|
fn as UTXOChainList,
|
|
4159
4159
|
dt as WalletOption,
|
|
@@ -4161,7 +4161,7 @@ export {
|
|
|
4161
4161
|
xn as derivationPathToString,
|
|
4162
4162
|
hn as erc20ABI,
|
|
4163
4163
|
gn as filterAssets,
|
|
4164
|
-
|
|
4164
|
+
te as formatBigIntToSafeValue,
|
|
4165
4165
|
ft as gasFeeMultiplier,
|
|
4166
4166
|
wt as getAssetType,
|
|
4167
4167
|
gt as getAsymmetricAssetShare,
|
|
@@ -4173,10 +4173,10 @@ export {
|
|
|
4173
4173
|
vn as getEstimatedPoolShare,
|
|
4174
4174
|
Cn as getLiquiditySlippage,
|
|
4175
4175
|
M as getMemoFor,
|
|
4176
|
-
|
|
4176
|
+
ie as getMinAmountByChain,
|
|
4177
4177
|
Ot as getSymmetricPoolShare,
|
|
4178
4178
|
Sn as getSymmetricWithdraw,
|
|
4179
4179
|
Mn as getTHORNameCost,
|
|
4180
|
-
|
|
4180
|
+
Ne as isGasAsset,
|
|
4181
4181
|
Nn as validateTHORName
|
|
4182
4182
|
};
|