@kodiak-finance/orderly-hooks 2.9.4 → 2.9.5
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 +58 -50
- package/dist/index.d.ts +58 -50
- package/dist/index.js +225 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +220 -155
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { createContext, createElement, useContext, useCallback, useState, useEffect, useMemo, useRef, useId, useLayoutEffect } from 'react';
|
|
2
2
|
import { get, WS, mutate as mutate$1 } from '@kodiak-finance/orderly-net';
|
|
3
3
|
import { usePluginScope } from '@kodiak-finance/orderly-plugin-core';
|
|
4
|
-
import { TesnetTokenFallback, ArbitrumSepoliaTokenInfo, SolanaDevnetTokenInfo, MarginMode, OrderType, OrderSide, SDKError, TrackerEventName, AccountStatusEnum, AlgoOrderType, AlgoOrderRootType, OrderStatus, ArbitrumSepoliaChainInfo, SolanaDevnetChainInfo, EMPTY_LIST, EMPTY_OBJECT, isNativeTokenChecker, nativeTokenAddress, ChainKey, chainsInfoMap,
|
|
4
|
+
import { TesnetTokenFallback, ArbitrumSepoliaTokenInfo, SolanaDevnetTokenInfo, MarginMode, OrderType, OrderSide, ARBITRUM_TESTNET_CHAINID, SOLANA_TESTNET_CHAINID, MONAD_TESTNET_CHAINID, ABSTRACT_TESTNET_CHAINID, BSC_TESTNET_CHAINID, SDKError, TrackerEventName, AccountStatusEnum, AlgoOrderType, AlgoOrderRootType, OrderStatus, ArbitrumSepoliaChainInfo, SolanaDevnetChainInfo, EMPTY_LIST, EMPTY_OBJECT, isNativeTokenChecker, nativeTokenAddress, ChainKey, chainsInfoMap, ARBITRUM_MAINNET_CHAINID, ChainNamespace, MaxUint256, DEPOSIT_FEE_RATE, ETHEREUM_MAINNET_CHAINID, LedgerWalletKey, SolanaChains, PositionType, DistributionType, TriggerPriceType } from '@kodiak-finance/orderly-types';
|
|
5
5
|
import useSWR5__default, { mutate } from 'swr';
|
|
6
6
|
import * as useSWR5 from 'swr';
|
|
7
7
|
export { useSWR5 as swr };
|
|
@@ -2175,6 +2175,16 @@ var useReferralInfo = () => {
|
|
|
2175
2175
|
getFirstRefCode
|
|
2176
2176
|
};
|
|
2177
2177
|
};
|
|
2178
|
+
|
|
2179
|
+
// src/referral/referralCode.ts
|
|
2180
|
+
var REFERRAL_CODE_MIN_LENGTH = 4;
|
|
2181
|
+
var REFERRAL_CODE_MAX_LENGTH = 15;
|
|
2182
|
+
function formatReferralCodeInput(raw) {
|
|
2183
|
+
return String(raw).replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/[^A-Z0-9]/g, "");
|
|
2184
|
+
}
|
|
2185
|
+
function isReferralCodeLengthValid(code) {
|
|
2186
|
+
return code.length >= REFERRAL_CODE_MIN_LENGTH && code.length <= REFERRAL_CODE_MAX_LENGTH;
|
|
2187
|
+
}
|
|
2178
2188
|
var useAppStore = create()(
|
|
2179
2189
|
immer((set) => ({
|
|
2180
2190
|
// accountInfo: null,
|
|
@@ -3285,6 +3295,129 @@ var ProxyConfigStore = class {
|
|
|
3285
3295
|
this._originConfigStore.clear();
|
|
3286
3296
|
}
|
|
3287
3297
|
};
|
|
3298
|
+
function createGetter(data, depth = 2) {
|
|
3299
|
+
const getValue = (value, defaultValue) => {
|
|
3300
|
+
if (defaultValue === void 0) {
|
|
3301
|
+
return value;
|
|
3302
|
+
}
|
|
3303
|
+
return value ?? defaultValue;
|
|
3304
|
+
};
|
|
3305
|
+
return new Proxy(data || {}, {
|
|
3306
|
+
get(target, property, receiver) {
|
|
3307
|
+
if (property === "isNil") {
|
|
3308
|
+
return isNil(data);
|
|
3309
|
+
}
|
|
3310
|
+
if (depth === 1) {
|
|
3311
|
+
return (defaultValue) => {
|
|
3312
|
+
if (!target) return defaultValue;
|
|
3313
|
+
return getValue(target[property], defaultValue);
|
|
3314
|
+
};
|
|
3315
|
+
}
|
|
3316
|
+
return (key, defaultValue) => {
|
|
3317
|
+
if (key) {
|
|
3318
|
+
return getValue(target[property]?.[key], defaultValue);
|
|
3319
|
+
} else {
|
|
3320
|
+
return getValue(target[property], defaultValue);
|
|
3321
|
+
}
|
|
3322
|
+
};
|
|
3323
|
+
}
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
// src/orderly/useSymbolsInfo.ts
|
|
3328
|
+
var useSymbolsInfo = () => {
|
|
3329
|
+
const symbolsInfo = useAppStore((state) => state.symbolsInfo);
|
|
3330
|
+
return useMemo(
|
|
3331
|
+
() => createGetter(symbolsInfo ? { ...symbolsInfo } : symbolsInfo),
|
|
3332
|
+
[symbolsInfo]
|
|
3333
|
+
);
|
|
3334
|
+
};
|
|
3335
|
+
var useSymbolsInfoStore = () => {
|
|
3336
|
+
return useAppStore((state) => state.symbolsInfo);
|
|
3337
|
+
};
|
|
3338
|
+
|
|
3339
|
+
// src/trading-rewards/useAllBrokers.ts
|
|
3340
|
+
var useAllBrokers = () => {
|
|
3341
|
+
const { data } = useQuery("/v1/public/broker/name", {
|
|
3342
|
+
formatter: (res) => {
|
|
3343
|
+
const { rows } = res;
|
|
3344
|
+
return rows?.map((item) => ({ [item.broker_id]: item.broker_name })).reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
3345
|
+
}
|
|
3346
|
+
});
|
|
3347
|
+
return [data];
|
|
3348
|
+
};
|
|
3349
|
+
|
|
3350
|
+
// src/useBadgeBySymbol.ts
|
|
3351
|
+
function getSymbolBase(symbol) {
|
|
3352
|
+
if (!symbol) return "";
|
|
3353
|
+
const parts = symbol.split("_");
|
|
3354
|
+
return parts.length >= 3 ? parts[1] ?? "" : symbol.match(/^([A-Za-z]+)/)?.[1] ?? symbol;
|
|
3355
|
+
}
|
|
3356
|
+
function getSymbolDisplayName(symbol, displaySymbolName) {
|
|
3357
|
+
const trimmedDisplayName = displaySymbolName?.trim();
|
|
3358
|
+
if (trimmedDisplayName) return trimmedDisplayName;
|
|
3359
|
+
return getSymbolBase(symbol);
|
|
3360
|
+
}
|
|
3361
|
+
function brokerNameBaseFromRaw(rawBrokerName) {
|
|
3362
|
+
if (!rawBrokerName) return void 0;
|
|
3363
|
+
const first = rawBrokerName.trim().split(/[ _-]/, 1)[0]?.trim() ?? "";
|
|
3364
|
+
return first.length > 0 ? first : void 0;
|
|
3365
|
+
}
|
|
3366
|
+
var useBadgeBySymbol = (symbol) => {
|
|
3367
|
+
const symbolsInfo = useSymbolsInfo();
|
|
3368
|
+
const [brokers] = useAllBrokers();
|
|
3369
|
+
return useMemo(() => {
|
|
3370
|
+
if (!symbol || symbolsInfo.isNil) {
|
|
3371
|
+
return {
|
|
3372
|
+
displaySymbolName: symbol ?? "",
|
|
3373
|
+
brokerId: void 0,
|
|
3374
|
+
brokerName: void 0,
|
|
3375
|
+
brokerNameRaw: void 0
|
|
3376
|
+
};
|
|
3377
|
+
}
|
|
3378
|
+
const getter = symbolsInfo[symbol];
|
|
3379
|
+
const info = typeof getter === "function" ? getter() : void 0;
|
|
3380
|
+
const displaySymbolName = getSymbolDisplayName(
|
|
3381
|
+
symbol,
|
|
3382
|
+
info?.display_symbol_name
|
|
3383
|
+
);
|
|
3384
|
+
const brokerId = info?.broker_id ?? void 0;
|
|
3385
|
+
const rawBrokerName = brokerId ? brokers?.[brokerId] : void 0;
|
|
3386
|
+
const base = brokerNameBaseFromRaw(rawBrokerName);
|
|
3387
|
+
const brokerName = base ? base.length > 7 ? `${base.slice(0, 7)}...` : base : void 0;
|
|
3388
|
+
return {
|
|
3389
|
+
displaySymbolName,
|
|
3390
|
+
brokerId,
|
|
3391
|
+
brokerName,
|
|
3392
|
+
brokerNameRaw: rawBrokerName
|
|
3393
|
+
};
|
|
3394
|
+
}, [brokers, symbolsInfo, symbol]);
|
|
3395
|
+
};
|
|
3396
|
+
function formatSymbolWithBroker(symbol, symbolsInfo, brokers) {
|
|
3397
|
+
if (!symbol) return "";
|
|
3398
|
+
let brokerNameBase;
|
|
3399
|
+
if (!symbolsInfo.isNil) {
|
|
3400
|
+
const getter = symbolsInfo[symbol];
|
|
3401
|
+
const info = typeof getter === "function" ? getter() : void 0;
|
|
3402
|
+
const brokerId = info?.broker_id ?? void 0;
|
|
3403
|
+
const rawBrokerName = brokerId ? brokers?.[brokerId] : void 0;
|
|
3404
|
+
brokerNameBase = brokerNameBaseFromRaw(rawBrokerName);
|
|
3405
|
+
}
|
|
3406
|
+
const base = getSymbolBase(symbol);
|
|
3407
|
+
const hasBrokerSuffix = symbol.includes("-") || symbol.split("_").length > 3;
|
|
3408
|
+
if (brokerNameBase && hasBrokerSuffix) {
|
|
3409
|
+
return `${base}-${brokerNameBase}`;
|
|
3410
|
+
}
|
|
3411
|
+
return base;
|
|
3412
|
+
}
|
|
3413
|
+
var useSymbolWithBroker = (symbol) => {
|
|
3414
|
+
const symbolsInfo = useSymbolsInfo();
|
|
3415
|
+
const [brokers] = useAllBrokers();
|
|
3416
|
+
return useMemo(
|
|
3417
|
+
() => formatSymbolWithBroker(symbol, symbolsInfo, brokers),
|
|
3418
|
+
[brokers, symbolsInfo, symbol]
|
|
3419
|
+
);
|
|
3420
|
+
};
|
|
3288
3421
|
var useMarkPriceStore = create((set, get3) => ({
|
|
3289
3422
|
markPrices: {},
|
|
3290
3423
|
// orderBook: {},
|
|
@@ -3380,36 +3513,6 @@ var useMarketsStream = () => {
|
|
|
3380
3513
|
}, [futures, tickers, markPrices]);
|
|
3381
3514
|
return { data: value };
|
|
3382
3515
|
};
|
|
3383
|
-
function createGetter(data, depth = 2) {
|
|
3384
|
-
const getValue = (value, defaultValue) => {
|
|
3385
|
-
if (defaultValue === void 0) {
|
|
3386
|
-
return value;
|
|
3387
|
-
}
|
|
3388
|
-
return value ?? defaultValue;
|
|
3389
|
-
};
|
|
3390
|
-
return new Proxy(data || {}, {
|
|
3391
|
-
get(target, property, receiver) {
|
|
3392
|
-
if (property === "isNil") {
|
|
3393
|
-
return isNil(data);
|
|
3394
|
-
}
|
|
3395
|
-
if (depth === 1) {
|
|
3396
|
-
return (defaultValue) => {
|
|
3397
|
-
if (!target) return defaultValue;
|
|
3398
|
-
return getValue(target[property], defaultValue);
|
|
3399
|
-
};
|
|
3400
|
-
}
|
|
3401
|
-
return (key, defaultValue) => {
|
|
3402
|
-
if (key) {
|
|
3403
|
-
return getValue(target[property]?.[key], defaultValue);
|
|
3404
|
-
} else {
|
|
3405
|
-
return getValue(target[property], defaultValue);
|
|
3406
|
-
}
|
|
3407
|
-
};
|
|
3408
|
-
}
|
|
3409
|
-
});
|
|
3410
|
-
}
|
|
3411
|
-
|
|
3412
|
-
// src/orderly/useRwaSymbolsInfo.ts
|
|
3413
3516
|
var isCurrentlyTrading = (nextClose, status, currentTime = Date.now()) => {
|
|
3414
3517
|
return currentTime < nextClose && status === "open";
|
|
3415
3518
|
};
|
|
@@ -3549,27 +3652,52 @@ var useGetRwaSymbolOpenTimeInterval = (symbol, thresholdMinutes = 30) => {
|
|
|
3549
3652
|
return { isRwa, open, openTimeInterval: filteredInterval, nextOpen };
|
|
3550
3653
|
}, [isRwa, open, openTimeInterval, nextOpen, thresholdMinutes]);
|
|
3551
3654
|
};
|
|
3552
|
-
var useSymbolsInfo = () => {
|
|
3553
|
-
const symbolsInfo = useAppStore((state) => state.symbolsInfo);
|
|
3554
|
-
return useMemo(
|
|
3555
|
-
() => createGetter(symbolsInfo ? { ...symbolsInfo } : symbolsInfo),
|
|
3556
|
-
[symbolsInfo]
|
|
3557
|
-
);
|
|
3558
|
-
};
|
|
3559
|
-
var useSymbolsInfoStore = () => {
|
|
3560
|
-
return useAppStore((state) => state.symbolsInfo);
|
|
3561
|
-
};
|
|
3562
3655
|
|
|
3563
|
-
// src/orderly/
|
|
3656
|
+
// src/orderly/markets/marketTypes.ts
|
|
3564
3657
|
var MarketsType = /* @__PURE__ */ ((MarketsType2) => {
|
|
3565
3658
|
MarketsType2[MarketsType2["FAVORITES"] = 0] = "FAVORITES";
|
|
3566
3659
|
MarketsType2[MarketsType2["RECENT"] = 1] = "RECENT";
|
|
3567
3660
|
MarketsType2[MarketsType2["ALL"] = 2] = "ALL";
|
|
3568
|
-
MarketsType2[MarketsType2["
|
|
3569
|
-
MarketsType2[MarketsType2["
|
|
3570
|
-
MarketsType2[MarketsType2["
|
|
3661
|
+
MarketsType2[MarketsType2["CRYPTO"] = 3] = "CRYPTO";
|
|
3662
|
+
MarketsType2[MarketsType2["RWA"] = 4] = "RWA";
|
|
3663
|
+
MarketsType2[MarketsType2["NEW_LISTING"] = 5] = "NEW_LISTING";
|
|
3664
|
+
MarketsType2[MarketsType2["COMMUNITY"] = 6] = "COMMUNITY";
|
|
3665
|
+
MarketsType2[MarketsType2["PRE_TGE"] = 7] = "PRE_TGE";
|
|
3571
3666
|
return MarketsType2;
|
|
3572
3667
|
})(MarketsType || {});
|
|
3668
|
+
|
|
3669
|
+
// src/orderly/markets/marketFilter.ts
|
|
3670
|
+
var filterMarkets = (params) => {
|
|
3671
|
+
const { markets, favorites, recent, newListing, type } = params;
|
|
3672
|
+
let curData = [];
|
|
3673
|
+
if (type === 2 /* ALL */ || type === 6 /* COMMUNITY */) {
|
|
3674
|
+
curData = markets;
|
|
3675
|
+
} else if (type === 3 /* CRYPTO */) {
|
|
3676
|
+
curData = markets.filter((item) => !item.isRwa);
|
|
3677
|
+
} else if (type === 4 /* RWA */) {
|
|
3678
|
+
curData = markets.filter((item) => item.isRwa);
|
|
3679
|
+
} else if (type === 7 /* PRE_TGE */) {
|
|
3680
|
+
curData = markets.filter((item) => item.isPreTge);
|
|
3681
|
+
} else if (type === 5 /* NEW_LISTING */) {
|
|
3682
|
+
curData = markets.filter((item) => isNewListing(item.created_time)).sort((a, b) => b.created_time - a.created_time);
|
|
3683
|
+
} else {
|
|
3684
|
+
const storageData = type === 0 /* FAVORITES */ ? favorites : type === 1 /* RECENT */ ? recent : newListing;
|
|
3685
|
+
const keys = storageData.map((item) => item.name);
|
|
3686
|
+
curData = markets?.filter((item) => keys.includes(item.symbol));
|
|
3687
|
+
}
|
|
3688
|
+
const favoriteKeys = favorites.map((item) => item.name);
|
|
3689
|
+
return curData?.map((item) => ({
|
|
3690
|
+
...item,
|
|
3691
|
+
isFavorite: type === 0 /* FAVORITES */ ? true : favoriteKeys.includes(item.symbol)
|
|
3692
|
+
}));
|
|
3693
|
+
};
|
|
3694
|
+
var isNewListing = (createdTime) => {
|
|
3695
|
+
const thirtyDaysInMs = 30 * 24 * 60 * 60 * 1e3;
|
|
3696
|
+
const now = Date.now();
|
|
3697
|
+
return now - createdTime < thirtyDaysInMs;
|
|
3698
|
+
};
|
|
3699
|
+
|
|
3700
|
+
// src/orderly/markets/useMarkets.ts
|
|
3573
3701
|
var MarketsStorageKey = "orderly_markets";
|
|
3574
3702
|
var DefaultFavoriteTab = { name: "Popular", id: 1 };
|
|
3575
3703
|
var useMarketsStore = () => {
|
|
@@ -3728,7 +3856,15 @@ var useMarkets = (type = 2 /* ALL */) => {
|
|
|
3728
3856
|
type
|
|
3729
3857
|
});
|
|
3730
3858
|
setMarkets(filterList);
|
|
3731
|
-
}, [
|
|
3859
|
+
}, [
|
|
3860
|
+
futures,
|
|
3861
|
+
symbolsInfo,
|
|
3862
|
+
rwaSymbolsInfo,
|
|
3863
|
+
favorites,
|
|
3864
|
+
recent,
|
|
3865
|
+
newListing,
|
|
3866
|
+
type
|
|
3867
|
+
]);
|
|
3732
3868
|
return [markets, store];
|
|
3733
3869
|
};
|
|
3734
3870
|
var addFieldToMarkets = (futures, symbolsInfo, rwaSymbolsInfo) => {
|
|
@@ -3738,10 +3874,12 @@ var addFieldToMarkets = (futures, symbolsInfo, rwaSymbolsInfo) => {
|
|
|
3738
3874
|
return {
|
|
3739
3875
|
...item,
|
|
3740
3876
|
broker_id: item.broker_id,
|
|
3741
|
-
display_symbol_name:
|
|
3877
|
+
display_symbol_name: getSymbolDisplayName(
|
|
3878
|
+
item.symbol,
|
|
3879
|
+
info("display_symbol_name")
|
|
3880
|
+
),
|
|
3742
3881
|
quote_dp: info("quote_dp"),
|
|
3743
3882
|
created_time: info("created_time"),
|
|
3744
|
-
displayName: info("displayName"),
|
|
3745
3883
|
leverage: getLeverage(info("base_imr")),
|
|
3746
3884
|
openInterest: getOpenInterest(item.open_interest, item.index_price),
|
|
3747
3885
|
"8h_funding": get8hFunding(item.est_funding_rate, info("funding_period")),
|
|
@@ -3751,40 +3889,17 @@ var addFieldToMarkets = (futures, symbolsInfo, rwaSymbolsInfo) => {
|
|
|
3751
3889
|
open: item["24h_open"]
|
|
3752
3890
|
}),
|
|
3753
3891
|
isRwa: !!rwaInfo,
|
|
3892
|
+
isPreTge: Boolean(item.is_pretge ?? info("is_pretge")),
|
|
3893
|
+
market_session: rwaInfo?.market_session,
|
|
3754
3894
|
rwaNextOpen: rwaInfo?.next_open,
|
|
3755
3895
|
rwaNextClose: rwaInfo?.next_close,
|
|
3756
3896
|
rwaStatus: rwaInfo?.status
|
|
3757
3897
|
};
|
|
3758
3898
|
});
|
|
3759
3899
|
};
|
|
3760
|
-
var filterMarkets = (params) => {
|
|
3761
|
-
const { markets, favorites, recent, newListing, type } = params;
|
|
3762
|
-
let curData = [];
|
|
3763
|
-
if (type === 2 /* ALL */ || type === 5 /* COMMUNITY */) {
|
|
3764
|
-
curData = markets;
|
|
3765
|
-
} else if (type === 3 /* RWA */) {
|
|
3766
|
-
curData = markets.filter((item) => item.isRwa);
|
|
3767
|
-
} else if (type === 4 /* NEW_LISTING */) {
|
|
3768
|
-
curData = markets.filter((item) => isNewListing(item.created_time)).sort((a, b) => b.created_time - a.created_time);
|
|
3769
|
-
} else {
|
|
3770
|
-
const storageData = type === 0 /* FAVORITES */ ? favorites : type === 1 /* RECENT */ ? recent : newListing;
|
|
3771
|
-
const keys = storageData.map((item) => item.name);
|
|
3772
|
-
curData = markets?.filter((item) => keys.includes(item.symbol));
|
|
3773
|
-
}
|
|
3774
|
-
const favoriteKeys = favorites.map((item) => item.name);
|
|
3775
|
-
return curData?.map((item) => ({
|
|
3776
|
-
...item,
|
|
3777
|
-
isFavorite: type === 0 /* FAVORITES */ ? true : favoriteKeys.includes(item.symbol)
|
|
3778
|
-
}));
|
|
3779
|
-
};
|
|
3780
3900
|
function isEmpty(value) {
|
|
3781
3901
|
return value === void 0 || value === null;
|
|
3782
3902
|
}
|
|
3783
|
-
var isNewListing = (createdTime) => {
|
|
3784
|
-
const thirtyDaysInMs = 30 * 24 * 60 * 60 * 1e3;
|
|
3785
|
-
const now = Date.now();
|
|
3786
|
-
return now - createdTime < thirtyDaysInMs;
|
|
3787
|
-
};
|
|
3788
3903
|
function get8hFunding(est_funding_rate, funding_period) {
|
|
3789
3904
|
let funding8h = 0;
|
|
3790
3905
|
if (isEmpty(est_funding_rate)) {
|
|
@@ -4506,12 +4621,13 @@ var useFundingRatesStore = () => {
|
|
|
4506
4621
|
return data;
|
|
4507
4622
|
};
|
|
4508
4623
|
|
|
4509
|
-
// src/orderly/useMarket.ts
|
|
4624
|
+
// src/orderly/markets/useMarket.ts
|
|
4510
4625
|
var DefaultTab = { name: "Popular", id: 1 };
|
|
4511
4626
|
var marketsKey = "markets";
|
|
4512
4627
|
var useMarket = (type) => {
|
|
4513
4628
|
const { configStore } = useContext(OrderlyContext);
|
|
4514
4629
|
const symbolsInfo = useSymbolsInfo();
|
|
4630
|
+
const rwaSymbolsInfo = useRwaSymbolsInfo();
|
|
4515
4631
|
const fundingRates = useFundingRates();
|
|
4516
4632
|
const { data: futures } = useMarketsStream();
|
|
4517
4633
|
const updateStore = (key, data) => {
|
|
@@ -4648,6 +4764,7 @@ var useMarket = (type) => {
|
|
|
4648
4764
|
const list = futures?.map((item) => {
|
|
4649
4765
|
const { open_interest = 0, index_price = 0 } = item;
|
|
4650
4766
|
const info = symbolsInfo[item.symbol];
|
|
4767
|
+
const rwaInfo = !rwaSymbolsInfo.isNil ? rwaSymbolsInfo[item.symbol]() : null;
|
|
4651
4768
|
const rate = fundingRates[item.symbol];
|
|
4652
4769
|
const est_funding_rate = rate("est_funding_rate");
|
|
4653
4770
|
const funding_period = info("funding_period");
|
|
@@ -4658,15 +4775,26 @@ var useMarket = (type) => {
|
|
|
4658
4775
|
"8h_funding": get8hFunding2(est_funding_rate, funding_period),
|
|
4659
4776
|
quote_dp: info("quote_dp"),
|
|
4660
4777
|
created_time: info("created_time"),
|
|
4778
|
+
isRwa: !!rwaInfo,
|
|
4779
|
+
isPreTge: Boolean(item.is_pretge ?? info("is_pretge")),
|
|
4661
4780
|
openInterest: new Decimal(open_interest || 0).mul(index_price || 0).toNumber()
|
|
4662
4781
|
};
|
|
4663
4782
|
});
|
|
4664
4783
|
return list || [];
|
|
4665
|
-
}, [symbolsInfo, futures, fundingRates]);
|
|
4784
|
+
}, [symbolsInfo, futures, fundingRates, rwaSymbolsInfo]);
|
|
4666
4785
|
const getData = (type2) => {
|
|
4667
4786
|
const localData = type2 === 0 /* FAVORITES */ ? [...favorites] : [...recent];
|
|
4668
4787
|
const keys = localData.map((item) => item.name);
|
|
4669
|
-
|
|
4788
|
+
let filter = marketsList;
|
|
4789
|
+
if (type2 == 3 /* CRYPTO */) {
|
|
4790
|
+
filter = marketsList?.filter((item) => !item.isRwa);
|
|
4791
|
+
} else if (type2 == 4 /* RWA */) {
|
|
4792
|
+
filter = marketsList?.filter((item) => item.isRwa);
|
|
4793
|
+
} else if (type2 == 7 /* PRE_TGE */) {
|
|
4794
|
+
filter = marketsList?.filter((item) => item.isPreTge);
|
|
4795
|
+
} else if (type2 != 2 /* ALL */ && type2 != 6 /* COMMUNITY */) {
|
|
4796
|
+
filter = marketsList?.filter((item) => keys.includes(item.symbol));
|
|
4797
|
+
}
|
|
4670
4798
|
const favoritesData = [...favorites];
|
|
4671
4799
|
const favoriteKeys = favoritesData.map((item) => item.name);
|
|
4672
4800
|
if (filter) {
|
|
@@ -4865,79 +4993,6 @@ var useSymbolLeverageMap = () => {
|
|
|
4865
4993
|
refresh: mutate6
|
|
4866
4994
|
};
|
|
4867
4995
|
};
|
|
4868
|
-
|
|
4869
|
-
// src/trading-rewards/useAllBrokers.ts
|
|
4870
|
-
var useAllBrokers = () => {
|
|
4871
|
-
const { data } = useQuery("/v1/public/broker/name", {
|
|
4872
|
-
formatter: (res) => {
|
|
4873
|
-
const { rows } = res;
|
|
4874
|
-
return rows?.map((item) => ({ [item.broker_id]: item.broker_name })).reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
4875
|
-
}
|
|
4876
|
-
});
|
|
4877
|
-
return [data];
|
|
4878
|
-
};
|
|
4879
|
-
|
|
4880
|
-
// src/useBadgeBySymbol.ts
|
|
4881
|
-
function brokerNameBaseFromRaw(rawBrokerName) {
|
|
4882
|
-
if (!rawBrokerName) return void 0;
|
|
4883
|
-
const first = rawBrokerName.trim().split(/[ _-]/, 1)[0]?.trim() ?? "";
|
|
4884
|
-
return first.length > 0 ? first : void 0;
|
|
4885
|
-
}
|
|
4886
|
-
var useBadgeBySymbol = (symbol) => {
|
|
4887
|
-
const symbolsInfo = useSymbolsInfo();
|
|
4888
|
-
const [brokers] = useAllBrokers();
|
|
4889
|
-
return useMemo(() => {
|
|
4890
|
-
if (!symbol || symbolsInfo.isNil) {
|
|
4891
|
-
return {
|
|
4892
|
-
displayName: symbol ?? "",
|
|
4893
|
-
brokerId: void 0,
|
|
4894
|
-
brokerName: void 0,
|
|
4895
|
-
brokerNameRaw: void 0
|
|
4896
|
-
};
|
|
4897
|
-
}
|
|
4898
|
-
const getter = symbolsInfo[symbol];
|
|
4899
|
-
const info = typeof getter === "function" ? getter() : void 0;
|
|
4900
|
-
const displayName = info?.displayName ?? info?.display_symbol_name ?? symbol;
|
|
4901
|
-
const brokerId = info?.broker_id ?? void 0;
|
|
4902
|
-
const rawBrokerName = brokerId ? brokers?.[brokerId] : void 0;
|
|
4903
|
-
const base = brokerNameBaseFromRaw(rawBrokerName);
|
|
4904
|
-
const brokerName = base ? base.length > 7 ? `${base.slice(0, 7)}...` : base : void 0;
|
|
4905
|
-
return {
|
|
4906
|
-
displayName,
|
|
4907
|
-
brokerId,
|
|
4908
|
-
brokerName,
|
|
4909
|
-
brokerNameRaw: rawBrokerName
|
|
4910
|
-
};
|
|
4911
|
-
}, [brokers, symbolsInfo, symbol]);
|
|
4912
|
-
};
|
|
4913
|
-
function formatSymbolWithBroker(symbol, symbolsInfo, brokers) {
|
|
4914
|
-
if (!symbol) return "";
|
|
4915
|
-
let brokerNameBase;
|
|
4916
|
-
if (!symbolsInfo.isNil) {
|
|
4917
|
-
const getter = symbolsInfo[symbol];
|
|
4918
|
-
const info = typeof getter === "function" ? getter() : void 0;
|
|
4919
|
-
const brokerId = info?.broker_id ?? void 0;
|
|
4920
|
-
const rawBrokerName = brokerId ? brokers?.[brokerId] : void 0;
|
|
4921
|
-
brokerNameBase = brokerNameBaseFromRaw(rawBrokerName);
|
|
4922
|
-
}
|
|
4923
|
-
const parts = symbol.split("_");
|
|
4924
|
-
const base = parts.length >= 3 ? parts[1] ?? "" : symbol.match(/^([A-Za-z]+)/)?.[1] ?? symbol;
|
|
4925
|
-
const hasBrokerSuffix = symbol.includes("-") || symbol.split("_").length > 3;
|
|
4926
|
-
if (brokerNameBase && hasBrokerSuffix) {
|
|
4927
|
-
return `${base}-${brokerNameBase}`;
|
|
4928
|
-
}
|
|
4929
|
-
return base;
|
|
4930
|
-
}
|
|
4931
|
-
var useSymbolWithBroker = (symbol) => {
|
|
4932
|
-
const symbolsInfo = useSymbolsInfo();
|
|
4933
|
-
const [brokers] = useAllBrokers();
|
|
4934
|
-
return useMemo(
|
|
4935
|
-
() => formatSymbolWithBroker(symbol, symbolsInfo, brokers),
|
|
4936
|
-
[brokers, symbolsInfo, symbol]
|
|
4937
|
-
);
|
|
4938
|
-
};
|
|
4939
|
-
|
|
4940
|
-
// src/orderly/useMarginModes.ts
|
|
4941
4996
|
var useMarginModes = () => {
|
|
4942
4997
|
const { data, error, isLoading, mutate: mutate6 } = usePrivateQuery("/v1/client/margin_modes", {
|
|
4943
4998
|
revalidateOnFocus: false,
|
|
@@ -12042,12 +12097,22 @@ var useStorageLedgerAddress = () => {
|
|
|
12042
12097
|
ledgerWallet
|
|
12043
12098
|
};
|
|
12044
12099
|
};
|
|
12045
|
-
var useTokensInfo = () => {
|
|
12046
|
-
const
|
|
12047
|
-
|
|
12100
|
+
var useTokensInfo = (networkId) => {
|
|
12101
|
+
const appTokensInfo = useAppStore((state) => state.tokensInfo);
|
|
12102
|
+
const mainTokensInfo = useMainTokenStore((state) => state.data);
|
|
12103
|
+
const testTokensInfo = useTestTokenStore((state) => state.data);
|
|
12104
|
+
return useMemo(() => {
|
|
12105
|
+
if (networkId === "mainnet") {
|
|
12106
|
+
return mainTokensInfo;
|
|
12107
|
+
}
|
|
12108
|
+
if (networkId === "testnet") {
|
|
12109
|
+
return testTokensInfo;
|
|
12110
|
+
}
|
|
12111
|
+
return appTokensInfo;
|
|
12112
|
+
}, [appTokensInfo, mainTokensInfo, networkId, testTokensInfo]);
|
|
12048
12113
|
};
|
|
12049
|
-
var useTokenInfo = (token) => {
|
|
12050
|
-
const tokensInfo =
|
|
12114
|
+
var useTokenInfo = (token, networkId) => {
|
|
12115
|
+
const tokensInfo = useTokensInfo(networkId);
|
|
12051
12116
|
return useMemo(() => {
|
|
12052
12117
|
return tokensInfo?.find((item) => item.token === token);
|
|
12053
12118
|
}, [tokensInfo, token]);
|
|
@@ -20232,6 +20297,6 @@ var ensureWindowEvents = () => {
|
|
|
20232
20297
|
};
|
|
20233
20298
|
ensureWindowEvents();
|
|
20234
20299
|
|
|
20235
|
-
export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, ERROR_MSG_CODES, EpochStatus, ExtendedConfigStore, FlagKeys, MaintenanceStatus, MarketCategoriesConfigProvider, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, formatSymbolWithBroker, getMinNotional, getPriceKey, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo2 as useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBadgeBySymbol, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeatureFlag, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetEstLiqPrice, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginModeBySymbol, useMarginModes, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketCategoriesConfig, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePositions, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolLeverageMap, useSymbolPriceRange, useSymbolWithBroker, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useUserStatistics, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
|
|
20300
|
+
export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, ERROR_MSG_CODES, EpochStatus, ExtendedConfigStore, FlagKeys, MaintenanceStatus, MarketCategoriesConfigProvider, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, REFERRAL_CODE_MAX_LENGTH, REFERRAL_CODE_MIN_LENGTH, StatusProvider, TESTNET_WHITE_CHAINS, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, formatReferralCodeInput, formatSymbolWithBroker, getMinNotional, getPriceKey, getSymbolBase, getSymbolDisplayName, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, isReferralCodeLengthValid, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo2 as useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBadgeBySymbol, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeatureFlag, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetEstLiqPrice, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginModeBySymbol, useMarginModes, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketCategoriesConfig, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePositions, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolLeverageMap, useSymbolPriceRange, useSymbolWithBroker, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useUserStatistics, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
|
|
20236
20301
|
//# sourceMappingURL=index.mjs.map
|
|
20237
20302
|
//# sourceMappingURL=index.mjs.map
|