Skip to main content
High-level React hooks library for dApp developers. Wraps @sodax/sdk with React Query into feature-organized hooks. Used alongside @sodax/wallet-sdk-react (no direct dependency — shared types come from @sodax/sdk).

Features

  • Swap/Intent — useQuote, useSwap, useSwapAllowance, useSwapApprove, useCancelSwap, useCreateLimitOrder, useCancelLimitOrder, useStatus
  • Bridge — useBridge, useBridgeDetailedStatus, useBridgeAllowance, useBridgeApprove, useGetBridgeableAmount, useGetBridgeableTokens
  • Money Market — useSupply, useWithdraw, useBorrow, useRepay, useMMAllowance, useMMApprove, plus reserves data hooks
  • Staking — useStake, useUnstake, useInstantUnstake, useClaim, useCancelUnstake, approval hooks, info/config/ratio queries
  • DEX — useDexDeposit, useDexWithdraw, useSupplyLiquidity, useDecreaseLiquidity, useClaimRewards, pool/position queries, param builders
  • Leverage Yield — useLeverageYieldDeposit, useLeverageYieldWithdraw, useLeverageYieldVaultSwap, useLeverageYieldDetailedStatus, useLeverageYieldNotifySolver, plus vault position/APR/TVL/share queries
  • Migration — useMigrateIcxToSoda, useRevertMigrateSodaToIcx, useMigratebnUSD, useMigrateBaln, useMigrationApprove, useMigrationAllowance
  • Bitcoin (Bound Exchange) — useRadfiAuth, useEnsureRadfiAccessToken, useRadfiSession, useTradingWallet, useTradingWalletBalance, useBitcoinBalance, useBitcoinTradingSetup, useFundTradingWallet, useRadfiWithdraw, useExpiredUtxos, useRenewUtxos
  • Partner — useFetchAssetsBalances, useGetAutoSwapPreferences, useIsTokenApproved, useApproveToken, useSetSwapPreference, useFeeClaimSwap, useFeeClaimWithdraw, usePartnerCancelIntent, useGetUserIntent, useGetIntentDetails
  • Recovery — useHubAssetBalances, useWithdrawHubAsset
  • Backend Queries — Intent tracking, swap-tx submission + status, orderbook, money market position queries
  • Shared — useXBalances, useDeriveUserWalletAddress, useGetUserHubWalletAddress, useStellarTrustlineCheck, useEstablishTrustline, useStellarGate, useNearStorageCheck, useRegisterNearStorage, useNearStorageGate, useEstimateGas
  • Sponsoring — useStellarAccountActive, useStellarAccountStatus, useSponsorConfig, useActivateStellarAccount

Installation

Quick Start

1. Set up providers

RPC URLs are injected through config.chains. SodaxProvider is the outermost wrapper; QueryClientProvider wraps everything inside it.
SodaxProvider builds its Sodax instance in the browser, so sodaxConfig ships in your bundle. Leave apiKey out of it: to send a SODAX API key, point api.baseURL and solver.solverApiEndpoint at your own backend proxy and attach the key there — see API key good practices.

2. Get a wallet provider

3. Use feature hooks

All mutation hooks accept no arguments at initialization. Domain inputs (params, walletProvider) flow through mutate(vars):

Requirements

  • Node.js >= 22.12.0
  • React >= 18
  • TypeScript

API Reference

Provider

  • SodaxProvider — Wraps your app, creates the Sodax SDK instance. Accepts config?: SodaxOptions.
  • createSodaxQueryClient() — Factory for a QueryClient with global mutation observability (onMutationError hook, meta.silent opt-out).

Swap Hooks

Money Market Hooks

Bridge Hooks

Staking Hooks

Leverage Position Hooks

A position is one Aave account owned by the user’s hub wallet, never their signing address — pass the signer as params.srcAddress and the SDK resolves the owner. Which write hook to use is decided by the operation, not by preference. increaseLeverage and decreaseLeverage only post a solver intent, and an intent the solver was never told about expires unfilled, so those go through useSubmitLeveragePositionIntent(), which reports it. withdraw, settle and cancel are synchronous on the hub and need no notification.
Resolving means the intent is live, not that leverage moved. Off-hub (spoke) origins are experimental and unverified on-chain; see each hook’s JSDoc.

DEX Hooks

Leverage Yield Hooks

Migration Hooks

Bitcoin (Bound Exchange) Hooks

Partner Hooks

Recovery Hooks

Shared Hooks

Sponsoring Hooks

Stellar accounts must exist on-chain before they can hold or receive anything, and a new user holds 0 XLM. These drive sponsored activation, where the SODAX sponsor pays the account’s base reserve.

Backend Query Hooks

Swaps API Hooks (sodax.api.swaps)

Typed wrappers over the backend Swaps API — one useSwapsApi* hook per endpoint (21 total). Highlights: See src/hooks/swapsApi/ for the full set (tokens, deadline, allowance, approve, submit/cancel intent, status, hash, packet, extra-data, intent lookups, limit orders, gas, fees).

Bridge API Hooks (sodax.api.bridge)

Typed wrappers over the backend Bridge API v2 — one useBridgeApi* hook per endpoint. Highlights: See src/hooks/bridgeApi/ for the full set (tokens, allowance, approve, create intent, fee, bridgeable amount, bridgeable pair).

API-key failures are terminal

Every retrying useSwapsApi*, useLeverageYieldApi* and useBridgeApi* hook defaults retry to retryUnlessAuthFailure(): transport blips retry up to 3 times, a 401/403 never replays. useSwapsApiStatus, useSwapsApiSubmitTxStatus, useLeverageYieldApiSubmitTxStatus and useBridgeApiSubmitTxStatus stop their 1s poll on a rejected key too, since retry bounds attempts within a tick rather than the interval — so a bad key surfaces once, on error, instead of re-requesting forever. Override either through queryOptions / mutationOptions. useDetailedStatus and useBridgeDetailedStatus stop on a rejected key as well, but by a different route: the SDK hands them the 401/403 inside a Result rather than throwing, so React Query never sees an error and retry has nothing to withhold. Their poll interval checks isAuthFailure(data.error) instead. It has to — a rejected key leaves the backend unanswered, so a relay miss behind it is never tagged DETAILED_STATUS_NOT_DELIVERED, and the not-delivered budget that stops every other unresolved read would never advance.

Utils

DEX param builders: NEAR storage gate:
  • resolveNearStorageGate() — Derive the NEP-141 storage-registration UI gate state (hook-free counterpart of useNearStorageGate)

Development

AI agent docs

AI-readable docs for @sodax/dapp-kit (and the other @sodax/* packages) are shipped via @sodax/skills — a separate npm package bundling Claude-Code SKILL.md files and a long-form knowledge tree. Recommended: skills CLI — from your project root:
npm + AGENTS.md pointer (fallback for web chats, or when you prefer a devDependency over the CLI):
Then point your agent at node_modules/@sodax/skills/AGENTS.md. See docs/ai-integration-guide.md for all install modes and per-tool wiring.

License

MIT

Support