@sodax/dapp-kit 2.0.0-rc.2 → 2.0.0-rc.4
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 +9 -63
- package/dist/index.d.ts +11 -4
- package/dist/index.mjs +3 -6
- package/package.json +31 -19
- package/src/providers/SodaxProvider.tsx +15 -11
- package/ai-exported/AGENTS.md +0 -134
- package/ai-exported/integration/README.md +0 -49
- package/ai-exported/integration/ai-rules.md +0 -79
- package/ai-exported/integration/architecture.md +0 -274
- package/ai-exported/integration/features/README.md +0 -29
- package/ai-exported/integration/features/auxiliary-services.md +0 -169
- package/ai-exported/integration/features/bitcoin.md +0 -87
- package/ai-exported/integration/features/bridge.md +0 -91
- package/ai-exported/integration/features/dex.md +0 -152
- package/ai-exported/integration/features/migration.md +0 -118
- package/ai-exported/integration/features/money-market.md +0 -116
- package/ai-exported/integration/features/staking.md +0 -123
- package/ai-exported/integration/features/swap.md +0 -101
- package/ai-exported/integration/quickstart.md +0 -187
- package/ai-exported/integration/recipes/README.md +0 -136
- package/ai-exported/integration/recipes/backend-queries.md +0 -157
- package/ai-exported/integration/recipes/bitcoin.md +0 -193
- package/ai-exported/integration/recipes/bridge.md +0 -174
- package/ai-exported/integration/recipes/dex.md +0 -204
- package/ai-exported/integration/recipes/invalidations.md +0 -115
- package/ai-exported/integration/recipes/migration.md +0 -212
- package/ai-exported/integration/recipes/money-market.md +0 -206
- package/ai-exported/integration/recipes/mutation-error-handling.md +0 -118
- package/ai-exported/integration/recipes/observability.md +0 -93
- package/ai-exported/integration/recipes/setup.md +0 -144
- package/ai-exported/integration/recipes/staking.md +0 -202
- package/ai-exported/integration/recipes/swap.md +0 -272
- package/ai-exported/integration/recipes/wallet-connectivity.md +0 -101
- package/ai-exported/integration/reference/README.md +0 -12
- package/ai-exported/integration/reference/glossary.md +0 -188
- package/ai-exported/integration/reference/hooks-index.md +0 -190
- package/ai-exported/integration/reference/public-api.md +0 -110
- package/ai-exported/integration/reference/querykey-conventions.md +0 -179
- package/ai-exported/migration/README.md +0 -60
- package/ai-exported/migration/ai-rules.md +0 -81
- package/ai-exported/migration/breaking-changes/hook-signatures.md +0 -233
- package/ai-exported/migration/breaking-changes/querykey-conventions.md +0 -108
- package/ai-exported/migration/breaking-changes/result-handling.md +0 -211
- package/ai-exported/migration/breaking-changes/sdk-leakage.md +0 -165
- package/ai-exported/migration/checklist.md +0 -89
- package/ai-exported/migration/features/README.md +0 -34
- package/ai-exported/migration/features/auxiliary-services.md +0 -114
- package/ai-exported/migration/features/bitcoin.md +0 -88
- package/ai-exported/migration/features/bridge.md +0 -123
- package/ai-exported/migration/features/dex.md +0 -101
- package/ai-exported/migration/features/migration.md +0 -120
- package/ai-exported/migration/features/money-market.md +0 -97
- package/ai-exported/migration/features/staking.md +0 -109
- package/ai-exported/migration/features/swap.md +0 -118
- package/ai-exported/migration/recipes.md +0 -188
- package/ai-exported/migration/reference/README.md +0 -15
- package/ai-exported/migration/reference/deleted-hooks.md +0 -110
- package/ai-exported/migration/reference/error-shape-crosswalk.md +0 -144
- package/ai-exported/migration/reference/renamed-hooks.md +0 -66
- package/dist/index.cjs +0 -2642
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1550
- package/dist/index.mjs.map +0 -1
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# Auxiliary services migration — v1 → v2 (dapp-kit)
|
|
2
|
-
|
|
3
|
-
Pair: [`../../integration/features/auxiliary-services.md`](../../integration/features/auxiliary-services.md).
|
|
4
|
-
|
|
5
|
-
Smaller surfaces grouped together: partner, recovery, backend queries, shared utilities. Most changes are mechanical — single-object params, mutateAsyncSafe — same as the other features.
|
|
6
|
-
|
|
7
|
-
## Partner
|
|
8
|
-
|
|
9
|
-
```diff
|
|
10
|
-
- const claim = useFeeClaimSwap(spokeProvider);
|
|
11
|
-
- await claim.mutateAsync(params);
|
|
12
|
-
+ const walletProvider = useWalletProvider({ xChainId: ChainKeys.SONIC_MAINNET });
|
|
13
|
-
+ const { mutateAsyncSafe: claim } = useFeeClaimSwap();
|
|
14
|
-
+ const result = await claim({ params, walletProvider });
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
`useApproveToken`, `useSetSwapPreference` — same pattern.
|
|
18
|
-
|
|
19
|
-
`useFetchAssetsBalances`, `useGetAutoSwapPreferences`, `useIsTokenApproved` — convert to single-object query shape.
|
|
20
|
-
|
|
21
|
-
## Recovery
|
|
22
|
-
|
|
23
|
-
```diff
|
|
24
|
-
- const withdraw = useWithdrawHubAsset(spokeProvider);
|
|
25
|
-
+ const { mutateAsyncSafe: withdraw } = useWithdrawHubAsset();
|
|
26
|
-
+ await withdraw({ params, walletProvider });
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Backend queries
|
|
30
|
-
|
|
31
|
-
Read-only. No `walletProvider` involved. Convert to single-object query shape.
|
|
32
|
-
|
|
33
|
-
```diff
|
|
34
|
-
- const { data: intent } = useBackendIntentByTxHash(txHash);
|
|
35
|
-
+ const { data: intent } = useBackendIntentByTxHash({ params: { txHash } });
|
|
36
|
-
|
|
37
|
-
- const { data: orderbook } = useBackendOrderbook({ offset: '0', limit: '20' });
|
|
38
|
-
+ const { data: orderbook } = useBackendOrderbook({ pagination: { offset: '0', limit: '20' } });
|
|
39
|
-
|
|
40
|
-
- const { data: position } = useBackendMoneyMarketPosition(userAddress);
|
|
41
|
-
+ const { data: position } = useBackendMoneyMarketPosition({ params: { userAddress } });
|
|
42
|
-
|
|
43
|
-
- const { data: assets } = useBackendAllMoneyMarketAssets();
|
|
44
|
-
+ const { data: assets } = useBackendAllMoneyMarketAssets({});
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
`useBackendSubmitSwapTx` is a mutation — per-call config flows through `mutate(vars)`:
|
|
48
|
-
|
|
49
|
-
```diff
|
|
50
|
-
- const submit = useBackendSubmitSwapTx({ baseURL: 'https://...' }); // v1: per-instance config
|
|
51
|
-
- await submit.mutateAsync(swapPayload);
|
|
52
|
-
+ const { mutateAsync: submit } = useBackendSubmitSwapTx();
|
|
53
|
-
+ await submit({ request: swapPayload, apiConfig: { baseURL: 'https://...' } }); // v2: per-call config
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Shared utilities
|
|
57
|
-
|
|
58
|
-
### `useXBalances`
|
|
59
|
-
|
|
60
|
-
v2 requires four fields under `params`: `xService` (from `@sodax/wallet-sdk-react`), `xChainId`, `xTokens`, and `address`. The token list is no longer optional.
|
|
61
|
-
|
|
62
|
-
```diff
|
|
63
|
-
- const { data: balances } = useXBalances(BSC_MAINNET_CHAIN_ID, address, tokens);
|
|
64
|
-
+ import { useXService, getXChainType } from '@sodax/wallet-sdk-react';
|
|
65
|
-
+ const xChainId = ChainKeys.BSC_MAINNET;
|
|
66
|
-
+ const xService = useXService({ xChainType: getXChainType(xChainId) });
|
|
67
|
-
+ const { data: balances } = useXBalances({
|
|
68
|
-
+ params: { xService, xChainId, xTokens, address },
|
|
69
|
-
+ });
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Note: the request param is still `xChainId` (not renamed to `chainKey`). This is intentional — `xChainId` overlays the cross-chain abstraction; the rename only happened for token-side fields. Don't conflate.
|
|
73
|
-
|
|
74
|
-
### `useEstimateGas`
|
|
75
|
-
|
|
76
|
-
```diff
|
|
77
|
-
- const estimate = useEstimateGas(walletProvider);
|
|
78
|
-
- await estimate.mutateAsync({ rawTx });
|
|
79
|
-
+ const { mutateAsyncSafe: estimateGas } = useEstimateGas();
|
|
80
|
-
+ const result = await estimateGas({ rawTx, walletProvider });
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### `useStellarTrustlineCheck` / `useRequestTrustline`
|
|
84
|
-
|
|
85
|
-
```diff
|
|
86
|
-
- const { data: hasTrustline } = useStellarTrustlineCheck(account, asset);
|
|
87
|
-
+ const { data: hasTrustline } = useStellarTrustlineCheck({ params: { account, asset } });
|
|
88
|
-
|
|
89
|
-
- const request = useRequestTrustline(walletProvider);
|
|
90
|
-
- await request.mutateAsync({ account, asset });
|
|
91
|
-
+ const { mutateAsync: request } = useRequestTrustline();
|
|
92
|
-
+ await request({ account, asset, walletProvider });
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### `useDeriveUserWalletAddress` / `useGetUserHubWalletAddress`
|
|
96
|
-
|
|
97
|
-
```diff
|
|
98
|
-
- const { data: hubAddress } = useDeriveUserWalletAddress(spokeChainKey, srcAddress);
|
|
99
|
-
+ const { data: hubAddress } = useDeriveUserWalletAddress({ params: { spokeChainKey, srcAddress } });
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Pitfalls
|
|
103
|
-
|
|
104
|
-
1. **`useBackendIntentByTxHash` polls every 1s while pending** — same as v1, but make sure your `queryOptions.refetchInterval` overrides if needed.
|
|
105
|
-
2. **`useBackendOrderbook` does NOT auto-refetch** — it has `staleTime: 30s` only, so data stays fresh for 30s after a fetch but won't refresh on its own. Trigger a refetch manually or pass `refetchInterval` via `queryOptions` if you need polling.
|
|
106
|
-
3. **`useXBalances` uses `xChainId` (not `chainKey`)** — request-side field name retained on this hook.
|
|
107
|
-
4. **`useBackendSubmitSwapTx` config moved to per-call.** v1 may have had `baseURL` at hook init; v2 puts it in `mutate(vars).apiConfig`. Lets you have a single hook serve multiple backends if needed.
|
|
108
|
-
|
|
109
|
-
## Cross-references
|
|
110
|
-
|
|
111
|
-
- [`../../integration/features/auxiliary-services.md`](../../integration/features/auxiliary-services.md) — v2 reference.
|
|
112
|
-
- [`../../integration/recipes/backend-queries.md`](../../integration/recipes/backend-queries.md) — backend hooks worked examples.
|
|
113
|
-
- [`../../integration/recipes/wallet-connectivity.md`](../../integration/recipes/wallet-connectivity.md) — `useXBalances` worked example.
|
|
114
|
-
- [`../../../../sdk/ai-exported/migration/features/auxiliary-services.md`](../../../../sdk/ai-exported/migration/features/auxiliary-services.md) — underlying SDK auxiliary migrations.
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# Bitcoin (Radfi) migration — v1 → v2 (dapp-kit)
|
|
2
|
-
|
|
3
|
-
Pair: [`../../integration/features/bitcoin.md`](../../integration/features/bitcoin.md).
|
|
4
|
-
|
|
5
|
-
Bitcoin / Radfi hook surface was new in v1 with limited adoption; v2 standardizes its shapes against the canonical hook conventions. Treat the v2 forms below as the canonical reference — if your v1 code used a different shape, swap to v2's directly.
|
|
6
|
-
|
|
7
|
-
## TL;DR
|
|
8
|
-
|
|
9
|
-
> Cross-cutting conventions (drop `spokeProvider`, single-object hook init, `mutate(vars)` for domain inputs, `mutateAsyncSafe` ergonomics) — see [`../breaking-changes/hook-signatures.md`](../breaking-changes/hook-signatures.md) and [`../breaking-changes/result-handling.md`](../breaking-changes/result-handling.md). Bitcoin-specific deltas:
|
|
10
|
-
|
|
11
|
-
1. **`useRadfiSession` API unchanged** — still takes a `walletProvider` directly (not via `mutate(vars)`); it manages session lifecycle.
|
|
12
|
-
2. **`useTradingWallet(walletAddress)` is synchronous** — no Query/Mutation; reads localStorage. Unchanged.
|
|
13
|
-
3. **`useBitcoinBalance` / `useTradingWalletBalance`** use single-object query shape `{ params, queryOptions }`.
|
|
14
|
-
4. **Withdrawal/funding mutations** follow the canonical mutation hook shape — only `{ mutationOptions }` at hook init; `walletProvider` and per-call config flow through `mutate(vars)`.
|
|
15
|
-
|
|
16
|
-
## v2 canonical shapes
|
|
17
|
-
|
|
18
|
-
### `useFundTradingWallet`
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
// @ai-snippets-skip
|
|
22
|
-
const walletProvider = useWalletProvider({ xChainId: ChainKeys.BITCOIN_MAINNET });
|
|
23
|
-
const { mutateAsyncSafe: fund } = useFundTradingWallet();
|
|
24
|
-
const result = await fund({ amount: 100_000n, walletProvider });
|
|
25
|
-
if (!result.ok) return;
|
|
26
|
-
const txId = result.value;
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### `useRadfiWithdraw`
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
// @ai-snippets-skip
|
|
33
|
-
const { mutateAsyncSafe: withdraw } = useRadfiWithdraw();
|
|
34
|
-
const result = await withdraw({
|
|
35
|
-
amount: '10000',
|
|
36
|
-
tokenId: '0:0',
|
|
37
|
-
withdrawTo,
|
|
38
|
-
walletProvider,
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### `useRenewUtxos`
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
// @ai-snippets-skip
|
|
46
|
-
await renewUtxos({ txIdVouts, walletProvider });
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### `useRadfiSession`
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
// @ai-snippets-skip
|
|
53
|
-
// Unchanged — still takes walletProvider directly (not via mutate vars).
|
|
54
|
-
const { isAuthed, tradingAddress, login, isLoginPending } = useRadfiSession(walletProvider);
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
The session-management lifecycle hook needs constant access to the wallet provider for token refresh — it doesn't fit the `mutate(vars)` pattern.
|
|
58
|
-
|
|
59
|
-
### `useBitcoinBalance` / `useTradingWalletBalance`
|
|
60
|
-
|
|
61
|
-
Single-object query shape:
|
|
62
|
-
|
|
63
|
-
```diff
|
|
64
|
-
- const { data } = useBitcoinBalance(address);
|
|
65
|
-
+ const { data } = useBitcoinBalance({ params: { address } });
|
|
66
|
-
|
|
67
|
-
- const { data } = useTradingWalletBalance(walletProvider, tradingAddress);
|
|
68
|
-
+ const { data } = useTradingWalletBalance({ params: { walletProvider, tradingAddress } });
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### `useExpiredUtxos`
|
|
72
|
-
|
|
73
|
-
```diff
|
|
74
|
-
- const { data: expiredUtxos } = useExpiredUtxos(walletProvider, tradingAddress);
|
|
75
|
-
+ const { data: expiredUtxos } = useExpiredUtxos({ params: { walletProvider, tradingAddress } });
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Pitfalls
|
|
79
|
-
|
|
80
|
-
1. **`useRadfiSession` is the lifecycle owner.** Don't create your own `useRadfiAuth` ad-hoc handlers if you're using `useRadfiSession` — it manages auth + refresh + persistence.
|
|
81
|
-
2. **Session tokens in localStorage are NOT for asset access.** They're API rate-limit tokens. Compromise of localStorage data doesn't let an attacker move funds.
|
|
82
|
-
3. **Trading wallet is auto-created** during first authentication — don't add a separate "create wallet" step in your UI.
|
|
83
|
-
4. **PSBT signing flow is internal.** v1 may have surfaced the unsigned PSBT for explicit consumer signing; v2 hooks orchestrate the full flow (build → sign → co-sign → broadcast) inside `mutationFn`.
|
|
84
|
-
|
|
85
|
-
## Cross-references
|
|
86
|
-
|
|
87
|
-
- [`../../integration/features/bitcoin.md`](../../integration/features/bitcoin.md) — v2 reference.
|
|
88
|
-
- [`../../integration/recipes/bitcoin.md`](../../integration/recipes/bitcoin.md) — full v2 worked examples.
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# Bridge migration — v1 → v2 (dapp-kit)
|
|
2
|
-
|
|
3
|
-
Pair: [`../../integration/features/bridge.md`](../../integration/features/bridge.md).
|
|
4
|
-
|
|
5
|
-
## TL;DR
|
|
6
|
-
|
|
7
|
-
> Cross-cutting conventions (drop `spokeProvider`, single-object hook init, `mutate(vars)` for domain inputs, `mutateAsyncSafe` ergonomics) — see [`../breaking-changes/hook-signatures.md`](../breaking-changes/hook-signatures.md) and [`../breaking-changes/result-handling.md`](../breaking-changes/result-handling.md). Feature-specific deltas below:
|
|
8
|
-
|
|
9
|
-
1. **`CreateBridgeIntentParams` field renames** (SDK-leakage):
|
|
10
|
-
- `srcChainId` → `srcChainKey`
|
|
11
|
-
- `dstChainId` → `dstChainKey`
|
|
12
|
-
- `recipient` → `dstAddress`
|
|
13
|
-
- **NEW required**: `srcAddress`
|
|
14
|
-
2. **`useBridge` return is `TxHashPair`, not a tuple.** v1 may have returned `[spokeTxHash, hubTxHash]`; v2 returns `{ srcChainTxHash, dstChainTxHash }`. Don't destructure as array.
|
|
15
|
-
3. **`useGetBridgeableAmount` reshape.** v1 took `(srcChainId, srcAsset, dstChainId, dstAsset)`. v2 takes `{ from: XToken, to: XToken }` — each `XToken` carries its own `chainKey`.
|
|
16
|
-
4. **`useGetBridgeableAmount` return value is `BridgeLimit`, not bare `bigint`.** Access `.value.amount` and `.value.decimals`.
|
|
17
|
-
5. **`useGetBridgeableTokens` is sync now** in the SDK. The hook still returns `UseQueryResult` but the underlying SDK call doesn't fire RPC — it's config-derived.
|
|
18
|
-
6. **Allowance/approve** — same shape changes as every other feature.
|
|
19
|
-
|
|
20
|
-
## Per-method delta
|
|
21
|
-
|
|
22
|
-
### `useBridge` — params + return
|
|
23
|
-
|
|
24
|
-
```diff
|
|
25
|
-
function BridgeButton({ srcAddress }) {
|
|
26
|
-
- const bridge = useBridge(spokeProvider);
|
|
27
|
-
+ const walletProvider = useWalletProvider({ xChainId: ChainKeys.BASE_MAINNET });
|
|
28
|
-
+ const { mutateAsyncSafe: bridge } = useBridge();
|
|
29
|
-
|
|
30
|
-
const handleBridge = async () => {
|
|
31
|
-
+ if (!walletProvider) return;
|
|
32
|
-
- const result = await bridge.mutateAsync({
|
|
33
|
-
- params: {
|
|
34
|
-
- srcChainId: BASE_MAINNET_CHAIN_ID,
|
|
35
|
-
- srcAsset: '0x...',
|
|
36
|
-
- amount: 1_000_000n,
|
|
37
|
-
- dstChainId: POLYGON_MAINNET_CHAIN_ID,
|
|
38
|
-
- dstAsset: '0x...',
|
|
39
|
-
- recipient: '0x...',
|
|
40
|
-
- },
|
|
41
|
-
- });
|
|
42
|
-
- if (result.ok) {
|
|
43
|
-
- const [spokeTxHash, hubTxHash] = result.value;
|
|
44
|
-
- /* ... */
|
|
45
|
-
- }
|
|
46
|
-
+ const result = await bridge({
|
|
47
|
-
+ params: {
|
|
48
|
-
+ srcChainKey: ChainKeys.BASE_MAINNET,
|
|
49
|
-
+ srcAddress, // NEW: required
|
|
50
|
-
+ srcAsset: '0x...',
|
|
51
|
-
+ amount: 1_000_000n,
|
|
52
|
-
+ dstChainKey: ChainKeys.POLYGON_MAINNET,
|
|
53
|
-
+ dstAsset: '0x...',
|
|
54
|
-
+ dstAddress: '0x...', // RENAMED from `recipient`
|
|
55
|
-
+ },
|
|
56
|
-
+ walletProvider,
|
|
57
|
-
+ });
|
|
58
|
-
+ if (!result.ok) return;
|
|
59
|
-
+ const { srcChainTxHash, dstChainTxHash } = result.value; // OBJECT, not tuple
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### `useGetBridgeableAmount` — params + return reshape
|
|
65
|
-
|
|
66
|
-
```diff
|
|
67
|
-
- const { data: amount } = useGetBridgeableAmount({
|
|
68
|
-
- params: {
|
|
69
|
-
- srcChainId: BASE_MAINNET_CHAIN_ID,
|
|
70
|
-
- srcAsset: '0x...',
|
|
71
|
-
- dstChainId: POLYGON_MAINNET_CHAIN_ID,
|
|
72
|
-
- dstAsset: '0x...',
|
|
73
|
-
- },
|
|
74
|
-
- });
|
|
75
|
-
- if (amount) {
|
|
76
|
-
- <p>Max: {formatUnits(amount, 6)}</p>; // v1 was bare bigint
|
|
77
|
-
- }
|
|
78
|
-
+ const { data: result } = useGetBridgeableAmount({
|
|
79
|
-
+ params: { from: srcXToken, to: dstXToken }, // each XToken carries chainKey
|
|
80
|
-
+ });
|
|
81
|
-
+ if (result?.ok) {
|
|
82
|
-
+ <p>Max: {formatUnits(result.value.amount, result.value.decimals)}</p>;
|
|
83
|
-
+ }
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### `useGetBridgeableTokens`
|
|
87
|
-
|
|
88
|
-
```diff
|
|
89
|
-
- const { data: tokens } = useGetBridgeableTokens(BASE_MAINNET_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, srcAsset);
|
|
90
|
-
+ const { data: result } = useGetBridgeableTokens({
|
|
91
|
-
+ params: { from: ChainKeys.BASE_MAINNET, to: ChainKeys.POLYGON_MAINNET, token: srcAsset },
|
|
92
|
-
+ });
|
|
93
|
-
+ if (result?.ok) {
|
|
94
|
-
+ const tokens: XToken[] = result.value;
|
|
95
|
-
+ }
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### `useBridgeAllowance` / `useBridgeApprove`
|
|
99
|
-
|
|
100
|
-
`useBridgeAllowance` query inputs (payload + walletProvider) all nest under `params` in v2:
|
|
101
|
-
|
|
102
|
-
```diff
|
|
103
|
-
- const { data: allowanceResult } = useBridgeAllowance({ params, spokeProvider });
|
|
104
|
-
+ const { data: isApproved } = useBridgeAllowance({
|
|
105
|
-
+ params: { payload: bridgeParams, walletProvider },
|
|
106
|
-
+ });
|
|
107
|
-
+ // `data` is `boolean | undefined` (already unwrapped).
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
`useBridgeApprove` mutation drops `spokeProvider` from hook init; `mutate(vars)` takes `{ params, walletProvider }`.
|
|
111
|
-
|
|
112
|
-
## Pitfalls
|
|
113
|
-
|
|
114
|
-
1. **`useGetBridgeableAmount` data shape changed.** v1 returned bare `bigint`; v2 returns `Result<BridgeLimit>` where `BridgeLimit = { amount, decimals, type }`. UI code that displayed the bigint directly needs `.value.amount`.
|
|
115
|
-
2. **Tokens must share the same vault** to be bridgeable. Use `useGetBridgeableTokens` to enumerate compatible destinations — passing an incompatible pair to `bridge()` rejects with `VALIDATION_FAILED`.
|
|
116
|
-
3. **`useBridge` return is `TxHashPair`** — destructure as `{ srcChainTxHash, dstChainTxHash }`, not `[a, b]`.
|
|
117
|
-
4. **`recipient` field renamed to `dstAddress`** for consistency with the rest of the SDK.
|
|
118
|
-
|
|
119
|
-
## Cross-references
|
|
120
|
-
|
|
121
|
-
- [`../../integration/features/bridge.md`](../../integration/features/bridge.md) — v2 reference.
|
|
122
|
-
- [`../../integration/recipes/bridge.md`](../../integration/recipes/bridge.md) — full v2 worked example.
|
|
123
|
-
- [`../../../../sdk/ai-exported/migration/features/bridge.md`](../../../../sdk/ai-exported/migration/features/bridge.md) — underlying SDK bridge migration.
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# DEX migration — v1 → v2 (dapp-kit)
|
|
2
|
-
|
|
3
|
-
Pair: [`../../integration/features/dex.md`](../../integration/features/dex.md).
|
|
4
|
-
|
|
5
|
-
## TL;DR
|
|
6
|
-
|
|
7
|
-
> Cross-cutting conventions (drop `spokeProvider`, single-object hook init, `mutate(vars)` for domain inputs, `mutateAsyncSafe` ergonomics) — see [`../breaking-changes/hook-signatures.md`](../breaking-changes/hook-signatures.md) and [`../breaking-changes/result-handling.md`](../breaking-changes/result-handling.md). Feature-specific deltas below:
|
|
8
|
-
|
|
9
|
-
1. **All mutations** (`useDexDeposit`, `useDexWithdraw`, `useSupplyLiquidity`, `useDecreaseLiquidity`, `useClaimRewards`, `useDexApprove`) — single-object hook init + `mutate({ params, walletProvider })`. SDK-leakage adds required `srcChainKey` + `srcAddress` to all action params.
|
|
10
|
-
2. **`useSupplyLiquidity` handles both mint-new and increase-existing** — pass `tokenId` in params for increase, omit for mint. Use `useCreateSupplyLiquidityParams` to handle the routing.
|
|
11
|
-
3. **`usePools` returns synchronously** in the SDK. The hook still returns `UseQueryResult` but the underlying call is config-derived (no RPC) — `staleTime: Infinity`, no auto-refresh.
|
|
12
|
-
4. **Param builders take a FLAT props object** — `useCreateDepositParams`, `useCreateWithdrawParams`, `useCreateSupplyLiquidityParams`, `useCreateDecreaseLiquidityParams` — NOT `{ params: { ... } }`-wrapped. Their inputs use `srcChainKey` (not `srcChainId`); the result is spread into the mutation's `params` field at the call site.
|
|
13
|
-
|
|
14
|
-
## Per-method delta
|
|
15
|
-
|
|
16
|
-
### `useDexDeposit` / `useDexWithdraw`
|
|
17
|
-
|
|
18
|
-
```diff
|
|
19
|
-
- const deposit = useDexDeposit(spokeProvider);
|
|
20
|
-
- await deposit.mutateAsync({ params: { asset, amount, poolToken } });
|
|
21
|
-
+ const walletProvider = useWalletProvider({ xChainId: ChainKeys.BASE_MAINNET });
|
|
22
|
-
+ const { mutateAsyncSafe: deposit } = useDexDeposit();
|
|
23
|
-
+ const result = await deposit({
|
|
24
|
-
+ params: {
|
|
25
|
-
+ srcChainKey: ChainKeys.BASE_MAINNET,
|
|
26
|
-
+ srcAddress, // NEW
|
|
27
|
-
+ asset,
|
|
28
|
-
+ amount,
|
|
29
|
-
+ poolToken,
|
|
30
|
-
+ },
|
|
31
|
-
+ walletProvider,
|
|
32
|
-
+ });
|
|
33
|
-
+ if (!result.ok) return;
|
|
34
|
-
+ const { srcChainTxHash, dstChainTxHash } = result.value;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### `useSupplyLiquidity` — mint vs increase routing
|
|
38
|
-
|
|
39
|
-
```diff
|
|
40
|
-
- // v1: separate hooks for mint and increase
|
|
41
|
-
- const mint = useMintLiquidity(spokeProvider);
|
|
42
|
-
- const increase = useIncreaseLiquidity(spokeProvider);
|
|
43
|
-
- if (existingTokenId) {
|
|
44
|
-
- await increase.mutateAsync({ params: { tokenId, poolKey, ... } });
|
|
45
|
-
- } else {
|
|
46
|
-
- await mint.mutateAsync({ params: { poolKey, ... } });
|
|
47
|
-
- }
|
|
48
|
-
|
|
49
|
-
+ // v2: single hook handles both via tokenId presence
|
|
50
|
-
+ const { mutateAsyncSafe: supply } = useSupplyLiquidity();
|
|
51
|
-
+ const supplyParams = useCreateSupplyLiquidityParams({
|
|
52
|
-
+ params: { poolKey, tickLower, tickUpper, amount0, amount1, tokenId: existingTokenId },
|
|
53
|
-
+ });
|
|
54
|
-
+ if (supplyParams && walletProvider) {
|
|
55
|
-
+ const result = await supply({ params: supplyParams, walletProvider });
|
|
56
|
-
+ }
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### `useDecreaseLiquidity` / `useClaimRewards`
|
|
60
|
-
|
|
61
|
-
Standard pattern — drop `spokeProvider` from hook init, add `srcChainKey` / `srcAddress` to params, pass `walletProvider` via `mutate(vars)`.
|
|
62
|
-
|
|
63
|
-
### `useDexAllowance` / `useDexApprove`
|
|
64
|
-
|
|
65
|
-
`useDexAllowance` wraps the deposit params under `params.payload`. Read-only — no `walletProvider`:
|
|
66
|
-
|
|
67
|
-
```diff
|
|
68
|
-
- const { data: allowance } = useDexAllowance({ params: depositParams, walletProvider });
|
|
69
|
-
+ const { data: isApproved } = useDexAllowance({ params: { payload: depositParams } });
|
|
70
|
-
+ // `data` is `boolean | undefined`; the hook calls `isAllowanceValid` with `raw: true`.
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
`useDexApprove` mutation drops `spokeProvider` from hook init; `mutate(vars)` takes `{ params, walletProvider }`.
|
|
74
|
-
|
|
75
|
-
### `usePoolData` / `usePositionInfo` / `usePools`
|
|
76
|
-
|
|
77
|
-
Convert to single-object query shape:
|
|
78
|
-
|
|
79
|
-
```diff
|
|
80
|
-
- const { data } = usePoolData(poolKey);
|
|
81
|
-
+ const { data } = usePoolData({ params: { poolKey } });
|
|
82
|
-
|
|
83
|
-
- const { data } = usePositionInfo(tokenId, poolKey);
|
|
84
|
-
+ const { data } = usePositionInfo({ params: { tokenId, poolKey } });
|
|
85
|
-
|
|
86
|
-
- const { data: pools } = usePools();
|
|
87
|
-
+ const { data: pools } = usePools({}); // single-object shape, even with no params
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Pitfalls
|
|
91
|
-
|
|
92
|
-
1. **`useSupplyLiquidity` is now ONE hook for both mint and increase.** v1 may have had two separate hooks. Use `tokenId` presence in `params` to drive the routing — `useCreateSupplyLiquidityParams` handles this for you.
|
|
93
|
-
2. **Two-step flow stays the same.** First `useDexDeposit` brings the spoke asset to the hub as pool-token shares. Then `useSupplyLiquidity` uses those shares to mint/grow a position. UI sequencing unchanged.
|
|
94
|
-
3. **Ticks are logarithmic.** Calculation libraries unchanged; just be aware that `tickLower` / `tickUpper` are tick indices, not prices.
|
|
95
|
-
4. **`usePools` never auto-refreshes** — pools are static config. Override `queryOptions.refetchInterval` only if you really know your config changed.
|
|
96
|
-
|
|
97
|
-
## Cross-references
|
|
98
|
-
|
|
99
|
-
- [`../../integration/features/dex.md`](../../integration/features/dex.md) — v2 reference.
|
|
100
|
-
- [`../../integration/recipes/dex.md`](../../integration/recipes/dex.md) — full v2 worked example.
|
|
101
|
-
- [`../../../../sdk/ai-exported/migration/features/dex.md`](../../../../sdk/ai-exported/migration/features/dex.md) — underlying SDK DEX migration.
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
# Migration migration — v1 → v2 (dapp-kit)
|
|
2
|
-
|
|
3
|
-
Pair: [`../../integration/features/migration.md`](../../integration/features/migration.md).
|
|
4
|
-
|
|
5
|
-
The biggest single API change in dapp-kit v2: v1 had a single `useMigrate(spokeProvider)`-style hook (often commented out by the time consumers needed it); v2 split it into 6 dedicated hooks.
|
|
6
|
-
|
|
7
|
-
## TL;DR
|
|
8
|
-
|
|
9
|
-
> Cross-cutting conventions (drop `spokeProvider`, single-object hook init, `mutate(vars)` for domain inputs, `mutateAsyncSafe` ergonomics) — see [`../breaking-changes/hook-signatures.md`](../breaking-changes/hook-signatures.md) and [`../breaking-changes/result-handling.md`](../breaking-changes/result-handling.md). Feature-specific deltas below:
|
|
10
|
-
|
|
11
|
-
1. **`useMigrate(spokeProvider)` is gone.** Replaced by **six per-action hooks**:
|
|
12
|
-
- `useMigrateIcxToSoda` — wICX (ICON) → SODA (Sonic)
|
|
13
|
-
- `useRevertMigrateSodaToIcx` — SODA → wICX (revert)
|
|
14
|
-
- `useMigratebnUSD` — legacy bnUSD ↔ new bnUSD (bidirectional)
|
|
15
|
-
- `useMigrateBaln` — BALN (ICON) → SODA with optional lock period
|
|
16
|
-
- `useMigrationApprove` — approve before migration (action-discriminated)
|
|
17
|
-
- `useMigrationAllowance` — check approval (action-discriminated)
|
|
18
|
-
2. **`useMigratebnUSD` is bidirectional.** v2 detects direction from `(srcbnUSD, dstbnUSD)` token addresses — no separate forward/reverse hook.
|
|
19
|
-
3. **All mutations** drop `spokeProvider`; `walletProvider` flows through `mutate(vars)`. SDK-leakage adds `srcChainKey` / `srcAddress` to all action params.
|
|
20
|
-
4. **`useMigrationApprove` / `useMigrationAllowance` are action-discriminated.** Same hook handles all migration approvals; pass `action: 'migrate' | 'revert'` to disambiguate.
|
|
21
|
-
5. **BALN `lockupPeriod` is a literal union, not arbitrary number.** `0 | 1 | 2 | 3 | 6 | 12 | 18 | 24` (months).
|
|
22
|
-
|
|
23
|
-
## Per-method delta
|
|
24
|
-
|
|
25
|
-
### v1 single hook → v2 six hooks
|
|
26
|
-
|
|
27
|
-
```diff
|
|
28
|
-
- // v1 — single hook
|
|
29
|
-
- const migrate = useMigrate(spokeProvider);
|
|
30
|
-
- await migrate.mutateAsync({ params: { type: 'icxToSoda', amount, /* ... */ } });
|
|
31
|
-
|
|
32
|
-
+ // v2 — pick the right hook
|
|
33
|
-
+ const { mutateAsyncSafe: migrate } = useMigrateIcxToSoda();
|
|
34
|
-
+ const result = await migrate({
|
|
35
|
-
+ params: {
|
|
36
|
-
+ srcChainKey: ChainKeys.ICON_MAINNET,
|
|
37
|
-
+ srcAddress: 'hx...',
|
|
38
|
-
+ address: 'cx88fd...', // wICX token address
|
|
39
|
-
+ amount,
|
|
40
|
-
+ dstAddress: '0x...', // Sonic recipient
|
|
41
|
-
+ },
|
|
42
|
-
+ walletProvider,
|
|
43
|
-
+ });
|
|
44
|
-
+ if (!result.ok) return;
|
|
45
|
-
+ const { srcChainTxHash, dstChainTxHash } = result.value;
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### `useMigratebnUSD` — bidirectional via token addresses
|
|
49
|
-
|
|
50
|
-
```diff
|
|
51
|
-
- // v1 might have had separate forward/reverse hooks (or all-in-one)
|
|
52
|
-
+ // v2: one hook; direction detected from (srcbnUSD, dstbnUSD)
|
|
53
|
-
+ const { mutateAsyncSafe: migratebnUSD } = useMigratebnUSD();
|
|
54
|
-
+ const result = await migratebnUSD({
|
|
55
|
-
+ params: {
|
|
56
|
-
+ srcChainKey: ChainKeys.BASE_MAINNET,
|
|
57
|
-
+ srcAddress: '0x...',
|
|
58
|
-
+ srcbnUSD: '0x... (legacy or new)',
|
|
59
|
-
+ dstChainKey: ChainKeys.ARBITRUM_MAINNET,
|
|
60
|
-
+ dstbnUSD: '0x... (the other one)',
|
|
61
|
-
+ amount,
|
|
62
|
-
+ dstAddress: '0x...',
|
|
63
|
-
+ },
|
|
64
|
-
+ walletProvider,
|
|
65
|
-
+ });
|
|
66
|
-
+ if (!result.ok) {
|
|
67
|
-
+ const direction = result.error.context?.direction; // 'forward' | 'reverse'
|
|
68
|
-
+ /* ... */
|
|
69
|
-
+ }
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### `useMigrateBaln` — lock period
|
|
73
|
-
|
|
74
|
-
```diff
|
|
75
|
-
+ const { mutateAsyncSafe: migrateBaln } = useMigrateBaln();
|
|
76
|
-
+ await migrateBaln({
|
|
77
|
-
+ params: {
|
|
78
|
-
+ srcChainKey: ChainKeys.ICON_MAINNET,
|
|
79
|
-
+ srcAddress: 'hx...',
|
|
80
|
-
+ amount,
|
|
81
|
-
+ lockupPeriod: 12, // 0 | 1 | 2 | 3 | 6 | 12 | 18 | 24
|
|
82
|
-
+ dstAddress: '0x...',
|
|
83
|
-
+ },
|
|
84
|
-
+ walletProvider,
|
|
85
|
-
+ });
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### `useMigrationApprove` / `useMigrationAllowance` — action-discriminated
|
|
89
|
-
|
|
90
|
-
```diff
|
|
91
|
-
- const { approve } = useMigrationApprove(spokeProvider);
|
|
92
|
-
- await approve(params);
|
|
93
|
-
+ const { data: isApproved } = useMigrationAllowance({
|
|
94
|
-
+ params: { params: revertParams, action: 'revert' },
|
|
95
|
-
+ });
|
|
96
|
-
+ const { mutateAsync: approve } = useMigrationApprove();
|
|
97
|
-
+ await approve({ params: revertParams, walletProvider, action: 'revert' });
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Approval requirements
|
|
101
|
-
|
|
102
|
-
| Migration | Approval needed? |
|
|
103
|
-
|---|---|
|
|
104
|
-
| ICX/wICX (ICON) → SODA | No (ICON has no ERC-20 allowance) |
|
|
105
|
-
| SODA → wICX (revert) | Yes |
|
|
106
|
-
| Legacy bnUSD ↔ new bnUSD (EVM/Stellar source) | Yes |
|
|
107
|
-
| BALN (ICON) → SODA | No |
|
|
108
|
-
|
|
109
|
-
## Pitfalls
|
|
110
|
-
|
|
111
|
-
1. **The single `useMigrate` is gone.** Pick the per-action hook that matches your migration. The v1 one-size-fits-all approach doesn't have a v2 shim.
|
|
112
|
-
2. **`useMigratebnUSD` direction detection.** v2 detects from token addresses. If both `srcbnUSD` and `dstbnUSD` are on the same side (both legacy or both new), the SDK rejects with `VALIDATION_FAILED`. Use `error.context?.direction` to disambiguate in error messaging.
|
|
113
|
-
3. **`lockupPeriod` is a literal union.** TypeScript rejects `lockupPeriod: 7`. Allowed: `0 | 1 | 2 | 3 | 6 | 12 | 18 | 24`. Reward multiplier ranges 0.5x (0 months) → 1.5x (24 months).
|
|
114
|
-
4. **ICON-side migrations don't need approval** — ICON has no ERC-20 allowance mechanism. Don't render an approve step for `useMigrateIcxToSoda` or `useMigrateBaln`.
|
|
115
|
-
|
|
116
|
-
## Cross-references
|
|
117
|
-
|
|
118
|
-
- [`../../integration/features/migration.md`](../../integration/features/migration.md) — v2 reference.
|
|
119
|
-
- [`../../integration/recipes/migration.md`](../../integration/recipes/migration.md) — full v2 worked examples (ICX, BALN, bnUSD, revert).
|
|
120
|
-
- [`../../../../sdk/ai-exported/migration/features/icx-bnusd-baln.md`](../../../../sdk/ai-exported/migration/features/icx-bnusd-baln.md) — underlying SDK migration migration.
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Money Market migration — v1 → v2 (dapp-kit)
|
|
2
|
-
|
|
3
|
-
Pair: [`../../integration/features/money-market.md`](../../integration/features/money-market.md).
|
|
4
|
-
|
|
5
|
-
## TL;DR
|
|
6
|
-
|
|
7
|
-
> Cross-cutting conventions (drop `spokeProvider`, single-object hook init, `mutate(vars)` for domain inputs, `mutateAsyncSafe` ergonomics) — see [`../breaking-changes/hook-signatures.md`](../breaking-changes/hook-signatures.md) and [`../breaking-changes/result-handling.md`](../breaking-changes/result-handling.md). Feature-specific deltas below:
|
|
8
|
-
|
|
9
|
-
1. **`useSupply` / `useBorrow` / `useWithdraw` / `useRepay`** all switch to single-object `{ mutationOptions }` hook init + `mutate({ params, walletProvider })`.
|
|
10
|
-
2. **`MoneyMarketSupplyParams<K>` (and the four similar action-param types) gained required `srcChainKey` + `srcAddress`** — SDK-leakage.
|
|
11
|
-
3. **`useMMAllowance` auto-skips on-chain checks for borrow/withdraw** — v1 may have had this too, but v2 returns `true` synchronously for those actions instead of issuing a no-op RPC.
|
|
12
|
-
4. **`useMMApprove` returns standard `SafeUseMutationResult`** — `isLoading` → `isPending`.
|
|
13
|
-
5. **Reserve data hooks renamed `address` → `userAddress`** in some queries (`useUserFormattedSummary`, `useUserReservesData`).
|
|
14
|
-
|
|
15
|
-
## Per-method delta
|
|
16
|
-
|
|
17
|
-
### `useSupply` (and `useBorrow` / `useWithdraw` / `useRepay`)
|
|
18
|
-
|
|
19
|
-
```diff
|
|
20
|
-
function SupplyButton({ token, amount, srcAddress }) {
|
|
21
|
-
- const supply = useSupply(spokeProvider);
|
|
22
|
-
+ const walletProvider = useWalletProvider({ xChainId: ChainKeys.BASE_MAINNET });
|
|
23
|
-
+ const { mutateAsyncSafe: supply, isPending } = useSupply();
|
|
24
|
-
|
|
25
|
-
const handleSupply = async () => {
|
|
26
|
-
+ if (!walletProvider) return;
|
|
27
|
-
- const result = await supply.mutateAsync({ params: { token, amount, action: 'supply' } });
|
|
28
|
-
- if (result.ok) {
|
|
29
|
-
- const txHashPair = result.value;
|
|
30
|
-
- /* ... */
|
|
31
|
-
- }
|
|
32
|
-
+ const result = await supply({
|
|
33
|
-
+ params: {
|
|
34
|
-
+ srcChainKey: ChainKeys.BASE_MAINNET, // NEW: required
|
|
35
|
-
+ srcAddress, // NEW: required
|
|
36
|
-
+ token,
|
|
37
|
-
+ amount,
|
|
38
|
-
+ action: 'supply',
|
|
39
|
-
+ },
|
|
40
|
-
+ walletProvider,
|
|
41
|
-
+ });
|
|
42
|
-
+ if (!result.ok) return;
|
|
43
|
-
+ const { srcChainTxHash, dstChainTxHash } = result.value; // TxHashPair
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
`useBorrow`, `useWithdraw`, `useRepay` follow the same pattern with their respective `action` literals (`'borrow'` / `'withdraw'` / `'repay'`). Borrow + repay can specify optional `dstChainKey` / `dstAddress` for cross-chain delivery.
|
|
49
|
-
|
|
50
|
-
### `useMMAllowance` — auto-skip
|
|
51
|
-
|
|
52
|
-
```diff
|
|
53
|
-
- const { data: isApproved } = useMMAllowance({ params, spokeProvider });
|
|
54
|
-
+ const { data: isApproved } = useMMAllowance({ params: { payload: params } });
|
|
55
|
-
+ // No walletProvider — read-only (SDK call uses `raw: true` internally).
|
|
56
|
-
+ // For borrow/withdraw actions, returns `true` synchronously (no RPC call).
|
|
57
|
-
+ // For supply/repay, reads on-chain allowance.
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### `useMMApprove`
|
|
61
|
-
|
|
62
|
-
```diff
|
|
63
|
-
- const { approve, isLoading } = useMMApprove(spokeProvider);
|
|
64
|
-
- await approve(params);
|
|
65
|
-
+ const { mutateAsync: approve, isPending } = useMMApprove();
|
|
66
|
-
+ await approve({ params, walletProvider });
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Reserve data hooks
|
|
70
|
-
|
|
71
|
-
Most got the single-object shape:
|
|
72
|
-
|
|
73
|
-
```diff
|
|
74
|
-
- const { data } = useReservesData({ ...refetchOptions });
|
|
75
|
-
+ const { data } = useReservesData({ queryOptions: { ...refetchOptions } });
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
User-position hooks renamed param fields:
|
|
79
|
-
|
|
80
|
-
```diff
|
|
81
|
-
- const { data } = useUserFormattedSummary({ spokeChainKey, address: userAddress });
|
|
82
|
-
+ const { data } = useUserFormattedSummary({ params: { spokeChainKey, userAddress } });
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Pitfalls
|
|
86
|
-
|
|
87
|
-
1. **`srcAddress` is the user's spoke-side address**, not the hub address. Hub wallet is derived internally.
|
|
88
|
-
2. **`useMMAllowance` returns `true` instantly for borrow/withdraw** — don't wait on the query state. Branch on `isApproved` directly.
|
|
89
|
-
3. **Cross-chain borrow/repay**: omit `dstChainKey` / `dstAddress` for same-chain. Don't pass `dstChainKey === srcChainKey` (let the default kick in).
|
|
90
|
-
4. **`MoneyMarketSupplyParams<K>` is now generic.** Use `as const` on `srcChainKey` for narrowing: `srcChainKey: ChainKeys.BASE_MAINNET as const`.
|
|
91
|
-
|
|
92
|
-
## Cross-references
|
|
93
|
-
|
|
94
|
-
- [`../../integration/features/money-market.md`](../../integration/features/money-market.md) — v2 reference.
|
|
95
|
-
- [`../../integration/recipes/money-market.md`](../../integration/recipes/money-market.md) — full v2 worked example.
|
|
96
|
-
- [`../breaking-changes/sdk-leakage.md`](../breaking-changes/sdk-leakage.md) — `srcChainKey`/`srcAddress` required.
|
|
97
|
-
- [`../../../../sdk/ai-exported/migration/features/money-market.md`](../../../../sdk/ai-exported/migration/features/money-market.md) — underlying SDK MM migration.
|