@sodax/dapp-kit 1.3.0-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") {
@@ -324,8 +326,22 @@ function useMMAllowance({
324
326
  const { sodax } = useSodaxContext();
325
327
  const defaultQueryOptions = {
326
328
  queryKey: ["mm", "allowance", params?.token, params?.action],
327
- enabled: !!spokeProvider,
328
- 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
329
345
  };
330
346
  queryOptions = {
331
347
  ...defaultQueryOptions,
@@ -337,6 +353,9 @@ function useMMAllowance({
337
353
  queryFn: async () => {
338
354
  if (!spokeProvider) throw new Error("Spoke provider is required");
339
355
  if (!params) throw new Error("Params are required");
356
+ if (params.action === "borrow" || params.action === "withdraw") {
357
+ return true;
358
+ }
340
359
  const allowance = await sodax.moneyMarket.isAllowanceValid(params, spokeProvider);
341
360
  if (!allowance.ok) {
342
361
  throw allowance.error;
@@ -1176,11 +1195,9 @@ function useInstantUnstakeRatio(amount, refetchInterval = 1e4) {
1176
1195
  }
1177
1196
  function useConvertedAssets(amount, refetchInterval = 1e4) {
1178
1197
  const { sodax } = useSodaxContext();
1179
- console.log("useConvertedAssets hook called with:", { amount: amount?.toString(), sodax: !!sodax });
1180
1198
  return reactQuery.useQuery({
1181
1199
  queryKey: ["soda", "convertedAssets", amount?.toString()],
1182
1200
  queryFn: async () => {
1183
- console.log("useConvertedAssets queryFn called with amount:", amount?.toString());
1184
1201
  if (!amount || amount <= 0n) {
1185
1202
  throw new Error("Amount must be greater than 0");
1186
1203
  }