Overview
The Portfolio Protocols service analyzes a Stacks wallet address to detect active positions across DeFi protocols. It checks token balances and transaction history to identify where users have deposited funds. Location:src/services/portfolioProtocols.js
How It Works
Match Protocol Contracts
Checks if wallet holds LP/receipt tokens or has transacted with known protocol contracts
Main Function
detectWalletProtocols(address)
Detects which protocols a wallet has active positions in.Stacks wallet address (e.g.,
SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7)Promise<Array<WalletProtocol>>
Detected protocol position with metadata
Usage Examples
Protocol Contract Addresses
The service monitors these known protocol contracts:StackingDAO
StackingDAO
Type: Stacking
Token: stSTX (liquid staking receipt)
Contract:
Token: stSTX (liquid staking receipt)
Contract:
SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-tokenZest Protocol
Zest Protocol
Type: Lending
Token: zsBTC (lending position)
Contract:
Token: zsBTC (lending position)
Contract:
SP2VCQJGH7PHP2DJK7Z0V48AGBHQAW3R3ZW1QF4N.zest-reward-distALEX Lab
ALEX Lab
Type: DEX / Yield
Token: atALEX (auto-compounding position)
Contract:
Token: atALEX (auto-compounding position)
Contract:
SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.auto-alex-v3Bitflow
Bitflow
Type: DEX LP
Token: stxSTX-LP (liquidity pool token)
Contract:
Token: stxSTX-LP (liquidity pool token)
Contract:
STTWD9SPRQVD3P733V89SV0P8EP8QSB5B00ZBZQ.stxstx-lp-token-v-1-2Hermetica
Hermetica
Type: Yield
Token: USDh (yield-bearing stablecoin)
Contract:
Token: USDh (yield-bearing stablecoin)
Contract:
SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1N.token-usdhVelar
Velar
Type: DEX LP
Token: WELSH-LP (liquidity pool token)
Contract:
Token: WELSH-LP (liquidity pool token)
Contract:
SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.wstx-welsh-lp-tokenGranite
Granite
Type: Borrowing
Token: sBTC Collateral
Contract:
Token: sBTC Collateral
Contract:
SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1N.granite-vaultDetection Logic
The service uses two detection methods for maximum accuracy:1. Token Balance Check
2. Transaction History Check
Confidence Levels
Confirmed
Wallet holds the protocol’s token (balance > 0). High confidence active position.
Likely
Wallet has transacted with protocol but holds no tokens. May have withdrawn funds or pending deposits.
Data Sources
This service uses the Hiro Stacks API for:
- Fungible token balances:
/extended/v1/address/{address}/balances - Transaction history:
/extended/v1/address/{address}/transactions
Error Handling
The function returns an empty array on errors:Performance
- Parallel Fetching: Token balances and transactions fetched simultaneously
- Transaction Limit: Only analyzes last 50 transactions for efficiency
- No Pagination: Single-request design for fast response times
Related
useWalletProtocols Hook
React hook wrapper for position detection
DefiLlama Service
Fetch protocol TVL and APY data