Overview
TheuseProtocols hook provides access to the complete list of Stacks DeFi protocols with built-in filtering and sorting capabilities. It enables users to browse protocols by type (Lending, DEX, Yield, Stacking) and automatically sorts by APY.
Source: src/hooks/useProtocols.js
Import
Hook Signature
Parameters
This hook takes no parameters.Return Values
Array of protocol objects, filtered by current
filter and sorted by APY (highest first).Each protocol object contains:name(string): Protocol name (e.g., “Zest Protocol”)type(string): Protocol type -"Lending","DEX","Yield", or"Stacking"apy(string): Annual percentage yield (e.g.,"8.2")tvl(string): Total value locked (e.g.,"$48.2M")asset(string): Supported assets (e.g.,"sBTC","STX","sBTC, STX")risk(string): Risk level -"Low","Medium", or"High"description(string): Brief protocol descriptionurl(string): Protocol website URLlogo(string, optional): Logo image URL or path
Current filter selection. One of:
"All", "Lending", "DEX", "Yield", or "Stacking".Defaults to "All" which shows all protocols.Update the protocol filter. Triggers a loading animation (800ms) when changed.Signature:
(filter: string) => voidValid values: "All", "Lending", "DEX", "Yield", "Stacking"true during filter transition animation (800ms), false otherwise. Use this to show loading states when filter changes.Usage Example
Filter Types
The hook supports these filter values:All
Shows all protocols across all types. This is the default filter.Use case: Browse entire protocol ecosystem
Lending
Shows only lending and borrowing protocols.Examples: Zest Protocol, ArkadikoUse case: Users wanting to lend assets or take loans
DEX
Shows only decentralized exchanges and swap protocols.Examples: ALEX, VelarUse case: Users wanting to trade tokens
Yield
Shows only yield farming and liquidity mining protocols.Use case: Users seeking passive income opportunities
Stacking
Shows only STX stacking protocols and pools.Examples: StackingDAO, Xverse StackingUse case: Users wanting to stack STX and earn BTC
Sorting Behavior
Protocols are automatically sorted by APY in descending order (highest first):This ensures users always see the highest-yielding opportunities first, regardless of the selected filter.
Loading Animation
When changing filters, the hook triggers an 800ms loading state:Protocol Data Source
The hook loads protocols from the staticPROTOCOLS array:
The protocol data is static. For real-time updates, consider integrating with DeFiLlama API or other data providers.
Best Practices
Show Filter Count
Display the number of protocols matching the current filter to help users understand results.
Smooth Transitions
Use the
loading state to animate filter changes and improve perceived performance.Empty States
Handle cases where no protocols match the filter (shouldn’t happen with default data, but good practice).
External Links
Always open protocol URLs in new tabs with
target="_blank" and rel="noopener noreferrer".Common Patterns
Filter Pills with Active State
Protocol Count Badge
Grid with Responsive Layout
Protocol Object Structure
Each protocol in theprotocols array has this structure:
Related Hooks
- useWallet - Connect wallet to interact with protocols
- useAIAdvisor - Get AI recommendations for protocols
- usePortfolio - Fetch user portfolio data
Related Services
- Protocol Data - Static protocol configuration
- Stacks API - Blockchain data fetching