feat(portfolio): dividend reinvestment button to compound earnings into more keys (#824) - #834
Merged
Chucks1093 merged 1 commit intoAug 29, 2026
Conversation
Add a Reinvest action on portfolio holding rows so holders can compound their unclaimed dividend earnings back into more creator keys. - Show an unclaimed dividend badge on holding rows where the unclaimedDividend balance is greater than zero - Add a Reinvest button that opens a confirmation modal showing the unclaimed amount, estimated whole keys to be bought, and any XLM remainder (via the new estimateReinvest helper) - Submit on confirm through the new useReinvestDividendMutation hook, which targets the reinvest_dividend contract function with the holding's key_id (creatorId) - Show a success toast 'Reinvested [amount] XLM — received [keys] keys' - Optimistically update the holding row (keys received and unclaimed balance cleared) and invalidate the wallet holdings cache afterwards Adds HeldKeyPosition.unclaimedDividend, a ReinvestDividendDialog component, the reinvestDividend utils, and unit tests for the helper, dialog, and holding-row badge/button/modal flow.
|
@meem08 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #824
Holders with unclaimed dividends previously had no UI to reinvest them. This PR adds a Reinvest action on portfolio holding rows so eligible holders can compound their unclaimed dividend earnings back into more creator keys, directly surfacing and submitting the
reinvest_dividendcontract call.Scope / What changed
Data model
unclaimedDividend(XLM) toHeldKeyPositioninsrc/utils/portfolioValue.utils.tsso holding rows know when a dividend balance is available.Reinvestment math (
src/utils/reinvestDividend.utils.ts)estimateReinvest— computes the whole keys a dividend buys at the current key price plus the XLM remainder that can't convert to a whole key.hasUnclaimedDividend/xlmToStroopshelpers.UI (
src/components/common/PortfolioHoldingRow.tsx,ReinvestDividendDialog.tsx)unclaimedDividend > 0.Contract call (
src/hooks/useWallet.ts→useReinvestDividendMutation)useTradeMutationpattern (optimistic cache update, rollback on error, invalidation on settle).mutationFntargets thereinvest_dividendcontract function with the holding'skey_id(= creatorId).Toast (
src/pages/LandingPage.tsx)Reinvested [amount] XLM — received [keys] keyson confirmation.Tests
src/utils/__tests__/reinvestDividend.utils.test.ts— estimate/remainder matrix.src/components/common/__tests__/PortfolioHoldingRow.reinvest.test.tsx— badge shown only when eligible, button hidden without a handler, modal content,onReinvestcalled with correctkey_id, disabled confirm when no whole key is purchasable.src/components/common/__tests__/ReinvestDividendDialog.test.tsx— displayed values and unavailable-estimate state.Acceptance criteria
key_idon confirmVerification
tsc -bpasseseslintpasses on all changed filesNotes
Real on-chain calls in this repository are currently simulated (see the existing
useTradeMutationcomment);useReinvestDividendMutationwires thekey_idpayload and follows the same shape so the actualreinvest_dividendcontract call can be dropped in once ABIs/TypeChain bindings land. This follows the established pattern and keeps the change minimal.