Skip to content

feat(yields): mini swapper modal#11730

Merged
gomesalexandre merged 17 commits intodevelopfrom
feat_swapper_modal
Jan 20, 2026
Merged

feat(yields): mini swapper modal#11730
gomesalexandre merged 17 commits intodevelopfrom
feat_swapper_modal

Conversation

@gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Jan 19, 2026

bober

Description

Extracts swapper into a modal ("mini swapper") for the yield flow:

  • Click "Get {TOKEN}" → opens swapper modal with buy asset pre-selected
  • Desktop: minimal chrome, just the swapper
  • Mobile: full drawer with header

Issue (if applicable)

Stacked on #11729

Risk

Low - new modal component, no changes to existing swapper logic.

Testing

Engineering

  • Mini swapper performs well on both mobile and desktop

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/d9cc0662-6c6d-4997-95b0-4840e2f01aee

Summary by CodeRabbit

  • New Features

    • Trade modal accessible directly from yields to start trades without leaving the page.
    • Modal passes success callbacks to the trade flow so actions can close or react to successful trades.
    • Added UI labels: potential earnings amount, Deposit Now, Strategy Info, and Overview.
  • Style

    • Modal-specific card styling to match in-modal appearance.

✏️ Tip: You can customize this high-level summary in your review settings.

gomesalexandre and others added 4 commits January 19, 2026 17:51
…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>
- Create SwapperModal component wrapping StandaloneMultiHopTrade in a Dialog
- Use MemoryRouter for isolated routing within modal
- Clear Redux trade state on modal open/close
- Show modal when user clicks "Get {TOKEN}" button
- Supports desktop modal and mobile drawer via existing Dialog component

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Adds a modal-based swap flow for depositing yield assets, new translation keys, and numerous modal-aware additions to the multi-hop trade components to support modal styling and an on-swap broadcast callback.

Changes

Cohort / File(s) Summary
Translations
src/assets/translations/en/main.json
Added assets.potentialEarningsAmount, assets.depositNow, assets.strategyInfo, assets.overview; added trailing comma on assets.getAsset.
Swapper modal components
src/components/SwapperModal/SwapperModal.tsx, src/components/SwapperModal/SwapperModalContent.tsx
New SwapperModal (Dialog wrapper) and SwapperModalContent (form init, default asset wiring, routing into trade UI); exported SwapperModal and SwapperModalContentProps.
Yield UI
src/pages/Yields/components/YieldAvailableToDeposit.tsx
Replaced navigation-to-trade with local state-managed SwapperModal; button opens modal and passes default asset id; modal cleared on close/success.
Standalone trade surface
src/components/MultiHopTrade/StandaloneMultiHopTrade.tsx
Extended props/types to accept isModal?: boolean and onSuccess?: () => void and threaded these through route/confirm/input components.
Modal styling constant
src/components/MultiHopTrade/const.ts
Added exported modalCardStyles for transparent/modal card styling.
Shared UI modal support
src/components/MultiHopTrade/components/SharedConfirm/SharedConfirm.tsx, src/components/MultiHopTrade/components/SharedTradeInput/SharedTradeInput.tsx
Added optional isModal?: boolean prop and conditional application of modalCardStyles for modal rendering.
Trade input plumbing
src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx
Added isModal?: boolean prop and forwarded to SharedTradeInput.
Confirm/footer/button plumbing
src/components/MultiHopTrade/components/TradeConfirm/TradeConfirm.tsx, .../TradeConfirm/TradeConfirmFooter.tsx, .../TradeConfirm/TradeFooterButton.tsx
Added isModal?: boolean and onSuccess?: () => void to TradeConfirm props; added onSwapTxBroadcast?: () => void prop and forwarded it to footer/button.
Execution hook changes
src/components/MultiHopTrade/components/TradeConfirm/hooks/useTradeButtonProps.tsx, .../useTradeExecution.tsx
Threaded new optional onSwapTxBroadcast?: () => void through useTradeButtonProps into useTradeExecution; useTradeExecution now accepts and invokes onSwapTxBroadcast after SellTxHash.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant YieldAvailableToDeposit
    participant SwapperModal
    participant SwapperModalContent
    participant StandaloneMultiHopTrade
    participant tradeInput as tradeInput State

    User->>YieldAvailableToDeposit: Click "Deposit Now"
    YieldAvailableToDeposit->>YieldAvailableToDeposit: set isSwapperModalOpen = true
    YieldAvailableToDeposit->>SwapperModal: open with defaultBuyAssetId
    SwapperModal->>SwapperModalContent: mount inside MemoryRouter
    SwapperModalContent->>tradeInput: dispatch clear()
    SwapperModalContent->>tradeInput: set default buy/sell assets (if provided)
    SwapperModalContent->>StandaloneMultiHopTrade: render trade UI (isModal=true, onSuccess)
    User->>StandaloneMultiHopTrade: perform swap -> executeTrade
    StandaloneMultiHopTrade->>useTradeExecution: broadcast SellTxHash
    useTradeExecution->>SwapperModalContent: call onSwapTxBroadcast (if provided)
    User->>SwapperModal: close modal (or onSuccess)
    SwapperModal->>tradeInput: dispatch clear()
    SwapperModal->>YieldAvailableToDeposit: onClose/onSuccess callback
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • NeOMakinG
  • premiumjibles

Poem

🐰 A little modal hopped into view,
Deposits and swaps now quick to do.
Default assets set with a gentle thump,
Trade, broadcast, close — a soft rabbit jump! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(yields): mini swapper modal' clearly and concisely describes the main change: introducing a modal-based swapper component for the yield feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat_swapper_modal

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

gomesalexandre and others added 6 commits January 19, 2026 19:23
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>
@gomesalexandre gomesalexandre changed the title feat(yields): add SwapperModal for in-context asset acquisition feat(yields): swapper modal Jan 19, 2026
gomesalexandre and others added 2 commits January 19, 2026 19:47
…at_swapper_modal

# Conflicts:
#	src/pages/Yields/components/YieldAvailableToDeposit.tsx
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gomesalexandre gomesalexandre changed the title feat(yields): swapper modal feat(yields): mini swapper modal Jan 19, 2026
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gomesalexandre gomesalexandre marked this pull request as ready for review January 19, 2026 19:06
@gomesalexandre gomesalexandre requested a review from a team as a code owner January 19, 2026 19:06
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Member

@0xApotheosis 0xApotheosis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so great. A few non-blocking suggestions:

  • when a trade is completed by the swapper model we should auto-close the modal, because its unlikely they'll want to swap again in this context
  • we have some double boarder radius shenanigans going on:
Image

Base automatically changed from feat_yield_final_polish to develop January 20, 2026 12:17
gomesalexandre and others added 3 commits January 20, 2026 13:52
Resolved conflicts in:
- YieldAvailableToDeposit.tsx: Keep SwapperModal integration
- YieldSuccess.tsx: Use imported YieldSuccessMessageKey type from utils
- main.json: Keep new translations (potentialEarningsAmount, depositNow, strategyInfo, overview)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ompletion

Thread an optional onSuccess callback through SwapperModal -> SwapperModalContent
-> StandaloneMultiHopTrade -> TradeConfirm. When trade completes, the callback
fires exactly once, allowing consumers like YieldAvailableToDeposit to auto-close
the modal instead of requiring manual dismissal.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…dcast

- Add modalCardStyles for seamless modal appearance (no nested borders)
- Thread isModal prop through component chain to apply transparent styling
- Change onSuccess callback to fire on swap TX broadcast (not trade completion)
- Callback fires before navigation for cleaner modal close timing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gomesalexandre
Copy link
Contributor Author

  • when a trade is completed by the swapper model we should auto-close the modal, because its unlikely they'll want to swap again in this context
  • we have some double boarder radius shenanigans going on:

Fixed on both counts!

image

Tested mini-swapper here on desktop/mobile:

https://jam.dev/c/244726b9-9182-4b10-ae0c-f768bcc86a5f

And regression tested trade page swapper:

https://jam.dev/c/1ba9eae5-54ce-4033-879e-79921a2b9472

And asset page:

https://jam.dev/c/cdd34fac-8a8b-4f03-94e7-ed4b120e4add

@gomesalexandre gomesalexandre enabled auto-merge (squash) January 20, 2026 14:15
@gomesalexandre gomesalexandre merged commit bf21fbc into develop Jan 20, 2026
4 checks passed
@gomesalexandre gomesalexandre deleted the feat_swapper_modal branch January 20, 2026 14:18
@coderabbitai coderabbitai bot mentioned this pull request Jan 20, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants