@sodax/dapp-kit 1.2.7-beta → 1.3.1-beta-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -150,9 +150,11 @@ function useSpokeProvider(spokeChainId, walletProvider) {
150
150
  sdk.spokeChainConfig[spokeChainId]
151
151
  );
152
152
  }
153
+ const evmRpcUrl = rpcConfig[spokeChainId];
153
154
  return new sdk.EvmSpokeProvider(
154
155
  walletProvider,
155
- sdk.spokeChainConfig[spokeChainId]
156
+ sdk.spokeChainConfig[spokeChainId],
157
+ typeof evmRpcUrl === "string" ? evmRpcUrl : void 0
156
158
  );
157
159
  }
158
160
  if (xChainType === "SUI") {
@@ -193,6 +195,12 @@ function useSpokeProvider(spokeChainId, walletProvider) {
193
195
  } : sdk.spokeChainConfig[spokeChainId]
194
196
  );
195
197
  }
198
+ if (xChainType === "NEAR") {
199
+ return new sdk.NearSpokeProvider(
200
+ walletProvider,
201
+ sdk.spokeChainConfig[spokeChainId]
202
+ );
203
+ }
196
204
  return void 0;
197
205
  }, [spokeChainId, xChainType, walletProvider, rpcConfig]);
198
206
  return spokeProvider;
@@ -318,8 +326,22 @@ function useMMAllowance({
318
326
  const { sodax } = useSodaxContext();
319
327
  const defaultQueryOptions = {
320
328
  queryKey: ["mm", "allowance", params?.token, params?.action],
321
- enabled: !!spokeProvider,
322
- refetchInterval: 5e3
329
+ /**
330
+ * IMPORTANT: Skip allowance checks for 'borrow' and 'withdraw' actions.
331
+ *
332
+ * Reason: According to the SDK's MoneyMarketService.isAllowanceValid() implementation,
333
+ * borrow and withdraw actions do NOT require ERC-20 token approval. The SDK's
334
+ * isAllowanceValid() method always returns `true` for these actions without making
335
+ * any on-chain allowance checks.
336
+ *
337
+ * This optimization prevents unnecessary RPC calls and avoids showing confusing states for actions that don't actually need approval.
338
+ *
339
+ * Only 'supply' and 'repay' actions require token approval and should trigger allowance checks.
340
+ */
341
+ enabled: !!spokeProvider && !!params && params.action !== "borrow" && params.action !== "withdraw",
342
+ refetchInterval: 5e3,
343
+ gcTime: 0
344
+ // Don't cache failed queries
323
345
  };
324
346
  queryOptions = {
325
347
  ...defaultQueryOptions,
@@ -331,6 +353,9 @@ function useMMAllowance({
331
353
  queryFn: async () => {
332
354
  if (!spokeProvider) throw new Error("Spoke provider is required");
333
355
  if (!params) throw new Error("Params are required");
356
+ if (params.action === "borrow" || params.action === "withdraw") {
357
+ return true;
358
+ }
334
359
  const allowance = await sodax.moneyMarket.isAllowanceValid(params, spokeProvider);
335
360
  if (!allowance.ok) {
336
361
  throw allowance.error;
@@ -354,13 +379,6 @@ function useMMApprove() {
354
379
  return allowance.value;
355
380
  },
356
381
  onSuccess: (_, { params, spokeProvider }) => {
357
- console.log("onSuccess invoked with queryKey:", [
358
- "mm",
359
- "allowance",
360
- spokeProvider?.chainConfig.chain.id,
361
- params.token,
362
- params.action
363
- ]);
364
382
  queryClient.invalidateQueries({
365
383
  queryKey: ["mm", "allowance", spokeProvider?.chainConfig.chain.id, params.token, params.action]
366
384
  });
@@ -1177,11 +1195,9 @@ function useInstantUnstakeRatio(amount, refetchInterval = 1e4) {
1177
1195
  }
1178
1196
  function useConvertedAssets(amount, refetchInterval = 1e4) {
1179
1197
  const { sodax } = useSodaxContext();
1180
- console.log("useConvertedAssets hook called with:", { amount: amount?.toString(), sodax: !!sodax });
1181
1198
  return reactQuery.useQuery({
1182
1199
  queryKey: ["soda", "convertedAssets", amount?.toString()],
1183
1200
  queryFn: async () => {
1184
- console.log("useConvertedAssets queryFn called with amount:", amount?.toString());
1185
1201
  if (!amount || amount <= 0n) {
1186
1202
  throw new Error("Amount must be greater than 0");
1187
1203
  }