OneShot SDK (v2)
Unified cross-chain quoting, execution, and wallet helpers for CrossChain Swaps. Works in browsers, Node.js, or serverless environments.
Features
- 🔄 Unified Cross-Chain Swaps - Seamless asset swaps across multi-chain networks
- 💰 Unified Balances - Fetch and cache real-time balances across all supported chains
- 📊 Smart Quoting Engine - Get accurate quotes with dynamic routes and live pricing
- 🔍 Token Discovery - Unified token search, metadata, and price lookup
- 🔗 Wallet-Agnostic Execution - Viem, Ethers, Solana, or custom wallet adapters
Core Concepts
- Headless Core SDK –
OneShotSDKexposes quote, execution, balance, and token search APIs that run in browsers, serverless, or Node without any framework assumptions. - Framework Bindings – React hooks (backed by SWR) and Vue composables wrap the same SDK instance, giving you cached quotes, balances, and execution state while preserving idiomatic patterns for each framework.
- Wallet Adapters – viem, ethers, and Solana adapters normalize transaction submission, confirmations, and chain switching; you can extend the
AdaptedWalletinterface for custom wallets. - Token & Balance APIs – shared helpers (
getTokenList,getTokensData,getBalances) keep asset search, metadata, and portfolio views in sync across your app and backend services.
Providers Architecture
The SDK keeps a single OneShotSDK instance in context so every hook or composable pulls from the same client:
- React – wrap your app with
OneShotProviderand call hooks such asuseQuoteoruseBalances; each hook reads the provider context. - Vue – call
provideOneShotinside setup code or installOneShotPluginon the app instance; composables (useQuote,useBalances, etc.) inject the SDK through Vue’s dependency injection.
Key Hooks
OneShot ships first-party React hooks and Vue composables, each wrapping the shared SDK instance:
useQuote(initialParams)– central cache for swap quotes with abort-safe refetching andsetParams.useExecuteTransaction()– orchestratesexecuteTransaction, exposingexecute,stage,message,result, anderror.useBalances(initialParams?)– fetches unified EVM/SVM balances with automatic retries on address changes.useTokenList()– paginated token search with caching per query +loadTokens/resetTokens.useTokensData(addresses)– pulls metadata and pricing for curated token sets.
The Vue equivalents (useQuote, useExecuteTransaction, useBalances, etc.) mirror the same API but use reactive refs/computed values instead of SWR.
State Management
- React hooks rely on SWR to share caches across components, abort inflight requests when params change, and keep previous data during refetches where it makes sense (balances).
- Vue composables watch reactive inputs with
watchEffect/watch, cancel work viaAbortController, and refresh data when computed parameters update. - Global quote and balance params live in
globalThisto ensure multiple components stay synchronized in React; Vue keeps refs inside each composable instance while still deduplicating calls through abort logic. - Execution state (
stage,message,error,result) is owned by theuseExecuteTransactionhook/composable so that UI elements can react to stage transitions without manual wiring.
