@sodax/dapp-kit 1.0.1-beta → 1.0.3-beta
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 +130 -39
- package/dist/index.d.mts +576 -346
- package/dist/index.d.ts +576 -346
- package/dist/index.js +357 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +354 -178
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/backend/README.md +148 -49
- package/src/hooks/backend/index.ts +2 -0
- package/src/hooks/backend/types.ts +4 -0
- package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +31 -20
- package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +25 -7
- package/src/hooks/backend/useBackendIntentByHash.ts +36 -26
- package/src/hooks/backend/useBackendIntentByTxHash.ts +41 -29
- package/src/hooks/backend/useBackendMoneyMarketAsset.ts +40 -27
- package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +45 -36
- package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +45 -36
- package/src/hooks/backend/useBackendMoneyMarketPosition.ts +34 -37
- package/src/hooks/backend/useBackendOrderbook.ts +38 -38
- package/src/hooks/backend/useBackendUserIntents.ts +81 -0
- package/src/hooks/mm/index.ts +2 -0
- package/src/hooks/mm/useAToken.ts +37 -20
- package/src/hooks/mm/useATokensBalances.ts +87 -0
- package/src/hooks/mm/useBorrow.ts +36 -36
- package/src/hooks/mm/useMMAllowance.ts +33 -24
- package/src/hooks/mm/useMMApprove.ts +43 -48
- package/src/hooks/mm/useRepay.ts +32 -36
- package/src/hooks/mm/useReservesData.ts +35 -16
- package/src/hooks/mm/useReservesHumanized.ts +15 -3
- package/src/hooks/mm/useReservesList.ts +28 -15
- package/src/hooks/mm/useReservesUsdFormat.ts +30 -21
- package/src/hooks/mm/useSupply.ts +34 -36
- package/src/hooks/mm/useUserFormattedSummary.ts +42 -20
- package/src/hooks/mm/useUserReservesData.ts +34 -19
- package/src/hooks/mm/useWithdraw.ts +33 -35
- package/src/hooks/swap/index.ts +2 -0
- package/src/hooks/swap/useCancelLimitOrder.ts +53 -0
- package/src/hooks/swap/useCreateLimitOrder.ts +72 -0
- package/src/hooks/swap/useSwapAllowance.ts +7 -7
- package/src/hooks/swap/useSwapApprove.ts +6 -6
package/dist/index.js
CHANGED
|
@@ -181,218 +181,275 @@ function useSpokeProvider(spokeChainId, walletProvider) {
|
|
|
181
181
|
}, [spokeChainId, xChainType, walletProvider, rpcConfig]);
|
|
182
182
|
return spokeProvider;
|
|
183
183
|
}
|
|
184
|
-
function useBorrow(
|
|
184
|
+
function useBorrow() {
|
|
185
185
|
const { sodax } = useSodaxContext();
|
|
186
186
|
return reactQuery.useMutation({
|
|
187
|
-
mutationFn: async (
|
|
187
|
+
mutationFn: async ({ params, spokeProvider }) => {
|
|
188
188
|
if (!spokeProvider) {
|
|
189
189
|
throw new Error("spokeProvider is not found");
|
|
190
190
|
}
|
|
191
|
-
const response = await sodax.moneyMarket.borrow(
|
|
192
|
-
{
|
|
193
|
-
token: spokeToken.address,
|
|
194
|
-
amount: viem.parseUnits(amount, 18),
|
|
195
|
-
action: "borrow",
|
|
196
|
-
toChainId,
|
|
197
|
-
toAddress
|
|
198
|
-
},
|
|
199
|
-
spokeProvider
|
|
200
|
-
);
|
|
191
|
+
const response = await sodax.moneyMarket.borrow(params, spokeProvider);
|
|
201
192
|
if (!response.ok) {
|
|
202
|
-
throw
|
|
193
|
+
throw response.error;
|
|
203
194
|
}
|
|
204
|
-
console.log("Borrow transaction submitted:", response);
|
|
205
195
|
return response;
|
|
206
196
|
}
|
|
207
197
|
});
|
|
208
198
|
}
|
|
209
|
-
function useRepay(
|
|
199
|
+
function useRepay() {
|
|
210
200
|
const { sodax } = useSodaxContext();
|
|
211
201
|
return reactQuery.useMutation({
|
|
212
|
-
mutationFn: async (
|
|
202
|
+
mutationFn: async ({ params, spokeProvider }) => {
|
|
213
203
|
if (!spokeProvider) {
|
|
214
204
|
throw new Error("spokeProvider is not found");
|
|
215
205
|
}
|
|
216
|
-
const response = await sodax.moneyMarket.repay(
|
|
217
|
-
{
|
|
218
|
-
token: spokeToken.address,
|
|
219
|
-
amount: viem.parseUnits(amount, spokeToken.decimals),
|
|
220
|
-
action: "repay",
|
|
221
|
-
toChainId,
|
|
222
|
-
toAddress
|
|
223
|
-
},
|
|
224
|
-
spokeProvider
|
|
225
|
-
);
|
|
206
|
+
const response = await sodax.moneyMarket.repay(params, spokeProvider);
|
|
226
207
|
if (!response.ok) {
|
|
227
|
-
throw
|
|
208
|
+
throw response.error;
|
|
228
209
|
}
|
|
229
|
-
console.log("Repay transaction submitted:", response);
|
|
230
210
|
return response;
|
|
231
211
|
}
|
|
232
212
|
});
|
|
233
213
|
}
|
|
234
|
-
function useSupply(
|
|
214
|
+
function useSupply() {
|
|
235
215
|
const { sodax } = useSodaxContext();
|
|
236
216
|
return reactQuery.useMutation({
|
|
237
|
-
mutationFn: async (
|
|
217
|
+
mutationFn: async ({ params, spokeProvider }) => {
|
|
238
218
|
if (!spokeProvider) {
|
|
239
219
|
throw new Error("spokeProvider is not found");
|
|
240
220
|
}
|
|
241
|
-
const response = await sodax.moneyMarket.supply(
|
|
242
|
-
{
|
|
243
|
-
token: spokeToken.address,
|
|
244
|
-
amount: viem.parseUnits(amount, spokeToken.decimals),
|
|
245
|
-
action: "supply",
|
|
246
|
-
toChainId,
|
|
247
|
-
toAddress
|
|
248
|
-
},
|
|
249
|
-
spokeProvider
|
|
250
|
-
);
|
|
221
|
+
const response = await sodax.moneyMarket.supply(params, spokeProvider);
|
|
251
222
|
if (!response.ok) {
|
|
252
|
-
throw
|
|
223
|
+
throw response.error;
|
|
253
224
|
}
|
|
254
|
-
console.log("Supply transaction submitted:", response);
|
|
255
225
|
return response;
|
|
256
226
|
}
|
|
257
227
|
});
|
|
258
228
|
}
|
|
259
|
-
function useWithdraw(
|
|
229
|
+
function useWithdraw() {
|
|
260
230
|
const { sodax } = useSodaxContext();
|
|
261
231
|
return reactQuery.useMutation({
|
|
262
|
-
mutationFn: async (
|
|
232
|
+
mutationFn: async ({ params, spokeProvider }) => {
|
|
263
233
|
if (!spokeProvider) {
|
|
264
234
|
throw new Error("spokeProvider is not found");
|
|
265
235
|
}
|
|
266
|
-
const response = await sodax.moneyMarket.withdraw(
|
|
267
|
-
{
|
|
268
|
-
token: spokeToken.address,
|
|
269
|
-
// vault token on hub chain decimals is 18
|
|
270
|
-
amount: viem.parseUnits(amount, 18),
|
|
271
|
-
action: "withdraw",
|
|
272
|
-
toChainId,
|
|
273
|
-
toAddress
|
|
274
|
-
},
|
|
275
|
-
spokeProvider
|
|
276
|
-
);
|
|
236
|
+
const response = await sodax.moneyMarket.withdraw(params, spokeProvider);
|
|
277
237
|
if (!response.ok) {
|
|
278
|
-
throw
|
|
238
|
+
throw response.error;
|
|
279
239
|
}
|
|
280
|
-
console.log("Withdraw transaction submitted:", response);
|
|
281
240
|
return response;
|
|
282
241
|
}
|
|
283
242
|
});
|
|
284
243
|
}
|
|
285
|
-
function useUserReservesData(
|
|
244
|
+
function useUserReservesData(params) {
|
|
286
245
|
const { sodax } = useSodaxContext();
|
|
246
|
+
const defaultQueryOptions = {
|
|
247
|
+
queryKey: ["mm", "userReservesData", params?.spokeProvider?.chainConfig.chain.id, params?.address],
|
|
248
|
+
enabled: !!params?.spokeProvider && !!params?.address,
|
|
249
|
+
refetchInterval: 5e3
|
|
250
|
+
};
|
|
251
|
+
const queryOptions = {
|
|
252
|
+
...defaultQueryOptions,
|
|
253
|
+
...params?.queryOptions
|
|
254
|
+
// override default query options if provided
|
|
255
|
+
};
|
|
287
256
|
return reactQuery.useQuery({
|
|
288
|
-
|
|
257
|
+
...queryOptions,
|
|
289
258
|
queryFn: async () => {
|
|
290
|
-
if (!spokeProvider) {
|
|
259
|
+
if (!params?.spokeProvider || !params?.address) {
|
|
291
260
|
throw new Error("Spoke provider or address is not defined");
|
|
292
261
|
}
|
|
293
|
-
return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);
|
|
294
|
-
}
|
|
295
|
-
enabled: !!spokeProvider && !!address,
|
|
296
|
-
refetchInterval
|
|
262
|
+
return await sodax.moneyMarket.data.getUserReservesData(params.spokeProvider);
|
|
263
|
+
}
|
|
297
264
|
});
|
|
298
265
|
}
|
|
299
|
-
function useReservesData() {
|
|
266
|
+
function useReservesData(params) {
|
|
267
|
+
const defaultQueryOptions = {
|
|
268
|
+
queryKey: ["mm", "reservesData"],
|
|
269
|
+
refetchInterval: 5e3
|
|
270
|
+
};
|
|
271
|
+
const queryOptions = {
|
|
272
|
+
...defaultQueryOptions,
|
|
273
|
+
...params?.queryOptions
|
|
274
|
+
// override default query options if provided
|
|
275
|
+
};
|
|
300
276
|
const { sodax } = useSodaxContext();
|
|
301
277
|
return reactQuery.useQuery({
|
|
302
|
-
|
|
278
|
+
...queryOptions,
|
|
303
279
|
queryFn: async () => {
|
|
304
280
|
return await sodax.moneyMarket.data.getReservesData();
|
|
305
281
|
}
|
|
306
282
|
});
|
|
307
283
|
}
|
|
308
|
-
function useMMAllowance(
|
|
284
|
+
function useMMAllowance({
|
|
285
|
+
params,
|
|
286
|
+
spokeProvider,
|
|
287
|
+
queryOptions
|
|
288
|
+
}) {
|
|
309
289
|
const { sodax } = useSodaxContext();
|
|
290
|
+
const defaultQueryOptions = {
|
|
291
|
+
queryKey: ["mm", "allowance", params?.token, params?.action],
|
|
292
|
+
enabled: !!spokeProvider,
|
|
293
|
+
refetchInterval: 5e3
|
|
294
|
+
};
|
|
295
|
+
queryOptions = {
|
|
296
|
+
...defaultQueryOptions,
|
|
297
|
+
...queryOptions
|
|
298
|
+
// override default query options if provided
|
|
299
|
+
};
|
|
310
300
|
return reactQuery.useQuery({
|
|
311
|
-
|
|
301
|
+
...queryOptions,
|
|
312
302
|
queryFn: async () => {
|
|
313
303
|
if (!spokeProvider) throw new Error("Spoke provider is required");
|
|
314
|
-
|
|
315
|
-
const allowance = await sodax.moneyMarket.isAllowanceValid(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
amount: viem.parseUnits(amount, actionBasedDecimals),
|
|
319
|
-
action
|
|
320
|
-
},
|
|
321
|
-
spokeProvider
|
|
322
|
-
);
|
|
323
|
-
if (allowance.ok) {
|
|
324
|
-
return allowance.value;
|
|
304
|
+
if (!params) throw new Error("Params are required");
|
|
305
|
+
const allowance = await sodax.moneyMarket.isAllowanceValid(params, spokeProvider);
|
|
306
|
+
if (!allowance.ok) {
|
|
307
|
+
throw allowance.error;
|
|
325
308
|
}
|
|
326
|
-
return
|
|
327
|
-
}
|
|
328
|
-
enabled: !!spokeProvider
|
|
309
|
+
return allowance.value;
|
|
310
|
+
}
|
|
329
311
|
});
|
|
330
312
|
}
|
|
331
|
-
function useMMApprove(
|
|
313
|
+
function useMMApprove() {
|
|
332
314
|
const { sodax } = useSodaxContext();
|
|
333
315
|
const queryClient = reactQuery.useQueryClient();
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
isPending,
|
|
337
|
-
error,
|
|
338
|
-
reset: resetError
|
|
339
|
-
} = reactQuery.useMutation({
|
|
340
|
-
mutationFn: async ({ amount, action }) => {
|
|
316
|
+
return reactQuery.useMutation({
|
|
317
|
+
mutationFn: async ({ params, spokeProvider }) => {
|
|
341
318
|
if (!spokeProvider) {
|
|
342
319
|
throw new Error("Spoke provider not found");
|
|
343
320
|
}
|
|
344
|
-
const
|
|
345
|
-
const allowance = await sodax.moneyMarket.approve(
|
|
346
|
-
{
|
|
347
|
-
token: token.address,
|
|
348
|
-
amount: viem.parseUnits(amount, actionBasedDecimals),
|
|
349
|
-
action
|
|
350
|
-
},
|
|
351
|
-
spokeProvider
|
|
352
|
-
);
|
|
321
|
+
const allowance = await sodax.moneyMarket.approve(params, spokeProvider, false);
|
|
353
322
|
if (!allowance.ok) {
|
|
354
|
-
throw
|
|
323
|
+
throw allowance.error;
|
|
355
324
|
}
|
|
356
|
-
return allowance.
|
|
325
|
+
return allowance.value;
|
|
357
326
|
},
|
|
358
|
-
onSuccess: () => {
|
|
359
|
-
|
|
327
|
+
onSuccess: (_, { params, spokeProvider }) => {
|
|
328
|
+
console.log("onSuccess invoked with queryKey:", [
|
|
329
|
+
"mm",
|
|
330
|
+
"allowance",
|
|
331
|
+
spokeProvider?.chainConfig.chain.id,
|
|
332
|
+
params.token,
|
|
333
|
+
params.action
|
|
334
|
+
]);
|
|
335
|
+
queryClient.invalidateQueries({
|
|
336
|
+
queryKey: ["mm", "allowance", spokeProvider?.chainConfig.chain.id, params.token, params.action]
|
|
337
|
+
});
|
|
360
338
|
}
|
|
361
339
|
});
|
|
362
|
-
return {
|
|
363
|
-
approve,
|
|
364
|
-
isLoading: isPending,
|
|
365
|
-
error,
|
|
366
|
-
resetError
|
|
367
|
-
};
|
|
368
340
|
}
|
|
369
|
-
function useAToken(aToken) {
|
|
341
|
+
function useAToken({ aToken, queryOptions }) {
|
|
370
342
|
const { sodax } = useSodaxContext();
|
|
343
|
+
const defaultQueryOptions = {
|
|
344
|
+
queryKey: ["mm", "aToken", aToken],
|
|
345
|
+
enabled: !!aToken
|
|
346
|
+
};
|
|
347
|
+
queryOptions = {
|
|
348
|
+
...defaultQueryOptions,
|
|
349
|
+
...queryOptions
|
|
350
|
+
// override default query options if provided
|
|
351
|
+
};
|
|
371
352
|
return reactQuery.useQuery({
|
|
372
|
-
|
|
353
|
+
...queryOptions,
|
|
373
354
|
queryFn: async () => {
|
|
374
355
|
if (!aToken) {
|
|
375
356
|
throw new Error("aToken address or hub provider is not defined");
|
|
376
357
|
}
|
|
358
|
+
if (!viem.isAddress(aToken)) {
|
|
359
|
+
throw new Error("aToken address is not a valid address");
|
|
360
|
+
}
|
|
377
361
|
const aTokenData = await sodax.moneyMarket.data.getATokenData(aToken);
|
|
378
362
|
return {
|
|
379
363
|
...aTokenData,
|
|
380
364
|
xChainId: sodax.hubProvider.chainConfig.chain.id
|
|
381
365
|
};
|
|
382
|
-
}
|
|
383
|
-
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function useATokensBalances({
|
|
370
|
+
aTokens,
|
|
371
|
+
spokeProvider,
|
|
372
|
+
userAddress,
|
|
373
|
+
queryOptions
|
|
374
|
+
}) {
|
|
375
|
+
const { sodax } = useSodaxContext();
|
|
376
|
+
const defaultQueryOptions = {
|
|
377
|
+
queryKey: ["mm", "aTokensBalances", aTokens, spokeProvider?.chainConfig.chain.id, userAddress],
|
|
378
|
+
enabled: aTokens.length > 0 && aTokens.every((token) => viem.isAddress(token)) && !!spokeProvider && !!userAddress
|
|
379
|
+
};
|
|
380
|
+
queryOptions = {
|
|
381
|
+
...defaultQueryOptions,
|
|
382
|
+
...queryOptions
|
|
383
|
+
// override default query options if provided
|
|
384
|
+
};
|
|
385
|
+
return reactQuery.useQuery({
|
|
386
|
+
...queryOptions,
|
|
387
|
+
queryFn: async () => {
|
|
388
|
+
if (aTokens.length === 0) {
|
|
389
|
+
return /* @__PURE__ */ new Map();
|
|
390
|
+
}
|
|
391
|
+
if (!spokeProvider || !userAddress) {
|
|
392
|
+
throw new Error("Spoke provider and user address are required");
|
|
393
|
+
}
|
|
394
|
+
for (const aToken of aTokens) {
|
|
395
|
+
if (!viem.isAddress(aToken)) {
|
|
396
|
+
throw new Error(`Invalid aToken address: ${aToken}`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const hubWalletAddress = await sdk.deriveUserWalletAddress(
|
|
400
|
+
sodax.hubProvider,
|
|
401
|
+
spokeProvider.chainConfig.chain.id,
|
|
402
|
+
userAddress
|
|
403
|
+
);
|
|
404
|
+
return await sodax.moneyMarket.data.getATokensBalances(aTokens, hubWalletAddress);
|
|
405
|
+
}
|
|
384
406
|
});
|
|
385
407
|
}
|
|
386
|
-
function useReservesUsdFormat() {
|
|
408
|
+
function useReservesUsdFormat(params) {
|
|
387
409
|
const { sodax } = useSodaxContext();
|
|
410
|
+
const defaultQueryOptions = { queryKey: ["mm", "reservesUsdFormat"] };
|
|
411
|
+
const queryOptions = {
|
|
412
|
+
...defaultQueryOptions,
|
|
413
|
+
...params?.queryOptions
|
|
414
|
+
// override default query options if provided
|
|
415
|
+
};
|
|
388
416
|
return reactQuery.useQuery({
|
|
389
|
-
|
|
417
|
+
...queryOptions,
|
|
390
418
|
queryFn: async () => {
|
|
391
419
|
const reserves = await sodax.moneyMarket.data.getReservesHumanized();
|
|
392
420
|
return sodax.moneyMarket.data.formatReservesUSD(sodax.moneyMarket.data.buildReserveDataWithPrice(reserves));
|
|
393
421
|
}
|
|
394
422
|
});
|
|
395
423
|
}
|
|
424
|
+
function useUserFormattedSummary(params) {
|
|
425
|
+
const { sodax } = useSodaxContext();
|
|
426
|
+
const defaultQueryOptions = {
|
|
427
|
+
queryKey: ["mm", "userFormattedSummary", params?.spokeProvider?.chainConfig.chain.id, params?.address],
|
|
428
|
+
enabled: !!params?.spokeProvider && !!params?.address,
|
|
429
|
+
refetchInterval: 5e3
|
|
430
|
+
};
|
|
431
|
+
const queryOptions = {
|
|
432
|
+
...defaultQueryOptions,
|
|
433
|
+
...params?.queryOptions
|
|
434
|
+
// override default query options if provided
|
|
435
|
+
};
|
|
436
|
+
return reactQuery.useQuery({
|
|
437
|
+
...queryOptions,
|
|
438
|
+
queryFn: async () => {
|
|
439
|
+
if (!params?.spokeProvider || !params?.address) {
|
|
440
|
+
throw new Error("Spoke provider or address is not defined");
|
|
441
|
+
}
|
|
442
|
+
const reserves = await sodax.moneyMarket.data.getReservesHumanized();
|
|
443
|
+
const formattedReserves = sodax.moneyMarket.data.formatReservesUSD(
|
|
444
|
+
sodax.moneyMarket.data.buildReserveDataWithPrice(reserves)
|
|
445
|
+
);
|
|
446
|
+
const userReserves = await sodax.moneyMarket.data.getUserReservesHumanized(params?.spokeProvider);
|
|
447
|
+
return sodax.moneyMarket.data.formatUserSummary(
|
|
448
|
+
sodax.moneyMarket.data.buildUserSummaryRequest(reserves, formattedReserves, userReserves)
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
396
453
|
var useQuote = (payload) => {
|
|
397
454
|
const { sodax } = useSodaxContext();
|
|
398
455
|
const queryKey = React.useMemo(() => {
|
|
@@ -514,135 +571,254 @@ function useCancelSwap(spokeProvider) {
|
|
|
514
571
|
}
|
|
515
572
|
});
|
|
516
573
|
}
|
|
517
|
-
|
|
574
|
+
function useCreateLimitOrder(spokeProvider) {
|
|
518
575
|
const { sodax } = useSodaxContext();
|
|
576
|
+
return reactQuery.useMutation({
|
|
577
|
+
mutationFn: async (params) => {
|
|
578
|
+
if (!spokeProvider) {
|
|
579
|
+
throw new Error("Spoke provider not found");
|
|
580
|
+
}
|
|
581
|
+
return sodax.swaps.createLimitOrder({
|
|
582
|
+
intentParams: params,
|
|
583
|
+
spokeProvider
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function useCancelLimitOrder() {
|
|
589
|
+
const { sodax } = useSodaxContext();
|
|
590
|
+
return reactQuery.useMutation({
|
|
591
|
+
mutationFn: async ({ intent, spokeProvider, timeout }) => {
|
|
592
|
+
return sodax.swaps.cancelLimitOrder({
|
|
593
|
+
intent,
|
|
594
|
+
spokeProvider,
|
|
595
|
+
timeout
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
var useBackendIntentByTxHash = (params) => {
|
|
601
|
+
const { sodax } = useSodaxContext();
|
|
602
|
+
const defaultQueryOptions = {
|
|
603
|
+
queryKey: ["api", "intent", "txHash", params?.params?.txHash],
|
|
604
|
+
enabled: !!params?.params?.txHash && params?.params?.txHash.length > 0,
|
|
605
|
+
retry: 3,
|
|
606
|
+
refetchInterval: 1e3
|
|
607
|
+
};
|
|
608
|
+
const queryOptions = {
|
|
609
|
+
...defaultQueryOptions,
|
|
610
|
+
...params?.queryOptions
|
|
611
|
+
};
|
|
519
612
|
return reactQuery.useQuery({
|
|
520
|
-
|
|
613
|
+
...queryOptions,
|
|
521
614
|
queryFn: async () => {
|
|
522
|
-
if (!txHash) {
|
|
615
|
+
if (!params?.params?.txHash) {
|
|
523
616
|
return void 0;
|
|
524
617
|
}
|
|
525
|
-
return sodax.backendApi.getIntentByTxHash(txHash);
|
|
526
|
-
}
|
|
527
|
-
refetchInterval,
|
|
528
|
-
enabled: !!txHash && txHash.length > 0,
|
|
529
|
-
retry: 3
|
|
618
|
+
return sodax.backendApi.getIntentByTxHash(params.params.txHash);
|
|
619
|
+
}
|
|
530
620
|
});
|
|
531
621
|
};
|
|
532
|
-
var useBackendIntentByHash = (
|
|
622
|
+
var useBackendIntentByHash = (params) => {
|
|
533
623
|
const { sodax } = useSodaxContext();
|
|
624
|
+
const defaultQueryOptions = {
|
|
625
|
+
queryKey: ["api", "intent", "hash", params?.params?.intentHash],
|
|
626
|
+
enabled: !!params?.params?.intentHash && params?.params?.intentHash.length > 0,
|
|
627
|
+
retry: 3
|
|
628
|
+
};
|
|
629
|
+
const queryOptions = {
|
|
630
|
+
...defaultQueryOptions,
|
|
631
|
+
...params?.queryOptions
|
|
632
|
+
};
|
|
534
633
|
return reactQuery.useQuery({
|
|
535
|
-
|
|
634
|
+
...queryOptions,
|
|
536
635
|
queryFn: async () => {
|
|
537
|
-
if (!intentHash) {
|
|
636
|
+
if (!params?.params?.intentHash) {
|
|
538
637
|
return void 0;
|
|
539
638
|
}
|
|
540
|
-
return sodax.backendApi.getIntentByHash(intentHash);
|
|
541
|
-
}
|
|
542
|
-
enabled: !!intentHash && intentHash.length > 0,
|
|
543
|
-
retry: 3
|
|
639
|
+
return sodax.backendApi.getIntentByHash(params.params.intentHash);
|
|
640
|
+
}
|
|
544
641
|
});
|
|
545
642
|
};
|
|
546
|
-
var
|
|
643
|
+
var useBackendUserIntents = ({
|
|
644
|
+
params,
|
|
645
|
+
queryOptions
|
|
646
|
+
}) => {
|
|
547
647
|
const { sodax } = useSodaxContext();
|
|
648
|
+
const defaultQueryOptions = {
|
|
649
|
+
queryKey: ["api", "intent", "user", params],
|
|
650
|
+
enabled: !!params && !!params.userAddress && params.userAddress.length > 0,
|
|
651
|
+
retry: 3
|
|
652
|
+
};
|
|
653
|
+
queryOptions = {
|
|
654
|
+
...defaultQueryOptions,
|
|
655
|
+
...queryOptions
|
|
656
|
+
// override default query options if provided
|
|
657
|
+
};
|
|
548
658
|
return reactQuery.useQuery({
|
|
549
|
-
|
|
659
|
+
...queryOptions,
|
|
550
660
|
queryFn: async () => {
|
|
551
|
-
if (!params
|
|
661
|
+
if (!params?.userAddress) {
|
|
552
662
|
return void 0;
|
|
553
663
|
}
|
|
554
|
-
return sodax.backendApi.
|
|
555
|
-
}
|
|
556
|
-
|
|
664
|
+
return sodax.backendApi.getUserIntents(params);
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
var useBackendOrderbook = (params) => {
|
|
669
|
+
const { sodax } = useSodaxContext();
|
|
670
|
+
const defaultQueryOptions = {
|
|
671
|
+
queryKey: ["api", "solver", "orderbook", params?.pagination?.offset, params?.pagination?.limit],
|
|
672
|
+
enabled: !!params?.pagination && !!params?.pagination.offset && !!params?.pagination.limit,
|
|
557
673
|
staleTime: 30 * 1e3,
|
|
558
674
|
// 30 seconds for real-time data
|
|
559
675
|
retry: 3
|
|
676
|
+
};
|
|
677
|
+
const queryOptions = {
|
|
678
|
+
...defaultQueryOptions,
|
|
679
|
+
...params?.queryOptions
|
|
680
|
+
// override default query options if provided
|
|
681
|
+
};
|
|
682
|
+
return reactQuery.useQuery({
|
|
683
|
+
...queryOptions,
|
|
684
|
+
queryFn: async () => {
|
|
685
|
+
if (!params?.pagination || !params?.pagination.offset || !params?.pagination.limit) {
|
|
686
|
+
return void 0;
|
|
687
|
+
}
|
|
688
|
+
return sodax.backendApi.getOrderbook(params.pagination);
|
|
689
|
+
}
|
|
560
690
|
});
|
|
561
691
|
};
|
|
562
|
-
var useBackendMoneyMarketPosition = (
|
|
692
|
+
var useBackendMoneyMarketPosition = (params) => {
|
|
563
693
|
const { sodax } = useSodaxContext();
|
|
694
|
+
const defaultQueryOptions = {
|
|
695
|
+
queryKey: ["api", "mm", "position", params?.userAddress],
|
|
696
|
+
enabled: !!params?.userAddress && params?.userAddress.length > 0,
|
|
697
|
+
retry: 3
|
|
698
|
+
};
|
|
699
|
+
const queryOptions = {
|
|
700
|
+
...defaultQueryOptions,
|
|
701
|
+
...params?.queryOptions
|
|
702
|
+
};
|
|
564
703
|
return reactQuery.useQuery({
|
|
565
|
-
|
|
704
|
+
...queryOptions,
|
|
566
705
|
queryFn: async () => {
|
|
567
|
-
if (!userAddress) {
|
|
706
|
+
if (!params?.userAddress) {
|
|
568
707
|
return void 0;
|
|
569
708
|
}
|
|
570
|
-
return sodax.backendApi.getMoneyMarketPosition(userAddress);
|
|
571
|
-
}
|
|
572
|
-
enabled: !!userAddress && userAddress.length > 0,
|
|
573
|
-
retry: 3
|
|
709
|
+
return sodax.backendApi.getMoneyMarketPosition(params.userAddress);
|
|
710
|
+
}
|
|
574
711
|
});
|
|
575
712
|
};
|
|
576
|
-
var useBackendAllMoneyMarketAssets = () => {
|
|
713
|
+
var useBackendAllMoneyMarketAssets = (params) => {
|
|
577
714
|
const { sodax } = useSodaxContext();
|
|
715
|
+
const defaultQueryOptions = {
|
|
716
|
+
queryKey: ["api", "mm", "assets", "all"],
|
|
717
|
+
enabled: true,
|
|
718
|
+
retry: 3
|
|
719
|
+
};
|
|
720
|
+
const queryOptions = {
|
|
721
|
+
...defaultQueryOptions,
|
|
722
|
+
...params?.queryOptions
|
|
723
|
+
};
|
|
578
724
|
return reactQuery.useQuery({
|
|
579
|
-
|
|
725
|
+
...queryOptions,
|
|
580
726
|
queryFn: async () => {
|
|
581
727
|
return sodax.backendApi.getAllMoneyMarketAssets();
|
|
582
|
-
}
|
|
583
|
-
retry: 3
|
|
728
|
+
}
|
|
584
729
|
});
|
|
585
730
|
};
|
|
586
|
-
var useBackendMoneyMarketAsset = (
|
|
731
|
+
var useBackendMoneyMarketAsset = (params) => {
|
|
587
732
|
const { sodax } = useSodaxContext();
|
|
733
|
+
const defaultQueryOptions = {
|
|
734
|
+
queryKey: ["api", "mm", "asset", params?.params?.reserveAddress],
|
|
735
|
+
enabled: !!params?.params?.reserveAddress && params?.params?.reserveAddress.length > 0,
|
|
736
|
+
retry: 3
|
|
737
|
+
};
|
|
738
|
+
const queryOptions = {
|
|
739
|
+
...defaultQueryOptions,
|
|
740
|
+
...params?.queryOptions
|
|
741
|
+
};
|
|
588
742
|
return reactQuery.useQuery({
|
|
589
|
-
|
|
743
|
+
...queryOptions,
|
|
590
744
|
queryFn: async () => {
|
|
591
|
-
if (!reserveAddress) {
|
|
745
|
+
if (!params?.params?.reserveAddress) {
|
|
592
746
|
return void 0;
|
|
593
747
|
}
|
|
594
|
-
return sodax.backendApi.getMoneyMarketAsset(reserveAddress);
|
|
595
|
-
}
|
|
596
|
-
enabled: !!reserveAddress && reserveAddress.length > 0,
|
|
597
|
-
retry: 3
|
|
748
|
+
return sodax.backendApi.getMoneyMarketAsset(params.params.reserveAddress);
|
|
749
|
+
}
|
|
598
750
|
});
|
|
599
751
|
};
|
|
600
752
|
var useBackendMoneyMarketAssetBorrowers = (params) => {
|
|
601
753
|
const { sodax } = useSodaxContext();
|
|
754
|
+
const defaultQueryOptions = {
|
|
755
|
+
queryKey: ["api", "mm", "asset", "borrowers", params],
|
|
756
|
+
enabled: !!params?.params?.reserveAddress && !!params.pagination.offset && !!params.pagination.limit,
|
|
757
|
+
retry: 3
|
|
758
|
+
};
|
|
759
|
+
const queryOptions = {
|
|
760
|
+
...defaultQueryOptions,
|
|
761
|
+
...params?.queryOptions
|
|
762
|
+
};
|
|
602
763
|
return reactQuery.useQuery({
|
|
603
|
-
|
|
764
|
+
...queryOptions,
|
|
604
765
|
queryFn: async () => {
|
|
605
|
-
if (!params
|
|
766
|
+
if (!params?.params?.reserveAddress || !params.pagination.offset || !params.pagination.limit) {
|
|
606
767
|
return void 0;
|
|
607
768
|
}
|
|
608
|
-
return sodax.backendApi.getMoneyMarketAssetBorrowers(params.reserveAddress, {
|
|
609
|
-
offset: params.offset,
|
|
610
|
-
limit: params.limit
|
|
769
|
+
return sodax.backendApi.getMoneyMarketAssetBorrowers(params.params.reserveAddress, {
|
|
770
|
+
offset: params.pagination.offset,
|
|
771
|
+
limit: params.pagination.limit
|
|
611
772
|
});
|
|
612
|
-
}
|
|
613
|
-
enabled: !!params.reserveAddress && !!params.offset && !!params.limit,
|
|
614
|
-
retry: 3
|
|
773
|
+
}
|
|
615
774
|
});
|
|
616
775
|
};
|
|
617
776
|
var useBackendMoneyMarketAssetSuppliers = (params) => {
|
|
618
777
|
const { sodax } = useSodaxContext();
|
|
778
|
+
const defaultQueryOptions = {
|
|
779
|
+
queryKey: ["api", "mm", "asset", "suppliers", params],
|
|
780
|
+
enabled: !!params?.params?.reserveAddress && !!params.pagination.offset && !!params.pagination.limit,
|
|
781
|
+
retry: 3
|
|
782
|
+
};
|
|
783
|
+
const queryOptions = {
|
|
784
|
+
...defaultQueryOptions,
|
|
785
|
+
...params?.queryOptions
|
|
786
|
+
};
|
|
619
787
|
return reactQuery.useQuery({
|
|
620
|
-
|
|
788
|
+
...queryOptions,
|
|
621
789
|
queryFn: async () => {
|
|
622
|
-
if (!params
|
|
790
|
+
if (!params?.params?.reserveAddress || !params.pagination.offset || !params.pagination.limit) {
|
|
623
791
|
return void 0;
|
|
624
792
|
}
|
|
625
|
-
return sodax.backendApi.getMoneyMarketAssetSuppliers(params.reserveAddress, {
|
|
626
|
-
offset: params.offset,
|
|
627
|
-
limit: params.limit
|
|
793
|
+
return sodax.backendApi.getMoneyMarketAssetSuppliers(params.params.reserveAddress, {
|
|
794
|
+
offset: params.pagination.offset,
|
|
795
|
+
limit: params.pagination.limit
|
|
628
796
|
});
|
|
629
|
-
}
|
|
630
|
-
enabled: !!params.reserveAddress && !!params.offset && !!params.limit,
|
|
631
|
-
retry: 3
|
|
797
|
+
}
|
|
632
798
|
});
|
|
633
799
|
};
|
|
634
800
|
var useBackendAllMoneyMarketBorrowers = (params) => {
|
|
635
801
|
const { sodax } = useSodaxContext();
|
|
802
|
+
const defaultQueryOptions = {
|
|
803
|
+
queryKey: ["api", "mm", "borrowers", "all", params],
|
|
804
|
+
enabled: !!params && !!params.pagination.offset && !!params.pagination.limit,
|
|
805
|
+
retry: 3
|
|
806
|
+
};
|
|
807
|
+
const queryOptions = {
|
|
808
|
+
...defaultQueryOptions,
|
|
809
|
+
...params?.queryOptions
|
|
810
|
+
};
|
|
636
811
|
return reactQuery.useQuery({
|
|
637
|
-
|
|
812
|
+
...queryOptions,
|
|
638
813
|
queryFn: async () => {
|
|
639
|
-
if (!params || !params.offset || !params.limit) {
|
|
814
|
+
if (!params || !params.pagination.offset || !params.pagination.limit) {
|
|
640
815
|
return void 0;
|
|
641
816
|
}
|
|
642
|
-
return sodax.backendApi.getAllMoneyMarketBorrowers(
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
817
|
+
return sodax.backendApi.getAllMoneyMarketBorrowers({
|
|
818
|
+
offset: params.pagination.offset,
|
|
819
|
+
limit: params.pagination.limit
|
|
820
|
+
});
|
|
821
|
+
}
|
|
646
822
|
});
|
|
647
823
|
};
|
|
648
824
|
function useBridgeAllowance(params, spokeProvider) {
|
|
@@ -1289,6 +1465,7 @@ exports.MIGRATION_MODE_BNUSD = MIGRATION_MODE_BNUSD;
|
|
|
1289
1465
|
exports.MIGRATION_MODE_ICX_SODA = MIGRATION_MODE_ICX_SODA;
|
|
1290
1466
|
exports.SodaxProvider = SodaxProvider;
|
|
1291
1467
|
exports.useAToken = useAToken;
|
|
1468
|
+
exports.useATokensBalances = useATokensBalances;
|
|
1292
1469
|
exports.useBackendAllMoneyMarketAssets = useBackendAllMoneyMarketAssets;
|
|
1293
1470
|
exports.useBackendAllMoneyMarketBorrowers = useBackendAllMoneyMarketBorrowers;
|
|
1294
1471
|
exports.useBackendIntentByHash = useBackendIntentByHash;
|
|
@@ -1298,14 +1475,17 @@ exports.useBackendMoneyMarketAssetBorrowers = useBackendMoneyMarketAssetBorrower
|
|
|
1298
1475
|
exports.useBackendMoneyMarketAssetSuppliers = useBackendMoneyMarketAssetSuppliers;
|
|
1299
1476
|
exports.useBackendMoneyMarketPosition = useBackendMoneyMarketPosition;
|
|
1300
1477
|
exports.useBackendOrderbook = useBackendOrderbook;
|
|
1478
|
+
exports.useBackendUserIntents = useBackendUserIntents;
|
|
1301
1479
|
exports.useBorrow = useBorrow;
|
|
1302
1480
|
exports.useBridge = useBridge;
|
|
1303
1481
|
exports.useBridgeAllowance = useBridgeAllowance;
|
|
1304
1482
|
exports.useBridgeApprove = useBridgeApprove;
|
|
1483
|
+
exports.useCancelLimitOrder = useCancelLimitOrder;
|
|
1305
1484
|
exports.useCancelSwap = useCancelSwap;
|
|
1306
1485
|
exports.useCancelUnstake = useCancelUnstake;
|
|
1307
1486
|
exports.useClaim = useClaim;
|
|
1308
1487
|
exports.useConvertedAssets = useConvertedAssets;
|
|
1488
|
+
exports.useCreateLimitOrder = useCreateLimitOrder;
|
|
1309
1489
|
exports.useDeriveUserWalletAddress = useDeriveUserWalletAddress;
|
|
1310
1490
|
exports.useEstimateGas = useEstimateGas;
|
|
1311
1491
|
exports.useGetBridgeableAmount = useGetBridgeableAmount;
|
|
@@ -1344,6 +1524,7 @@ exports.useUnstakeAllowance = useUnstakeAllowance;
|
|
|
1344
1524
|
exports.useUnstakeApprove = useUnstakeApprove;
|
|
1345
1525
|
exports.useUnstakingInfo = useUnstakingInfo;
|
|
1346
1526
|
exports.useUnstakingInfoWithPenalty = useUnstakingInfoWithPenalty;
|
|
1527
|
+
exports.useUserFormattedSummary = useUserFormattedSummary;
|
|
1347
1528
|
exports.useUserReservesData = useUserReservesData;
|
|
1348
1529
|
exports.useWithdraw = useWithdraw;
|
|
1349
1530
|
//# sourceMappingURL=index.js.map
|