@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)
DEX (Decentralized Exchange)
Get available pools list (
usePools)Get pool data for a selected pool (
usePoolData)Get token balances for pool tokens (
usePoolBalances)Get position information by token ID (
usePositionInfo)Deposit tokens to a pool (
useDexDeposit)Withdraw tokens from a pool (
useDexWithdraw)Check token allowance for DEX operations (
useDexAllowance)Approve token spending for DEX operations (
useDexApprove)Calculate liquidity amounts based on price range (
useLiquidityAmounts)Supply liquidity to a pool (
useSupplyLiquidity)Decrease liquidity from a position (
useDecreaseLiquidity)
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 orderuseCreateLimitOrder()- Create a limit order intent (no deadline, must be cancelled manually)Note: Limit orders use
useSwapAllowance()for checking token allowance (same as swaps)Note: Limit orders use
useSwapApprove()for approving token spending (same as swaps)Note: Limit orders use
useCancelSwap()for cancelling (same as swaps)useStatus()- 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
DEX Hooks
usePools()- Get available pools list from the DEX serviceusePoolData()- Get pool data for a selected poolusePoolBalances()- Get token balances for pool tokensusePositionInfo()- Get position information by token IDuseDexDeposit()- Deposit tokens to a pooluseDexWithdraw()- Withdraw tokens from a pooluseDexAllowance()- Check token allowance for DEX operationsuseDexApprove()- Approve token spending for DEX operationsuseLiquidityAmounts()- Calculate liquidity amounts based on price rangeuseSupplyLiquidity()- Supply liquidity to a pooluseDecreaseLiquidity()- Decrease liquidity from a positionuseCreateDepositParams()- Build and memoize pool deposit params with basic amount validationuseCreateWithdrawParams()- Build and memoize pool withdrawal params with basic amount validationuseCreateSupplyLiquidityParams()- Build and memoize supply liquidity params with price and slippage validationuseCreateDecreaseLiquidityParams()- Build and memoize decrease liquidity params with percentage and slippage validation
DEX Utils
createDepositParamsProps()- Create deposit params for a pool token using pool data and spoke asset infocreateWithdrawParamsProps()- Create withdraw params for a pool token with optional destination infocreateSupplyLiquidityParamsProps()- Create concentrated liquidity supply params from price range, amounts, and slippagecreateDecreaseLiquidityParamsProps()- Create decrease liquidity params from position info, percentage, and slippage
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development
License
Support
Last updated