@sodax/dapp-kit
dApp Kit is a collection of React components, hooks, and utilities designed to streamline dApp development within the Sodax ecosystem. It provides seamless integration with Sodax smart contracts, enabling easy data querying and transaction execution. Additionally, it offers built-in wallet connectivity for all supported wallets in the Sodax network, simplifying the user onboarding experience. Under the hood, dApp Kit leverages @sodax/wallet-kit and @sodax/sdk for seamless functionality.
Features
Money Market
Supply tokens to the money market (
useSupply)Withdraw tokens from the money market (
useWithdraw)Borrow tokens from the money market (
useBorrow)Repay borrowed tokens (
useRepay)Check token allowance (
useMMAllowance)Approve token spending (
useMMApprove)Get user reserves data (
useUserReservesData)Get reserves data (
useReservesData)Get humanized reserves data (
useReservesHumanized)Get list of reserves (
useReservesList)Get USD formatted reserves data (
useReservesUsdFormat)Get formatted user portfolio summary (
useUserFormattedSummary)
Swap/Intent
Get quote for an intent order (
useQuote)Create and submit an swap intent order (
useSwap)Get status of an intent order (
useStatus)Check token allowance (
useSwapAllowance)Approve token spending (
useSwapApprove)Cancel a swap intent order (
useCancelSwap)
Provider
Get hub chain provider (
useHubProvider)Get spoke chain provider (
useSpokeProvider)Get wallet provider (
useWalletProvider)
Bridge
Bridge tokens between chains (
useBridge)Check token allowance for bridging (
useBridgeAllowance)Approve source token for bridging (
useBridgeApprove)Get max amount available to be bridged (
useGetBridgeableAmount)Get available destination tokens based on provided source token (
useGetBridgeableTokens)
Shared
Derive user wallet address for hub abstraction (
useDeriveUserWalletAddress)Check if Stellar trustline is established for an asset (
useStellarTrustlineCheck)Request creation of Stellar trustline line for an asset (
useRequestTrustline)
Staking
Stake SODA tokens to receive xSODA shares (
useStake)Unstake xSODA shares (
useUnstake)Instant unstake xSODA shares with penalty (
useInstantUnstake)Claim unstaked SODA tokens after unstaking period (
useClaim)Cancel unstake request (
useCancelUnstake)Check SODA token allowance for staking (
useStakeAllowance)Approve SODA token spending for staking (
useStakeApprove)Check xSODA token allowance for unstaking (
useUnstakeAllowance)Approve xSODA token spending for unstaking (
useUnstakeApprove)Check xSODA token allowance for instant unstaking (
useInstantUnstakeAllowance)Approve xSODA token spending for instant unstaking (
useInstantUnstakeApprove)Get comprehensive staking information (
useStakingInfo)Get unstaking information with penalty details (
useUnstakingInfoWithPenalty)Get unstaking information (
useUnstakingInfo)Get staking configuration (
useStakingConfig)Get stake ratio (SODA to xSODA conversion rate) (
useStakeRatio)Get instant unstake ratio (xSODA to SODA conversion rate with penalty) (
useInstantUnstakeRatio)Get converted assets amount for xSODA shares (
useConvertedAssets)
Installation
Quick Start
First, install the required dependencies:
Set up the providers in your app:
Use the hooks in your components:
Requirements
Node.js >= 18.0.0
React >= 19
TypeScript
API Reference
Components
SodaxProvider- Main provider component for Sodax ecosystem integration
Hooks
Money Market Hooks
useBorrow()- Borrow tokens from the money marketuseRepay()- Repay borrowed tokensuseSupply()- Supply tokens to the money marketuseWithdraw()- Withdraw supplied tokensuseUserReservesData()- Get user's reserves data(supplied asset and debt)useReservesData()- Get reserves datauseMMAllowance()- Check token allowance for a specific amountuseMMApprove()- Approve token spendinguseAToken()- Fetch aToken token data
Swap Hooks
useQuote()- Get quote for an intent orderuseSwap()- Create and submit an intent orderuseStatus()- Get status of an intent orderuseSwapAllowance()- Check token allowance for an intent orderuseSwapApprove()- Approve token spendinguseCancelSwap()- Cancel a swap intent order
Shared Hooks
useSodaxContext()- Access Sodax context and configurationuseEstimateGas()- Estimate gas costs for transactionsuseDeriveUserWalletAddress()- Derive user wallet address for hub abstraction
Bridge Hooks
useBridge()- Execute bridge transactions to transfer tokens between chainsuseBridgeAllowance()- Check token allowance for bridge operationsuseBridgeApprove()- Approve token spending for bridge actionsuseGetBridgeableAmount()- Get maximum amount available to be bridgeduseGetBridgeableTokens()- Get available destination tokens for bridging
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development
License
Support
Last updated