@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sodax/dapp-kit",
3
3
  "license": "MIT",
4
- "version": "1.3.0-beta",
4
+ "version": "1.3.1-beta-rc1",
5
5
  "description": "dapp-kit of New World",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "viem": "2.29.2",
19
- "@sodax/sdk": "1.3.0-beta",
20
- "@sodax/types": "1.3.0-beta"
19
+ "@sodax/sdk": "1.3.1-beta-rc1",
20
+ "@sodax/types": "1.3.1-beta-rc1"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "19.0.8",
@@ -38,14 +38,27 @@ export function useMMAllowance({
38
38
 
39
39
  const defaultQueryOptions = {
40
40
  queryKey: ['mm', 'allowance', params?.token, params?.action],
41
- enabled: !!spokeProvider,
41
+ /**
42
+ * IMPORTANT: Skip allowance checks for 'borrow' and 'withdraw' actions.
43
+ *
44
+ * Reason: According to the SDK's MoneyMarketService.isAllowanceValid() implementation,
45
+ * borrow and withdraw actions do NOT require ERC-20 token approval. The SDK's
46
+ * isAllowanceValid() method always returns `true` for these actions without making
47
+ * any on-chain allowance checks.
48
+ *
49
+ * This optimization prevents unnecessary RPC calls and avoids showing confusing states for actions that don't actually need approval.
50
+ *
51
+ * Only 'supply' and 'repay' actions require token approval and should trigger allowance checks.
52
+ */
53
+ enabled: !!spokeProvider && !!params && params.action !== 'borrow' && params.action !== 'withdraw',
42
54
  refetchInterval: 5000,
55
+ gcTime: 0, // Don't cache failed queries
43
56
  };
44
57
 
45
58
  queryOptions = {
46
59
  ...defaultQueryOptions,
47
60
  ...queryOptions, // override default query options if provided
48
- }
61
+ };
49
62
 
50
63
  return useQuery({
51
64
  ...queryOptions,
@@ -53,6 +66,21 @@ export function useMMAllowance({
53
66
  if (!spokeProvider) throw new Error('Spoke provider is required');
54
67
  if (!params) throw new Error('Params are required');
55
68
 
69
+ /**
70
+ * Early return for borrow/withdraw actions: these actions do NOT require ERC-20 token approval.
71
+ *
72
+ * The SDK's MoneyMarketService.isAllowanceValid() always returns `true` for borrow/withdraw
73
+ * without checking on-chain allowance. This is because:
74
+ * - Borrow: User receives tokens (no approval needed)
75
+ * - Withdraw: User withdraws their own supplied tokens (no approval needed)
76
+ *
77
+ * By returning `true` here, we avoid unnecessary RPC calls and ensure consistent behavior
78
+ * with the SDK's implementation.
79
+ */
80
+ if (params.action === 'borrow' || params.action === 'withdraw') {
81
+ return true;
82
+ }
83
+
56
84
  const allowance = await sodax.moneyMarket.isAllowanceValid(params, spokeProvider);
57
85
 
58
86
  if (!allowance.ok) {
@@ -67,9 +67,12 @@ export function useSpokeProvider(
67
67
  spokeChainConfig[spokeChainId] as SonicSpokeChainConfig,
68
68
  );
69
69
  }
70
+ // EVM RPC: flat RpcConfig keyed by chain id (same shape as app's rpcConfig)
71
+ const evmRpcUrl = rpcConfig[spokeChainId];
70
72
  return new EvmSpokeProvider(
71
73
  walletProvider as IEvmWalletProvider,
72
74
  spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,
75
+ typeof evmRpcUrl === 'string' ? evmRpcUrl : undefined,
73
76
  );
74
77
  }
75
78
 
@@ -23,12 +23,12 @@ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
23
23
  export function useConvertedAssets(amount: bigint | undefined, refetchInterval = 10000): UseQueryResult<bigint, Error> {
24
24
  const { sodax } = useSodaxContext();
25
25
 
26
- console.log('useConvertedAssets hook called with:', { amount: amount?.toString(), sodax: !!sodax });
26
+ // console.log('useConvertedAssets hook called with:', { amount: amount?.toString(), sodax: !!sodax });
27
27
 
28
28
  return useQuery({
29
29
  queryKey: ['soda', 'convertedAssets', amount?.toString()],
30
30
  queryFn: async () => {
31
- console.log('useConvertedAssets queryFn called with amount:', amount?.toString());
31
+ // console.log('useConvertedAssets queryFn called with amount:', amount?.toString());
32
32
  if (!amount || amount <= 0n) {
33
33
  throw new Error('Amount must be greater than 0');
34
34
  }