@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 +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/mm/useMMAllowance.ts +30 -2
- package/src/hooks/provider/useSpokeProvider.ts +3 -0
- package/src/hooks/staking/useConvertedAssets.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -144,9 +144,11 @@ function useSpokeProvider(spokeChainId, walletProvider) {
|
|
|
144
144
|
spokeChainConfig[spokeChainId]
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
|
+
const evmRpcUrl = rpcConfig[spokeChainId];
|
|
147
148
|
return new EvmSpokeProvider(
|
|
148
149
|
walletProvider,
|
|
149
|
-
spokeChainConfig[spokeChainId]
|
|
150
|
+
spokeChainConfig[spokeChainId],
|
|
151
|
+
typeof evmRpcUrl === "string" ? evmRpcUrl : void 0
|
|
150
152
|
);
|
|
151
153
|
}
|
|
152
154
|
if (xChainType === "SUI") {
|
|
@@ -318,8 +320,22 @@ function useMMAllowance({
|
|
|
318
320
|
const { sodax } = useSodaxContext();
|
|
319
321
|
const defaultQueryOptions = {
|
|
320
322
|
queryKey: ["mm", "allowance", params?.token, params?.action],
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
/**
|
|
324
|
+
* IMPORTANT: Skip allowance checks for 'borrow' and 'withdraw' actions.
|
|
325
|
+
*
|
|
326
|
+
* Reason: According to the SDK's MoneyMarketService.isAllowanceValid() implementation,
|
|
327
|
+
* borrow and withdraw actions do NOT require ERC-20 token approval. The SDK's
|
|
328
|
+
* isAllowanceValid() method always returns `true` for these actions without making
|
|
329
|
+
* any on-chain allowance checks.
|
|
330
|
+
*
|
|
331
|
+
* This optimization prevents unnecessary RPC calls and avoids showing confusing states for actions that don't actually need approval.
|
|
332
|
+
*
|
|
333
|
+
* Only 'supply' and 'repay' actions require token approval and should trigger allowance checks.
|
|
334
|
+
*/
|
|
335
|
+
enabled: !!spokeProvider && !!params && params.action !== "borrow" && params.action !== "withdraw",
|
|
336
|
+
refetchInterval: 5e3,
|
|
337
|
+
gcTime: 0
|
|
338
|
+
// Don't cache failed queries
|
|
323
339
|
};
|
|
324
340
|
queryOptions = {
|
|
325
341
|
...defaultQueryOptions,
|
|
@@ -331,6 +347,9 @@ function useMMAllowance({
|
|
|
331
347
|
queryFn: async () => {
|
|
332
348
|
if (!spokeProvider) throw new Error("Spoke provider is required");
|
|
333
349
|
if (!params) throw new Error("Params are required");
|
|
350
|
+
if (params.action === "borrow" || params.action === "withdraw") {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
334
353
|
const allowance = await sodax.moneyMarket.isAllowanceValid(params, spokeProvider);
|
|
335
354
|
if (!allowance.ok) {
|
|
336
355
|
throw allowance.error;
|
|
@@ -1170,11 +1189,9 @@ function useInstantUnstakeRatio(amount, refetchInterval = 1e4) {
|
|
|
1170
1189
|
}
|
|
1171
1190
|
function useConvertedAssets(amount, refetchInterval = 1e4) {
|
|
1172
1191
|
const { sodax } = useSodaxContext();
|
|
1173
|
-
console.log("useConvertedAssets hook called with:", { amount: amount?.toString(), sodax: !!sodax });
|
|
1174
1192
|
return useQuery({
|
|
1175
1193
|
queryKey: ["soda", "convertedAssets", amount?.toString()],
|
|
1176
1194
|
queryFn: async () => {
|
|
1177
|
-
console.log("useConvertedAssets queryFn called with amount:", amount?.toString());
|
|
1178
1195
|
if (!amount || amount <= 0n) {
|
|
1179
1196
|
throw new Error("Amount must be greater than 0");
|
|
1180
1197
|
}
|