fix: yield correct symbol for approve rows + wait for on-chain complete before next tx#11823
Conversation
For exit actions on liquid staking yields (Lido stETH, Rocket Pool rETH, etc.), the approval and unstake steps were incorrectly showing the input token symbol (e.g., "Approve ETH") instead of the receipt/output token (e.g., "Approve stETH"). This is because during unstaking, you approve the receipt token for the withdrawal contract. Adds resolveAssetSymbolForTx() to determine the correct display symbol based on transaction type and action direction, and updates YieldForm, YieldManager, and useYieldTransactionFlow to use it. Co-Authored-By: Claude Opus 4.6 <[email protected]>
After broadcasting the first tx in a multi-step flow (e.g., Approval → Unstake), the code only waited for the yield.xyz API to acknowledge the tx (status != Created), then immediately signed the next tx. Since the chain nonce hadn't incremented yet (first tx still pending on-chain), the second tx failed with "transaction replacement underpriced". Add viem's waitForTransactionReceipt after broadcasting non-final EVM transactions to ensure the chain nonce has incremented before proceeding to the next step. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Move assertNever before first usage for top-to-bottom readability - Use idiomatic `return assertNever()` pattern for exhaustive switch - Fix outputTokenAsset selector to use outputTokenAssetId directly Co-Authored-By: Claude Opus 4.6 <[email protected]>
📝 WalkthroughWalkthroughA new utility function Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
The yield.xyz API returns balances and expects amounts in the underlying/ input token (AVAX, ETH), not the receipt token (sAVAX, rETH). For pricePerShare tokens where 1 receipt > 1 underlying, this caused a visible amount mismatch. Separate display concerns: input area (icon, symbol, precision, market data) uses input token, while button/title text keeps receipt token to describe the user action. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The yield.xyz v1 API doesn't expose pricePerShareState, so discriminate rebasing tokens (stETH/Lido) from pricePerShare tokens (sAVAX, rETH, mETH) using providerId. Non-rebasing liquid staking tokens now consistently show the underlying/input token (AVAX, ETH) across the entire exit form, while rebasing tokens (stETH) correctly show the receipt token in labels/headings. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Approval steps on yield exit now show the actual receipt token being approved (rETH, stETH, sAVAX) instead of the native asset. Native assets like ETH/AVAX can't be ERC-20 approved — the approval always targets the receipt token contract. Also reverts unnecessary rebasing/pricePerShare display logic, keeping the changeset minimal. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Description
Two targeted fixes for the yield transaction flow:
Show correct token in approval step labels — Approval steps on yield exit now show the actual receipt token being approved (rETH, stETH, sAVAX) instead of the native/underlying asset. Native assets like ETH/AVAX can't be ERC-20 approved — the approval always targets the receipt token contract. Confirmed via yield.xyz API responses:
0xae78736C...(rETH contract) → "Approve rETH"0xae7ab965...(stETH contract) → "Approve stETH"Wait for on-chain receipt between multi-step yield transactions — For EVM chains, the hook now waits for the on-chain transaction receipt before polling for the next transaction step. This prevents race conditions where the API hasn't yet confirmed the previous step.
Issue (if applicable)
Risk
Low — UI label change for approval steps only, plus a timing fix for multi-step tx flows. No changes to transaction amounts or contract interactions.
Testing
Engineering
yarn type-checkpassesyarn lintpassesnpx vitest run src/lib/yieldxyz/— 99 tests passOperations
Screenshots (if applicable)
https://jam.dev/c/0345edfe-db55-4c71-91f3-d08296a08ce5
https://jam.dev/c/79d807e2-d5f5-4f57-a43d-418c77b97dea
Summary by CodeRabbit
Release Notes
New Features
Tests