@sodax/dapp-kit 2.0.0-rc.2 → 2.0.0-rc.20
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/README.md +29 -74
- package/dist/index.d.ts +780 -58
- package/dist/index.mjs +841 -143
- package/package.json +31 -19
- package/src/hooks/_mutationContract.test.ts +15 -2
- package/src/hooks/backend/index.ts +1 -5
- package/src/hooks/bitcoin/index.ts +2 -0
- package/src/hooks/bitcoin/resolveBtcReadAddress.test.ts +54 -0
- package/src/hooks/bitcoin/resolveBtcReadAddress.ts +21 -0
- package/src/hooks/bitcoin/useBitcoinTradingSetup.ts +45 -0
- package/src/hooks/bitcoin/useEnsureRadfiAccessToken.ts +57 -0
- package/src/hooks/bitcoin/useFundTradingWallet.ts +1 -1
- package/src/hooks/bitcoin/useRadfiAuth.ts +2 -2
- package/src/hooks/bitcoin/useRadfiWithdraw.ts +2 -2
- package/src/hooks/bitcoin/useRenewUtxos.ts +2 -2
- package/src/hooks/bitcoin/useTradingWallet.ts +1 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/leverageYield/index.ts +9 -0
- package/src/hooks/leverageYield/useLeverageYieldDeposit.ts +40 -0
- package/src/hooks/leverageYield/useLeverageYieldEffectiveApr.ts +42 -0
- package/src/hooks/leverageYield/useLeverageYieldNotifySolver.ts +34 -0
- package/src/hooks/leverageYield/useLeverageYieldPosition.ts +40 -0
- package/src/hooks/leverageYield/useLeverageYieldPreviewRedeem.ts +43 -0
- package/src/hooks/leverageYield/useLeverageYieldShareBalances.ts +74 -0
- package/src/hooks/leverageYield/useLeverageYieldTotalAssets.ts +36 -0
- package/src/hooks/leverageYield/useLeverageYieldVaultSwap.ts +50 -0
- package/src/hooks/leverageYield/useLeverageYieldWithdraw.ts +40 -0
- package/src/hooks/mm/useATokensBalances.ts +7 -1
- package/src/hooks/mm/useUserFormattedSummary.ts +5 -1
- package/src/hooks/mm/useUserReservesData.ts +5 -1
- package/src/hooks/partner/index.ts +4 -0
- package/src/hooks/partner/useFeeClaimWithdraw.ts +88 -0
- package/src/hooks/partner/useGetIntentDetails.ts +39 -0
- package/src/hooks/partner/useGetUserIntent.ts +35 -0
- package/src/hooks/partner/usePartnerCancelIntent.ts +52 -0
- package/src/hooks/shared/index.ts +4 -0
- package/src/hooks/shared/isUserRejectedError.test.ts +42 -0
- package/src/hooks/shared/isUserRejectedError.ts +30 -0
- package/src/hooks/shared/useGetUserHubWalletAddress.ts +5 -1
- package/src/hooks/shared/useNearStorageCheck.ts +45 -0
- package/src/hooks/shared/useNearStorageGate.ts +60 -0
- package/src/hooks/shared/useRegisterNearStorage.ts +46 -0
- package/src/hooks/swapsApi/index.ts +41 -0
- package/src/hooks/swapsApi/isTerminalSwapIntentStatus.test.ts +24 -0
- package/src/hooks/swapsApi/isTerminalSwapIntentStatus.ts +11 -0
- package/src/hooks/swapsApi/useSwapsApiAllowance.ts +40 -0
- package/src/hooks/swapsApi/useSwapsApiApprove.ts +42 -0
- package/src/hooks/swapsApi/useSwapsApiCancelIntent.ts +41 -0
- package/src/hooks/swapsApi/useSwapsApiCreateIntent.ts +41 -0
- package/src/hooks/swapsApi/useSwapsApiCreateLimitOrder.ts +41 -0
- package/src/hooks/swapsApi/useSwapsApiDeadline.ts +36 -0
- package/src/hooks/swapsApi/useSwapsApiEstimateGas.ts +40 -0
- package/src/hooks/swapsApi/useSwapsApiFilledIntent.ts +41 -0
- package/src/hooks/swapsApi/useSwapsApiIntent.ts +40 -0
- package/src/hooks/swapsApi/useSwapsApiIntentExtraData.ts +41 -0
- package/src/hooks/swapsApi/useSwapsApiIntentHash.ts +40 -0
- package/src/hooks/swapsApi/useSwapsApiIntentPacket.ts +43 -0
- package/src/hooks/swapsApi/useSwapsApiPartnerFee.ts +40 -0
- package/src/hooks/swapsApi/useSwapsApiQuote.ts +55 -0
- package/src/hooks/swapsApi/useSwapsApiSolverFee.ts +40 -0
- package/src/hooks/swapsApi/useSwapsApiStatus.ts +45 -0
- package/src/hooks/swapsApi/useSwapsApiSubmitIntent.ts +43 -0
- package/src/hooks/{backend/useBackendSubmitSwapTx.ts → swapsApi/useSwapsApiSubmitTx.ts} +16 -17
- package/src/hooks/swapsApi/useSwapsApiSubmitTxStatus.ts +55 -0
- package/src/hooks/swapsApi/useSwapsApiTokens.ts +34 -0
- package/src/hooks/swapsApi/useSwapsApiTokensByChain.ts +40 -0
- package/src/providers/SodaxProvider.tsx +17 -14
- package/src/utils/index.ts +1 -0
- package/src/utils/nearStorageGate.test.ts +46 -0
- package/src/utils/nearStorageGate.ts +39 -0
- package/ai-exported/AGENTS.md +0 -134
- package/ai-exported/integration/README.md +0 -49
- package/ai-exported/integration/ai-rules.md +0 -79
- package/ai-exported/integration/architecture.md +0 -274
- package/ai-exported/integration/features/README.md +0 -29
- package/ai-exported/integration/features/auxiliary-services.md +0 -169
- package/ai-exported/integration/features/bitcoin.md +0 -87
- package/ai-exported/integration/features/bridge.md +0 -91
- package/ai-exported/integration/features/dex.md +0 -152
- package/ai-exported/integration/features/migration.md +0 -118
- package/ai-exported/integration/features/money-market.md +0 -116
- package/ai-exported/integration/features/staking.md +0 -123
- package/ai-exported/integration/features/swap.md +0 -101
- package/ai-exported/integration/quickstart.md +0 -187
- package/ai-exported/integration/recipes/README.md +0 -136
- package/ai-exported/integration/recipes/backend-queries.md +0 -157
- package/ai-exported/integration/recipes/bitcoin.md +0 -193
- package/ai-exported/integration/recipes/bridge.md +0 -174
- package/ai-exported/integration/recipes/dex.md +0 -204
- package/ai-exported/integration/recipes/invalidations.md +0 -115
- package/ai-exported/integration/recipes/migration.md +0 -212
- package/ai-exported/integration/recipes/money-market.md +0 -206
- package/ai-exported/integration/recipes/mutation-error-handling.md +0 -118
- package/ai-exported/integration/recipes/observability.md +0 -93
- package/ai-exported/integration/recipes/setup.md +0 -144
- package/ai-exported/integration/recipes/staking.md +0 -202
- package/ai-exported/integration/recipes/swap.md +0 -272
- package/ai-exported/integration/recipes/wallet-connectivity.md +0 -101
- package/ai-exported/integration/reference/README.md +0 -12
- package/ai-exported/integration/reference/glossary.md +0 -188
- package/ai-exported/integration/reference/hooks-index.md +0 -190
- package/ai-exported/integration/reference/public-api.md +0 -110
- package/ai-exported/integration/reference/querykey-conventions.md +0 -179
- package/ai-exported/migration/README.md +0 -60
- package/ai-exported/migration/ai-rules.md +0 -81
- package/ai-exported/migration/breaking-changes/hook-signatures.md +0 -233
- package/ai-exported/migration/breaking-changes/querykey-conventions.md +0 -108
- package/ai-exported/migration/breaking-changes/result-handling.md +0 -211
- package/ai-exported/migration/breaking-changes/sdk-leakage.md +0 -165
- package/ai-exported/migration/checklist.md +0 -89
- package/ai-exported/migration/features/README.md +0 -34
- package/ai-exported/migration/features/auxiliary-services.md +0 -114
- package/ai-exported/migration/features/bitcoin.md +0 -88
- package/ai-exported/migration/features/bridge.md +0 -123
- package/ai-exported/migration/features/dex.md +0 -101
- package/ai-exported/migration/features/migration.md +0 -120
- package/ai-exported/migration/features/money-market.md +0 -97
- package/ai-exported/migration/features/staking.md +0 -109
- package/ai-exported/migration/features/swap.md +0 -118
- package/ai-exported/migration/recipes.md +0 -188
- package/ai-exported/migration/reference/README.md +0 -15
- package/ai-exported/migration/reference/deleted-hooks.md +0 -110
- package/ai-exported/migration/reference/error-shape-crosswalk.md +0 -144
- package/ai-exported/migration/reference/renamed-hooks.md +0 -66
- package/dist/index.cjs +0 -2642
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1550
- package/dist/index.mjs.map +0 -1
- package/src/hooks/backend/useBackendSubmitSwapTxStatus.ts +0 -59
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createContext, useCallback, useContext, useState, useRef, useEffect, useMemo } from 'react';
|
|
3
|
-
import { ChainKeys, RadfiApiError, normalizePsbtToBase64, ClService, Sodax } from '@sodax/sdk';
|
|
1
|
+
import { isSodaxError, ChainKeys, RadfiApiError, normalizePsbtToBase64, ClService, Sodax } from '@sodax/sdk';
|
|
4
2
|
export * from '@sodax/sdk';
|
|
3
|
+
import { useMutation, useQuery, useQueryClient, useQueries, QueryClient, MutationCache } from '@tanstack/react-query';
|
|
4
|
+
import { createContext, useCallback, useContext, useState, useRef, useEffect, useMemo } from 'react';
|
|
5
5
|
import { isAddress, erc20Abi, parseUnits } from 'viem';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
|
+
// src/hooks/shared/isUserRejectedError.ts
|
|
9
|
+
function isUserRejectedError(error) {
|
|
10
|
+
return isSodaxError(error) && error.code === "USER_REJECTED";
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
// src/hooks/shared/unwrapResult.ts
|
|
9
14
|
function unwrapResult(result) {
|
|
10
15
|
if (!result.ok) {
|
|
@@ -140,59 +145,76 @@ function useRequestTrustline(token) {
|
|
|
140
145
|
);
|
|
141
146
|
return { requestTrustline, isLoading, isRequested, error, data };
|
|
142
147
|
}
|
|
143
|
-
function
|
|
148
|
+
function useNearStorageCheck({
|
|
144
149
|
params,
|
|
145
150
|
queryOptions
|
|
146
151
|
} = {}) {
|
|
147
152
|
const { sodax } = useSodaxContext();
|
|
148
|
-
const
|
|
149
|
-
const
|
|
153
|
+
const token = params?.token;
|
|
154
|
+
const accountId = params?.accountId;
|
|
155
|
+
const chainId = params?.chainId;
|
|
150
156
|
return useQuery({
|
|
151
|
-
queryKey: ["shared", "
|
|
157
|
+
queryKey: ["shared", "nearStorageCheck", chainId, token, accountId],
|
|
152
158
|
queryFn: async () => {
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return await sodax.hubProvider.getUserHubWalletAddress(spokeAddress, spokeChainId);
|
|
159
|
+
if (chainId !== ChainKeys.NEAR_MAINNET) return true;
|
|
160
|
+
if (!token || !accountId) return false;
|
|
161
|
+
return sodax.spoke.near.isStorageRegistered(token, accountId);
|
|
157
162
|
},
|
|
158
|
-
enabled: !!
|
|
159
|
-
refetchInterval: false,
|
|
163
|
+
enabled: !!token && !!accountId,
|
|
160
164
|
...queryOptions
|
|
161
165
|
});
|
|
162
166
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
// Pair symbol + address: readable in devtools, unique on-chain (symbol alone
|
|
167
|
-
// can collide — e.g. scam tokens copying legitimate ticker).
|
|
168
|
-
queryKey: ["shared", "xBalances", xChainId, xTokens.map((x) => [x.symbol, x.address]), address],
|
|
169
|
-
queryFn: async () => {
|
|
170
|
-
if (!xService) return {};
|
|
171
|
-
return xService.getBalances(address, xTokens);
|
|
172
|
-
},
|
|
173
|
-
enabled: !!xService && !!address && xTokens.length > 0,
|
|
174
|
-
refetchInterval: REFETCH_INTERVAL_MS
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function useXBalances({
|
|
178
|
-
params,
|
|
179
|
-
queryOptions
|
|
167
|
+
function useRegisterNearStorage({
|
|
168
|
+
mutationOptions
|
|
180
169
|
} = {}) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
170
|
+
const { sodax } = useSodaxContext();
|
|
171
|
+
const queryClient = useQueryClient();
|
|
172
|
+
return useSafeMutation({
|
|
173
|
+
mutationKey: ["shared", "registerNearStorage"],
|
|
174
|
+
...mutationOptions,
|
|
175
|
+
mutationFn: async ({ token, accountId, walletProvider, deposit }) => sodax.spoke.near.registerStorage({ token, accountId, walletProvider, deposit, raw: false }),
|
|
176
|
+
onSuccess: async (data, vars, ctx) => {
|
|
177
|
+
queryClient.invalidateQueries({
|
|
178
|
+
queryKey: ["shared", "nearStorageCheck", ChainKeys.NEAR_MAINNET, vars.token, vars.accountId]
|
|
179
|
+
});
|
|
180
|
+
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
181
|
+
}
|
|
189
182
|
});
|
|
190
183
|
}
|
|
184
|
+
function resolveNearStorageGate(chainKey, check) {
|
|
185
|
+
const isNear = chainKey === ChainKeys.NEAR_MAINNET;
|
|
186
|
+
const isChecking = check.isLoading;
|
|
187
|
+
const isRegistered = check.data;
|
|
188
|
+
return {
|
|
189
|
+
isNear,
|
|
190
|
+
needsRegistration: isNear && !isChecking && isRegistered === false,
|
|
191
|
+
blocksAction: isNear && (isChecking || isRegistered === false)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
191
194
|
|
|
192
|
-
// src/hooks/
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
// src/hooks/shared/useNearStorageGate.ts
|
|
196
|
+
function useNearStorageGate({
|
|
197
|
+
dstChainKey,
|
|
198
|
+
token,
|
|
199
|
+
accountId,
|
|
200
|
+
walletProvider
|
|
201
|
+
}) {
|
|
202
|
+
const nearWalletProvider = walletProvider?.chainType === "NEAR" ? walletProvider : void 0;
|
|
203
|
+
const storageCheck = useNearStorageCheck({ params: { token, accountId, chainId: dstChainKey } });
|
|
204
|
+
const { mutateAsyncSafe: register, isPending: isRegistering } = useRegisterNearStorage();
|
|
205
|
+
const { isNear, needsRegistration, blocksAction } = resolveNearStorageGate(dstChainKey, storageCheck);
|
|
206
|
+
const registerStorage = async () => {
|
|
207
|
+
if (!nearWalletProvider || !token || !accountId) return void 0;
|
|
208
|
+
return register({ token, accountId, walletProvider: nearWalletProvider });
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
isNear,
|
|
212
|
+
needsRegistration,
|
|
213
|
+
blocksAction,
|
|
214
|
+
isChecking: storageCheck.isLoading,
|
|
215
|
+
isRegistering,
|
|
216
|
+
registerStorage
|
|
217
|
+
};
|
|
196
218
|
}
|
|
197
219
|
var SESSION_KEY = (address) => `radfi_session_${address}`;
|
|
198
220
|
function saveRadfiSession(address, session) {
|
|
@@ -254,7 +276,7 @@ function useRadfiAuth({
|
|
|
254
276
|
clearRadfiSession(walletAddress);
|
|
255
277
|
}
|
|
256
278
|
throw new Error(
|
|
257
|
-
"This wallet is already registered with
|
|
279
|
+
"This wallet is already registered with Bound Exchange from another session. Please clear your browser storage for this site and try again, or wait for the previous session to expire."
|
|
258
280
|
);
|
|
259
281
|
}
|
|
260
282
|
throw err;
|
|
@@ -262,6 +284,99 @@ function useRadfiAuth({
|
|
|
262
284
|
}
|
|
263
285
|
});
|
|
264
286
|
}
|
|
287
|
+
|
|
288
|
+
// src/hooks/bitcoin/resolveBtcReadAddress.ts
|
|
289
|
+
function resolveBtcReadAddress(chainKey, address) {
|
|
290
|
+
if (chainKey !== ChainKeys.BITCOIN_MAINNET) return address;
|
|
291
|
+
return loadRadfiSession(address)?.tradingAddress ?? address;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/hooks/shared/useGetUserHubWalletAddress.ts
|
|
295
|
+
function useGetUserHubWalletAddress({
|
|
296
|
+
params,
|
|
297
|
+
queryOptions
|
|
298
|
+
} = {}) {
|
|
299
|
+
const { sodax } = useSodaxContext();
|
|
300
|
+
const spokeChainId = params?.spokeChainId;
|
|
301
|
+
const spokeAddress = params?.spokeAddress;
|
|
302
|
+
return useQuery({
|
|
303
|
+
queryKey: ["shared", "userHubWalletAddress", spokeChainId, spokeAddress],
|
|
304
|
+
queryFn: async () => {
|
|
305
|
+
if (!spokeChainId || !spokeAddress) {
|
|
306
|
+
throw new Error("Spoke chain id and address are required");
|
|
307
|
+
}
|
|
308
|
+
return await sodax.hubProvider.getUserHubWalletAddress(
|
|
309
|
+
resolveBtcReadAddress(spokeChainId, spokeAddress),
|
|
310
|
+
spokeChainId
|
|
311
|
+
);
|
|
312
|
+
},
|
|
313
|
+
enabled: !!spokeChainId && !!spokeAddress,
|
|
314
|
+
refetchInterval: false,
|
|
315
|
+
...queryOptions
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
var REFETCH_INTERVAL_MS = 5e3;
|
|
319
|
+
function getXBalancesQueryOptions({ xService, xChainId, xTokens, address }) {
|
|
320
|
+
return {
|
|
321
|
+
// Pair symbol + address: readable in devtools, unique on-chain (symbol alone
|
|
322
|
+
// can collide — e.g. scam tokens copying legitimate ticker).
|
|
323
|
+
queryKey: ["shared", "xBalances", xChainId, xTokens.map((x) => [x.symbol, x.address]), address],
|
|
324
|
+
queryFn: async () => {
|
|
325
|
+
if (!xService) return {};
|
|
326
|
+
return xService.getBalances(address, xTokens);
|
|
327
|
+
},
|
|
328
|
+
enabled: !!xService && !!address && xTokens.length > 0,
|
|
329
|
+
refetchInterval: REFETCH_INTERVAL_MS
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function useXBalances({
|
|
333
|
+
params,
|
|
334
|
+
queryOptions
|
|
335
|
+
} = {}) {
|
|
336
|
+
return useQuery({
|
|
337
|
+
...getXBalancesQueryOptions({
|
|
338
|
+
xService: params?.xService,
|
|
339
|
+
xChainId: params?.xChainId,
|
|
340
|
+
xTokens: params?.xTokens ?? [],
|
|
341
|
+
address: params?.address
|
|
342
|
+
}),
|
|
343
|
+
...queryOptions
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/hooks/provider/useHubProvider.ts
|
|
348
|
+
function useHubProvider() {
|
|
349
|
+
const { sodax } = useSodaxContext();
|
|
350
|
+
return sodax.hubProvider;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/hooks/bitcoin/useEnsureRadfiAccessToken.ts
|
|
354
|
+
function useEnsureRadfiAccessToken({
|
|
355
|
+
mutationOptions
|
|
356
|
+
} = {}) {
|
|
357
|
+
const { sodax } = useSodaxContext();
|
|
358
|
+
return useSafeMutation({
|
|
359
|
+
mutationKey: ["bitcoin", "ensureAccessToken"],
|
|
360
|
+
...mutationOptions,
|
|
361
|
+
mutationFn: async ({ walletProvider }) => {
|
|
362
|
+
const radfi = sodax.spoke.bitcoin.radfi;
|
|
363
|
+
const walletAddress = await walletProvider.getWalletAddress();
|
|
364
|
+
const session = loadRadfiSession(walletAddress);
|
|
365
|
+
if (session?.refreshToken && !radfi.refreshToken) {
|
|
366
|
+
radfi.setRadfiAccessToken(session.accessToken, session.refreshToken);
|
|
367
|
+
}
|
|
368
|
+
await radfi.ensureRadfiAccessToken(walletProvider);
|
|
369
|
+
const accessToken = radfi.accessToken;
|
|
370
|
+
if (!accessToken) {
|
|
371
|
+
throw new Error("Failed to obtain a Bound Exchange access token");
|
|
372
|
+
}
|
|
373
|
+
if (session) {
|
|
374
|
+
saveRadfiSession(walletAddress, { ...session, accessToken, refreshToken: radfi.refreshToken });
|
|
375
|
+
}
|
|
376
|
+
return accessToken;
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
265
380
|
var REFRESH_INTERVAL = 5 * 60 * 1e3;
|
|
266
381
|
function useRadfiSession(walletProvider) {
|
|
267
382
|
const { sodax } = useSodaxContext();
|
|
@@ -397,6 +512,19 @@ function useTradingWalletBalance({
|
|
|
397
512
|
...queryOptions
|
|
398
513
|
});
|
|
399
514
|
}
|
|
515
|
+
var INERT = { wallet: void 0, tradingBalance: void 0 };
|
|
516
|
+
function useBitcoinTradingSetup({
|
|
517
|
+
chainKey,
|
|
518
|
+
walletProvider,
|
|
519
|
+
address
|
|
520
|
+
}) {
|
|
521
|
+
const isBitcoin = chainKey === ChainKeys.BITCOIN_MAINNET;
|
|
522
|
+
const wallet = isBitcoin ? walletProvider : void 0;
|
|
523
|
+
const { tradingAddress } = useTradingWallet(isBitcoin ? address : void 0);
|
|
524
|
+
const { data: tradingBalance } = useTradingWalletBalance({ params: { walletProvider: wallet, tradingAddress } });
|
|
525
|
+
if (!isBitcoin) return INERT;
|
|
526
|
+
return { wallet, tradingBalance };
|
|
527
|
+
}
|
|
400
528
|
function useExpiredUtxos({
|
|
401
529
|
params,
|
|
402
530
|
queryOptions
|
|
@@ -432,7 +560,7 @@ function useRenewUtxos({
|
|
|
432
560
|
const session = loadRadfiSession(userAddress);
|
|
433
561
|
const accessToken = session?.accessToken || radfi.accessToken;
|
|
434
562
|
if (!accessToken) {
|
|
435
|
-
throw new Error("
|
|
563
|
+
throw new Error("Bound Exchange authentication required. Please login first.");
|
|
436
564
|
}
|
|
437
565
|
const buildResult = await radfi.buildRenewUtxoTransaction({ userAddress, txIdVouts }, accessToken);
|
|
438
566
|
const signedTx = await walletProvider.signTransaction(buildResult.base64Psbt, false);
|
|
@@ -460,7 +588,7 @@ function useRadfiWithdraw({
|
|
|
460
588
|
const session = loadRadfiSession(userAddress);
|
|
461
589
|
const accessToken = session?.accessToken || radfi.accessToken;
|
|
462
590
|
if (!accessToken) {
|
|
463
|
-
throw new Error("
|
|
591
|
+
throw new Error("Bound Exchange authentication required. Please login first.");
|
|
464
592
|
}
|
|
465
593
|
const buildResult = await radfi.withdrawToUser({ userAddress, amount, tokenId, withdrawTo }, accessToken);
|
|
466
594
|
const signedTx = await walletProvider.signTransaction(buildResult.base64Psbt, false);
|
|
@@ -581,7 +709,10 @@ function useUserReservesData({
|
|
|
581
709
|
if (!spokeChainKey || !userAddress) {
|
|
582
710
|
throw new Error("spokeChainKey and userAddress are required");
|
|
583
711
|
}
|
|
584
|
-
return sodax.moneyMarket.data.getUserReservesData(
|
|
712
|
+
return sodax.moneyMarket.data.getUserReservesData(
|
|
713
|
+
spokeChainKey,
|
|
714
|
+
resolveBtcReadAddress(spokeChainKey, userAddress)
|
|
715
|
+
);
|
|
585
716
|
},
|
|
586
717
|
enabled: !!spokeChainKey && !!userAddress,
|
|
587
718
|
refetchInterval: 5e3,
|
|
@@ -707,7 +838,10 @@ function useATokensBalances({
|
|
|
707
838
|
throw new Error(`Invalid aToken address: ${aToken}`);
|
|
708
839
|
}
|
|
709
840
|
}
|
|
710
|
-
const hubWalletAddress = await sodax.hubProvider.getUserHubWalletAddress(
|
|
841
|
+
const hubWalletAddress = await sodax.hubProvider.getUserHubWalletAddress(
|
|
842
|
+
resolveBtcReadAddress(spokeChainKey, userAddress),
|
|
843
|
+
spokeChainKey
|
|
844
|
+
);
|
|
711
845
|
return sodax.moneyMarket.data.getATokensBalances(aTokens, hubWalletAddress);
|
|
712
846
|
},
|
|
713
847
|
enabled: aTokens.length > 0 && !!spokeChainKey && !!userAddress,
|
|
@@ -742,7 +876,10 @@ function useUserFormattedSummary({
|
|
|
742
876
|
}
|
|
743
877
|
const [reserves, userReserves] = await Promise.all([
|
|
744
878
|
sodax.moneyMarket.data.getReservesHumanized(),
|
|
745
|
-
sodax.moneyMarket.data.getUserReservesHumanized(
|
|
879
|
+
sodax.moneyMarket.data.getUserReservesHumanized(
|
|
880
|
+
spokeChainKey,
|
|
881
|
+
resolveBtcReadAddress(spokeChainKey, userAddress)
|
|
882
|
+
)
|
|
746
883
|
]);
|
|
747
884
|
const formattedReserves = sodax.moneyMarket.data.formatReservesUSD(
|
|
748
885
|
sodax.moneyMarket.data.buildReserveDataWithPrice(reserves)
|
|
@@ -956,189 +1093,500 @@ var useBackendUserIntents = ({
|
|
|
956
1093
|
...queryOptions
|
|
957
1094
|
});
|
|
958
1095
|
};
|
|
1096
|
+
var useBackendOrderbook = ({
|
|
1097
|
+
params,
|
|
1098
|
+
queryOptions
|
|
1099
|
+
} = {}) => {
|
|
1100
|
+
const { sodax } = useSodaxContext();
|
|
1101
|
+
const pagination = params?.pagination;
|
|
1102
|
+
return useQuery({
|
|
1103
|
+
queryKey: ["backend", "orderbook", pagination?.offset, pagination?.limit],
|
|
1104
|
+
queryFn: async () => {
|
|
1105
|
+
if (!pagination?.offset || !pagination?.limit) {
|
|
1106
|
+
throw new Error("Pagination offset and limit are required");
|
|
1107
|
+
}
|
|
1108
|
+
return unwrapResult(await sodax.backendApi.getOrderbook(pagination));
|
|
1109
|
+
},
|
|
1110
|
+
enabled: !!pagination?.offset && !!pagination?.limit,
|
|
1111
|
+
staleTime: 30 * 1e3,
|
|
1112
|
+
retry: 3,
|
|
1113
|
+
...queryOptions
|
|
1114
|
+
});
|
|
1115
|
+
};
|
|
1116
|
+
var useBackendMoneyMarketPosition = ({
|
|
1117
|
+
params,
|
|
1118
|
+
queryOptions
|
|
1119
|
+
} = {}) => {
|
|
1120
|
+
const { sodax } = useSodaxContext();
|
|
1121
|
+
const userAddress = params?.userAddress;
|
|
1122
|
+
return useQuery({
|
|
1123
|
+
queryKey: ["backend", "mm", "position", userAddress],
|
|
1124
|
+
queryFn: async () => {
|
|
1125
|
+
if (!userAddress) return void 0;
|
|
1126
|
+
return unwrapResult(await sodax.backendApi.getMoneyMarketPosition(userAddress));
|
|
1127
|
+
},
|
|
1128
|
+
enabled: !!userAddress && userAddress.length > 0,
|
|
1129
|
+
retry: 3,
|
|
1130
|
+
...queryOptions
|
|
1131
|
+
});
|
|
1132
|
+
};
|
|
1133
|
+
var useBackendAllMoneyMarketAssets = ({
|
|
1134
|
+
queryOptions
|
|
1135
|
+
} = {}) => {
|
|
1136
|
+
const { sodax } = useSodaxContext();
|
|
1137
|
+
return useQuery({
|
|
1138
|
+
queryKey: ["backend", "mm", "assets", "all"],
|
|
1139
|
+
queryFn: async () => {
|
|
1140
|
+
return unwrapResult(await sodax.backendApi.getAllMoneyMarketAssets());
|
|
1141
|
+
},
|
|
1142
|
+
retry: 3,
|
|
1143
|
+
...queryOptions
|
|
1144
|
+
});
|
|
1145
|
+
};
|
|
1146
|
+
var useBackendMoneyMarketAsset = ({
|
|
1147
|
+
params,
|
|
1148
|
+
queryOptions
|
|
1149
|
+
} = {}) => {
|
|
1150
|
+
const { sodax } = useSodaxContext();
|
|
1151
|
+
const reserveAddress = params?.reserveAddress;
|
|
1152
|
+
return useQuery({
|
|
1153
|
+
queryKey: ["backend", "mm", "asset", reserveAddress],
|
|
1154
|
+
queryFn: async () => {
|
|
1155
|
+
if (!reserveAddress) return void 0;
|
|
1156
|
+
return unwrapResult(await sodax.backendApi.getMoneyMarketAsset(reserveAddress));
|
|
1157
|
+
},
|
|
1158
|
+
enabled: !!reserveAddress && reserveAddress.length > 0,
|
|
1159
|
+
retry: 3,
|
|
1160
|
+
...queryOptions
|
|
1161
|
+
});
|
|
1162
|
+
};
|
|
1163
|
+
var useBackendMoneyMarketAssetBorrowers = ({
|
|
1164
|
+
params,
|
|
1165
|
+
queryOptions
|
|
1166
|
+
} = {}) => {
|
|
1167
|
+
const { sodax } = useSodaxContext();
|
|
1168
|
+
const reserveAddress = params?.reserveAddress;
|
|
1169
|
+
const pagination = params?.pagination;
|
|
1170
|
+
return useQuery({
|
|
1171
|
+
queryKey: ["backend", "mm", "asset", "borrowers", reserveAddress, pagination],
|
|
1172
|
+
queryFn: async () => {
|
|
1173
|
+
if (!reserveAddress || !pagination?.offset || !pagination?.limit) {
|
|
1174
|
+
return void 0;
|
|
1175
|
+
}
|
|
1176
|
+
return unwrapResult(
|
|
1177
|
+
await sodax.backendApi.getMoneyMarketAssetBorrowers(reserveAddress, {
|
|
1178
|
+
offset: pagination.offset,
|
|
1179
|
+
limit: pagination.limit
|
|
1180
|
+
})
|
|
1181
|
+
);
|
|
1182
|
+
},
|
|
1183
|
+
enabled: !!reserveAddress && !!pagination?.offset && !!pagination?.limit,
|
|
1184
|
+
retry: 3,
|
|
1185
|
+
...queryOptions
|
|
1186
|
+
});
|
|
1187
|
+
};
|
|
1188
|
+
var useBackendMoneyMarketAssetSuppliers = ({
|
|
1189
|
+
params,
|
|
1190
|
+
queryOptions
|
|
1191
|
+
} = {}) => {
|
|
1192
|
+
const { sodax } = useSodaxContext();
|
|
1193
|
+
const reserveAddress = params?.reserveAddress;
|
|
1194
|
+
const pagination = params?.pagination;
|
|
1195
|
+
return useQuery({
|
|
1196
|
+
queryKey: ["backend", "mm", "asset", "suppliers", reserveAddress, pagination],
|
|
1197
|
+
queryFn: async () => {
|
|
1198
|
+
if (!reserveAddress || !pagination?.offset || !pagination?.limit) {
|
|
1199
|
+
return void 0;
|
|
1200
|
+
}
|
|
1201
|
+
return unwrapResult(
|
|
1202
|
+
await sodax.backendApi.getMoneyMarketAssetSuppliers(reserveAddress, {
|
|
1203
|
+
offset: pagination.offset,
|
|
1204
|
+
limit: pagination.limit
|
|
1205
|
+
})
|
|
1206
|
+
);
|
|
1207
|
+
},
|
|
1208
|
+
enabled: !!reserveAddress && !!pagination?.offset && !!pagination?.limit,
|
|
1209
|
+
retry: 3,
|
|
1210
|
+
...queryOptions
|
|
1211
|
+
});
|
|
1212
|
+
};
|
|
1213
|
+
var useBackendAllMoneyMarketBorrowers = ({
|
|
1214
|
+
params,
|
|
1215
|
+
queryOptions
|
|
1216
|
+
} = {}) => {
|
|
1217
|
+
const { sodax } = useSodaxContext();
|
|
1218
|
+
const pagination = params?.pagination;
|
|
1219
|
+
return useQuery({
|
|
1220
|
+
queryKey: ["backend", "mm", "borrowers", "all", pagination],
|
|
1221
|
+
queryFn: async () => {
|
|
1222
|
+
if (!pagination?.offset || !pagination?.limit) {
|
|
1223
|
+
return void 0;
|
|
1224
|
+
}
|
|
1225
|
+
return unwrapResult(
|
|
1226
|
+
await sodax.backendApi.getAllMoneyMarketBorrowers({
|
|
1227
|
+
offset: pagination.offset,
|
|
1228
|
+
limit: pagination.limit
|
|
1229
|
+
})
|
|
1230
|
+
);
|
|
1231
|
+
},
|
|
1232
|
+
enabled: !!pagination?.offset && !!pagination?.limit,
|
|
1233
|
+
retry: 3,
|
|
1234
|
+
...queryOptions
|
|
1235
|
+
});
|
|
1236
|
+
};
|
|
1237
|
+
var useSwapsApiTokens = ({
|
|
1238
|
+
params,
|
|
1239
|
+
queryOptions
|
|
1240
|
+
} = {}) => {
|
|
1241
|
+
const { sodax } = useSodaxContext();
|
|
1242
|
+
const apiConfig = params?.apiConfig;
|
|
1243
|
+
return useQuery({
|
|
1244
|
+
queryKey: ["swapsApi", "tokens"],
|
|
1245
|
+
queryFn: async () => unwrapResult(await sodax.api.swaps.getTokens(apiConfig)),
|
|
1246
|
+
retry: 3,
|
|
1247
|
+
...queryOptions
|
|
1248
|
+
});
|
|
1249
|
+
};
|
|
1250
|
+
var useSwapsApiTokensByChain = ({
|
|
1251
|
+
params,
|
|
1252
|
+
queryOptions
|
|
1253
|
+
} = {}) => {
|
|
1254
|
+
const { sodax } = useSodaxContext();
|
|
1255
|
+
const chainKey = params?.chainKey;
|
|
1256
|
+
const apiConfig = params?.apiConfig;
|
|
1257
|
+
return useQuery({
|
|
1258
|
+
queryKey: ["swapsApi", "tokens", chainKey],
|
|
1259
|
+
queryFn: async () => {
|
|
1260
|
+
if (!chainKey) return void 0;
|
|
1261
|
+
return unwrapResult(await sodax.api.swaps.getTokensByChain(chainKey, apiConfig));
|
|
1262
|
+
},
|
|
1263
|
+
enabled: !!chainKey && chainKey.length > 0,
|
|
1264
|
+
retry: 3,
|
|
1265
|
+
...queryOptions
|
|
1266
|
+
});
|
|
1267
|
+
};
|
|
1268
|
+
var useSwapsApiQuote = ({
|
|
1269
|
+
params,
|
|
1270
|
+
queryOptions
|
|
1271
|
+
} = {}) => {
|
|
1272
|
+
const { sodax } = useSodaxContext();
|
|
1273
|
+
const body = params?.body;
|
|
1274
|
+
const query = params?.query;
|
|
1275
|
+
const apiConfig = params?.apiConfig;
|
|
1276
|
+
return useQuery({
|
|
1277
|
+
// Hash the whole request body so every quote input — including partnerFee and the other
|
|
1278
|
+
// SwapExtrasV2 fields — is a cache dimension; a partnerFee change alters the quote and must
|
|
1279
|
+
// miss the cache. QuoteRequestV2 is bigint-free (compile-time guaranteed), so React Query's
|
|
1280
|
+
// default key hashing handles the object directly.
|
|
1281
|
+
queryKey: ["swapsApi", "quote", body, query?.includeTxData ?? false],
|
|
1282
|
+
queryFn: async () => {
|
|
1283
|
+
if (!body) return void 0;
|
|
1284
|
+
return unwrapResult(await sodax.api.swaps.getQuote(body, query, apiConfig));
|
|
1285
|
+
},
|
|
1286
|
+
enabled: !!body,
|
|
1287
|
+
retry: 3,
|
|
1288
|
+
...queryOptions
|
|
1289
|
+
});
|
|
1290
|
+
};
|
|
1291
|
+
var useSwapsApiDeadline = ({
|
|
1292
|
+
params,
|
|
1293
|
+
queryOptions
|
|
1294
|
+
} = {}) => {
|
|
1295
|
+
const { sodax } = useSodaxContext();
|
|
1296
|
+
const query = params?.query;
|
|
1297
|
+
const apiConfig = params?.apiConfig;
|
|
1298
|
+
return useQuery({
|
|
1299
|
+
queryKey: ["swapsApi", "deadline", query?.offsetSeconds ?? null],
|
|
1300
|
+
queryFn: async () => unwrapResult(await sodax.api.swaps.getDeadline(query, apiConfig)),
|
|
1301
|
+
retry: 3,
|
|
1302
|
+
...queryOptions
|
|
1303
|
+
});
|
|
1304
|
+
};
|
|
1305
|
+
var useSwapsApiAllowance = ({
|
|
1306
|
+
params,
|
|
1307
|
+
queryOptions
|
|
1308
|
+
} = {}) => {
|
|
1309
|
+
const { sodax } = useSodaxContext();
|
|
1310
|
+
const body = params?.body;
|
|
1311
|
+
const apiConfig = params?.apiConfig;
|
|
1312
|
+
return useQuery({
|
|
1313
|
+
queryKey: ["swapsApi", "allowance", body?.srcChainKey, body?.inputToken, body?.inputAmount, body?.srcAddress],
|
|
1314
|
+
queryFn: async () => {
|
|
1315
|
+
if (!body) return void 0;
|
|
1316
|
+
return unwrapResult(await sodax.api.swaps.checkAllowance(body, apiConfig));
|
|
1317
|
+
},
|
|
1318
|
+
enabled: !!body,
|
|
1319
|
+
retry: 3,
|
|
1320
|
+
...queryOptions
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
959
1323
|
|
|
960
|
-
// src/hooks/
|
|
961
|
-
var
|
|
1324
|
+
// src/hooks/swapsApi/useSwapsApiApprove.ts
|
|
1325
|
+
var useSwapsApiApprove = ({
|
|
962
1326
|
mutationOptions
|
|
963
1327
|
} = {}) => {
|
|
964
1328
|
const { sodax } = useSodaxContext();
|
|
965
1329
|
return useSafeMutation({
|
|
966
|
-
mutationKey: ["
|
|
1330
|
+
mutationKey: ["swapsApi", "approve"],
|
|
967
1331
|
retry: 3,
|
|
968
1332
|
...mutationOptions,
|
|
969
|
-
mutationFn: async ({
|
|
1333
|
+
mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.swaps.approve(body, apiConfig))
|
|
1334
|
+
});
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
// src/hooks/swapsApi/useSwapsApiCreateIntent.ts
|
|
1338
|
+
var useSwapsApiCreateIntent = ({
|
|
1339
|
+
mutationOptions
|
|
1340
|
+
} = {}) => {
|
|
1341
|
+
const { sodax } = useSodaxContext();
|
|
1342
|
+
return useSafeMutation({
|
|
1343
|
+
mutationKey: ["swapsApi", "createIntent"],
|
|
1344
|
+
retry: 3,
|
|
1345
|
+
...mutationOptions,
|
|
1346
|
+
mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.swaps.createIntent(body, apiConfig))
|
|
1347
|
+
});
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
// src/hooks/swapsApi/useSwapsApiSubmitIntent.ts
|
|
1351
|
+
var useSwapsApiSubmitIntent = ({
|
|
1352
|
+
mutationOptions
|
|
1353
|
+
} = {}) => {
|
|
1354
|
+
const { sodax } = useSodaxContext();
|
|
1355
|
+
return useSafeMutation({
|
|
1356
|
+
mutationKey: ["swapsApi", "submitIntent"],
|
|
1357
|
+
retry: false,
|
|
1358
|
+
...mutationOptions,
|
|
1359
|
+
mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.swaps.submitIntent(body, apiConfig))
|
|
970
1360
|
});
|
|
971
1361
|
};
|
|
972
|
-
|
|
1362
|
+
|
|
1363
|
+
// src/hooks/swapsApi/isTerminalSwapIntentStatus.ts
|
|
1364
|
+
var isTerminalSwapIntentStatus = (status) => status === 3 || status === 4;
|
|
1365
|
+
|
|
1366
|
+
// src/hooks/swapsApi/useSwapsApiStatus.ts
|
|
1367
|
+
var useSwapsApiStatus = ({
|
|
973
1368
|
params,
|
|
974
1369
|
queryOptions
|
|
975
1370
|
} = {}) => {
|
|
976
1371
|
const { sodax } = useSodaxContext();
|
|
977
|
-
const
|
|
978
|
-
const srcChainKey = params?.srcChainKey;
|
|
1372
|
+
const intentTxHash = params?.intentTxHash;
|
|
979
1373
|
const apiConfig = params?.apiConfig;
|
|
980
1374
|
return useQuery({
|
|
981
|
-
queryKey: ["
|
|
1375
|
+
queryKey: ["swapsApi", "status", intentTxHash],
|
|
982
1376
|
queryFn: async () => {
|
|
983
|
-
if (!
|
|
984
|
-
return unwrapResult(
|
|
985
|
-
await sodax.backendApi.getSubmitSwapTxStatus(
|
|
986
|
-
{
|
|
987
|
-
txHash,
|
|
988
|
-
srcChainKey
|
|
989
|
-
},
|
|
990
|
-
apiConfig
|
|
991
|
-
)
|
|
992
|
-
);
|
|
1377
|
+
if (!intentTxHash) return void 0;
|
|
1378
|
+
return unwrapResult(await sodax.api.swaps.getStatus({ intentTxHash }, apiConfig));
|
|
993
1379
|
},
|
|
994
|
-
enabled: !!
|
|
1380
|
+
enabled: !!intentTxHash && intentTxHash.length > 0,
|
|
995
1381
|
retry: 3,
|
|
996
|
-
refetchInterval: (query) =>
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1382
|
+
refetchInterval: (query) => isTerminalSwapIntentStatus(query.state.data?.status) ? false : 1e3,
|
|
1383
|
+
...queryOptions
|
|
1384
|
+
});
|
|
1385
|
+
};
|
|
1386
|
+
|
|
1387
|
+
// src/hooks/swapsApi/useSwapsApiCancelIntent.ts
|
|
1388
|
+
var useSwapsApiCancelIntent = ({
|
|
1389
|
+
mutationOptions
|
|
1390
|
+
} = {}) => {
|
|
1391
|
+
const { sodax } = useSodaxContext();
|
|
1392
|
+
return useSafeMutation({
|
|
1393
|
+
mutationKey: ["swapsApi", "cancelIntent"],
|
|
1394
|
+
retry: 3,
|
|
1395
|
+
...mutationOptions,
|
|
1396
|
+
mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.swaps.cancelIntent(body, apiConfig))
|
|
1397
|
+
});
|
|
1398
|
+
};
|
|
1399
|
+
var useSwapsApiIntentHash = ({
|
|
1400
|
+
params,
|
|
1401
|
+
queryOptions
|
|
1402
|
+
} = {}) => {
|
|
1403
|
+
const { sodax } = useSodaxContext();
|
|
1404
|
+
const intent = params?.intent;
|
|
1405
|
+
const apiConfig = params?.apiConfig;
|
|
1406
|
+
return useQuery({
|
|
1407
|
+
queryKey: ["swapsApi", "intentHash", intent?.intentId?.toString()],
|
|
1408
|
+
queryFn: async () => {
|
|
1409
|
+
if (!intent) return void 0;
|
|
1410
|
+
return unwrapResult(await sodax.api.swaps.getIntentHash({ intent }, apiConfig));
|
|
1000
1411
|
},
|
|
1412
|
+
enabled: !!intent,
|
|
1413
|
+
retry: 3,
|
|
1001
1414
|
...queryOptions
|
|
1002
1415
|
});
|
|
1003
1416
|
};
|
|
1004
|
-
var
|
|
1417
|
+
var useSwapsApiIntentPacket = ({
|
|
1005
1418
|
params,
|
|
1006
1419
|
queryOptions
|
|
1007
1420
|
} = {}) => {
|
|
1008
1421
|
const { sodax } = useSodaxContext();
|
|
1009
|
-
const
|
|
1422
|
+
const body = params?.body;
|
|
1423
|
+
const apiConfig = params?.apiConfig;
|
|
1010
1424
|
return useQuery({
|
|
1011
|
-
queryKey: ["
|
|
1425
|
+
queryKey: ["swapsApi", "intentPacket", body?.chainId, body?.fillTxHash],
|
|
1426
|
+
queryFn: async () => {
|
|
1427
|
+
if (!body) return void 0;
|
|
1428
|
+
return unwrapResult(await sodax.api.swaps.getSolvedIntentPacket(body, apiConfig));
|
|
1429
|
+
},
|
|
1430
|
+
enabled: !!body,
|
|
1431
|
+
retry: 3,
|
|
1432
|
+
...queryOptions
|
|
1433
|
+
});
|
|
1434
|
+
};
|
|
1435
|
+
var useSwapsApiIntentExtraData = ({
|
|
1436
|
+
params,
|
|
1437
|
+
queryOptions
|
|
1438
|
+
} = {}) => {
|
|
1439
|
+
const { sodax } = useSodaxContext();
|
|
1440
|
+
const body = params?.body;
|
|
1441
|
+
const apiConfig = params?.apiConfig;
|
|
1442
|
+
return useQuery({
|
|
1443
|
+
queryKey: ["swapsApi", "intentExtraData", body?.txHash ?? body?.intent?.intentId?.toString()],
|
|
1012
1444
|
queryFn: async () => {
|
|
1013
|
-
if (!
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1016
|
-
return unwrapResult(await sodax.backendApi.getOrderbook(pagination));
|
|
1445
|
+
if (!body || !body.txHash && !body.intent) return void 0;
|
|
1446
|
+
return unwrapResult(await sodax.api.swaps.getIntentSubmitTxExtraData(body, apiConfig));
|
|
1017
1447
|
},
|
|
1018
|
-
enabled: !!
|
|
1019
|
-
staleTime: 30 * 1e3,
|
|
1448
|
+
enabled: !!body && (!!body.txHash || !!body.intent),
|
|
1020
1449
|
retry: 3,
|
|
1021
1450
|
...queryOptions
|
|
1022
1451
|
});
|
|
1023
1452
|
};
|
|
1024
|
-
var
|
|
1453
|
+
var useSwapsApiFilledIntent = ({
|
|
1025
1454
|
params,
|
|
1026
1455
|
queryOptions
|
|
1027
1456
|
} = {}) => {
|
|
1028
1457
|
const { sodax } = useSodaxContext();
|
|
1029
|
-
const
|
|
1458
|
+
const txHash = params?.txHash;
|
|
1459
|
+
const apiConfig = params?.apiConfig;
|
|
1030
1460
|
return useQuery({
|
|
1031
|
-
queryKey: ["
|
|
1461
|
+
queryKey: ["swapsApi", "filledIntent", txHash],
|
|
1032
1462
|
queryFn: async () => {
|
|
1033
|
-
if (!
|
|
1034
|
-
return unwrapResult(await sodax.
|
|
1463
|
+
if (!txHash) return void 0;
|
|
1464
|
+
return unwrapResult(await sodax.api.swaps.getFilledIntent(txHash, apiConfig));
|
|
1035
1465
|
},
|
|
1036
|
-
enabled: !!
|
|
1466
|
+
enabled: !!txHash && txHash.length > 0,
|
|
1037
1467
|
retry: 3,
|
|
1038
1468
|
...queryOptions
|
|
1039
1469
|
});
|
|
1040
1470
|
};
|
|
1041
|
-
var
|
|
1471
|
+
var useSwapsApiIntent = ({
|
|
1472
|
+
params,
|
|
1042
1473
|
queryOptions
|
|
1043
1474
|
} = {}) => {
|
|
1044
1475
|
const { sodax } = useSodaxContext();
|
|
1476
|
+
const txHash = params?.txHash;
|
|
1477
|
+
const apiConfig = params?.apiConfig;
|
|
1045
1478
|
return useQuery({
|
|
1046
|
-
queryKey: ["
|
|
1479
|
+
queryKey: ["swapsApi", "intent", txHash],
|
|
1047
1480
|
queryFn: async () => {
|
|
1048
|
-
|
|
1481
|
+
if (!txHash) return void 0;
|
|
1482
|
+
return unwrapResult(await sodax.api.swaps.getIntent(txHash, apiConfig));
|
|
1049
1483
|
},
|
|
1484
|
+
enabled: !!txHash && txHash.length > 0,
|
|
1050
1485
|
retry: 3,
|
|
1051
1486
|
...queryOptions
|
|
1052
1487
|
});
|
|
1053
1488
|
};
|
|
1054
|
-
|
|
1489
|
+
|
|
1490
|
+
// src/hooks/swapsApi/useSwapsApiCreateLimitOrder.ts
|
|
1491
|
+
var useSwapsApiCreateLimitOrder = ({
|
|
1492
|
+
mutationOptions
|
|
1493
|
+
} = {}) => {
|
|
1494
|
+
const { sodax } = useSodaxContext();
|
|
1495
|
+
return useSafeMutation({
|
|
1496
|
+
mutationKey: ["swapsApi", "createLimitOrder"],
|
|
1497
|
+
retry: 3,
|
|
1498
|
+
...mutationOptions,
|
|
1499
|
+
mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.swaps.createLimitOrderIntent(body, apiConfig))
|
|
1500
|
+
});
|
|
1501
|
+
};
|
|
1502
|
+
var useSwapsApiEstimateGas = ({
|
|
1055
1503
|
params,
|
|
1056
1504
|
queryOptions
|
|
1057
1505
|
} = {}) => {
|
|
1058
1506
|
const { sodax } = useSodaxContext();
|
|
1059
|
-
const
|
|
1507
|
+
const body = params?.body;
|
|
1508
|
+
const apiConfig = params?.apiConfig;
|
|
1060
1509
|
return useQuery({
|
|
1061
|
-
queryKey: ["
|
|
1510
|
+
queryKey: ["swapsApi", "estimateGas", body?.chainKey, body?.tx],
|
|
1062
1511
|
queryFn: async () => {
|
|
1063
|
-
if (!
|
|
1064
|
-
return unwrapResult(await sodax.
|
|
1512
|
+
if (!body) return void 0;
|
|
1513
|
+
return unwrapResult(await sodax.api.swaps.estimateGas(body, apiConfig));
|
|
1065
1514
|
},
|
|
1066
|
-
enabled: !!
|
|
1515
|
+
enabled: !!body,
|
|
1067
1516
|
retry: 3,
|
|
1068
1517
|
...queryOptions
|
|
1069
1518
|
});
|
|
1070
1519
|
};
|
|
1071
|
-
var
|
|
1520
|
+
var useSwapsApiPartnerFee = ({
|
|
1072
1521
|
params,
|
|
1073
1522
|
queryOptions
|
|
1074
1523
|
} = {}) => {
|
|
1075
1524
|
const { sodax } = useSodaxContext();
|
|
1076
|
-
const
|
|
1077
|
-
const
|
|
1525
|
+
const amount = params?.amount;
|
|
1526
|
+
const apiConfig = params?.apiConfig;
|
|
1078
1527
|
return useQuery({
|
|
1079
|
-
queryKey: ["
|
|
1528
|
+
queryKey: ["swapsApi", "partnerFee", amount],
|
|
1080
1529
|
queryFn: async () => {
|
|
1081
|
-
if (!
|
|
1082
|
-
|
|
1083
|
-
}
|
|
1084
|
-
return unwrapResult(
|
|
1085
|
-
await sodax.backendApi.getMoneyMarketAssetBorrowers(reserveAddress, {
|
|
1086
|
-
offset: pagination.offset,
|
|
1087
|
-
limit: pagination.limit
|
|
1088
|
-
})
|
|
1089
|
-
);
|
|
1530
|
+
if (!amount) return void 0;
|
|
1531
|
+
return unwrapResult(await sodax.api.swaps.getPartnerFee({ amount }, apiConfig));
|
|
1090
1532
|
},
|
|
1091
|
-
enabled: !!
|
|
1533
|
+
enabled: !!amount && amount.length > 0,
|
|
1092
1534
|
retry: 3,
|
|
1093
1535
|
...queryOptions
|
|
1094
1536
|
});
|
|
1095
1537
|
};
|
|
1096
|
-
var
|
|
1538
|
+
var useSwapsApiSolverFee = ({
|
|
1097
1539
|
params,
|
|
1098
1540
|
queryOptions
|
|
1099
1541
|
} = {}) => {
|
|
1100
1542
|
const { sodax } = useSodaxContext();
|
|
1101
|
-
const
|
|
1102
|
-
const
|
|
1543
|
+
const amount = params?.amount;
|
|
1544
|
+
const apiConfig = params?.apiConfig;
|
|
1103
1545
|
return useQuery({
|
|
1104
|
-
queryKey: ["
|
|
1546
|
+
queryKey: ["swapsApi", "solverFee", amount],
|
|
1105
1547
|
queryFn: async () => {
|
|
1106
|
-
if (!
|
|
1107
|
-
|
|
1108
|
-
}
|
|
1109
|
-
return unwrapResult(
|
|
1110
|
-
await sodax.backendApi.getMoneyMarketAssetSuppliers(reserveAddress, {
|
|
1111
|
-
offset: pagination.offset,
|
|
1112
|
-
limit: pagination.limit
|
|
1113
|
-
})
|
|
1114
|
-
);
|
|
1548
|
+
if (!amount) return void 0;
|
|
1549
|
+
return unwrapResult(await sodax.api.swaps.getSolverFee({ amount }, apiConfig));
|
|
1115
1550
|
},
|
|
1116
|
-
enabled: !!
|
|
1551
|
+
enabled: !!amount && amount.length > 0,
|
|
1117
1552
|
retry: 3,
|
|
1118
1553
|
...queryOptions
|
|
1119
1554
|
});
|
|
1120
1555
|
};
|
|
1121
|
-
|
|
1556
|
+
|
|
1557
|
+
// src/hooks/swapsApi/useSwapsApiSubmitTx.ts
|
|
1558
|
+
var useSwapsApiSubmitTx = ({
|
|
1559
|
+
mutationOptions
|
|
1560
|
+
} = {}) => {
|
|
1561
|
+
const { sodax } = useSodaxContext();
|
|
1562
|
+
return useSafeMutation({
|
|
1563
|
+
mutationKey: ["swapsApi", "submitTx"],
|
|
1564
|
+
retry: 3,
|
|
1565
|
+
...mutationOptions,
|
|
1566
|
+
mutationFn: async ({ request, apiConfig }) => unwrapResult(await sodax.api.swaps.submitTx(request, apiConfig))
|
|
1567
|
+
});
|
|
1568
|
+
};
|
|
1569
|
+
var useSwapsApiSubmitTxStatus = ({
|
|
1122
1570
|
params,
|
|
1123
1571
|
queryOptions
|
|
1124
1572
|
} = {}) => {
|
|
1125
1573
|
const { sodax } = useSodaxContext();
|
|
1126
|
-
const
|
|
1574
|
+
const txHash = params?.txHash;
|
|
1575
|
+
const srcChainKey = params?.srcChainKey;
|
|
1576
|
+
const apiConfig = params?.apiConfig;
|
|
1127
1577
|
return useQuery({
|
|
1128
|
-
queryKey: ["
|
|
1578
|
+
queryKey: ["swapsApi", "submitTx", "status", txHash, srcChainKey],
|
|
1129
1579
|
queryFn: async () => {
|
|
1130
|
-
if (!
|
|
1131
|
-
|
|
1132
|
-
}
|
|
1133
|
-
return unwrapResult(
|
|
1134
|
-
await sodax.backendApi.getAllMoneyMarketBorrowers({
|
|
1135
|
-
offset: pagination.offset,
|
|
1136
|
-
limit: pagination.limit
|
|
1137
|
-
})
|
|
1138
|
-
);
|
|
1580
|
+
if (!txHash || !srcChainKey) return void 0;
|
|
1581
|
+
return unwrapResult(await sodax.api.swaps.getSubmitTxStatus({ txHash, srcChainKey }, apiConfig));
|
|
1139
1582
|
},
|
|
1140
|
-
enabled: !!
|
|
1583
|
+
enabled: !!txHash && txHash.length > 0 && !!srcChainKey,
|
|
1141
1584
|
retry: 3,
|
|
1585
|
+
refetchInterval: (query) => {
|
|
1586
|
+
const status = query.state.data?.data?.status;
|
|
1587
|
+
if (status === "solved" || status === "failed") return false;
|
|
1588
|
+
return 1e3;
|
|
1589
|
+
},
|
|
1142
1590
|
...queryOptions
|
|
1143
1591
|
});
|
|
1144
1592
|
};
|
|
@@ -1764,6 +2212,107 @@ function useFeeClaimSwap({
|
|
|
1764
2212
|
}
|
|
1765
2213
|
});
|
|
1766
2214
|
}
|
|
2215
|
+
function usePartnerCancelIntent({
|
|
2216
|
+
mutationOptions
|
|
2217
|
+
} = {}) {
|
|
2218
|
+
const { sodax } = useSodaxContext();
|
|
2219
|
+
const queryClient = useQueryClient();
|
|
2220
|
+
return useSafeMutation({
|
|
2221
|
+
mutationKey: ["partner", "cancelIntent"],
|
|
2222
|
+
...mutationOptions,
|
|
2223
|
+
mutationFn: async (vars) => unwrapResult(await sodax.partners.feeClaim.cancelIntent({ ...vars, raw: false })),
|
|
2224
|
+
onSuccess: async (data, vars, ctx) => {
|
|
2225
|
+
queryClient.invalidateQueries({
|
|
2226
|
+
queryKey: ["partner", "feeClaim", "assetsBalances", vars.params.srcAddress]
|
|
2227
|
+
});
|
|
2228
|
+
queryClient.invalidateQueries({
|
|
2229
|
+
queryKey: [
|
|
2230
|
+
"partner",
|
|
2231
|
+
"feeClaim",
|
|
2232
|
+
"userIntent",
|
|
2233
|
+
vars.params.srcAddress,
|
|
2234
|
+
vars.params.fromToken,
|
|
2235
|
+
vars.params.toToken
|
|
2236
|
+
]
|
|
2237
|
+
});
|
|
2238
|
+
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
function useGetUserIntent({ params, queryOptions } = {}) {
|
|
2243
|
+
const { sodax } = useSodaxContext();
|
|
2244
|
+
const user = params?.user;
|
|
2245
|
+
const fromToken = params?.fromToken;
|
|
2246
|
+
const toToken = params?.toToken;
|
|
2247
|
+
return useQuery({
|
|
2248
|
+
queryKey: ["partner", "feeClaim", "userIntent", user, fromToken, toToken],
|
|
2249
|
+
queryFn: async () => {
|
|
2250
|
+
if (!user || !fromToken || !toToken) {
|
|
2251
|
+
throw new Error("user, fromToken and toToken are required");
|
|
2252
|
+
}
|
|
2253
|
+
const result = await sodax.partners.feeClaim.getUserIntent({ user, fromToken, toToken });
|
|
2254
|
+
if (!result.ok) throw result.error;
|
|
2255
|
+
return result.value;
|
|
2256
|
+
},
|
|
2257
|
+
enabled: !!user && !!fromToken && !!toToken,
|
|
2258
|
+
...queryOptions
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
var ZERO_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
2262
|
+
function useGetIntentDetails({
|
|
2263
|
+
params,
|
|
2264
|
+
queryOptions
|
|
2265
|
+
} = {}) {
|
|
2266
|
+
const { sodax } = useSodaxContext();
|
|
2267
|
+
const intentHash = params?.intentHash;
|
|
2268
|
+
const hasIntent = !!intentHash && intentHash !== ZERO_HASH;
|
|
2269
|
+
return useQuery({
|
|
2270
|
+
queryKey: ["partner", "feeClaim", "intentDetails", intentHash],
|
|
2271
|
+
queryFn: async () => {
|
|
2272
|
+
if (!intentHash) {
|
|
2273
|
+
throw new Error("intentHash is required");
|
|
2274
|
+
}
|
|
2275
|
+
const result = await sodax.partners.feeClaim.getIntentDetails(intentHash);
|
|
2276
|
+
if (!result.ok) throw result.error;
|
|
2277
|
+
return result.value;
|
|
2278
|
+
},
|
|
2279
|
+
enabled: hasIntent,
|
|
2280
|
+
...queryOptions
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
function useFeeClaimWithdraw({
|
|
2284
|
+
mutationOptions
|
|
2285
|
+
} = {}) {
|
|
2286
|
+
const { sodax } = useSodaxContext();
|
|
2287
|
+
const queryClient = useQueryClient();
|
|
2288
|
+
return useSafeMutation({
|
|
2289
|
+
mutationKey: ["partner", "feeClaimWithdraw"],
|
|
2290
|
+
...mutationOptions,
|
|
2291
|
+
mutationFn: async ({ params, walletProvider }) => {
|
|
2292
|
+
const bridgeParams = {
|
|
2293
|
+
params: {
|
|
2294
|
+
srcChainKey: ChainKeys.SONIC_MAINNET,
|
|
2295
|
+
srcAddress: params.srcAddress,
|
|
2296
|
+
srcToken: params.feeToken,
|
|
2297
|
+
amount: params.amount,
|
|
2298
|
+
dstChainKey: params.dstChainKey,
|
|
2299
|
+
dstToken: params.dstToken,
|
|
2300
|
+
recipient: params.recipient
|
|
2301
|
+
},
|
|
2302
|
+
raw: false,
|
|
2303
|
+
walletProvider
|
|
2304
|
+
};
|
|
2305
|
+
return unwrapResult(await sodax.bridge.bridge(bridgeParams));
|
|
2306
|
+
},
|
|
2307
|
+
onSuccess: async (data, vars, ctx) => {
|
|
2308
|
+
queryClient.invalidateQueries({
|
|
2309
|
+
queryKey: ["partner", "feeClaim", "assetsBalances", vars.params.srcAddress]
|
|
2310
|
+
});
|
|
2311
|
+
queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
|
|
2312
|
+
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
1767
2316
|
function useHubAssetBalances({
|
|
1768
2317
|
params,
|
|
1769
2318
|
queryOptions
|
|
@@ -2482,11 +3031,162 @@ function useClaimRewards({
|
|
|
2482
3031
|
}
|
|
2483
3032
|
});
|
|
2484
3033
|
}
|
|
3034
|
+
function useLeverageYieldEffectiveApr({
|
|
3035
|
+
params,
|
|
3036
|
+
queryOptions
|
|
3037
|
+
} = {}) {
|
|
3038
|
+
const { sodax } = useSodaxContext();
|
|
3039
|
+
const vault = params?.vault;
|
|
3040
|
+
return useQuery({
|
|
3041
|
+
queryKey: ["leverageYield", "effectiveApr", vault],
|
|
3042
|
+
queryFn: async () => {
|
|
3043
|
+
if (!vault) throw new Error("vault is required");
|
|
3044
|
+
const result = await sodax.leverageYield.getEffectiveApr(vault);
|
|
3045
|
+
if (!result.ok) throw result.error;
|
|
3046
|
+
return result.value;
|
|
3047
|
+
},
|
|
3048
|
+
enabled: !!vault,
|
|
3049
|
+
refetchInterval: 6e4,
|
|
3050
|
+
...queryOptions
|
|
3051
|
+
});
|
|
3052
|
+
}
|
|
3053
|
+
function useLeverageYieldPosition({
|
|
3054
|
+
params,
|
|
3055
|
+
queryOptions
|
|
3056
|
+
} = {}) {
|
|
3057
|
+
const { sodax } = useSodaxContext();
|
|
3058
|
+
const vault = params?.vault;
|
|
3059
|
+
return useQuery({
|
|
3060
|
+
queryKey: ["leverageYield", "position", vault],
|
|
3061
|
+
queryFn: async () => {
|
|
3062
|
+
if (!vault) throw new Error("vault is required");
|
|
3063
|
+
const result = await sodax.leverageYield.getPosition(vault);
|
|
3064
|
+
if (!result.ok) throw result.error;
|
|
3065
|
+
return result.value;
|
|
3066
|
+
},
|
|
3067
|
+
enabled: !!vault,
|
|
3068
|
+
refetchInterval: 3e4,
|
|
3069
|
+
...queryOptions
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
function useLeverageYieldTotalAssets({
|
|
3073
|
+
params,
|
|
3074
|
+
queryOptions
|
|
3075
|
+
} = {}) {
|
|
3076
|
+
const { sodax } = useSodaxContext();
|
|
3077
|
+
const vault = params?.vault;
|
|
3078
|
+
return useQuery({
|
|
3079
|
+
queryKey: ["leverageYield", "totalAssets", vault],
|
|
3080
|
+
queryFn: async () => {
|
|
3081
|
+
if (!vault) throw new Error("vault is required");
|
|
3082
|
+
const result = await sodax.leverageYield.getTotalAssets(vault);
|
|
3083
|
+
if (!result.ok) throw result.error;
|
|
3084
|
+
return result.value;
|
|
3085
|
+
},
|
|
3086
|
+
enabled: !!vault,
|
|
3087
|
+
refetchInterval: 6e4,
|
|
3088
|
+
...queryOptions
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
function useLeverageYieldPreviewRedeem({
|
|
3092
|
+
params,
|
|
3093
|
+
queryOptions
|
|
3094
|
+
} = {}) {
|
|
3095
|
+
const { sodax } = useSodaxContext();
|
|
3096
|
+
const vault = params?.vault;
|
|
3097
|
+
const shares = params?.shares;
|
|
3098
|
+
return useQuery({
|
|
3099
|
+
queryKey: ["leverageYield", "previewRedeem", vault, shares?.toString()],
|
|
3100
|
+
queryFn: async () => {
|
|
3101
|
+
if (!vault || shares === void 0) throw new Error("vault and shares are required");
|
|
3102
|
+
const result = await sodax.leverageYield.previewRedeem(vault, shares);
|
|
3103
|
+
if (!result.ok) throw result.error;
|
|
3104
|
+
return result.value;
|
|
3105
|
+
},
|
|
3106
|
+
enabled: !!vault && shares !== void 0,
|
|
3107
|
+
refetchInterval: 6e4,
|
|
3108
|
+
...queryOptions
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
function useLeverageYieldShareBalances({
|
|
3112
|
+
params,
|
|
3113
|
+
queryOptions
|
|
3114
|
+
} = {}) {
|
|
3115
|
+
const { sodax } = useSodaxContext();
|
|
3116
|
+
const vault = params?.vault;
|
|
3117
|
+
const holders = params?.holders;
|
|
3118
|
+
return useQueries({
|
|
3119
|
+
queries: (holders ?? []).map(({ chainKey, address }) => ({
|
|
3120
|
+
queryKey: ["leverageYield", "shareBalance", vault, chainKey, address],
|
|
3121
|
+
refetchInterval: 15e3,
|
|
3122
|
+
...queryOptions,
|
|
3123
|
+
enabled: !!vault,
|
|
3124
|
+
queryFn: async () => {
|
|
3125
|
+
if (!vault) throw new Error("vault is required");
|
|
3126
|
+
const holder = await sodax.hubProvider.getUserHubWalletAddress(address, chainKey);
|
|
3127
|
+
const result = await sodax.leverageYield.getShareBalance(vault, holder);
|
|
3128
|
+
if (!result.ok) throw result.error;
|
|
3129
|
+
return { chainKey, holder, shares: result.value };
|
|
3130
|
+
}
|
|
3131
|
+
}))
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
// src/hooks/leverageYield/useLeverageYieldDeposit.ts
|
|
3136
|
+
function useLeverageYieldDeposit({
|
|
3137
|
+
mutationOptions
|
|
3138
|
+
} = {}) {
|
|
3139
|
+
const { sodax } = useSodaxContext();
|
|
3140
|
+
return useSafeMutation({
|
|
3141
|
+
mutationKey: ["leverageYield", "deposit"],
|
|
3142
|
+
...mutationOptions,
|
|
3143
|
+
mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.deposit(vars))
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
|
|
3147
|
+
// src/hooks/leverageYield/useLeverageYieldNotifySolver.ts
|
|
3148
|
+
function useLeverageYieldNotifySolver({
|
|
3149
|
+
mutationOptions
|
|
3150
|
+
} = {}) {
|
|
3151
|
+
const { sodax } = useSodaxContext();
|
|
3152
|
+
return useSafeMutation({
|
|
3153
|
+
mutationKey: ["leverageYield", "notifySolver"],
|
|
3154
|
+
...mutationOptions,
|
|
3155
|
+
mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.notifySolver(vars))
|
|
3156
|
+
});
|
|
3157
|
+
}
|
|
3158
|
+
function useLeverageYieldVaultSwap({
|
|
3159
|
+
mutationOptions
|
|
3160
|
+
} = {}) {
|
|
3161
|
+
const { sodax } = useSodaxContext();
|
|
3162
|
+
const queryClient = useQueryClient();
|
|
3163
|
+
return useSafeMutation({
|
|
3164
|
+
mutationKey: ["leverageYield", "vaultSwap"],
|
|
3165
|
+
...mutationOptions,
|
|
3166
|
+
mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.vaultSwap({ ...vars, raw: false })),
|
|
3167
|
+
onSuccess: async (data, vars, ctx) => {
|
|
3168
|
+
queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
|
|
3169
|
+
queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
|
|
3170
|
+
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
3171
|
+
}
|
|
3172
|
+
});
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
// src/hooks/leverageYield/useLeverageYieldWithdraw.ts
|
|
3176
|
+
function useLeverageYieldWithdraw({
|
|
3177
|
+
mutationOptions
|
|
3178
|
+
} = {}) {
|
|
3179
|
+
const { sodax } = useSodaxContext();
|
|
3180
|
+
return useSafeMutation({
|
|
3181
|
+
mutationKey: ["leverageYield", "withdraw"],
|
|
3182
|
+
...mutationOptions,
|
|
3183
|
+
mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.withdraw(vars))
|
|
3184
|
+
});
|
|
3185
|
+
}
|
|
2485
3186
|
var SodaxProvider = ({ children, config }) => {
|
|
2486
|
-
const
|
|
2487
|
-
const
|
|
2488
|
-
|
|
2489
|
-
return /* @__PURE__ */ jsx(SodaxContext.Provider, { value: { sodax }, children });
|
|
3187
|
+
const sodax = useMemo(() => new Sodax(config), [config]);
|
|
3188
|
+
const contextValue = useMemo(() => ({ sodax }), [sodax]);
|
|
3189
|
+
return /* @__PURE__ */ jsx(SodaxContext.Provider, { value: contextValue, children });
|
|
2490
3190
|
};
|
|
2491
3191
|
var defaultOnMutationError = (error) => {
|
|
2492
3192
|
console.error("[sodax] Mutation error:", error);
|
|
@@ -2514,6 +3214,4 @@ function createSodaxQueryClient({
|
|
|
2514
3214
|
});
|
|
2515
3215
|
}
|
|
2516
3216
|
|
|
2517
|
-
export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getXBalancesQueryOptions, loadRadfiSession, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook,
|
|
2518
|
-
//# sourceMappingURL=index.mjs.map
|
|
2519
|
-
//# sourceMappingURL=index.mjs.map
|
|
3217
|
+
export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getXBalancesQueryOptions, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
|