feat: yield improvements following CR#11729
Conversation
…eature
- Replace generic "Exit" terminology with type-specific labels:
- "Unstake" for staking yields (native-staking, pooled-staking, etc.)
- "Withdraw" for vault/lending yields
- Add proper disabled state to exit button with tooltip explaining why
(no active position or no withdrawable amount)
- Show position card even without connected wallet with "Connect Wallet" button
- Display zeroed values maintaining consistent layout
- Add "Get {TOKEN}" button in Available to Deposit section when user has no balance
- Navigates to swapper with the token pre-selected as buy asset
- Add new i18n keys for type-specific success messages and loading states
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Show "Get {TOKEN}" button when user has no balance for yield input token
- Only display when wallet is connected
- Routes to /trade/{assetId} with buy asset pre-selected
- Store swapper modal implementation as .diffs for future use
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds a typed YieldType and many yield-type-aware utilities; updates translation keys for yield flows; propagates yieldType through transaction/title/label logic across Yield components; adds wallet-connectivity gating and a zero-state "Get Asset" action that navigates to trade. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant YieldUI as YieldAvailableToDeposit / YieldPositionCard
participant Wallet as useWallet / KeyManager
participant Router as TradeNavigator
participant YieldUtils as yieldxyz utils
User->>YieldUI: open Yields page
YieldUI->>Wallet: check isConnected, wallet type, ledger read-only
alt wallet unavailable or precision missing
YieldUI-->>User: render zero-state card (0 balance) with "Get Asset" / "Connect"
User->>YieldUI: click "Get Asset"
YieldUI->>Router: navigateToTrade(inputTokenAssetId)
Router-->>User: open trade flow
else wallet available
YieldUI->>YieldUtils: request labels/keys using yieldType
YieldUI-->>User: render balance card with actions
User->>YieldUI: initiate action (Enter/Exit)
YieldUI->>YieldUtils: format titles / determine success key using yieldType
YieldUI->>Wallet: perform tx flow (connect/sign)
YieldUI-->>User: show loading / success messages
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 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 |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- YieldPositionCard: show zeroed position with Connect Wallet button instead of hiding - YieldAvailableToDeposit: properly handle Ledger read-only mode using established pattern Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…asset 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/pages/Yields/components/YieldSuccess.tsx`:
- Around line 27-32: The UI is missing translations for the new success message
keys so add entries for "successUnstaked" and "successWithdrawn" to the English
translations JSON used by the app, then ensure the component that accepts
successMessageKey (the union including 'successUnstaked' and 'successWithdrawn')
consumes them via translate('...') so the raw keys don't render; locate where
translate('successEnter'|'successExit'|'successClaim'...) is used and add
matching JSON values for the two new keys with appropriate copy.
0xApotheosis
left a comment
There was a problem hiding this comment.
All looks good! The comment from CodeRabbit below seems valid to address before merging.
Without wallet connected:
✅ Go to /yields, click any yield
✅ Verify "My Position" card shows with $0 and "Connect Wallet" button
✅ Verify "Available to Deposit" card is hidden
✅ Click "Connect Wallet" → should open wallet modal
With wallet connected (no balance for yield token):
✅ Find yield for token you don't have
✅ Verify "Get {TOKEN}" button appears in "Available to Deposit" card
✅ Click → should navigate to /trade/{assetId} with buy asset selected
With wallet connected (has balance):
✅ Verify "Available to Deposit" shows your balance and potential earnings
Ledger read-only mode:
✅ Connect Ledger, then unplug device
✅ Verify "Available to Deposit" card still shows (read-only mode)
Add successUnstaked and successWithdrawn translation entries for the YieldSuccess component. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…bels - Add YieldType union type with exhaustiveness checks for all yield type handling - Replace generic "enter/exit" UI labels with contextual terminology: - Staking yields: stake/unstake - Vault/lending yields: deposit/withdraw - Restaking: restake/unstake - Add utility functions: getYieldActionLabelKeys, getYieldLoadingStateKeys, getYieldHeadingKeys, getYieldPendingStatusKeys, getYieldMinAmountKey, getYieldSuccessMessageKey with exhaustiveness checks - Update YieldSuccess component with typed successMessageKey prop - Clean up unused translations and remove old enter/exit keys - Add comprehensive tests for new utility functions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Prefer ripgrep over grep and use jq for JSON file querying to avoid context bloat and improve performance when working with large files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/MultiHopTrade/components/Earn/EarnConfirm.tsx (1)
149-178: PassyieldTypefor active-step button text.When a step is active,
getTransactionButtonTextis called withoutyieldType, so staking/restaking flows can render “Deposit/Withdraw” instead of “Stake/Unstake/Restake”.🔧 Suggested fix
- const confirmButtonText = useMemo(() => { + const confirmButtonText = useMemo(() => { + const yieldType = selectedYield?.mechanics.type if (activeStepIndex >= 0 && transactionSteps[activeStepIndex]) { const currentStep = transactionSteps[activeStepIndex] - return getTransactionButtonText(currentStep.type, currentStep.originalTitle) + return getTransactionButtonText(currentStep.type, currentStep.originalTitle, yieldType) } // USDT reset required before other transactions if (isUsdtResetRequired) { return translate('yieldXYZ.resetAllowance') } // Before execution starts, use the first CREATED transaction from quoteData - const yieldType = selectedYield?.mechanics.type const firstCreatedTx = quoteData?.transactions?.find(tx => tx.status === 'CREATED') if (firstCreatedTx) { return getTransactionButtonText(firstCreatedTx.type, firstCreatedTx.title, yieldType) }
🤖 Fix all issues with AI agents
In `@src/lib/yieldxyz/utils.ts`:
- Around line 16-114: Both getTransactionButtonText and formatYieldTxTitle treat
'restaking' the same as other staking types and thus show "Stake" instead of
"Restake"; fix by special-casing yieldType === 'restaking' in those functions
(before using labelKey/TX mappings) to return "Restake" (and "Restake
{assetSymbol}" in formatYieldTxTitle) or otherwise consult a restake-specific
mapping; update any relevant TX_TYPE_TO_LABELS/TX_TITLE_PATTERNS lookups only if
you want title/type-based "restake" detection, and ensure the change aligns with
the existing isStakingType behavior and getYieldActionLabelKeys naming.
…ields Restaking yields now use "Stake/Unstake" terminology consistently instead of "Restake/Unstake" to match the other staking yield types. - Update getYieldActionLabelKeys to return 'defi.stake' for restaking - Update getYieldSuccessMessageKey to return 'successStaked' for restaking - Remove unused successRestaked and actions.restake translations - Update tests to reflect consistent terminology @coderabbitai resolve Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Description
Addresses code review feedback from #11703 and improves yield UX:
/trade/{assetId}with buy asset pre-selected when clicking "Get {TOKEN}"Issue (if applicable)
Tackles CR from #11703 (review)
Risk
Low - UI-only changes, no transaction logic modifications.
None.
Testing
Engineering
Without wallet connected:
/yields, click any yieldWith wallet connected (no balance for yield token):
/trade/{assetId}with buy asset selectedWith wallet connected (has balance):
Ledger read-only mode:
Operations
Same as above on preview environment.
Screenshots (if applicable)
https://jam.dev/c/07594f51-6916-4026-ad60-7e342f134c6e
Summary by CodeRabbit
New Features
Bug Fixes / UX
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.