fix: yield improvements - validator handling, disabled states, UI consistency - #11743
Conversation
Yields like solana-sol-lido-staking have requiresValidatorSelection: false but still require validatorAddress in the API request. This fix: - UI: Only shows validator info when requiresValidatorSelection is true - API: Still passes validatorAddress when the field exists in args This prevents showing "Figment" validator in UI for yields that don't actually require validator selection, while still satisfying API requirements. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When closing the yield deposit modal on a yield-specific route (e.g., /yields/solana-sol-lido-staking?modal=yield), the modal now removes the modal search params instead of using navigate(-1). This keeps the user on the yield detail page instead of unexpectedly navigating back to the yields list. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, yield opportunities in the DeFi drawer tab (e.g., "Drift CASH Lending", "Kamino CASH Lending") showed no icon because: 1. The yieldId was used as assetId (invalid for icon lookup) 2. The provider icon was used but often empty/missing Now: - Added inputAssetId to YieldOpportunityDisplay type - Pass inputAssetId when creating yield opportunity items - Use AssetIcon component for yield items in position details This ensures yields show the proper underlying asset icon (e.g., CASH icon for CASH lending opportunities). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add UI indicators for yields with status.enter=false - Disable enter/exit buttons when status is false - Show warning alerts in modals for disabled actions - Filter disabled yields from lists unless user has balance - Don't auto-select disabled yields as default - Fix CASH icon not loading by handling null inputTokens array - Add translations for depositsDisabled and withdrawalsDisabled Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Test augmenting inputTokens when array is provided - Test fallback to token when inputTokens is null (CASH fix) - Test fallback to token when inputTokens is empty array - Test status preservation (enter/exit flags) - Test metadata preservation (underMaintenance, deprecated) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Filter disabled yields from "Other X Yields" related markets section - Fix "Available to Earn" filter options to use unfiltered data so options don't shrink when a filter is applied - Unify balance terminology to "Balance" across all yield components - Extract isYieldDisabled utility for code reuse Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Show provider/validator icon and name in Earn tab yield selector - Add missing yieldXYZ.manage translation - Remove dead translation keys: learnMore, myBalance, protocol, yourBalance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace DEFAULT_NATIVE_VALIDATOR_BY_CHAIN_ID with DEFAULT_VALIDATOR_BY_YIELD_ID - Add getDefaultValidatorForYield utility function - Remove user's highest balance validator fallback from navigation - Default validators are now determined by yield ID, not chain ID: - cosmos-atom-native-staking: ShapeShift DAO - solana-sol-native-multivalidator-staking: Figment - Update all yield components to use the new yield ID based approach - Add unit tests for getDefaultValidatorForYield Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds yield-level disable flags and UI; centralizes default validator lookup by yield ID via getDefaultValidatorForYield; introduces isYieldDisabled; filters disabled yields without balance; propagates inputAssetId through yield opportunity flows; updates translations and numerous Yield-related components. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as Yields UI
participant Utils as yieldxyz/utils
participant Router
participant Validators as ValidatorService
User->>UI: Click yield entry
UI->>Utils: isYieldDisabled(yield)
Utils-->>UI: true/false
alt disabled && zero balance
UI-->>User: show tooltip / prevent navigation
else
UI->>Utils: getDefaultValidatorForYield(yieldId)
Utils-->>UI: maybe-default-validator
alt default validator exists
UI->>Router: navigate to /yields/{yieldId}?validator={addr}
else
UI->>Validators: fetch validators (if required)
Validators-->>UI: validators list
UI->>Router: navigate to /yields/{yieldId}
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ts_fr_this_time_no_cap
Variables that early return null now use the maybe prefix for clarity. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@src/components/EarnDashboard/components/PositionDetails/StakingPositionsByProvider.tsx`:
- Around line 125-129: Remove the unreachable fallback to y.yieldId when mapping
opportunities in StakingPositionsByProvider.tsx: replace uses of y.inputAssetId
?? y.yieldId for assetId and underlyingAssetId with y.inputAssetId directly
(since useYieldAsOpportunities.ts guarantees inputAssetId is present);
alternatively, update the YieldOpportunityDisplay type to make inputAssetId
non-optional so callers and mappers like the map over yieldOpportunities reflect
that contract.
useYieldAsOpportunities filters out yields without inputAssetId, so the fallback to yieldId was unreachable. Type now reflects the actual guarantee. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/StakingVaults/hooks/useYieldAsOpportunities.ts (1)
73-81: Guard against missing default validator in balances.If
getDefaultValidatorForYield()returns a validator that isn’t present inbalancesForYield.byValidator,validatorBalancebecomes undefined and the UI shows0even when the user has balances on other validators. Add a presence check and fall back to the first available validator in that case.🔧 Suggested fix
- const defaultValidatorAddress = getDefaultValidatorForYield(yieldItem.id) - const validatorAddresses = Object.keys(balancesForYield.byValidator) - const selectedValidatorAddress = defaultValidatorAddress ?? validatorAddresses[0] + const defaultValidatorAddress = getDefaultValidatorForYield(yieldItem.id) + const validatorAddresses = Object.keys(balancesForYield.byValidator) + const selectedValidatorAddress = + defaultValidatorAddress && + balancesForYield.byValidator[defaultValidatorAddress] + ? defaultValidatorAddress + : validatorAddresses[0]
…ssing providers - Fix YieldProviderInfo not showing for liquid staking yields like Lido (changed condition from !isStaking to !isStaking || !requiresValidatorSelection) - Add fallback for providers not in API (e.g., Drift) to still show provider info - Add provider descriptions for yearn, spark, rocket-pool, drift Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Nice catch @NeOMakinG! Reported this one to Yield (missing in /providers). |



Description
Validator Handling Improvements
solana-sol-lido-staking(the only one with such issue atm, but could well apply to others) incorrectly showing Figment validator whenrequiresValidatorSelection: falseDEFAULT_VALIDATOR_BY_YIELD_ID)getDefaultValidatorForYieldutility function for consistent validator lookupcosmos-atom-native-staking→ ShapeShift DAOsolana-sol-native-multivalidator-staking→ FigmentDisabled Yield States
isYieldDisabledutility function to centralize disabled check logicUI Consistency
/yieldsinstead of staying on current yield detail pageCode Cleanup
learnMore,myBalance,protocol,yourBalanceyieldXYZ.managetranslation keygetDefaultValidatorForYieldand yield augmentation functions (65 tests passing)Risk
Low-Medium risk. Changes affect yield UI display and navigation logic. No on-chain transaction modifications.
Yield.xyz integration - display and navigation only, no transaction logic changes.
Testing
Engineering
Validator Display:
/#/yields/solana-sol-lido-staking?accountId=solana%3A5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp%3AETpdrEkK8n3jPLysUZCNe1LHdM76GSrbHgAtVpCvWYLp/#/yields/cosmos-atom-native-staking/#/yields/solana-sol-native-multivalidator-stakingDisabled Yields: (note disabled yield here is the one mentioned above i.e solana-sol-lido-staking, which has enter disabled upstream currently i.e the bug that MbMaria was experiencing)
5. Navigate to yields list - verify disabled yields are filtered out (unless user has balance)
6. Navigate to a yield detail page with "Other X Yields" section - verify disabled yields are not shown
7. Apply filters on yields list - verify filter dropdown options don't shrink
Modal Navigation:
8. Navigate to any yield deets page
9. Click deposit to open modal
10. Close modal - verify you remain on the yield detail page (not redirected to
/yields)DeFi Tab Icons:
11. Open wallet drawer → DeFi tab
12. Verify yield opportunities show their asset icons (e.g., CASH icon for "Drift CASH Lending")
Earn Tab:
13. Navigate to Trade → Earn tab
14. Click yield selector dropdown
15. Verify each yield shows provider/validator icon and name
Balance Terminology:
16. Check various yield pages - balance labels should consistently show "Balance" (not "My Balance" or "Your Balance")
Operations
All changes are within the existing Yield.xyz feature flag scope.
Screenshots (if applicable)
https://jam.dev/c/d91e776f-f8ca-4816-b878-f7f15dd046c2
https://jam.dev/c/10a4ceae-a2ac-4038-9919-8e664a92b1de
https://jam.dev/c/539b61da-ad34-4b47-ae32-f0df69eb5631
https://jam.dev/c/607887d1-a225-49ac-b2ac-a2173e3d96f5
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
UI/UX Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.