@pear-protocol/symmio-client 0.2.29 → 0.2.31
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/react/index.d.mts +7 -4
- package/dist/react/index.d.ts +7 -4
- package/dist/react/index.js +83 -118
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +83 -118
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/provider.js +34 -5
- package/dist/react/provider.js.map +1 -1
- package/dist/react/provider.mjs +34 -5
- package/dist/react/provider.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { SymmSDK, CloseOrderRequest, CancelOpenRequest, ClosePositionRequest, Op
|
|
|
5
5
|
import * as viem from 'viem';
|
|
6
6
|
import { Address, WalletClient, Hex, PublicClient } from 'viem';
|
|
7
7
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
8
|
-
import { UseMutationOptions, useQueryClient
|
|
8
|
+
import { UseMutationOptions, useQueryClient } from '@tanstack/react-query';
|
|
9
9
|
import * as node_modules_viem__types_actions_siwe_verifySiweMessage from 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
10
10
|
import * as node_modules_viem__types_utils_ccip from 'node_modules/viem/_types/utils/ccip';
|
|
11
11
|
import * as node_modules__pear_protocol_symm_core_dist_types from 'node_modules/@pear-protocol/symm-core/dist/types';
|
|
@@ -8706,8 +8706,6 @@ interface SymmTokenSelectionMarket extends MarketItem {
|
|
|
8706
8706
|
priceChange24hPercent: number | null;
|
|
8707
8707
|
}
|
|
8708
8708
|
interface UseSymmTokenSelectionMarketsReturn {
|
|
8709
|
-
query: ReturnType<typeof useSymmHedgerMarkets>;
|
|
8710
|
-
priceQuery: ReturnType<typeof useQuery>;
|
|
8711
8709
|
markets: SymmTokenSelectionMarket[];
|
|
8712
8710
|
marketsBySymbol: Map<string, SymmTokenSelectionMarket>;
|
|
8713
8711
|
marketsById: Map<number, SymmTokenSelectionMarket>;
|
|
@@ -8875,9 +8873,10 @@ interface SymmTokenMetadata {
|
|
|
8875
8873
|
priceChange24hPercent: number;
|
|
8876
8874
|
netFunding: number;
|
|
8877
8875
|
markPrice: number;
|
|
8876
|
+
fundingRate: number;
|
|
8877
|
+
nextFundingTime: number;
|
|
8878
8878
|
}
|
|
8879
8879
|
interface UseSymmTokenSelectionMetadataReturn {
|
|
8880
|
-
query: ReturnType<typeof useQuery>;
|
|
8881
8880
|
isLoading: boolean;
|
|
8882
8881
|
isPriceDataReady: boolean;
|
|
8883
8882
|
isUnsupported: boolean;
|
|
@@ -9099,8 +9098,12 @@ type SymmWsState = {
|
|
|
9099
9098
|
declare const useSymmWsStore: zustand.UseBoundStore<zustand.StoreApi<SymmWsState>>;
|
|
9100
9099
|
|
|
9101
9100
|
type MarkPrices = Record<string, number>;
|
|
9101
|
+
type FundingRates = Record<string, number>;
|
|
9102
|
+
type NextFundingTimes = Record<string, number>;
|
|
9102
9103
|
type BinanceMarkPriceState = {
|
|
9103
9104
|
markPrices: MarkPrices;
|
|
9105
|
+
fundingRates: FundingRates;
|
|
9106
|
+
nextFundingTimes: NextFundingTimes;
|
|
9104
9107
|
subscribeSymbol: (symmSymbol: string, binanceSymbol: string) => void;
|
|
9105
9108
|
unsubscribeSymbol: (symmSymbol: string, binanceSymbol: string) => void;
|
|
9106
9109
|
};
|
package/dist/react/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { SymmSDK, CloseOrderRequest, CancelOpenRequest, ClosePositionRequest, Op
|
|
|
5
5
|
import * as viem from 'viem';
|
|
6
6
|
import { Address, WalletClient, Hex, PublicClient } from 'viem';
|
|
7
7
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
8
|
-
import { UseMutationOptions, useQueryClient
|
|
8
|
+
import { UseMutationOptions, useQueryClient } from '@tanstack/react-query';
|
|
9
9
|
import * as node_modules_viem__types_actions_siwe_verifySiweMessage from 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
10
10
|
import * as node_modules_viem__types_utils_ccip from 'node_modules/viem/_types/utils/ccip';
|
|
11
11
|
import * as node_modules__pear_protocol_symm_core_dist_types from 'node_modules/@pear-protocol/symm-core/dist/types';
|
|
@@ -8706,8 +8706,6 @@ interface SymmTokenSelectionMarket extends MarketItem {
|
|
|
8706
8706
|
priceChange24hPercent: number | null;
|
|
8707
8707
|
}
|
|
8708
8708
|
interface UseSymmTokenSelectionMarketsReturn {
|
|
8709
|
-
query: ReturnType<typeof useSymmHedgerMarkets>;
|
|
8710
|
-
priceQuery: ReturnType<typeof useQuery>;
|
|
8711
8709
|
markets: SymmTokenSelectionMarket[];
|
|
8712
8710
|
marketsBySymbol: Map<string, SymmTokenSelectionMarket>;
|
|
8713
8711
|
marketsById: Map<number, SymmTokenSelectionMarket>;
|
|
@@ -8875,9 +8873,10 @@ interface SymmTokenMetadata {
|
|
|
8875
8873
|
priceChange24hPercent: number;
|
|
8876
8874
|
netFunding: number;
|
|
8877
8875
|
markPrice: number;
|
|
8876
|
+
fundingRate: number;
|
|
8877
|
+
nextFundingTime: number;
|
|
8878
8878
|
}
|
|
8879
8879
|
interface UseSymmTokenSelectionMetadataReturn {
|
|
8880
|
-
query: ReturnType<typeof useQuery>;
|
|
8881
8880
|
isLoading: boolean;
|
|
8882
8881
|
isPriceDataReady: boolean;
|
|
8883
8882
|
isUnsupported: boolean;
|
|
@@ -9099,8 +9098,12 @@ type SymmWsState = {
|
|
|
9099
9098
|
declare const useSymmWsStore: zustand.UseBoundStore<zustand.StoreApi<SymmWsState>>;
|
|
9100
9099
|
|
|
9101
9100
|
type MarkPrices = Record<string, number>;
|
|
9101
|
+
type FundingRates = Record<string, number>;
|
|
9102
|
+
type NextFundingTimes = Record<string, number>;
|
|
9102
9103
|
type BinanceMarkPriceState = {
|
|
9103
9104
|
markPrices: MarkPrices;
|
|
9105
|
+
fundingRates: FundingRates;
|
|
9106
|
+
nextFundingTimes: NextFundingTimes;
|
|
9104
9107
|
subscribeSymbol: (symmSymbol: string, binanceSymbol: string) => void;
|
|
9105
9108
|
unsubscribeSymbol: (symmSymbol: string, binanceSymbol: string) => void;
|
|
9106
9109
|
};
|
package/dist/react/index.js
CHANGED
|
@@ -161,7 +161,9 @@ var BinanceWsManager = class {
|
|
|
161
161
|
symbol: normalizeBaseSymbol(raw.s),
|
|
162
162
|
markPrice: parseFloat(raw.p),
|
|
163
163
|
indexPrice: parseFloat(raw.i),
|
|
164
|
-
time: raw.E
|
|
164
|
+
time: raw.E,
|
|
165
|
+
fundingRate: parseFloat(raw.r ?? "0"),
|
|
166
|
+
nextFundingTime: Number(raw.T ?? 0)
|
|
165
167
|
});
|
|
166
168
|
};
|
|
167
169
|
this.addStreamCallback(streamName, id, wrappedCb);
|
|
@@ -180,7 +182,9 @@ var BinanceWsManager = class {
|
|
|
180
182
|
symbol: normalizeBaseSymbol(entry.s),
|
|
181
183
|
markPrice: parseFloat(entry.p),
|
|
182
184
|
indexPrice: parseFloat(entry.i),
|
|
183
|
-
time: entry.E
|
|
185
|
+
time: entry.E,
|
|
186
|
+
fundingRate: parseFloat(entry.r ?? "0"),
|
|
187
|
+
nextFundingTime: Number(entry.T ?? 0)
|
|
184
188
|
}))
|
|
185
189
|
);
|
|
186
190
|
};
|
|
@@ -360,6 +364,8 @@ function getPrevRefCount(binanceSymbol) {
|
|
|
360
364
|
}
|
|
361
365
|
var useBinanceMarkPriceStore = zustand.create((set) => ({
|
|
362
366
|
markPrices: {},
|
|
367
|
+
fundingRates: {},
|
|
368
|
+
nextFundingTimes: {},
|
|
363
369
|
subscribeSymbol: (symmSymbol, rawBinanceSymbol) => {
|
|
364
370
|
const binanceSymbol = normalizeBinanceSymbol(rawBinanceSymbol);
|
|
365
371
|
const nextRefCount = getNextRefCount(binanceSymbol);
|
|
@@ -372,16 +378,29 @@ var useBinanceMarkPriceStore = zustand.create((set) => ({
|
|
|
372
378
|
allMarkPricesUnsubscribe = wsManager.subscribeAllMarkPrices((entries) => {
|
|
373
379
|
set((state) => {
|
|
374
380
|
let nextMarkPrices = null;
|
|
381
|
+
let nextFundingRates = null;
|
|
382
|
+
let nextFundingTimes = null;
|
|
375
383
|
entries.forEach((entry) => {
|
|
376
384
|
const canonicalSymbol = normalizeBinanceSymbol(entry.symbol);
|
|
377
385
|
const mappedSymbols = streamSymbols.get(canonicalSymbol);
|
|
378
386
|
if (!mappedSymbols || mappedSymbols.size === 0) return;
|
|
379
387
|
nextMarkPrices ??= { ...state.markPrices };
|
|
388
|
+
nextFundingRates ??= { ...state.fundingRates };
|
|
389
|
+
nextFundingTimes ??= { ...state.nextFundingTimes };
|
|
380
390
|
mappedSymbols.forEach((mappedSymbol) => {
|
|
381
391
|
nextMarkPrices[mappedSymbol] = entry.markPrice;
|
|
392
|
+
nextFundingRates[mappedSymbol] = entry.fundingRate;
|
|
393
|
+
nextFundingTimes[mappedSymbol] = entry.nextFundingTime;
|
|
382
394
|
});
|
|
383
395
|
});
|
|
384
|
-
|
|
396
|
+
if (!nextMarkPrices || !nextFundingRates || !nextFundingTimes) {
|
|
397
|
+
return state;
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
markPrices: nextMarkPrices,
|
|
401
|
+
fundingRates: nextFundingRates,
|
|
402
|
+
nextFundingTimes
|
|
403
|
+
};
|
|
385
404
|
});
|
|
386
405
|
});
|
|
387
406
|
}
|
|
@@ -410,10 +429,20 @@ var useBinanceMarkPriceStore = zustand.create((set) => ({
|
|
|
410
429
|
allMarkPricesUnsubscribe = null;
|
|
411
430
|
}
|
|
412
431
|
set((state) => {
|
|
413
|
-
if (state.markPrices[symmSymbol] == null
|
|
432
|
+
if (state.markPrices[symmSymbol] == null && state.fundingRates[symmSymbol] == null && state.nextFundingTimes[symmSymbol] == null) {
|
|
433
|
+
return state;
|
|
434
|
+
}
|
|
414
435
|
const nextMarkPrices = { ...state.markPrices };
|
|
436
|
+
const nextFundingRates = { ...state.fundingRates };
|
|
437
|
+
const nextFundingTimes = { ...state.nextFundingTimes };
|
|
415
438
|
delete nextMarkPrices[symmSymbol];
|
|
416
|
-
|
|
439
|
+
delete nextFundingRates[symmSymbol];
|
|
440
|
+
delete nextFundingTimes[symmSymbol];
|
|
441
|
+
return {
|
|
442
|
+
markPrices: nextMarkPrices,
|
|
443
|
+
fundingRates: nextFundingRates,
|
|
444
|
+
nextFundingTimes
|
|
445
|
+
};
|
|
417
446
|
});
|
|
418
447
|
}
|
|
419
448
|
}));
|
|
@@ -25562,7 +25591,9 @@ function useSymmTokenSelectionMarkets(params) {
|
|
|
25562
25591
|
}, [baseMarkets, liveMarkPrices, priceQuery.data]);
|
|
25563
25592
|
const marketsBySymbol = react.useMemo(
|
|
25564
25593
|
() => new Map(
|
|
25565
|
-
markets.filter(
|
|
25594
|
+
markets.filter(
|
|
25595
|
+
(m) => !!m.symbol
|
|
25596
|
+
).map((m) => [m.symbol, m])
|
|
25566
25597
|
),
|
|
25567
25598
|
[markets]
|
|
25568
25599
|
);
|
|
@@ -25570,64 +25601,7 @@ function useSymmTokenSelectionMarkets(params) {
|
|
|
25570
25601
|
() => new Map(markets.map((market) => [market.id, market])),
|
|
25571
25602
|
[markets]
|
|
25572
25603
|
);
|
|
25573
|
-
react.useEffect(() => {
|
|
25574
|
-
console.debug("[useSymmTokenSelectionMarkets] data flow", {
|
|
25575
|
-
params,
|
|
25576
|
-
query: {
|
|
25577
|
-
status: query.status,
|
|
25578
|
-
fetchStatus: query.fetchStatus,
|
|
25579
|
-
isLoading: query.isLoading,
|
|
25580
|
-
isSuccess: query.isSuccess,
|
|
25581
|
-
isError: query.isError,
|
|
25582
|
-
error: query.error
|
|
25583
|
-
},
|
|
25584
|
-
priceQuery: {
|
|
25585
|
-
status: priceQuery.status,
|
|
25586
|
-
fetchStatus: priceQuery.fetchStatus,
|
|
25587
|
-
isLoading: priceQuery.isLoading,
|
|
25588
|
-
isSuccess: priceQuery.isSuccess,
|
|
25589
|
-
isError: priceQuery.isError,
|
|
25590
|
-
error: priceQuery.error
|
|
25591
|
-
},
|
|
25592
|
-
marketSymbols,
|
|
25593
|
-
symbolsKey,
|
|
25594
|
-
liveMarkPrices,
|
|
25595
|
-
tickerSnapshots: priceQuery.data?.tickerSnapshots ?? {},
|
|
25596
|
-
result: {
|
|
25597
|
-
marketCount: markets.length,
|
|
25598
|
-
markets: markets.map((market) => ({
|
|
25599
|
-
id: market.id,
|
|
25600
|
-
symbol: market.symbol,
|
|
25601
|
-
markPrice: market.markPrice,
|
|
25602
|
-
prevDayPrice: market.prevDayPrice,
|
|
25603
|
-
priceChange24h: market.priceChange24h,
|
|
25604
|
-
priceChange24hPercent: market.priceChange24hPercent
|
|
25605
|
-
}))
|
|
25606
|
-
}
|
|
25607
|
-
});
|
|
25608
|
-
}, [
|
|
25609
|
-
liveMarkPrices,
|
|
25610
|
-
marketSymbols,
|
|
25611
|
-
markets,
|
|
25612
|
-
params,
|
|
25613
|
-
priceQuery.data,
|
|
25614
|
-
priceQuery.error,
|
|
25615
|
-
priceQuery.fetchStatus,
|
|
25616
|
-
priceQuery.isError,
|
|
25617
|
-
priceQuery.isLoading,
|
|
25618
|
-
priceQuery.isSuccess,
|
|
25619
|
-
priceQuery.status,
|
|
25620
|
-
query.error,
|
|
25621
|
-
query.fetchStatus,
|
|
25622
|
-
query.isError,
|
|
25623
|
-
query.isLoading,
|
|
25624
|
-
query.isSuccess,
|
|
25625
|
-
query.status,
|
|
25626
|
-
symbolsKey
|
|
25627
|
-
]);
|
|
25628
25604
|
return {
|
|
25629
|
-
query,
|
|
25630
|
-
priceQuery,
|
|
25631
25605
|
markets,
|
|
25632
25606
|
marketsBySymbol,
|
|
25633
25607
|
marketsById,
|
|
@@ -26026,6 +26000,12 @@ function useSymmChartSelection(input) {
|
|
|
26026
26000
|
}
|
|
26027
26001
|
|
|
26028
26002
|
// src/utils/chart-metrics.ts
|
|
26003
|
+
function normalizeWeight(weight) {
|
|
26004
|
+
if (!Number.isFinite(weight) || weight <= 0) {
|
|
26005
|
+
return 0;
|
|
26006
|
+
}
|
|
26007
|
+
return weight <= 1 ? weight : weight / 100;
|
|
26008
|
+
}
|
|
26029
26009
|
function getPositiveValue(metadata, field) {
|
|
26030
26010
|
const value = metadata?.[field];
|
|
26031
26011
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
@@ -26045,7 +26025,8 @@ function computeWeightedProduct(tokens, metadataMap, field, invert = false) {
|
|
|
26045
26025
|
return null;
|
|
26046
26026
|
}
|
|
26047
26027
|
hasToken = true;
|
|
26048
|
-
const
|
|
26028
|
+
const normalizedWeight = normalizeWeight(token.weight);
|
|
26029
|
+
const exponent = invert ? -normalizedWeight : normalizedWeight;
|
|
26049
26030
|
product *= Math.pow(price, exponent);
|
|
26050
26031
|
}
|
|
26051
26032
|
return hasToken ? product : 1;
|
|
@@ -26168,7 +26149,7 @@ async function fetchTickerSnapshot(symbol) {
|
|
|
26168
26149
|
openPrice: ticker.openPrice
|
|
26169
26150
|
};
|
|
26170
26151
|
}
|
|
26171
|
-
function toSymmTokenMetadata(currentPrice, prevDayPrice) {
|
|
26152
|
+
function toSymmTokenMetadata(currentPrice, prevDayPrice, fundingRate, nextFundingTime) {
|
|
26172
26153
|
const priceChange24h = currentPrice - prevDayPrice;
|
|
26173
26154
|
const priceChange24hPercent = prevDayPrice !== 0 ? (currentPrice - prevDayPrice) / prevDayPrice * 100 : 0;
|
|
26174
26155
|
return {
|
|
@@ -26176,9 +26157,10 @@ function toSymmTokenMetadata(currentPrice, prevDayPrice) {
|
|
|
26176
26157
|
prevDayPrice,
|
|
26177
26158
|
priceChange24h,
|
|
26178
26159
|
priceChange24hPercent,
|
|
26179
|
-
netFunding:
|
|
26180
|
-
|
|
26181
|
-
|
|
26160
|
+
netFunding: fundingRate,
|
|
26161
|
+
markPrice: currentPrice,
|
|
26162
|
+
fundingRate,
|
|
26163
|
+
nextFundingTime
|
|
26182
26164
|
};
|
|
26183
26165
|
}
|
|
26184
26166
|
function useSymmTokenSelectionMetadata(selection, options = {}) {
|
|
@@ -26192,6 +26174,12 @@ function useSymmTokenSelectionMetadata(selection, options = {}) {
|
|
|
26192
26174
|
const unavailableReason = isUnsupported ? `Binance market data is unavailable for ${unsupportedSymbols.join(", ")}.` : null;
|
|
26193
26175
|
const symbolsKey = [...selectedSymbols].sort().join(",");
|
|
26194
26176
|
const liveMarkPrices = useBinanceMarkPriceStore((state) => state.markPrices);
|
|
26177
|
+
const liveFundingRates = useBinanceMarkPriceStore(
|
|
26178
|
+
(state) => state.fundingRates
|
|
26179
|
+
);
|
|
26180
|
+
const liveNextFundingTimes = useBinanceMarkPriceStore(
|
|
26181
|
+
(state) => state.nextFundingTimes
|
|
26182
|
+
);
|
|
26195
26183
|
const query = reactQuery.useQuery({
|
|
26196
26184
|
queryKey: ["symm", "chart-metadata", symbolsKey],
|
|
26197
26185
|
queryFn: async () => {
|
|
@@ -26224,13 +26212,27 @@ function useSymmTokenSelectionMetadata(selection, options = {}) {
|
|
|
26224
26212
|
const isLoading = query.isLoading;
|
|
26225
26213
|
for (const token of longTokens) {
|
|
26226
26214
|
const currentPrice = liveMarkPrices[token.symbol];
|
|
26215
|
+
const fundingRate = liveFundingRates[token.symbol];
|
|
26216
|
+
const nextFundingTime = liveNextFundingTimes[token.symbol];
|
|
26227
26217
|
const ticker = tickerSnapshots[token.symbol];
|
|
26228
|
-
longMeta[token.symbol] = currentPrice != null && ticker ? toSymmTokenMetadata(
|
|
26218
|
+
longMeta[token.symbol] = currentPrice != null && ticker ? toSymmTokenMetadata(
|
|
26219
|
+
currentPrice,
|
|
26220
|
+
ticker.openPrice,
|
|
26221
|
+
fundingRate ?? 0,
|
|
26222
|
+
nextFundingTime ?? 0
|
|
26223
|
+
) : null;
|
|
26229
26224
|
}
|
|
26230
26225
|
for (const token of shortTokens) {
|
|
26231
26226
|
const currentPrice = liveMarkPrices[token.symbol];
|
|
26227
|
+
const fundingRate = liveFundingRates[token.symbol];
|
|
26228
|
+
const nextFundingTime = liveNextFundingTimes[token.symbol];
|
|
26232
26229
|
const ticker = tickerSnapshots[token.symbol];
|
|
26233
|
-
shortMeta[token.symbol] = currentPrice != null && ticker ? toSymmTokenMetadata(
|
|
26230
|
+
shortMeta[token.symbol] = currentPrice != null && ticker ? toSymmTokenMetadata(
|
|
26231
|
+
currentPrice,
|
|
26232
|
+
ticker.openPrice,
|
|
26233
|
+
fundingRate ?? 0,
|
|
26234
|
+
nextFundingTime ?? 0
|
|
26235
|
+
) : null;
|
|
26234
26236
|
}
|
|
26235
26237
|
const allLongReady = longTokens.every(
|
|
26236
26238
|
(t) => longMeta[t.symbol]?.currentPrice != null
|
|
@@ -26251,7 +26253,6 @@ function useSymmTokenSelectionMetadata(selection, options = {}) {
|
|
|
26251
26253
|
const weightedRatio24h = computeWeightedRatio24h(metricInput) ?? 0;
|
|
26252
26254
|
const sumNetFunding = computeNetFundingSum(metricInput);
|
|
26253
26255
|
return {
|
|
26254
|
-
query,
|
|
26255
26256
|
isLoading,
|
|
26256
26257
|
isPriceDataReady,
|
|
26257
26258
|
isUnsupported,
|
|
@@ -26268,60 +26269,17 @@ function useSymmTokenSelectionMetadata(selection, options = {}) {
|
|
|
26268
26269
|
}, [
|
|
26269
26270
|
isUnsupported,
|
|
26270
26271
|
longTokens,
|
|
26272
|
+
query,
|
|
26271
26273
|
query.data,
|
|
26272
26274
|
query.isLoading,
|
|
26273
26275
|
shortTokens,
|
|
26274
26276
|
unavailableReason,
|
|
26275
26277
|
unsupportedSymbols,
|
|
26276
26278
|
selectedSymbols.length,
|
|
26279
|
+
liveFundingRates,
|
|
26280
|
+
liveNextFundingTimes,
|
|
26277
26281
|
liveMarkPrices
|
|
26278
26282
|
]);
|
|
26279
|
-
react.useEffect(() => {
|
|
26280
|
-
console.debug("[useSymmTokenSelectionMetadata] data flow", {
|
|
26281
|
-
selection,
|
|
26282
|
-
options,
|
|
26283
|
-
query: {
|
|
26284
|
-
status: query.status,
|
|
26285
|
-
fetchStatus: query.fetchStatus,
|
|
26286
|
-
isLoading: query.isLoading,
|
|
26287
|
-
isSuccess: query.isSuccess,
|
|
26288
|
-
isError: query.isError,
|
|
26289
|
-
error: query.error
|
|
26290
|
-
},
|
|
26291
|
-
selectedSymbols,
|
|
26292
|
-
unsupportedSymbols,
|
|
26293
|
-
unavailableReason,
|
|
26294
|
-
liveMarkPrices,
|
|
26295
|
-
tickerSnapshots: query.data?.tickerSnapshots ?? {},
|
|
26296
|
-
result: {
|
|
26297
|
-
isLoading: result.isLoading,
|
|
26298
|
-
isPriceDataReady: result.isPriceDataReady,
|
|
26299
|
-
isUnsupported: result.isUnsupported,
|
|
26300
|
-
longTokensMetadata: result.longTokensMetadata,
|
|
26301
|
-
shortTokensMetadata: result.shortTokensMetadata,
|
|
26302
|
-
weightedRatio: result.weightedRatio,
|
|
26303
|
-
weightedRatio24h: result.weightedRatio24h,
|
|
26304
|
-
priceRatio: result.priceRatio,
|
|
26305
|
-
priceRatio24h: result.priceRatio24h,
|
|
26306
|
-
sumNetFunding: result.sumNetFunding
|
|
26307
|
-
}
|
|
26308
|
-
});
|
|
26309
|
-
}, [
|
|
26310
|
-
liveMarkPrices,
|
|
26311
|
-
options,
|
|
26312
|
-
query.data,
|
|
26313
|
-
query.error,
|
|
26314
|
-
query.fetchStatus,
|
|
26315
|
-
query.isError,
|
|
26316
|
-
query.isLoading,
|
|
26317
|
-
query.isSuccess,
|
|
26318
|
-
query.status,
|
|
26319
|
-
result,
|
|
26320
|
-
selectedSymbols,
|
|
26321
|
-
selection,
|
|
26322
|
-
unavailableReason,
|
|
26323
|
-
unsupportedSymbols
|
|
26324
|
-
]);
|
|
26325
26283
|
return result;
|
|
26326
26284
|
}
|
|
26327
26285
|
|
|
@@ -26351,6 +26309,12 @@ function toBinanceInterval(interval) {
|
|
|
26351
26309
|
}
|
|
26352
26310
|
|
|
26353
26311
|
// src/react/hooks/use-symm-chart-candles.ts
|
|
26312
|
+
function normalizeWeight2(weight) {
|
|
26313
|
+
if (!Number.isFinite(weight) || weight <= 0) {
|
|
26314
|
+
return 0;
|
|
26315
|
+
}
|
|
26316
|
+
return weight <= 1 ? weight : weight / 100;
|
|
26317
|
+
}
|
|
26354
26318
|
function areIntervalsEqual(currentInterval, nextInterval) {
|
|
26355
26319
|
return currentInterval === toBinanceInterval(nextInterval);
|
|
26356
26320
|
}
|
|
@@ -26388,7 +26352,8 @@ function computeWeightedValues(tokens, candlesBySymbol, invert = false) {
|
|
|
26388
26352
|
if (!(candle.o > 0 && candle.h > 0 && candle.l > 0 && candle.c > 0)) {
|
|
26389
26353
|
return null;
|
|
26390
26354
|
}
|
|
26391
|
-
const
|
|
26355
|
+
const normalizedWeight = normalizeWeight2(token.weight);
|
|
26356
|
+
const exponent = invert ? -normalizedWeight : normalizedWeight;
|
|
26392
26357
|
o *= Math.pow(candle.o, exponent);
|
|
26393
26358
|
h *= Math.pow(candle.h, exponent);
|
|
26394
26359
|
l *= Math.pow(candle.l, exponent);
|