@orderly.network/hooks 2.0.1 → 2.0.2
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 +67 -46
- package/dist/index.d.ts +67 -46
- package/dist/index.js +79 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -28,7 +28,7 @@ declare global {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
declare const _default: "2.0.
|
|
31
|
+
declare const _default: "2.0.2";
|
|
32
32
|
|
|
33
33
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
34
34
|
formatter?: (data: any) => T;
|
|
@@ -196,7 +196,7 @@ type BaseConfigProviderProps = {
|
|
|
196
196
|
chainFilter?: filteredChains | filterChainsFunc;
|
|
197
197
|
customChains?: Chains<undefined, undefined>;
|
|
198
198
|
};
|
|
199
|
-
type
|
|
199
|
+
type ExclusiveConfigProviderProps = {
|
|
200
200
|
brokerId: string;
|
|
201
201
|
brokerName?: string;
|
|
202
202
|
networkId: NetworkId;
|
|
@@ -207,7 +207,7 @@ type ConfigProviderExclusionProps = {
|
|
|
207
207
|
networkId?: never;
|
|
208
208
|
configStore: ConfigStore;
|
|
209
209
|
};
|
|
210
|
-
type ConfigProviderProps = BaseConfigProviderProps &
|
|
210
|
+
type ConfigProviderProps = BaseConfigProviderProps & ExclusiveConfigProviderProps;
|
|
211
211
|
declare const OrderlyConfigProvider: FC<PropsWithChildren<ConfigProviderProps>>;
|
|
212
212
|
|
|
213
213
|
declare const OrderlyTrackerProvider: ({ children }: PropsWithChildren) => react_jsx_runtime.JSX.Element;
|
|
@@ -1134,20 +1134,20 @@ declare namespace RefferalAPI {
|
|
|
1134
1134
|
referee_info: Referee;
|
|
1135
1135
|
}
|
|
1136
1136
|
type ReferralCode = {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1137
|
+
code: string;
|
|
1138
|
+
max_rebate_rate: number;
|
|
1139
|
+
referee_rebate_rate: number;
|
|
1140
|
+
referrer_rebate_rate: number;
|
|
1141
|
+
total_invites: number;
|
|
1142
|
+
total_traded: number;
|
|
1143
1143
|
};
|
|
1144
1144
|
type Referrer = {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1145
|
+
total_invites: number;
|
|
1146
|
+
total_traded: number;
|
|
1147
|
+
total_referee_volume: number;
|
|
1148
|
+
total_referee_fee: number;
|
|
1149
|
+
referral_codes: ReferralCode[];
|
|
1150
|
+
total_referrer_rebate: number;
|
|
1151
1151
|
"1d_invites": number;
|
|
1152
1152
|
"7d_invites": number;
|
|
1153
1153
|
"30d_invites": number;
|
|
@@ -1165,49 +1165,50 @@ declare namespace RefferalAPI {
|
|
|
1165
1165
|
"30d_referrer_rebate": number;
|
|
1166
1166
|
};
|
|
1167
1167
|
type Referee = {
|
|
1168
|
-
|
|
1169
|
-
|
|
1168
|
+
referer_code?: string;
|
|
1169
|
+
referee_rebate_rate?: number;
|
|
1170
1170
|
"1d_referee_rebate": number;
|
|
1171
1171
|
"7d_referee_rebate": number;
|
|
1172
1172
|
"30d_referee_rebate": number;
|
|
1173
|
-
|
|
1173
|
+
total_referee_rebate: number;
|
|
1174
1174
|
};
|
|
1175
1175
|
type RefereeInfoItem = {
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1176
|
+
account_id: string;
|
|
1177
|
+
code_binding_time: number;
|
|
1178
|
+
fee: number;
|
|
1179
|
+
referral_code: string;
|
|
1180
|
+
referral_rebate: number;
|
|
1181
|
+
register_time: number;
|
|
1182
|
+
trade_status: string;
|
|
1183
|
+
user_address: string;
|
|
1184
|
+
volume: number;
|
|
1185
1185
|
};
|
|
1186
1186
|
type UserVolStats = {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1187
|
+
perp_volume_last_30_days: number;
|
|
1188
|
+
perp_volume_last_7_days: number;
|
|
1189
|
+
perp_volume_ltd: number;
|
|
1190
|
+
perp_volume_ytd: number;
|
|
1191
1191
|
};
|
|
1192
1192
|
type Distribution = {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1193
|
+
amount: number;
|
|
1194
|
+
created_time: number;
|
|
1195
|
+
id: number;
|
|
1196
|
+
status: string;
|
|
1197
|
+
token: string;
|
|
1198
|
+
type: string;
|
|
1199
|
+
updated_time: number;
|
|
1200
1200
|
};
|
|
1201
1201
|
type ReferralRebateSummary = {
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1202
|
+
daily_traded_referral: number;
|
|
1203
|
+
referral_rebate: number;
|
|
1204
|
+
volume: number;
|
|
1205
|
+
fee: number;
|
|
1206
|
+
date: string;
|
|
1206
1207
|
};
|
|
1207
1208
|
type RefereeRebateSummary = {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1209
|
+
referee_rebate: number;
|
|
1210
|
+
fee: number;
|
|
1211
|
+
date: string;
|
|
1211
1212
|
};
|
|
1212
1213
|
type DayliVolume = {
|
|
1213
1214
|
date: string;
|
|
@@ -1673,4 +1674,24 @@ declare const useOrderEntity: (order: {
|
|
|
1673
1674
|
};
|
|
1674
1675
|
};
|
|
1675
1676
|
|
|
1676
|
-
|
|
1677
|
+
type RestrictedAreasReturns = {
|
|
1678
|
+
ip?: string;
|
|
1679
|
+
invalidRegions?: string[];
|
|
1680
|
+
restrictedAreasOpen?: boolean;
|
|
1681
|
+
contact?: {
|
|
1682
|
+
url?: string;
|
|
1683
|
+
text?: string;
|
|
1684
|
+
};
|
|
1685
|
+
};
|
|
1686
|
+
interface IRestrictedAreasParams {
|
|
1687
|
+
enableDefault?: boolean;
|
|
1688
|
+
customRestrictedIps?: string[];
|
|
1689
|
+
customRestrictedRegions?: string[];
|
|
1690
|
+
contact?: {
|
|
1691
|
+
url?: string;
|
|
1692
|
+
text?: string;
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
declare const useRestrictedAreas: (params: IRestrictedAreasParams) => RestrictedAreasReturns;
|
|
1696
|
+
|
|
1697
|
+
export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, AssetHistoryStatusEnum, type Brokers, type Chain, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, type EpochInfoItem, type EpochInfoType, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, type IRestrictedAreasParams, MarketsStorageKey, MarketsType, type NewListing, type OrderBookItem, type OrderParams, type OrderbookData, type OrderbookOptions, type OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, OrderlyTrackerProvider, type PosterLayoutConfig, type PriceMode, type Recent, RefferalAPI, type RestrictedAreasReturns, ScopeType, StatusContext, type StatusContextState, StatusProvider, type SymbolInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseOrderEntryMetaState, WalletConnectorContext, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, type chainFilter, type chainFilterFunc, checkNotional, cleanStringStyle, type filteredChains$1 as filteredChains, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useBoolean, useChain, useChains, useCheckReferralCode, useCollateral, useCommission, useConfig, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useKeyStore, useLazyQuery, useLeverage, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useNetworkInfo, useOrderEntity, useOrderEntry, useOrderEntry$1 as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, usePositionActions, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedAreas, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useTPSLOrder, useTickerStream, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWithdraw, useWsStatus, index as utils, _default as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare global {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
declare const _default: "2.0.
|
|
31
|
+
declare const _default: "2.0.2";
|
|
32
32
|
|
|
33
33
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
34
34
|
formatter?: (data: any) => T;
|
|
@@ -196,7 +196,7 @@ type BaseConfigProviderProps = {
|
|
|
196
196
|
chainFilter?: filteredChains | filterChainsFunc;
|
|
197
197
|
customChains?: Chains<undefined, undefined>;
|
|
198
198
|
};
|
|
199
|
-
type
|
|
199
|
+
type ExclusiveConfigProviderProps = {
|
|
200
200
|
brokerId: string;
|
|
201
201
|
brokerName?: string;
|
|
202
202
|
networkId: NetworkId;
|
|
@@ -207,7 +207,7 @@ type ConfigProviderExclusionProps = {
|
|
|
207
207
|
networkId?: never;
|
|
208
208
|
configStore: ConfigStore;
|
|
209
209
|
};
|
|
210
|
-
type ConfigProviderProps = BaseConfigProviderProps &
|
|
210
|
+
type ConfigProviderProps = BaseConfigProviderProps & ExclusiveConfigProviderProps;
|
|
211
211
|
declare const OrderlyConfigProvider: FC<PropsWithChildren<ConfigProviderProps>>;
|
|
212
212
|
|
|
213
213
|
declare const OrderlyTrackerProvider: ({ children }: PropsWithChildren) => react_jsx_runtime.JSX.Element;
|
|
@@ -1134,20 +1134,20 @@ declare namespace RefferalAPI {
|
|
|
1134
1134
|
referee_info: Referee;
|
|
1135
1135
|
}
|
|
1136
1136
|
type ReferralCode = {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1137
|
+
code: string;
|
|
1138
|
+
max_rebate_rate: number;
|
|
1139
|
+
referee_rebate_rate: number;
|
|
1140
|
+
referrer_rebate_rate: number;
|
|
1141
|
+
total_invites: number;
|
|
1142
|
+
total_traded: number;
|
|
1143
1143
|
};
|
|
1144
1144
|
type Referrer = {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1145
|
+
total_invites: number;
|
|
1146
|
+
total_traded: number;
|
|
1147
|
+
total_referee_volume: number;
|
|
1148
|
+
total_referee_fee: number;
|
|
1149
|
+
referral_codes: ReferralCode[];
|
|
1150
|
+
total_referrer_rebate: number;
|
|
1151
1151
|
"1d_invites": number;
|
|
1152
1152
|
"7d_invites": number;
|
|
1153
1153
|
"30d_invites": number;
|
|
@@ -1165,49 +1165,50 @@ declare namespace RefferalAPI {
|
|
|
1165
1165
|
"30d_referrer_rebate": number;
|
|
1166
1166
|
};
|
|
1167
1167
|
type Referee = {
|
|
1168
|
-
|
|
1169
|
-
|
|
1168
|
+
referer_code?: string;
|
|
1169
|
+
referee_rebate_rate?: number;
|
|
1170
1170
|
"1d_referee_rebate": number;
|
|
1171
1171
|
"7d_referee_rebate": number;
|
|
1172
1172
|
"30d_referee_rebate": number;
|
|
1173
|
-
|
|
1173
|
+
total_referee_rebate: number;
|
|
1174
1174
|
};
|
|
1175
1175
|
type RefereeInfoItem = {
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1176
|
+
account_id: string;
|
|
1177
|
+
code_binding_time: number;
|
|
1178
|
+
fee: number;
|
|
1179
|
+
referral_code: string;
|
|
1180
|
+
referral_rebate: number;
|
|
1181
|
+
register_time: number;
|
|
1182
|
+
trade_status: string;
|
|
1183
|
+
user_address: string;
|
|
1184
|
+
volume: number;
|
|
1185
1185
|
};
|
|
1186
1186
|
type UserVolStats = {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1187
|
+
perp_volume_last_30_days: number;
|
|
1188
|
+
perp_volume_last_7_days: number;
|
|
1189
|
+
perp_volume_ltd: number;
|
|
1190
|
+
perp_volume_ytd: number;
|
|
1191
1191
|
};
|
|
1192
1192
|
type Distribution = {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1193
|
+
amount: number;
|
|
1194
|
+
created_time: number;
|
|
1195
|
+
id: number;
|
|
1196
|
+
status: string;
|
|
1197
|
+
token: string;
|
|
1198
|
+
type: string;
|
|
1199
|
+
updated_time: number;
|
|
1200
1200
|
};
|
|
1201
1201
|
type ReferralRebateSummary = {
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1202
|
+
daily_traded_referral: number;
|
|
1203
|
+
referral_rebate: number;
|
|
1204
|
+
volume: number;
|
|
1205
|
+
fee: number;
|
|
1206
|
+
date: string;
|
|
1206
1207
|
};
|
|
1207
1208
|
type RefereeRebateSummary = {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1209
|
+
referee_rebate: number;
|
|
1210
|
+
fee: number;
|
|
1211
|
+
date: string;
|
|
1211
1212
|
};
|
|
1212
1213
|
type DayliVolume = {
|
|
1213
1214
|
date: string;
|
|
@@ -1673,4 +1674,24 @@ declare const useOrderEntity: (order: {
|
|
|
1673
1674
|
};
|
|
1674
1675
|
};
|
|
1675
1676
|
|
|
1676
|
-
|
|
1677
|
+
type RestrictedAreasReturns = {
|
|
1678
|
+
ip?: string;
|
|
1679
|
+
invalidRegions?: string[];
|
|
1680
|
+
restrictedAreasOpen?: boolean;
|
|
1681
|
+
contact?: {
|
|
1682
|
+
url?: string;
|
|
1683
|
+
text?: string;
|
|
1684
|
+
};
|
|
1685
|
+
};
|
|
1686
|
+
interface IRestrictedAreasParams {
|
|
1687
|
+
enableDefault?: boolean;
|
|
1688
|
+
customRestrictedIps?: string[];
|
|
1689
|
+
customRestrictedRegions?: string[];
|
|
1690
|
+
contact?: {
|
|
1691
|
+
url?: string;
|
|
1692
|
+
text?: string;
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
declare const useRestrictedAreas: (params: IRestrictedAreasParams) => RestrictedAreasReturns;
|
|
1696
|
+
|
|
1697
|
+
export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, AssetHistoryStatusEnum, type Brokers, type Chain, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, type EpochInfoItem, type EpochInfoType, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, type IRestrictedAreasParams, MarketsStorageKey, MarketsType, type NewListing, type OrderBookItem, type OrderParams, type OrderbookData, type OrderbookOptions, type OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, OrderlyTrackerProvider, type PosterLayoutConfig, type PriceMode, type Recent, RefferalAPI, type RestrictedAreasReturns, ScopeType, StatusContext, type StatusContextState, StatusProvider, type SymbolInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseOrderEntryMetaState, WalletConnectorContext, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, type chainFilter, type chainFilterFunc, checkNotional, cleanStringStyle, type filteredChains$1 as filteredChains, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useBoolean, useChain, useChains, useCheckReferralCode, useCollateral, useCommission, useConfig, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useKeyStore, useLazyQuery, useLeverage, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useNetworkInfo, useOrderEntity, useOrderEntry, useOrderEntry$1 as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, usePositionActions, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedAreas, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useTPSLOrder, useTickerStream, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWithdraw, useWsStatus, index as utils, _default as version };
|
package/dist/index.js
CHANGED
|
@@ -60,9 +60,9 @@ var __export = (target, all) => {
|
|
|
60
60
|
// src/version.ts
|
|
61
61
|
if (typeof window !== "undefined") {
|
|
62
62
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
63
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.0.
|
|
63
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.0.2";
|
|
64
64
|
}
|
|
65
|
-
var version_default = "2.0.
|
|
65
|
+
var version_default = "2.0.2";
|
|
66
66
|
var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
|
|
67
67
|
var OrderlyContext = React.createContext({
|
|
68
68
|
// configStore: new MemoryConfigStore(),
|
|
@@ -310,10 +310,10 @@ var useAccount = () => {
|
|
|
310
310
|
};
|
|
311
311
|
var usePrivateQuery = (query, options) => {
|
|
312
312
|
const { formatter, ...swrOptions } = options || {};
|
|
313
|
-
const
|
|
313
|
+
const { state } = useAccount();
|
|
314
314
|
const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
|
|
315
315
|
return useSWR__default.default(
|
|
316
|
-
() =>
|
|
316
|
+
() => state.status >= types.AccountStatusEnum.EnableTrading || state.status === types.AccountStatusEnum.EnableTradingWithoutConnected ? [query, state.accountId] : null,
|
|
317
317
|
(url, init2) => {
|
|
318
318
|
return fetcher(url, init2, { formatter });
|
|
319
319
|
},
|
|
@@ -327,15 +327,15 @@ var usePrivateQuery = (query, options) => {
|
|
|
327
327
|
};
|
|
328
328
|
var usePrivateInfiniteQuery = (getKey, options) => {
|
|
329
329
|
const { formatter, ...restOptions } = options || {};
|
|
330
|
-
const
|
|
330
|
+
const { state } = useAccount();
|
|
331
331
|
const middleware = Array.isArray(restOptions?.use) ? restOptions?.use ?? [] : [];
|
|
332
332
|
const result = useSWRInfinite__default.default(
|
|
333
333
|
(pageIndex, previousPageData) => {
|
|
334
334
|
const queryKey = getKey(pageIndex, previousPageData);
|
|
335
|
-
if (
|
|
336
|
-
return
|
|
335
|
+
if (queryKey && (state.status >= types.AccountStatusEnum.EnableTrading || state.status === types.AccountStatusEnum.EnableTradingWithoutConnected)) {
|
|
336
|
+
return [queryKey, state.accountId];
|
|
337
337
|
}
|
|
338
|
-
return
|
|
338
|
+
return null;
|
|
339
339
|
},
|
|
340
340
|
(url, init2) => {
|
|
341
341
|
return restOptions.fetcher?.(url, init2) || net.get(url, init2, formatter);
|
|
@@ -529,11 +529,11 @@ var useWS = () => {
|
|
|
529
529
|
return { ...result, timestamp };
|
|
530
530
|
}
|
|
531
531
|
});
|
|
532
|
-
if (account5.stateValue.status === types.AccountStatusEnum.EnableTrading && account5.stateValue.accountId) {
|
|
532
|
+
if ((account5.stateValue.status === types.AccountStatusEnum.EnableTrading || account5.stateValue.status === types.AccountStatusEnum.EnableTradingWithoutConnected) && account5.stateValue.accountId) {
|
|
533
533
|
websocketClient.openPrivate(account5.stateValue.accountId);
|
|
534
534
|
}
|
|
535
535
|
account5.on("change:status", (nextState) => {
|
|
536
|
-
if (nextState.status === types.AccountStatusEnum.EnableTrading && nextState.accountId) {
|
|
536
|
+
if ((nextState.status === types.AccountStatusEnum.EnableTrading || nextState.status === types.AccountStatusEnum.EnableTradingWithoutConnected) && nextState.accountId) {
|
|
537
537
|
websocketClient.openPrivate(nextState.accountId);
|
|
538
538
|
} else {
|
|
539
539
|
websocketClient.closePrivate(1e3, "switch account");
|
|
@@ -3717,10 +3717,10 @@ var useMarginRatio = () => {
|
|
|
3717
3717
|
});
|
|
3718
3718
|
}, [rows, markPrices, totalCollateral]);
|
|
3719
3719
|
const currentLeverage = React.useMemo(() => {
|
|
3720
|
-
if (state.status
|
|
3721
|
-
return
|
|
3720
|
+
if (state.status >= types.AccountStatusEnum.EnableTrading || state.status === types.AccountStatusEnum.EnableTradingWithoutConnected) {
|
|
3721
|
+
return perp.account.currentLeverage(marginRatio);
|
|
3722
3722
|
}
|
|
3723
|
-
return
|
|
3723
|
+
return null;
|
|
3724
3724
|
}, [marginRatio, state.status]);
|
|
3725
3725
|
const mmr = React.useMemo(() => {
|
|
3726
3726
|
if (!rows || rows.length <= 0 || notional == null)
|
|
@@ -4284,6 +4284,7 @@ var useDeposit = (options) => {
|
|
|
4284
4284
|
amount
|
|
4285
4285
|
}).then((res) => {
|
|
4286
4286
|
return updateAllowanceWhenTxSuccess(res.hash);
|
|
4287
|
+
}).catch((e) => {
|
|
4287
4288
|
});
|
|
4288
4289
|
},
|
|
4289
4290
|
[account5, getAllowance, options?.address, dst]
|
|
@@ -14494,6 +14495,70 @@ var useOrderEntity = (order, options) => {
|
|
|
14494
14495
|
symbolInfo
|
|
14495
14496
|
};
|
|
14496
14497
|
};
|
|
14498
|
+
var useRestrictedAreas = (params) => {
|
|
14499
|
+
const {
|
|
14500
|
+
enableDefault = false,
|
|
14501
|
+
customRestrictedIps = [],
|
|
14502
|
+
customRestrictedRegions = [],
|
|
14503
|
+
contact = {}
|
|
14504
|
+
} = params;
|
|
14505
|
+
const apiBaseUrl = useConfig("apiBaseUrl");
|
|
14506
|
+
const [invalidWebCity, setInvalidWebCity] = React.useState([]);
|
|
14507
|
+
const [invalidWebCountry, setInvalidWebCountry] = React.useState([]);
|
|
14508
|
+
const [invalidRegions, setInvalidRegions] = React.useState([]);
|
|
14509
|
+
const [allInvalidAreas, setAllInvalidAreas] = React.useState([]);
|
|
14510
|
+
const [city, setCity] = React.useState("");
|
|
14511
|
+
const [region, setRegion] = React.useState("");
|
|
14512
|
+
const [ip, setIp] = React.useState("");
|
|
14513
|
+
const [restrictedAreasOpen, setRestrictedAreasOpen] = React.useState(false);
|
|
14514
|
+
React.useEffect(() => {
|
|
14515
|
+
const fetchData = async () => {
|
|
14516
|
+
try {
|
|
14517
|
+
const areaRes = await fetch(`${apiBaseUrl}/v1/restricted_areas`);
|
|
14518
|
+
const areaResdata = await areaRes.json();
|
|
14519
|
+
const ipRes = await fetch(`${apiBaseUrl}/v1/ip_info`);
|
|
14520
|
+
const ipData = await ipRes.json();
|
|
14521
|
+
if (areaResdata.success && ipData.success) {
|
|
14522
|
+
const invalidCountries = areaResdata?.data?.invalid_web_country?.toLocaleLowerCase()?.replace(/\s+/g, "").split(",");
|
|
14523
|
+
const invalidCities = areaResdata?.data?.invalid_web_city?.toLocaleLowerCase()?.replace(/\s+/g, "").split(",");
|
|
14524
|
+
const combinedInvalidRegions = (enableDefault ? invalidCities.concat(invalidCountries) : []).concat(
|
|
14525
|
+
customRestrictedRegions?.map(
|
|
14526
|
+
(item) => item?.replace(/\s+/g, "")?.toLocaleLowerCase()
|
|
14527
|
+
)
|
|
14528
|
+
);
|
|
14529
|
+
const allInvalidAreas2 = [
|
|
14530
|
+
enableDefault ? areaResdata?.data?.invalid_web_country : "",
|
|
14531
|
+
enableDefault ? areaResdata?.data?.invalid_web_city : "",
|
|
14532
|
+
customRestrictedRegions?.join(", ")
|
|
14533
|
+
].filter((item) => !!item);
|
|
14534
|
+
setInvalidWebCity(invalidCities);
|
|
14535
|
+
setInvalidWebCountry(invalidCountries);
|
|
14536
|
+
setInvalidRegions(combinedInvalidRegions);
|
|
14537
|
+
setAllInvalidAreas(allInvalidAreas2);
|
|
14538
|
+
const { city: city2, region: region2, ip: ip2 } = ipData.data;
|
|
14539
|
+
setCity(city2);
|
|
14540
|
+
setRegion(region2);
|
|
14541
|
+
setIp(ip2);
|
|
14542
|
+
if (combinedInvalidRegions.includes(
|
|
14543
|
+
ipData?.data?.city?.replace(/\s+/g, "").toLocaleLowerCase()
|
|
14544
|
+
) || combinedInvalidRegions.includes(
|
|
14545
|
+
ipData?.data?.region?.replace(/\s+/g, "").toLocaleLowerCase()
|
|
14546
|
+
) || customRestrictedIps.includes(ipData?.data?.ip)) {
|
|
14547
|
+
setRestrictedAreasOpen(true);
|
|
14548
|
+
}
|
|
14549
|
+
}
|
|
14550
|
+
} catch (error) {
|
|
14551
|
+
}
|
|
14552
|
+
};
|
|
14553
|
+
fetchData();
|
|
14554
|
+
}, [apiBaseUrl]);
|
|
14555
|
+
return {
|
|
14556
|
+
ip,
|
|
14557
|
+
invalidRegions: allInvalidAreas,
|
|
14558
|
+
restrictedAreasOpen,
|
|
14559
|
+
contact
|
|
14560
|
+
};
|
|
14561
|
+
};
|
|
14497
14562
|
|
|
14498
14563
|
Object.defineProperty(exports, "unstable_serialize", {
|
|
14499
14564
|
enumerable: true,
|
|
@@ -14597,6 +14662,7 @@ exports.useRefereeInfo = useRefereeInfo;
|
|
|
14597
14662
|
exports.useRefereeRebateSummary = useRefereeRebateSummary;
|
|
14598
14663
|
exports.useReferralInfo = useReferralInfo;
|
|
14599
14664
|
exports.useReferralRebateSummary = useReferralRebateSummary;
|
|
14665
|
+
exports.useRestrictedAreas = useRestrictedAreas;
|
|
14600
14666
|
exports.useSessionStorage = useSessionStorage;
|
|
14601
14667
|
exports.useSettleSubscription = useSettleSubscription;
|
|
14602
14668
|
exports.useSimpleDI = useSimpleDI;
|