@orderly.network/hooks 0.0.33 → 0.0.35
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.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -177,7 +177,8 @@ var signatureMiddleware = (useSWRNext) => {
|
|
|
177
177
|
const { apiBaseUrl } = useContext(OrderlyContext);
|
|
178
178
|
return (key, fetcher4, config) => {
|
|
179
179
|
try {
|
|
180
|
-
const extendedFetcher = (
|
|
180
|
+
const extendedFetcher = (args) => __async(void 0, null, function* () {
|
|
181
|
+
let url = Array.isArray(args) ? args[0] : args;
|
|
181
182
|
let account5 = SimpleDI.get("account");
|
|
182
183
|
let fullUrl = `${apiBaseUrl}${url}`;
|
|
183
184
|
const signer = account5.signer;
|
|
@@ -271,7 +272,7 @@ var usePrivateQuery = (query, options) => {
|
|
|
271
272
|
const account5 = useAccount();
|
|
272
273
|
const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_b = options == null ? void 0 : options.use) != null ? _b : [] : [];
|
|
273
274
|
return useSWR(
|
|
274
|
-
() => account5.state.status >= AccountStatusEnum.EnableTrading ? query : null,
|
|
275
|
+
() => account5.state.status >= AccountStatusEnum.EnableTrading ? [query, account5.state.accountId] : null,
|
|
275
276
|
// query,
|
|
276
277
|
(url, init) => {
|
|
277
278
|
return fetcher(url, init, { formatter });
|
|
@@ -678,6 +679,8 @@ var mergeItems = (data, update) => {
|
|
|
678
679
|
const [price, quantity] = item;
|
|
679
680
|
const index = data.findIndex(([p], index2) => p === price);
|
|
680
681
|
if (index === -1) {
|
|
682
|
+
if (quantity === 0)
|
|
683
|
+
continue;
|
|
681
684
|
data.push(item);
|
|
682
685
|
} else {
|
|
683
686
|
if (quantity === 0) {
|
|
@@ -1038,10 +1041,8 @@ var usePositionStream = (symbol, options) => {
|
|
|
1038
1041
|
const formatedPositions = useMemo(() => {
|
|
1039
1042
|
if (!(data == null ? void 0 : data.rows) || !symbolInfo || !accountInfo)
|
|
1040
1043
|
return null;
|
|
1041
|
-
const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows.filter((item) => {
|
|
1042
|
-
return item.
|
|
1043
|
-
}) : data.rows.filter((item) => {
|
|
1044
|
-
return item.symbol === symbol && item.position_qty !== 0;
|
|
1044
|
+
const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows : data.rows.filter((item) => {
|
|
1045
|
+
return item.symbol === symbol;
|
|
1045
1046
|
});
|
|
1046
1047
|
let unrealPnL_total = zero, notional_total = zero, unsettlementPnL_total = zero;
|
|
1047
1048
|
const formatted = filteredData.map((item) => {
|
|
@@ -1117,7 +1118,7 @@ var usePositionStream = (symbol, options) => {
|
|
|
1117
1118
|
if (!symbolInfo || !accountInfo)
|
|
1118
1119
|
return formatedPositions[0];
|
|
1119
1120
|
const total = totalCollateral.toNumber();
|
|
1120
|
-
return formatedPositions[0].map((item) => {
|
|
1121
|
+
return formatedPositions[0].filter((item) => item.position_qty !== 0).map((item) => {
|
|
1121
1122
|
const info = symbolInfo == null ? void 0 : symbolInfo[item.symbol];
|
|
1122
1123
|
const MMR = positions.MMR({
|
|
1123
1124
|
baseMMR: info("base_mmr"),
|