@sodax/skills 2.0.0-rc.10

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.
Files changed (202) hide show
  1. package/.claude-plugin/plugin.json +18 -0
  2. package/AGENTS.md +83 -0
  3. package/LICENSE +21 -0
  4. package/README.md +49 -0
  5. package/package.json +58 -0
  6. package/skills/sodax-dapp-kit/SKILL.md +129 -0
  7. package/skills/sodax-dapp-kit/integration/knowledge/README.md +49 -0
  8. package/skills/sodax-dapp-kit/integration/knowledge/ai-rules.md +80 -0
  9. package/skills/sodax-dapp-kit/integration/knowledge/architecture.md +276 -0
  10. package/skills/sodax-dapp-kit/integration/knowledge/features/README.md +29 -0
  11. package/skills/sodax-dapp-kit/integration/knowledge/features/auxiliary-services.md +169 -0
  12. package/skills/sodax-dapp-kit/integration/knowledge/features/bitcoin.md +87 -0
  13. package/skills/sodax-dapp-kit/integration/knowledge/features/bridge.md +91 -0
  14. package/skills/sodax-dapp-kit/integration/knowledge/features/dex.md +152 -0
  15. package/skills/sodax-dapp-kit/integration/knowledge/features/migration.md +118 -0
  16. package/skills/sodax-dapp-kit/integration/knowledge/features/money-market.md +144 -0
  17. package/skills/sodax-dapp-kit/integration/knowledge/features/staking.md +123 -0
  18. package/skills/sodax-dapp-kit/integration/knowledge/features/swap.md +101 -0
  19. package/skills/sodax-dapp-kit/integration/knowledge/quickstart.md +188 -0
  20. package/skills/sodax-dapp-kit/integration/knowledge/recipes/README.md +136 -0
  21. package/skills/sodax-dapp-kit/integration/knowledge/recipes/backend-queries.md +157 -0
  22. package/skills/sodax-dapp-kit/integration/knowledge/recipes/bitcoin.md +193 -0
  23. package/skills/sodax-dapp-kit/integration/knowledge/recipes/bridge.md +174 -0
  24. package/skills/sodax-dapp-kit/integration/knowledge/recipes/dex.md +204 -0
  25. package/skills/sodax-dapp-kit/integration/knowledge/recipes/invalidations.md +115 -0
  26. package/skills/sodax-dapp-kit/integration/knowledge/recipes/migration.md +212 -0
  27. package/skills/sodax-dapp-kit/integration/knowledge/recipes/money-market.md +207 -0
  28. package/skills/sodax-dapp-kit/integration/knowledge/recipes/mutation-error-handling.md +118 -0
  29. package/skills/sodax-dapp-kit/integration/knowledge/recipes/observability.md +93 -0
  30. package/skills/sodax-dapp-kit/integration/knowledge/recipes/setup.md +168 -0
  31. package/skills/sodax-dapp-kit/integration/knowledge/recipes/staking.md +202 -0
  32. package/skills/sodax-dapp-kit/integration/knowledge/recipes/swap.md +272 -0
  33. package/skills/sodax-dapp-kit/integration/knowledge/recipes/wallet-connectivity.md +128 -0
  34. package/skills/sodax-dapp-kit/integration/knowledge/reference/README.md +12 -0
  35. package/skills/sodax-dapp-kit/integration/knowledge/reference/glossary.md +190 -0
  36. package/skills/sodax-dapp-kit/integration/knowledge/reference/hooks-index.md +190 -0
  37. package/skills/sodax-dapp-kit/integration/knowledge/reference/public-api.md +110 -0
  38. package/skills/sodax-dapp-kit/integration/knowledge/reference/querykey-conventions.md +179 -0
  39. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/README.md +60 -0
  40. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/ai-rules.md +81 -0
  41. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/hook-signatures.md +233 -0
  42. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/querykey-conventions.md +108 -0
  43. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/result-handling.md +211 -0
  44. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/sdk-leakage.md +167 -0
  45. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/checklist.md +89 -0
  46. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/README.md +34 -0
  47. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/auxiliary-services.md +114 -0
  48. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/bitcoin.md +88 -0
  49. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/bridge.md +160 -0
  50. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/dex.md +101 -0
  51. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/migration.md +120 -0
  52. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/money-market.md +139 -0
  53. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/staking.md +109 -0
  54. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/swap.md +133 -0
  55. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/recipes.md +185 -0
  56. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/README.md +15 -0
  57. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/deleted-hooks.md +110 -0
  58. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/error-shape-crosswalk.md +144 -0
  59. package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/renamed-hooks.md +68 -0
  60. package/skills/sodax-sdk/SKILL.md +140 -0
  61. package/skills/sodax-sdk/backend-api/SKILL.md +52 -0
  62. package/skills/sodax-sdk/bridge/SKILL.md +49 -0
  63. package/skills/sodax-sdk/dex/SKILL.md +50 -0
  64. package/skills/sodax-sdk/integration/knowledge/README.md +43 -0
  65. package/skills/sodax-sdk/integration/knowledge/ai-rules.md +75 -0
  66. package/skills/sodax-sdk/integration/knowledge/architecture.md +517 -0
  67. package/skills/sodax-sdk/integration/knowledge/chain-specifics.md +189 -0
  68. package/skills/sodax-sdk/integration/knowledge/features/README.md +21 -0
  69. package/skills/sodax-sdk/integration/knowledge/features/backend-api.md +81 -0
  70. package/skills/sodax-sdk/integration/knowledge/features/bridge.md +172 -0
  71. package/skills/sodax-sdk/integration/knowledge/features/dex.md +182 -0
  72. package/skills/sodax-sdk/integration/knowledge/features/migration.md +181 -0
  73. package/skills/sodax-sdk/integration/knowledge/features/money-market.md +198 -0
  74. package/skills/sodax-sdk/integration/knowledge/features/partner.md +63 -0
  75. package/skills/sodax-sdk/integration/knowledge/features/recovery.md +50 -0
  76. package/skills/sodax-sdk/integration/knowledge/features/staking.md +171 -0
  77. package/skills/sodax-sdk/integration/knowledge/features/swap.md +273 -0
  78. package/skills/sodax-sdk/integration/knowledge/quickstart.md +213 -0
  79. package/skills/sodax-sdk/integration/knowledge/recipes/README.md +21 -0
  80. package/skills/sodax-sdk/integration/knowledge/recipes/backend-server-init.md +69 -0
  81. package/skills/sodax-sdk/integration/knowledge/recipes/chain-key-narrowing.md +65 -0
  82. package/skills/sodax-sdk/integration/knowledge/recipes/gas-estimation.md +33 -0
  83. package/skills/sodax-sdk/integration/knowledge/recipes/initialize-sodax.md +78 -0
  84. package/skills/sodax-sdk/integration/knowledge/recipes/raw-tx-flow.md +71 -0
  85. package/skills/sodax-sdk/integration/knowledge/recipes/result-and-errors.md +104 -0
  86. package/skills/sodax-sdk/integration/knowledge/recipes/signed-tx-flow.md +46 -0
  87. package/skills/sodax-sdk/integration/knowledge/recipes/testing.md +101 -0
  88. package/skills/sodax-sdk/integration/knowledge/reference/README.md +18 -0
  89. package/skills/sodax-sdk/integration/knowledge/reference/chain-keys.md +67 -0
  90. package/skills/sodax-sdk/integration/knowledge/reference/error-codes.md +165 -0
  91. package/skills/sodax-sdk/integration/knowledge/reference/glossary.md +32 -0
  92. package/skills/sodax-sdk/integration/knowledge/reference/public-api.md +138 -0
  93. package/skills/sodax-sdk/integration/knowledge/reference/wallet-providers.md +62 -0
  94. package/skills/sodax-sdk/migration/SKILL.md +65 -0
  95. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/README.md +58 -0
  96. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/ai-rules.md +76 -0
  97. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/breaking-changes/architecture.md +344 -0
  98. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/breaking-changes/result-and-errors.md +363 -0
  99. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/breaking-changes/type-system.md +341 -0
  100. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/checklist.md +67 -0
  101. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/README.md +37 -0
  102. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/backend-api.md +92 -0
  103. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/bridge.md +128 -0
  104. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/dex.md +143 -0
  105. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/migration.md +151 -0
  106. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/money-market.md +214 -0
  107. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/partner.md +59 -0
  108. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/recovery.md +35 -0
  109. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/staking.md +143 -0
  110. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/swap.md +198 -0
  111. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/recipes.md +350 -0
  112. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/README.md +18 -0
  113. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/deleted-exports.md +127 -0
  114. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/error-code-crosswalk.md +104 -0
  115. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/return-shapes.md +49 -0
  116. package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/sodax-config.md +145 -0
  117. package/skills/sodax-sdk/money-market/SKILL.md +52 -0
  118. package/skills/sodax-sdk/partner/SKILL.md +51 -0
  119. package/skills/sodax-sdk/recovery/SKILL.md +49 -0
  120. package/skills/sodax-sdk/staking/SKILL.md +49 -0
  121. package/skills/sodax-sdk/swap/SKILL.md +67 -0
  122. package/skills/sodax-wallet-sdk-core/SKILL.md +114 -0
  123. package/skills/sodax-wallet-sdk-core/integration/knowledge/README.md +108 -0
  124. package/skills/sodax-wallet-sdk-core/integration/knowledge/ai-rules.md +141 -0
  125. package/skills/sodax-wallet-sdk-core/integration/knowledge/architecture.md +212 -0
  126. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/README.md +22 -0
  127. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/bitcoin.md +103 -0
  128. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/evm.md +102 -0
  129. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/icon.md +88 -0
  130. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/injective.md +92 -0
  131. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/near.md +92 -0
  132. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/solana.md +104 -0
  133. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/stacks.md +91 -0
  134. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/stellar.md +95 -0
  135. package/skills/sodax-wallet-sdk-core/integration/knowledge/features/sui.md +96 -0
  136. package/skills/sodax-wallet-sdk-core/integration/knowledge/quickstart.md +259 -0
  137. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/README.md +15 -0
  138. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/bridge-to-sdk.md +145 -0
  139. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/defaults-and-overrides.md +159 -0
  140. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/library-exports.md +129 -0
  141. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/setup-browser-extension.md +137 -0
  142. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/setup-private-key.md +115 -0
  143. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/sign-and-broadcast.md +201 -0
  144. package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/testing.md +163 -0
  145. package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/README.md +13 -0
  146. package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/chain-support.md +65 -0
  147. package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/glossary.md +28 -0
  148. package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/interfaces.md +131 -0
  149. package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/provider-classes.md +54 -0
  150. package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/public-api.md +128 -0
  151. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/README.md +84 -0
  152. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/ai-rules.md +139 -0
  153. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/README.md +14 -0
  154. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/base-wallet-provider.md +52 -0
  155. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/defaults-config.md +57 -0
  156. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/folder-layout.md +99 -0
  157. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/library-exports.md +58 -0
  158. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/checklist.md +62 -0
  159. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/recipes/README.md +12 -0
  160. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/recipes/adopt-defaults.md +84 -0
  161. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/recipes/adopt-library-exports.md +99 -0
  162. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/README.md +12 -0
  163. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/added-fields.md +71 -0
  164. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/deleted-exports.md +35 -0
  165. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/renamed-symbols.md +31 -0
  166. package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/return-shapes.md +23 -0
  167. package/skills/sodax-wallet-sdk-react/SKILL.md +154 -0
  168. package/skills/sodax-wallet-sdk-react/integration/knowledge/README.md +103 -0
  169. package/skills/sodax-wallet-sdk-react/integration/knowledge/ai-rules.md +136 -0
  170. package/skills/sodax-wallet-sdk-react/integration/knowledge/architecture.md +185 -0
  171. package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/01-minimal-evm.tsx +75 -0
  172. package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/02-multi-chain-modal.tsx +169 -0
  173. package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/03-nextjs-app-router.tsx +99 -0
  174. package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/04-walletconnect-setup.tsx +89 -0
  175. package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/README.md +29 -0
  176. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/batch-operations.md +224 -0
  177. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/bridge-to-sdk.md +165 -0
  178. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/chain-detection.md +259 -0
  179. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/connect-button.md +159 -0
  180. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/multi-chain-modal.md +203 -0
  181. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/setup.md +163 -0
  182. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/sign-message.md +138 -0
  183. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/sub-path-imports.md +97 -0
  184. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/switch-chain.md +144 -0
  185. package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/walletconnect-setup.md +139 -0
  186. package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/api-surface.md +176 -0
  187. package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/chain-support.md +79 -0
  188. package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/connectors.md +75 -0
  189. package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/hooks.md +212 -0
  190. package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/wallet-brands.md +107 -0
  191. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/README.md +49 -0
  192. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/ai-rules.md +144 -0
  193. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/breaking-changes.md +310 -0
  194. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/checklist.md +159 -0
  195. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/connect-button.md +170 -0
  196. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/multi-chain-modal.md +245 -0
  197. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/ssr-setup.md +165 -0
  198. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/walletconnect-migration.md +170 -0
  199. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/components.md +75 -0
  200. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/config.md +339 -0
  201. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/hooks.md +336 -0
  202. package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/imports.md +158 -0
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "sodax-skills",
3
+ "skills": [
4
+ "./skills/sodax-sdk",
5
+ "./skills/sodax-sdk/swap",
6
+ "./skills/sodax-sdk/money-market",
7
+ "./skills/sodax-sdk/bridge",
8
+ "./skills/sodax-sdk/staking",
9
+ "./skills/sodax-sdk/dex",
10
+ "./skills/sodax-sdk/migration",
11
+ "./skills/sodax-sdk/partner",
12
+ "./skills/sodax-sdk/recovery",
13
+ "./skills/sodax-sdk/backend-api",
14
+ "./skills/sodax-wallet-sdk-core",
15
+ "./skills/sodax-wallet-sdk-react",
16
+ "./skills/sodax-dapp-kit"
17
+ ]
18
+ }
package/AGENTS.md ADDED
@@ -0,0 +1,83 @@
1
+ # AGENTS.md — `@sodax/skills` router
2
+
3
+ > Tool-neutral entry point. You are looking at the consumer-facing AI material for the `@sodax/*` SDKs. If you can read multiple `SKILL.md` files, load **2–3 skills** based on what the user is building (table below). Then follow each skill's internal workflow.
4
+
5
+ ## What's here
6
+
7
+ This package ships **four mode-gated broad skills** (`skills/<name>/SKILL.md`) — one per SODAX SDK package — plus **nested granular per-feature skills** under `sodax-sdk` (one per Core SDK feature service). Each broad skill bundles two long-form **knowledge** subtrees: `integration/knowledge/` (writing new v2 code) and `migration-v1-to-v2/knowledge/` (porting v1 → v2). Granular skills are single-file SKILL.md that link into their parent's knowledge tree. Skills are action-oriented (when to use, workflow, anti-patterns, links into knowledge); knowledge is the reference material your workflow points at. SKILL.md gates by mode at the top — pick integration or migration based on the consumer signal.
8
+
9
+ | SDK package | Broad skill | Granular per-feature skills |
10
+ |---|---|---|
11
+ | `@sodax/sdk` | `sodax-sdk` | `sodax-sdk/swap`, `sodax-sdk/money-market`, `sodax-sdk/bridge`, `sodax-sdk/staking`, `sodax-sdk/dex`, `sodax-sdk/migration`, `sodax-sdk/partner`, `sodax-sdk/recovery`, `sodax-sdk/backend-api` |
12
+ | `@sodax/wallet-sdk-core` | `sodax-wallet-sdk-core` | — |
13
+ | `@sodax/wallet-sdk-react` | `sodax-wallet-sdk-react` | — |
14
+ | `@sodax/dapp-kit` | `sodax-dapp-kit` | — |
15
+
16
+ **When to prefer a granular skill:** if the consumer has already picked a feature (e.g. *"swap with Sodax"*, *"supply on money market"*), load the matching granular skill — it's ~3 KB vs `sodax-sdk`'s ~13 KB and points at exactly the knowledge files needed for that feature. Load the broad `sodax-sdk` skill when the feature is undecided, the task spans multiple features, or the consumer is porting a full v1 codebase.
17
+
18
+ > **What about `@sodax/types`?** No skill. The package has no consumer-facing surface — it's pure TypeScript types, re-exported through `@sodax/sdk`. Importing `@sodax/types` directly invites version skew. The SDK skills cover all `@sodax/types` symbols you need.
19
+
20
+ ## Route by consumer intent
21
+
22
+ Pick the consumer's situation, load the listed skills in order. Each entry names the **skill** + the **mode** to run it in. SKILL.md has the mode decision-tree at the top — follow that section.
23
+
24
+ | Consumer is… | Load skills (mode) |
25
+ |---|---|
26
+ | **Scaffolding ONE specific Core SDK feature** (swap, money-market, bridge, staking, dex, migration, partner, recovery, backend-api) | `sodax-sdk/<feature>` (granular, covers both modes via internal links). Add `sodax-wallet-sdk-core` (integration) if it signs and lives outside React. Skip the broad `sodax-sdk` skill |
27
+ | **Building a NEW React dapp** | `sodax-wallet-sdk-react` (integration) → `sodax-dapp-kit` (integration) → (`sodax-sdk` (integration) only if dropping below dapp-kit) |
28
+ | **Building a NEW React app, no dapp-kit** (calling the SDK directly) | `sodax-wallet-sdk-react` (integration) → `sodax-sdk` (integration) |
29
+ | **Building a NEW Node / backend service or script** | `sodax-sdk` (integration) → `sodax-wallet-sdk-core` (integration; only if it signs) |
30
+ | **Building a NEW non-React browser flow** | `sodax-wallet-sdk-core` (integration) → `sodax-sdk` (integration) |
31
+ | **Porting an EXISTING v1 React dapp** | `sodax-wallet-sdk-react` (migration) → `sodax-dapp-kit` (migration) → `sodax-sdk` (migration). Then switch each skill to integration mode for any new code. |
32
+ | **Porting an EXISTING v1 backend** | `sodax-sdk` (migration) → `sodax-wallet-sdk-core` (migration; often no-op — additive only) |
33
+
34
+ If you don't know which situation applies, **ask the user** rather than guessing. Two signals to listen for:
35
+
36
+ - "Migrate / upgrade / port" + v1 fingerprints (`useSpokeProvider`, `*_MAINNET_CHAIN_ID`, `xChainId`, `useXWagmiStore`, `MoneyMarketError`/`IntentError`/etc.) → migration first.
37
+ - "Add / build / integrate" + no existing SODAX code → integration only.
38
+
39
+ If both: do migration first. Stale v1 patterns leak into new code if you skip it.
40
+
41
+ ## How to use a skill
42
+
43
+ Each `SKILL.md` is short on purpose. Follow it like a procedure:
44
+
45
+ 1. The skill's frontmatter `description` tells you the trigger conditions.
46
+ 2. The body's **Workflow** section links into knowledge files. Read them in order — token budgets are sized so the right 2–3 files fit in your context.
47
+ 3. The **Top traps** + **Conventions** sections are the consolidated DO / DO NOT list. Skipping them is the most common cause of generating v1 code.
48
+ 4. The **Verification** section is the done-criteria. Run those checks before reporting the task complete.
49
+
50
+ ## Layout reference
51
+
52
+ ```
53
+ packages/skills/
54
+ ├── AGENTS.md # You are here
55
+ ├── .claude-plugin/plugin.json # Skill registry (broad + nested granular paths)
56
+ └── skills/ # Each broad skill is mode-gated; some have nested granular children
57
+ ├── sodax-sdk/ {SKILL.md, integration/knowledge/, migration-v1-to-v2/knowledge/,
58
+ │ <feature>/SKILL.md ×9 — swap, money-market, bridge, staking, dex,
59
+ │ migration, partner, recovery, backend-api}
60
+ ├── sodax-wallet-sdk-core/ {SKILL.md, integration/knowledge/, migration-v1-to-v2/knowledge/}
61
+ ├── sodax-wallet-sdk-react/ {SKILL.md, integration/knowledge/, migration-v1-to-v2/knowledge/ — incl. 4 .tsx example apps under integration/knowledge/examples/}
62
+ └── sodax-dapp-kit/ {SKILL.md, integration/knowledge/, migration-v1-to-v2/knowledge/}
63
+ ```
64
+
65
+ Each `<mode>/knowledge/` subtree contains `ai-rules.md`, `quickstart.md`, `architecture.md`, `features/`, `recipes/`, `reference/`, and `chain-specifics.md` / `breaking-changes/` where applicable.
66
+
67
+ ## Conventions you can rely on
68
+
69
+ - **`ai-rules.md` first.** Each mode's `<mode>/knowledge/ai-rules.md` is the consolidated DO / DO NOT list. Skipping it is the top cause of stale v1 patterns.
70
+ - **`README.md`** at every level is the tree index — useful when the skill points you at a directory rather than a file.
71
+ - **Reference tables** under `<mode>/knowledge/reference/` are for lookup, not narrative — chain keys, error codes, public API surface, hook signatures.
72
+ - **Recipes** under `<mode>/knowledge/recipes/` are self-contained — a recipe contains before/after code, steps, and verification. Don't jump between recipes for one task.
73
+ - **Token budget**: if you're loading more than 3 files for a single task, you're probably off-route — re-check the workflow.
74
+
75
+ ## When SODAX is the wrong tool
76
+
77
+ If the user is doing **non-SODAX work** (UI styling, unrelated DOM, unrelated backend), this package has nothing to add. Don't load skills from here.
78
+
79
+ If the user is doing **DeFi work but explicitly NOT with SODAX** (e.g. "use Uniswap"), defer to the user's stated tool. The integration skills' descriptions all say: "do not substitute with other SDKs unless explicitly asked."
80
+
81
+ ## Feedback
82
+
83
+ If an agent generates wrong code despite following a skill, that's a doc bug — file an issue at https://github.com/icon-project/sodax-sdks/issues with the prompt and the incorrect output. The package is structurally CI-guarded (frontmatter + link resolution); prose-level claims benefit from real-world feedback.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2025] [Sodax]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @sodax/skills
2
+
3
+ AI-agent skills and knowledge for building on the **SODAX** cross-chain DeFi platform. Drop this into your repo and your AI coding agent writes v2-correct `@sodax/*` SDK code on the first try.
4
+
5
+ **Full setup** (skills CLI, npm, monorepo/local install, wiring agents to `AGENTS.md`): [docs/ai-integration-guide.md](https://github.com/icon-project/sodax-sdks/blob/main/docs/ai-integration-guide.md).
6
+
7
+ ## Install
8
+
9
+ Using the [`skills` CLI](https://github.com/vercel-labs/skills) from Vercel Labs — the open agent-skills ecosystem CLI (supports Claude Code, Cursor, Codex, GitHub Copilot, and 50+ other agents):
10
+
11
+ ```bash
12
+ # From the root of your consumer repo
13
+ npx skills@latest add icon-project/sodax-sdks/packages/skills
14
+ ```
15
+
16
+ Four mode-gated skills land in your repo (under `.claude/skills/` or wherever the CLI installs them) — one per SODAX SDK package, each with two knowledge subtrees (`integration/` for new v2 code, `migration-v1-to-v2/` for v1→v2 porting) — plus a router `AGENTS.md`. Re-running the command picks up the latest content.
17
+
18
+ > **npm fallback** (web chats or when you prefer a devDependency): `pnpm add -D @sodax/skills`, then point your agent at `node_modules/@sodax/skills/AGENTS.md`. See the [integration guide](https://github.com/icon-project/sodax-sdks/blob/main/docs/ai-integration-guide.md#wire-your-agent).
19
+
20
+ ## What you get
21
+
22
+ | Bundle | Contains |
23
+ |---|---|
24
+ | **4 mode-gated skills** under `skills/sodax-<pkg>/SKILL.md` | One skill per SODAX SDK package. `<pkg>` ∈ `sdk`, `wallet-sdk-core`, `wallet-sdk-react`, `dapp-kit`. Each SKILL.md gates by mode (integration vs migration) at the top of the body. |
25
+ | **Knowledge** under `skills/sodax-<pkg>/{integration,migration-v1-to-v2}/knowledge/` | Long-form supporting docs — features, recipes, reference tables, breaking-change writeups, code examples. Each skill ships both mode subtrees so `npx skills add` copies the full reference together. |
26
+ | **`AGENTS.md`** at the package root | Tool-neutral router: maps the consumer's stated task to the right skill + mode. |
27
+
28
+ Skills are short and action-oriented (workflow + anti-patterns + links). Knowledge is the lookup material. Don't read knowledge files top-to-bottom — the skill tells the agent which file is relevant for the current task.
29
+
30
+ ## Which skill applies?
31
+
32
+ After install, your agent picks based on what you're building. Quick guide:
33
+
34
+ | You're building | Load these skills (mode) |
35
+ |---|---|
36
+ | Backend / Node app (no React) using `@sodax/sdk` | `sodax-sdk` (integration) + `sodax-wallet-sdk-core` (integration; if signing) |
37
+ | React dapp using `@sodax/dapp-kit` | `sodax-dapp-kit` (integration) + `sodax-wallet-sdk-react` (integration; always) + `sodax-sdk` (integration; for any unwrapped operations) |
38
+ | React app calling the SDK directly (no `dapp-kit`) | `sodax-sdk` (integration) + `sodax-wallet-sdk-react` (integration) |
39
+ | **Porting v1 code** | Same skills, switched to migration mode (each SKILL.md mode-gates by consumer signal). |
40
+
41
+ `AGENTS.md` says the same thing in router form — your agent reads it first and picks.
42
+
43
+ ## Why this exists
44
+
45
+ LLM training data drifts: snippets from chat often use stale method names, reshaped types, or outdated error codes. Public docs help humans, not agents — an agent only reads what's in its context window. This package ships the right material in agent-native form so the agent reads it before generating code. The content is version-locked to the SDK — upgrade `@sodax/skills`, the docs upgrade with it.
46
+
47
+ ## Feedback
48
+
49
+ If your agent generates wrong code despite reading the docs, that's a doc bug — please open an issue on the [Sodax SDKs repo](https://github.com/icon-project/sodax-sdks/issues) with the prompt and the incorrect output. The per-skill `knowledge/` subtrees are structurally CI-guarded (frontmatter, link resolution); prose claims benefit from real-world feedback.
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@sodax/skills",
3
+ "private": false,
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "version": "2.0.0-rc.10",
8
+ "license": "MIT",
9
+ "description": "AI-agent skills and knowledge for consumers of @sodax/* SDKs (Claude Code, Codex, Cursor, …)",
10
+ "keywords": [
11
+ "sodax",
12
+ "skills",
13
+ "ai",
14
+ "claude-code",
15
+ "agents"
16
+ ],
17
+ "homepage": "https://github.com/icon-project/sodax-sdks/tree/main/packages/skills",
18
+ "bugs": {
19
+ "url": "https://github.com/icon-project/sodax-sdks/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/icon-project/sodax-sdks"
24
+ },
25
+ "type": "module",
26
+ "engines": {
27
+ "node": ">=20.0.0"
28
+ },
29
+ "files": [
30
+ ".claude-plugin",
31
+ "skills",
32
+ "AGENTS.md",
33
+ "README.md"
34
+ ],
35
+ "devDependencies": {
36
+ "typescript": "5.5.4",
37
+ "@tanstack/react-query": "5.87.4",
38
+ "@types/react": "19.0.8",
39
+ "@types/react-dom": "19.0.3",
40
+ "react": "19.1.1",
41
+ "react-dom": "19.1.1",
42
+ "viem": "2.29.2",
43
+ "yaml": "2.8.2"
44
+ },
45
+ "scripts": {
46
+ "lint": "biome lint . --write",
47
+ "pretty": "biome format . --write",
48
+ "check:ai-structural": "bash ./scripts/check-skills.sh",
49
+ "check:ai-imports": "bash ./scripts/check-ai-imports.sh",
50
+ "check:ai-snippets": "bash ./scripts/check-ai-snippets.sh",
51
+ "check:ai-tsx-examples": "bash ./scripts/check-ai-tsx-examples.sh",
52
+ "check:ai-keys": "bash ./scripts/check-ai-keys.sh",
53
+ "check:ai-consistency": "bash ./scripts/check-ai-consistency.sh",
54
+ "check:ai": "pnpm run check:ai-structural && pnpm run check:ai-imports && pnpm run check:ai-snippets && pnpm run check:ai-tsx-examples && pnpm run check:ai-keys && pnpm run check:ai-consistency",
55
+ "ci": "pnpm run pretty && pnpm run check:ai",
56
+ "clean": "rm -rf node_modules && rm -rf .turbo"
57
+ }
58
+ }
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: sodax-dapp-kit
3
+ description: 'INTEGRATION (write NEW code) — @sodax/dapp-kit is React hooks wrapping @sodax/sdk with React Query across 11 feature domains (swap, money market, staking, bridge, dex, migration, partner, recovery, bitcoin/Radfi, backend queries, shared). React-only — Node and backend code uses `@sodax/sdk` directly. Use whenever a React dapp needs SODAX feature hooks. Triggers on "use @sodax/dapp-kit", "useSwap", "useMoneyMarket", "useStake", "useBridge", "useDex", "useMigrate", any `use<Feature>` hook name from dapp-kit, "Sodax React hooks", "dapp-kit query / mutation". v2 hook shape: mutation hooks return `SafeUseMutationResult` with `mutateAsyncSafe(vars): Promise<Result<TData>>`. mutationFn unwraps SDK Result<T> and throws on `!ok` so React Query''s native error model engages. Hook-owned invalidations — consumer onSuccess runs after. MIGRATION (port v1 → v2) — a deep canonicalization pass: single-object hook params, mandatory `mutateAsyncSafe`, hook-owned invalidations, throw-on-`Result.!ok` inside `mutationFn`, canonical queryKey/mutationKey conventions. Plus the SDK underneath was reshaped (chain-key-driven routing, `Result<T>` everywhere, `WalletProviderSlot<K, Raw>`). v1 dapp-kit code will not compile against v2. Triggers on "migrate @sodax/dapp-kit", "useSpokeProvider gone", "dapp-kit v1 → v2", "invalidateMmQueries broken", "dapp-kit hook signatures changed", v1 fingerprints (positional args, hook-init `spokeProvider`, `useSpokeProvider`, `invalidateMmQueries`, legacy `useMigrate`, `*_MAINNET_CHAIN_ID`). Load this skill if EITHER applies; the body gates by mode.'
4
+ ---
5
+
6
+ # When to use this skill
7
+
8
+ AGENTS.md routes you here when you're working with `@sodax/dapp-kit` v2 — either writing new code or porting from v1.
9
+
10
+ **Pick your mode:**
11
+
12
+ - Writing NEW v2 code (greenfield dapp-kit usage, no v1 hooks)? → § **Integration mode** below.
13
+ - Porting EXISTING v1 code to v2 (grep finds `useSpokeProvider`, `invalidateMmQueries`, legacy `useMigrate`, `*_MAINNET_CHAIN_ID`)? → § **Migration mode** below.
14
+ - Both? → migration first, then integration. Stale v1 patterns leak into new code if you skip it.
15
+
16
+ For backend / Node → use `sodax-sdk` (dapp-kit is React-only).
17
+ Every dapp-kit consumer also needs wallet connectivity — also load `sodax-wallet-sdk-react`.
18
+
19
+ ---
20
+
21
+ ## Integration mode (writing new v2 code)
22
+
23
+ Pick this mode when the consumer is a React dapp using `@sodax/dapp-kit` hooks. Common signals:
24
+
25
+ - Any feature hook: `useSwap`, `useMoneyMarket*`, `useStake`, `useBridge`, `useDex*`, `useMigrate*`, `useRadfi*`, `usePartner*`, `useRecovery*`.
26
+ - "Wire React Query for SODAX" — `SodaxProvider`, `createSodaxQueryClient`.
27
+ - "Branch on mutation result without try/catch" — `mutateAsyncSafe`.
28
+ - "Custom invalidation on success" — consumer-provided `onSuccess` (note: hook-owned invalidations already run; yours runs *after*).
29
+
30
+ ### Workflow
31
+
32
+ 1. Read [`integration/knowledge/ai-rules.md`](./integration/knowledge/ai-rules.md) — DO / DO NOT / workflow / stop conditions.
33
+ 2. Read [`integration/knowledge/quickstart.md`](./integration/knowledge/quickstart.md) — install + wire providers + first feature.
34
+ 3. Read [`integration/knowledge/architecture.md`](./integration/knowledge/architecture.md) — hook shapes, queryKey conventions, `useSafeMutation`, `unwrapResult`, `Result<T>`.
35
+ 4. For each feature you use, read [`integration/knowledge/features/`](./integration/knowledge/features/) — `swap.md`, `money-market.md`, `staking.md`, `bridge.md`, `dex.md`, `migration.md`, `bitcoin.md` (Radfi, dapp-kit-unique), `auxiliary-services.md` (partner + recovery + backend + shared).
36
+ 5. Recipes → [`integration/knowledge/recipes/`](./integration/knowledge/recipes/) — `setup.md`, `wallet-connectivity.md`, per-feature, `mutation-error-handling.md`, `observability.md`, `invalidations.md`.
37
+ 6. Lookups → [`integration/knowledge/reference/`](./integration/knowledge/reference/) — `hooks-index.md`, `querykey-conventions.md`, `public-api.md`, `glossary.md`.
38
+
39
+ ### v2 in one minute
40
+
41
+ 1. **Hooks accept a single object with one or two top-level keys.** Mutation hooks take only `{ mutationOptions }` at hook-init; query hooks take `{ params, queryOptions }`. ALL domain inputs (`params`, `walletProvider`, per-call config) flow through `mutate(vars)` for mutations.
42
+ 2. **Every mutation hook returns `SafeUseMutationResult`** — extends React Query's `UseMutationResult` with `mutateAsyncSafe(vars): Promise<Result<TData>>` (never rejects). Use `mutateAsyncSafe` for sequenced flows; `mutateAsync` for try/catch flows; `mutate` for fire-and-forget render-driven flows.
43
+ 3. **`mutationFn` throws on SDK `!ok`.** dapp-kit calls `unwrapResult` on the SDK's `Result<T>`, throwing on failure. This makes React Query's native error model engage (`isError`, `error`, `onError`, `retry`, devtools). `mutateAsyncSafe` packages the throw back into `Result<T>` for ergonomic branching.
44
+ 4. **Hook-owned invalidations.** Each mutation hook invalidates the relevant query keys in its `onSuccess`, derived from `vars`. Consumer-provided `onSuccess` runs after. v1's manual `invalidateMmQueries` utilities are gone.
45
+ 5. **Canonical queryKey shape.** `[feature, action, ...identifiers]`. First segment matches the directory name (`swap`, `mm`, `bridge`, `staking`, `dex`, `bitcoin`, `partner`, `recovery`, `backend`, `shared`, `migrate`). camelCase. Bigints stringified.
46
+
47
+ ### Conventions agents must follow (integration)
48
+
49
+ - **Use dapp-kit's exported hooks.** Don't wrap with React Query's `useMutation` directly — consumers depend on `mutateAsyncSafe`.
50
+ - **Branch on `mutateAsyncSafe`'s `Result.ok` for sequenced flows.** The user-reject case is modal, not exceptional.
51
+ - **`ChainKeys.*` over hard-coded chain strings.** The set evolves per release.
52
+ - **Drop `spokeProvider`.** It's not a v2 concept. `walletProvider` flows through `mutate(vars)` for signed flows.
53
+ - **Don't recreate hook-owned invalidations.** Each mutation hook already invalidates the relevant keys; consumer `onSuccess` runs after for any extra logic.
54
+ - Import only from the package root: `import { useSwap, SodaxProvider, createSodaxQueryClient } from '@sodax/dapp-kit'`. dapp-kit re-exports `@sodax/sdk`'s public surface (`ChainKeys`, `SodaxConfig`, types) — you can import them from dapp-kit directly.
55
+ - Don't add `@sodax/types` as a dependency — re-exported via `@sodax/sdk`.
56
+
57
+ ### Top traps to avoid (integration)
58
+
59
+ 1. **Reaching for `useSpokeProvider`.** Deleted. Pass `walletProvider` from `useWalletProvider({ xChainId: chainKey })` (`@sodax/wallet-sdk-react`) directly into `mutate(vars)`.
60
+ 2. **Treating mutation `data` as `Result<T>`.** v2's `mutationFn` unwraps before resolving — `data` is the unwrapped success value (e.g. `SwapResponse`, `TxHashPair`). For SDK failures, look at `mutation.error` or use `mutateAsyncSafe` for the `Result<T>` shape.
61
+ 3. **Forgetting `try/catch` on `mutateAsync`.** v2's `mutateAsync` rejects on SDK `!ok`. Prefer `mutateAsyncSafe` (never rejects).
62
+ 4. **Hook-level `spokeProvider` / `params`.** v1 hooks took these positionally or at hook-init. v2 hooks take only `{ mutationOptions }` (mutations) or `{ params, queryOptions }` (queries). All domain inputs live in `mutate(vars)` for mutations.
63
+ 5. **Reading `xToken.xChainId` or hard-coding `*_MAINNET_CHAIN_ID`.** SDK leakage — these were renamed: `XToken.chainKey`, `ChainKeys.X_MAINNET`.
64
+
65
+ ### Verification (integration)
66
+
67
+ ```bash
68
+ pnpm tsc --noEmit # must exit clean
69
+ ```
70
+
71
+ In browser:
72
+ - Successful mutations populate `data` with the unwrapped success value.
73
+ - SDK `!ok` errors arrive via `mutation.error` (when using `mutate` / `mutateAsync`) or as `result.ok === false` (when using `mutateAsyncSafe`).
74
+ - React Query devtools show hook-owned invalidations firing on success.
75
+
76
+ ---
77
+
78
+ ## Migration mode (v1 → v2 porting)
79
+
80
+ Pick this mode when the consumer has v1 dapp-kit patterns. Grep signals:
81
+
82
+ ```bash
83
+ grep -rE 'useSpokeProvider|invalidateMmQueries|useMigrate\b' src/
84
+ grep -rE '_MAINNET_CHAIN_ID\b|\bxChainId\b' src/
85
+ ```
86
+
87
+ If the project has both v1 patterns AND wants new features: **migration first, then integration**. Stale v1 patterns leak into new code if you skip it.
88
+
89
+ The SDK underneath also changed — load the `sodax-sdk` skill (migration mode) alongside this one (the migration trees cross-link).
90
+
91
+ ### Workflow
92
+
93
+ 1. Read [`migration-v1-to-v2/knowledge/ai-rules.md`](./migration-v1-to-v2/knowledge/ai-rules.md) — DO / DO NOT / workflow / stop conditions.
94
+ 2. Read [`migration-v1-to-v2/knowledge/README.md`](./migration-v1-to-v2/knowledge/README.md) — overview, reading order, glossary.
95
+ 3. Walk [`checklist.md`](./migration-v1-to-v2/knowledge/checklist.md) — top-down cross-cutting steps.
96
+ 4. **Cross-cutting breaking changes** in order:
97
+ - [`breaking-changes/hook-signatures.md`](./migration-v1-to-v2/knowledge/breaking-changes/hook-signatures.md) — single-arg policy + `ReadHookParams` / `MutationHookParams`.
98
+ - [`breaking-changes/result-handling.md`](./migration-v1-to-v2/knowledge/breaking-changes/result-handling.md) — `Result<T>` success-path → throws; `mutateAsyncSafe`.
99
+ - [`breaking-changes/querykey-conventions.md`](./migration-v1-to-v2/knowledge/breaking-changes/querykey-conventions.md) — camelCase + default mutationKey.
100
+ - [`breaking-changes/sdk-leakage.md`](./migration-v1-to-v2/knowledge/breaking-changes/sdk-leakage.md) — cross-links to SDK migration tree.
101
+ 5. **Per-feature playbooks** under [`features/`](./migration-v1-to-v2/knowledge/features/) — `swap.md`, `money-market.md`, `staking.md`, `bridge.md`, `dex.md`, `migration.md`, `bitcoin.md`, `auxiliary-services.md`.
102
+ 6. **Codemods + adapters** → [`recipes.md`](./migration-v1-to-v2/knowledge/recipes.md).
103
+ 7. **Reference** → [`reference/`](./migration-v1-to-v2/knowledge/reference/) — `deleted-hooks.md` (e.g. `useSpokeProvider`, `invalidateMmQueries`, legacy `useMigrate`), `renamed-hooks.md`, `error-shape-crosswalk.md`.
104
+
105
+ ### Top traps to avoid (migration)
106
+
107
+ 1. **Reaching for `useSpokeProvider`.** Deleted. Pass `walletProvider` from `useWalletProvider({ xChainId: chainKey })` (`@sodax/wallet-sdk-react`) directly into `mutate(vars)`.
108
+ 2. **Treating mutation `data` as `Result<T>`.** v2's `mutationFn` unwraps before resolving — `data` is the unwrapped success value.
109
+ 3. **Forgetting `try/catch` on `mutateAsync`.** v2's `mutateAsync` rejects on SDK `!ok`. Prefer `mutateAsyncSafe` (never rejects).
110
+ 4. **Hook-level `spokeProvider` / `params`.** v1 hooks took these positionally or at hook-init. v2 hooks take only `{ mutationOptions }` (mutations) or `{ params, queryOptions }` (queries). All domain inputs live in `mutate(vars)` for mutations.
111
+ 5. **Reading `xToken.xChainId` or hard-coding `*_MAINNET_CHAIN_ID`.** SDK leakage. Renamed: `XToken.chainKey`, `ChainKeys.X_MAINNET`.
112
+
113
+ ### Verification (migration)
114
+
115
+ ```bash
116
+ pnpm tsc --noEmit # must exit clean
117
+ grep -rE 'useSpokeProvider|invalidateMmQueries\b' src/ # empty
118
+ ```
119
+
120
+ Manual:
121
+ - Sequenced flows use `mutateAsyncSafe` and branch on `result.ok`.
122
+ - React Query devtools show hook-owned invalidations on success (consumer `onSuccess` runs after, doesn't duplicate them).
123
+
124
+ ---
125
+
126
+ # Related skills
127
+
128
+ - `sodax-wallet-sdk-react` — wire the wallet, get the `walletProvider` to feed into dapp-kit `mutate(vars)`.
129
+ - `sodax-sdk` — for any direct SDK call alongside dapp-kit hooks (and where the SDK-level v1 → v2 work happens).
@@ -0,0 +1,49 @@
1
+ # Integration — `@sodax/dapp-kit` v2
2
+
3
+ This tree documents v2 of the dapp-kit React hooks for **new consumers** building against it. If you're porting v1 code, start at [`README.md`](../../migration-v1-to-v2/knowledge/README.md) instead.
4
+
5
+ ## Files in this tree
6
+
7
+ | File | What's in it |
8
+ |---|---|
9
+ | [`ai-rules.md`](ai-rules.md) | **Read first.** DO / DO NOT / workflow / stop-conditions for AI agents writing v2 dapp-kit code. |
10
+ | [`quickstart.md`](quickstart.md) | Install, wire providers, get a wallet provider, run your first mutation. |
11
+ | [`architecture.md`](architecture.md) | Every v2 design concept the hooks rest on: ReadHookParams / MutationHookParams, useSafeMutation, unwrapResult, queryKey conventions, mutateAsyncSafe semantics, createSodaxQueryClient. |
12
+ | [`features/swap.md`](features/swap.md) | Swap hooks: `useQuote`, `useSwap`, `useSwapAllowance`, `useSwapApprove`, limit orders, status polling. |
13
+ | [`features/money-market.md`](features/money-market.md) | Money market hooks: `useSupply`, `useBorrow`, `useWithdraw`, `useRepay`, allowance/approve, reserves data. |
14
+ | [`features/staking.md`](features/staking.md) | Staking hooks: `useStake`, `useUnstake`, `useInstantUnstake`, `useClaim`, `useCancelUnstake`, info/ratio reads. |
15
+ | [`features/bridge.md`](features/bridge.md) | Bridge hooks: `useBridge`, allowance/approve, bridgeable amount/tokens. |
16
+ | [`features/dex.md`](features/dex.md) | DEX hooks: deposit/withdraw, supply/decrease liquidity, claim rewards, position info, pools. |
17
+ | [`features/migration.md`](features/migration.md) | Migration hooks: ICX/bnUSD/BALN forward + reverse, allowance/approve. |
18
+ | [`features/bitcoin.md`](features/bitcoin.md) | Radfi hooks (dapp-kit-unique): session, trading wallet, fund/withdraw, UTXOs. |
19
+ | [`features/auxiliary-services.md`](features/auxiliary-services.md) | Partner, recovery, backend queries, shared (xBalances, gas estimation, trustlines). |
20
+ | [`recipes/`](recipes/) | Copy-paste patterns: setup, wallet connectivity, per-feature flows, mutation error handling, observability, invalidations. |
21
+ | [`reference/`](reference/) | Lookup tables: full hook index, queryKey conventions, public API surface, glossary. |
22
+
23
+ ## Reading order for a new integrator
24
+
25
+ 1. **[`ai-rules.md`](ai-rules.md)** — agent rules, before any code.
26
+ 2. **[`quickstart.md`](quickstart.md)** — get providers wired and a button rendering.
27
+ 3. **[`architecture.md`](architecture.md)** — understand `useSafeMutation` / `mutateAsyncSafe` / hook shapes before writing call sites.
28
+ 4. **[`recipes/`](recipes/)** — pick the patterns you need (mutation error handling, observability, invalidations).
29
+ 5. **[`features/<x>.md`](features/)** — read the file for the feature you're integrating (reference shape; pair with the matching recipe in `recipes/<x>.md` for working examples).
30
+ 6. **[`reference/`](reference/)** — keep open while writing for table lookups.
31
+
32
+ ## Cross-references to migration
33
+
34
+ If your project also has v1 dapp-kit call sites, port them first using:
35
+
36
+ - [`README.md`](../../migration-v1-to-v2/knowledge/README.md) — overview, reading order, and v1↔v2 glossary.
37
+ - [`checklist.md`](../../migration-v1-to-v2/knowledge/checklist.md) — top-down cross-cutting checklist.
38
+ - [`breaking-changes/`](../../migration-v1-to-v2/knowledge/breaking-changes/) — the four cross-cutting changes (hook-signatures, result-handling, queryKey-conventions, sdk-leakage).
39
+ - [`features/`](../../migration-v1-to-v2/knowledge/features/) — per-feature playbooks in lockstep with `integration/features/` here.
40
+
41
+ The naming rule: **every file in `integration/features/` has a sibling in `migration/features/` with the same filename.** When you're deep in one, the other is one path-swap away.
42
+
43
+ ## Cross-references to the underlying SDK
44
+
45
+ `@sodax/dapp-kit` re-exports `@sodax/sdk` at the package root, so most types you'd reach for (`ChainKeys`, `SodaxConfig`, `CreateIntentParams`, `XToken`, `Result`, `SodaxError`) are available from `@sodax/dapp-kit` directly. The Core SDK has its own skill — load `sodax-sdk` (integration mode) (sibling under `@sodax/skills`). Useful for:
46
+
47
+ - The full SDK migration playbook for v1→v2 (chain-key terminology, `Result<T>` semantics, ConfigService) — referenced from [`breaking-changes/sdk-leakage.md`](../../migration-v1-to-v2/knowledge/breaking-changes/sdk-leakage.md).
48
+ - Architectural concepts that surface through hook signatures (`SodaxError<C>` vocabulary, `WalletProviderSlot<K, Raw>` discriminator semantics).
49
+ - Backend / Node.js usage patterns (where dapp-kit isn't applicable).
@@ -0,0 +1,80 @@
1
+ # AI rules — `@sodax/dapp-kit` integration
2
+
3
+ DO / DO NOT / workflow / stop conditions for AI agents writing v2 dapp-kit code. Read this **before** the per-feature docs — these rules prevent the most common load-bearing v2 traps.
4
+
5
+ ## Workflow (do these in order)
6
+
7
+ 1. **Survey the project before touching code.**
8
+
9
+ ```bash
10
+ pnpm tsc --noEmit # baseline typecheck
11
+ grep -rE '@sodax/(dapp-kit|sdk|wallet-sdk-react)' --include='*.ts' --include='*.tsx' src/ # see what's already imported
12
+ ```
13
+
14
+ 2. **Wire providers first if not already wired.** [`recipes/setup.md`](recipes/setup.md). Provider stack: `SodaxProvider > QueryClientProvider > SodaxWalletProvider > YourApp`.
15
+ 3. **Pick `mutate` / `mutateAsync` / `mutateAsyncSafe` deliberately.** See [`recipes/mutation-error-handling.md`](recipes/mutation-error-handling.md). Default to `mutateAsyncSafe` for sequenced flows.
16
+ 4. **Branch on `result.ok` for `mutateAsyncSafe` results, or on `mutation.isError` / `mutation.error`** for fire-and-forget. Never assume mutation success.
17
+ 5. **Use `useWalletProvider({ xChainId: chainKey })` from `@sodax/wallet-sdk-react` for every signed flow.** Pass the result into `mutate(vars).walletProvider`. Don't create or import any `*SpokeProvider` class — those don't exist in v2.
18
+
19
+ ## DO
20
+
21
+ - **DO** call dapp-kit's exported hooks (which wrap `useSafeMutation`). Never call React Query's `useMutation` directly inside a wrapper around a dapp-kit hook — consumers depend on `mutateAsyncSafe`.
22
+ - **DO** branch on `mutateAsyncSafe`'s `Result.ok` for sequenced flows (`if (!hasAllowance) await approve(...); await action(...);`). User-rejects are modal, not exceptional.
23
+ - **DO** use `ChainKeys.X_MAINNET` constants for chain identifiers. Never hard-code chain key strings (`'sonic'`, `'0xa4b1.arbitrum'`).
24
+ - **DO** import everything from `@sodax/dapp-kit` (or `@sodax/sdk` for SDK-only types and constants — `@sodax/dapp-kit` re-exports them anyway).
25
+ - **DO** preserve literal chain keys in generic positions where possible (e.g. `srcChainKey: ChainKeys.ETHEREUM_MAINNET as const`) — TypeScript narrowing flows from the literal, including the `walletProvider` parameter type.
26
+ - **DO** use the canonical hook shape: queries take `{ params, queryOptions }`; mutations take only `{ mutationOptions }` and flow domain inputs through `mutate(vars)`.
27
+ - **DO** compose `onSuccess` instead of replacing it: `mutationOptions: { onSuccess: (data, vars, ctx) => myExtra(...) }` runs AFTER dapp-kit's hook-owned invalidations.
28
+
29
+ ## DO NOT
30
+
31
+ - **DO NOT** call `useSpokeProvider` — it's deleted. v1 React consumers got a `SpokeProvider` from this hook; v2 has no such concept. Pass `walletProvider` directly into `mutate(vars)`.
32
+ - **DO NOT** treat mutation `data` as `Result<T>`. `mutationFn` calls `unwrapResult` and throws on `!ok`; `data` is the unwrapped success value (e.g. `SwapResponse`, `TxHashPair`). For SDK failures, look at `mutation.error` or use `mutateAsyncSafe`.
33
+ - **DO NOT** call `mutateAsync` without `try/catch`. It rejects on SDK `!ok`; an unhandled rejection lands in the global handler. Prefer `mutateAsyncSafe` for sequenced flows.
34
+ - **DO NOT** put `params`, `walletProvider`, or per-call config at the hook-init level. They go in `mutate(vars)` for mutations and in `params` for queries.
35
+ - **DO NOT** override `queryKey`, `queryFn`, or `enabled` via `queryOptions` — the hook owns those. The `queryOptions` slot is typed `Omit<UseQueryOptions, 'queryKey' | 'queryFn' | 'enabled'>`.
36
+ - **DO NOT** override `mutationFn` via `mutationOptions` — the hook owns it. Type prevents this.
37
+ - **DO NOT** import from `@sodax/dapp-kit/dist/...`. Deep-imports unstable; only the package root barrel is the public contract.
38
+ - **DO NOT** add `@sodax/types` as a separate dependency. It's re-exported transitively via `@sodax/sdk` (which dapp-kit re-exports). Adding it independently invites version skew.
39
+ - **DO NOT** recreate the v1 `invalidateMmQueries(...)` utility or anything similar. Each mutation hook invalidates the relevant keys in its own `onSuccess`. Add cross-feature invalidations via consumer `onSuccess`.
40
+ - **DO NOT** destructure cross-chain mutation results as arrays — `[a, b] = result.value` is wrong. The shape is `TxHashPair = { srcChainTxHash, dstChainTxHash }` (object). This applies to `useBridge`, `useStake`/`useUnstake`/etc., `useDexDeposit`/`useDexWithdraw`, all four MM mutations, and all four migration mutations.
41
+ - **DO NOT** use legacy chain-id constants (`BSC_MAINNET_CHAIN_ID`, etc.). They're gone in v2 — use `ChainKeys.X_MAINNET`.
42
+ - **DO NOT** reach for `as any` / `as IEvmWalletProvider` casts when wiring `useWalletProvider({ xChainId })` into mutation `mutate(vars)`. v2 supports the broad-union case structurally; the cast is not needed. See `recipes/wallet-connectivity.md` § "No type cast is needed".
43
+
44
+ ## Stop conditions (defer to user)
45
+
46
+ | Signal | Why stop |
47
+ |---|---|
48
+ | User wants a chain not in `ChainKeys.*` | Adding a new chain requires SDK-level changes — out of scope for consumer code. |
49
+ | User wants to use React Server Components / RSC patterns | dapp-kit is client-side React (uses React Query, hooks, browser APIs). Server Components don't run hooks. Tell the user the dapp-kit code goes in client components. |
50
+ | User wants to skip the wallet-sdk-react integration | If they have their own wallet abstraction, it's possible — they need to construct objects satisfying `I*WalletProvider` interfaces from `@sodax/sdk`. Refer them to the `sodax-sdk` (integration mode) skill (sibling under `@sodax/skills`) for non-React patterns. |
51
+ | User wants to use v1 dapp-kit (positional args, `useSpokeProvider`, `Result<T>` in success path) | Tell them to either upgrade or stay on v1. The shapes are not compatible. |
52
+
53
+ ## Verification protocol
54
+
55
+ Before declaring a dapp-kit integration "done":
56
+
57
+ ```bash
58
+ # 1. Type-check the consumer.
59
+ pnpm -C <consumer> tsc --noEmit
60
+
61
+ # 2. Confirm no leftover v1 patterns (if porting).
62
+ grep -rE '\buseSpokeProvider\b|\binvalidateMmQueries\b|_MAINNET_CHAIN_ID\b|\bxChainId\b' src/
63
+
64
+ # 3. Confirm all SDK-level mutation results are handled (either mutateAsyncSafe + result.ok branch
65
+ # or mutateAsync wrapped in try/catch).
66
+ grep -rE 'mutateAsync\(' src/ | grep -v 'try\|catch\|mutateAsyncSafe'
67
+
68
+ # 4. Confirm all hooks are imported from @sodax/dapp-kit, not deep paths.
69
+ # (matches `'@sodax/dapp-kit/dist'` and similar deep-import patterns)
70
+ grep -rE "@sodax/dapp-kit/[a-z]" src/ # zero hits expected (only the root path is public)
71
+ ```
72
+
73
+ ## Done criteria
74
+
75
+ - [ ] `SodaxProvider` + `QueryClientProvider` (preferably `createSodaxQueryClient()`) wired at the app root.
76
+ - [ ] Every mutation invocation uses `mutateAsyncSafe` (preferred), `mutateAsync` wrapped in `try/catch`, or fire-and-forget `mutate` with state read in render.
77
+ - [ ] No `useSpokeProvider`, no `invalidateMmQueries`, no `*_MAINNET_CHAIN_ID` constants, no `xChainId` outside known v2 hooks (e.g. `useXBalances` still uses `xChainId`).
78
+ - [ ] No `import` from `@sodax/dapp-kit/dist/...` or any other deep path.
79
+ - [ ] No standalone `@sodax/types` dependency in `package.json`.
80
+ - [ ] Consumer typecheck (`pnpm tsc --noEmit`) is clean.