@ape.swap/bonds-sdk 5.0.5 → 5.0.7-test.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/main.js
CHANGED
|
@@ -46977,6 +46977,7 @@ const useSDKConfig = (config) => {
|
|
|
46977
46977
|
throw new Error('Just a hotfix for latest versions of react-query that make queryFn a required prop');
|
|
46978
46978
|
},
|
|
46979
46979
|
initialData,
|
|
46980
|
+
enabled: typeof window !== 'undefined',
|
|
46980
46981
|
});
|
|
46981
46982
|
return data;
|
|
46982
46983
|
};
|
|
@@ -47108,6 +47109,7 @@ function useTierPoints() {
|
|
|
47108
47109
|
queryFn: () => fetchUserPoints(account, SDKConfig.useTiers, apiUrl),
|
|
47109
47110
|
refetchInterval: 120000, // i.e. 2 mins
|
|
47110
47111
|
refetchOnWindowFocus: false,
|
|
47112
|
+
enabled: typeof window !== 'undefined',
|
|
47111
47113
|
});
|
|
47112
47114
|
}
|
|
47113
47115
|
|
|
@@ -47485,6 +47487,7 @@ function useBondsList() {
|
|
|
47485
47487
|
staleTime: Infinity,
|
|
47486
47488
|
refetchInterval: 300000, // 5 min
|
|
47487
47489
|
refetchOnWindowFocus: false,
|
|
47490
|
+
enabled: typeof window !== 'undefined',
|
|
47488
47491
|
});
|
|
47489
47492
|
}
|
|
47490
47493
|
const getBondsList = async (queryClient) => {
|
|
@@ -48731,19 +48734,20 @@ const fetchUserOwnedBills = async (chainId, account, bonds, tokenPrices, priceAp
|
|
|
48731
48734
|
};
|
|
48732
48735
|
|
|
48733
48736
|
function useTokenPrices() {
|
|
48734
|
-
|
|
48735
|
-
const SDKConfig = useSDKConfig();
|
|
48736
|
-
const priceApi = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.priceApi;
|
|
48737
|
-
const apiv2 = (_b = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _b === void 0 ? void 0 : _b.apiV2;
|
|
48737
|
+
const queryClient = useQueryClient();
|
|
48738
48738
|
return useQuery({
|
|
48739
48739
|
queryKey: [QUERY_KEYS.TOKEN_PRICES],
|
|
48740
|
-
queryFn: () => getTokenPrices(
|
|
48740
|
+
queryFn: () => getTokenPrices(queryClient),
|
|
48741
48741
|
refetchInterval: 30000, // 30 sec
|
|
48742
48742
|
refetchOnMount: false,
|
|
48743
48743
|
refetchOnWindowFocus: false,
|
|
48744
|
+
enabled: typeof window !== 'undefined',
|
|
48744
48745
|
});
|
|
48745
48746
|
}
|
|
48746
|
-
const getTokenPrices = async (
|
|
48747
|
+
const getTokenPrices = async (queryClient) => {
|
|
48748
|
+
const { urls } = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([QUERY_KEYS.SDK_CONFIG]);
|
|
48749
|
+
const apiv2 = urls['apiV2'];
|
|
48750
|
+
const priceApi = urls['priceApi'];
|
|
48747
48751
|
try {
|
|
48748
48752
|
const response = await axios.get(`${priceApi}/realtime/prices`);
|
|
48749
48753
|
return response.data;
|
|
@@ -49163,7 +49167,7 @@ function useUserBonds() {
|
|
|
49163
49167
|
return useQuery({
|
|
49164
49168
|
queryKey: [QUERY_KEYS.USER_BONDS, address, publicKey, (_b = (_a = Object.keys(tokenPrices !== null && tokenPrices !== void 0 ? tokenPrices : {})) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : null],
|
|
49165
49169
|
queryFn: () => getUserBonds(address, solanaAccount, bondList, queryClient),
|
|
49166
|
-
enabled: !!bondList && !!(address || solanaAccount) && !!tokenPrices,
|
|
49170
|
+
enabled: !!bondList && !!(address || solanaAccount) && !!tokenPrices && typeof window !== 'undefined',
|
|
49167
49171
|
refetchInterval: 120000,
|
|
49168
49172
|
refetchOnWindowFocus: false,
|
|
49169
49173
|
refetchOnMount: false,
|
|
@@ -49318,6 +49322,7 @@ function useChainFilterOption() {
|
|
|
49318
49322
|
queryKey: [`${QUERY_KEYS.CHAIN_FILTER_OPTION}`],
|
|
49319
49323
|
queryFn: () => cookie,
|
|
49320
49324
|
initialData: cookie,
|
|
49325
|
+
enabled: typeof window !== 'undefined',
|
|
49321
49326
|
});
|
|
49322
49327
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49323
49328
|
const urlParams = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : null;
|
|
@@ -52275,6 +52280,7 @@ const usePopups = () => {
|
|
|
52275
52280
|
throw new Error('Just a hotfix for latest versions of react-query that make queryFn a required prop');
|
|
52276
52281
|
},
|
|
52277
52282
|
initialData: [],
|
|
52283
|
+
enabled: typeof window !== 'undefined',
|
|
52278
52284
|
});
|
|
52279
52285
|
const queryClient = useQueryClient();
|
|
52280
52286
|
const addPopup = useCallback((newPopup) => {
|
|
@@ -53591,6 +53597,7 @@ function useFavoriteTokens() {
|
|
|
53591
53597
|
queryKey: [QUERY_KEYS.FAVORITE_TOKENS],
|
|
53592
53598
|
queryFn: () => cookie,
|
|
53593
53599
|
initialData: cookie,
|
|
53600
|
+
enabled: typeof window !== 'undefined',
|
|
53594
53601
|
});
|
|
53595
53602
|
const queryClient = useQueryClient();
|
|
53596
53603
|
const addFavToken = useCallback((newValue) => {
|
|
@@ -53781,6 +53788,7 @@ function useGetBondRecommendations(user, contract, limit = '3') {
|
|
|
53781
53788
|
staleTime: Infinity,
|
|
53782
53789
|
refetchOnWindowFocus: false,
|
|
53783
53790
|
refetchOnMount: false,
|
|
53791
|
+
enabled: typeof window !== 'undefined',
|
|
53784
53792
|
});
|
|
53785
53793
|
}
|
|
53786
53794
|
|
|
@@ -56192,6 +56200,7 @@ function useBondsListPreTGE() {
|
|
|
56192
56200
|
staleTime: Infinity,
|
|
56193
56201
|
refetchInterval: 300000, // 5 min
|
|
56194
56202
|
refetchOnWindowFocus: false,
|
|
56203
|
+
enabled: typeof window !== 'undefined',
|
|
56195
56204
|
});
|
|
56196
56205
|
}
|
|
56197
56206
|
const getPreTGEList = async (apiRealTimeURL, apiUrl) => {
|
|
@@ -59217,7 +59226,7 @@ function useBondsData() {
|
|
|
59217
59226
|
queryKey: [QUERY_KEYS.BONDS_DATA, bondList === null || bondList === void 0 ? void 0 : bondList.length, preTGEList === null || preTGEList === void 0 ? void 0 : preTGEList.length],
|
|
59218
59227
|
queryFn: () => calculateBondsData(queryClient),
|
|
59219
59228
|
refetchInterval: 25000, // i.e. 25 sec
|
|
59220
|
-
enabled: !!bondList && !!preTGEList,
|
|
59229
|
+
enabled: !!bondList && !!preTGEList && typeof window !== 'undefined',
|
|
59221
59230
|
refetchOnWindowFocus: true,
|
|
59222
59231
|
refetchOnMount: false,
|
|
59223
59232
|
refetchOnReconnect: true,
|
|
@@ -59994,7 +60003,7 @@ function useUserBondsPreTGE() {
|
|
|
59994
60003
|
queryFn: () => fetchPreTGEUserBonds(chains, tokenPrices, preTGEList, address, apiUrl),
|
|
59995
60004
|
refetchInterval: 30000,
|
|
59996
60005
|
refetchOnWindowFocus: false,
|
|
59997
|
-
enabled: !!preTGEList && preTGEList.length > 0 && !!address && !!tokenPrices,
|
|
60006
|
+
enabled: !!preTGEList && preTGEList.length > 0 && !!address && !!tokenPrices && typeof window !== 'undefined',
|
|
59998
60007
|
});
|
|
59999
60008
|
}
|
|
60000
60009
|
const fetchPreTGEUserBonds = async (chains, tokenPrices, preTGEList, account, apiUrl) => {
|
|
@@ -62541,7 +62550,7 @@ function useUserTokensBalance(tokens, chainId) {
|
|
|
62541
62550
|
queryFn: () => getTokensBalance(accountToUse, tokens, chainId, apiUrl),
|
|
62542
62551
|
staleTime: 45000,
|
|
62543
62552
|
refetchOnWindowFocus: false,
|
|
62544
|
-
enabled: !!accountToUse,
|
|
62553
|
+
enabled: !!accountToUse && typeof window !== 'undefined',
|
|
62545
62554
|
});
|
|
62546
62555
|
}
|
|
62547
62556
|
const getTokensBalance = async (account, tokens, chainId, apiUrl) => {
|
|
@@ -63462,6 +63471,7 @@ function useAllowance(currency, spender, account, chainId) {
|
|
|
63462
63471
|
refetchInterval: 10000, // i.e. 10 sec
|
|
63463
63472
|
refetchOnWindowFocus: false,
|
|
63464
63473
|
retry: 1,
|
|
63474
|
+
enabled: typeof window !== 'undefined',
|
|
63465
63475
|
});
|
|
63466
63476
|
}
|
|
63467
63477
|
const getTokenAllowance = async (currency, spender, account, chainId) => {
|
|
@@ -63638,6 +63648,7 @@ const useSlippage = () => {
|
|
|
63638
63648
|
queryFn: () => {
|
|
63639
63649
|
throw new Error('Just a hotfix for latest versions of react-query that make queryFn a required prop');
|
|
63640
63650
|
},
|
|
63651
|
+
enabled: typeof window !== 'undefined',
|
|
63641
63652
|
});
|
|
63642
63653
|
// Handler to modify the setting within React Query's cache
|
|
63643
63654
|
const setSlippage = (newValue, chainId) => {
|
|
@@ -63797,7 +63808,7 @@ const useSoulZapBondQuote = (typedValue, inputCurrency, bond, account, tierProof
|
|
|
63797
63808
|
queryKey: [QUERY_KEYS.ZAP_TOKEN_QUOTE, queryKey],
|
|
63798
63809
|
queryFn: fetchZapDetails,
|
|
63799
63810
|
refetchInterval: 60000, // i.e. 60 sec
|
|
63800
|
-
enabled: !!queryKey,
|
|
63811
|
+
enabled: !!queryKey && typeof window !== 'undefined',
|
|
63801
63812
|
retry: 1,
|
|
63802
63813
|
});
|
|
63803
63814
|
const zapError = !!error;
|
|
@@ -64419,7 +64430,13 @@ function useTierProofSignature(bondAddress, chainId, isUserRestricted) {
|
|
|
64419
64430
|
retry: 1,
|
|
64420
64431
|
refetchInterval: 1800000, // 30 mins
|
|
64421
64432
|
initialData: null,
|
|
64422
|
-
enabled: !!bondAddress &&
|
|
64433
|
+
enabled: !!bondAddress &&
|
|
64434
|
+
!!account &&
|
|
64435
|
+
!!apiAddress &&
|
|
64436
|
+
!!chainId &&
|
|
64437
|
+
SDKConfig.useTiers &&
|
|
64438
|
+
!isUserRestricted &&
|
|
64439
|
+
typeof window !== 'undefined',
|
|
64423
64440
|
});
|
|
64424
64441
|
}
|
|
64425
64442
|
const getTierProofSig = async (apiAddress, account, bondAddress, chainId) => {
|
|
@@ -66013,7 +66030,7 @@ slippage = 0.5) => {
|
|
|
66013
66030
|
queryKey: [QUERY_KEYS.ZAP_TOKEN_QUOTE, 'jupiter-solana', directQueryParams, preferDirectRoutes, slippage],
|
|
66014
66031
|
queryFn: fetchJupiterQuote,
|
|
66015
66032
|
refetchInterval: 60000,
|
|
66016
|
-
enabled: !!directQueryParams,
|
|
66033
|
+
enabled: !!directQueryParams && typeof window !== 'undefined',
|
|
66017
66034
|
retry: 1,
|
|
66018
66035
|
staleTime: 30000,
|
|
66019
66036
|
});
|
|
@@ -66816,6 +66833,7 @@ function useCurrencyBalance(currency, account, chainId) {
|
|
|
66816
66833
|
refetchInterval: 10000, // i.e. 10 sec
|
|
66817
66834
|
refetchOnWindowFocus: false,
|
|
66818
66835
|
retry: 1,
|
|
66836
|
+
enabled: typeof window !== 'undefined',
|
|
66819
66837
|
});
|
|
66820
66838
|
}
|
|
66821
66839
|
const getTokenBalance = async (currency, account, chainId) => {
|
|
@@ -67111,6 +67129,7 @@ function useHotBondContracts() {
|
|
|
67111
67129
|
refetchOnWindowFocus: false,
|
|
67112
67130
|
refetchOnMount: false,
|
|
67113
67131
|
retry: 1,
|
|
67132
|
+
enabled: typeof window !== 'undefined',
|
|
67114
67133
|
});
|
|
67115
67134
|
}
|
|
67116
67135
|
function useHotBonds() {
|
|
@@ -67121,7 +67140,11 @@ function useHotBonds() {
|
|
|
67121
67140
|
queryFn: () => getHotBonds(bondsData, hotBondContracts),
|
|
67122
67141
|
refetchOnWindowFocus: false,
|
|
67123
67142
|
refetchInterval: 30000,
|
|
67124
|
-
enabled: !!bondsData &&
|
|
67143
|
+
enabled: !!bondsData &&
|
|
67144
|
+
bondsData.length > 0 &&
|
|
67145
|
+
!!hotBondContracts &&
|
|
67146
|
+
hotBondContracts.length > 0 &&
|
|
67147
|
+
typeof window !== 'undefined',
|
|
67125
67148
|
retry: 0,
|
|
67126
67149
|
});
|
|
67127
67150
|
}
|
|
@@ -88786,6 +88809,7 @@ function useGetBondApiStats(contractAddress) {
|
|
|
88786
88809
|
refetchOnWindowFocus: false,
|
|
88787
88810
|
refetchOnMount: false,
|
|
88788
88811
|
retry: 1,
|
|
88812
|
+
enabled: typeof window !== 'undefined',
|
|
88789
88813
|
});
|
|
88790
88814
|
}
|
|
88791
88815
|
|
|
@@ -89680,7 +89704,7 @@ function useHistoricalPrice(cgId) {
|
|
|
89680
89704
|
queryFn: () => getHistoricalPrice(cgId, queryClient),
|
|
89681
89705
|
refetchOnWindowFocus: false,
|
|
89682
89706
|
refetchInterval: 300000,
|
|
89683
|
-
enabled: !!cgId,
|
|
89707
|
+
enabled: !!cgId && typeof window !== 'undefined',
|
|
89684
89708
|
retry: 0,
|
|
89685
89709
|
});
|
|
89686
89710
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
1
|
+
import { QueryClient, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
3
3
|
export interface TokenPrices {
|
|
4
4
|
chainId: ChainId;
|
|
@@ -12,4 +12,4 @@ export interface TokenPrices {
|
|
|
12
12
|
secondsAgoUpdated: number;
|
|
13
13
|
}
|
|
14
14
|
export default function useTokenPrices(): UseQueryResult<Partial<Record<ChainId, TokenPrices[]>>>;
|
|
15
|
-
export declare const getTokenPrices: (
|
|
15
|
+
export declare const getTokenPrices: (queryClient: QueryClient) => Promise<Partial<Record<ChainId, TokenPrices[]>>>;
|