Skip to content

feat(auto-invest): configuration panel in investor settings (#476) - #488

Open
solomonadzape95 wants to merge 1 commit into
StellarState:devfrom
solomonadzape95:feature/476-auto-invest-settings
Open

solomonadzape95 wants to merge 1 commit into
StellarState:devfrom
solomonadzape95:feature/476-auto-invest-settings

Conversation

@solomonadzape95

Copy link
Copy Markdown
Contributor

Summary

Implements #476 — an auto-invest configuration panel in investor settings where the investor sets the sectors, minimum yield, maximum invoice age, and per-invoice cap for automatic investing. The top toggle enables/disables with a confirmation step, rules are saved with set_auto_invest_rule, and recent AutoInvestExecuted events are listed underneath.

Changes

  • Rule domain (lib/autoInvest.ts) — sector catalogue, default rule, draft → rule validation (required sectors, 0–100% yield, integer day age, positive amount), and wire mapping. Validation is what blocks a save with empty required fields.
  • Contract wiring (lib/api/index.ts, hooks/useAutoInvest.ts) — fetchAutoInvestRule, setAutoInvestRule, disableAutoInvest, and fetchAutoInvestExecutedEvents, exposed through useAutoInvest with optimistic save/disable and rollback on failure.
  • Settings panel (components/investor/AutoInvestSettingsPanel.tsx) — sector multi-select chips, min yield, max invoice age, max amount per invoice; enable/disable switch at the top; inline validation errors.
  • Disable confirmation (components/investor/DisableAutoInvestDialog.tsx) — two-step confirmation before pulling the disable_auto_invest kill switch.
  • Rule summary (components/investor/AutoInvestRuleSummary.tsx) — active configuration card, shown whenever a rule exists.
  • Recent activity (components/investor/AutoInvestActivityList.tsx) — latest AutoInvestExecuted events with amount, yield, and sector.
  • Surfaced on the settings page (/settings#auto-invest) and linked from the investor dashboard.

Acceptance criteria

  • All rule fields save correctly to contract on submit
  • Disable toggle correctly calls disable_auto_invest with confirmation
  • Current rule summary displays correct active configuration
  • Recent activity list shows correct AutoInvestExecuted events
  • Validation prevents saving with empty required fields

Testing

New coverage (27 tests):

  • lib/__tests__/autoInvest.test.ts — validation of every required field, sector filtering, draft round-trip, wire mapping
  • hooks/__tests__/useAutoInvest.test.tsx — registry read, optimistic save/disable, rollback + toast on contract failure, disconnected no-fetch
  • components/investor/__tests__/AutoInvestRuleSummary.test.tsx — active/disabled summary values
  • components/investor/__tests__/AutoInvestActivityList.test.tsx — event rows and empty state
  • components/investor/__tests__/AutoInvestSettingsPanel.test.tsx — empty-field blocking, parse + submit, summary vs form, disable confirmation, re-enable, activity, disconnected

Targeted run: npx vitest run lib/__tests__/autoInvest.test.ts hooks/__tests__/useAutoInvest.test.tsx components/investor/__tests__/AutoInvest*.test.tsx → 27 passed.

Merge safety

This branch is cut from dev and intentionally touches only lib/api/index.ts, components/dashboard/InvestorDashboard.tsx, and the settings page among files shared with #474/#475 — and only in disjoint regions (the auto-invest API block is appended at the end of lib/api; the KYC/watchlist blocks are earlier). I verified a local merge of #474 → #475 → #476 in order: no conflicts, and the combined feature suites (84 tests) all pass.

Note: dev already has pre-existing failing tests/build errors unrelated to this change; this branch adds 27 passing tests and does not introduce new failures.

Closes #476

@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@solomonadzape95 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! 🚀

Learn more about application limits

…gs (StellarState#476)

- Add auto-invest rule domain: sectors, min yield, max invoice age, per-invoice cap with validation (lib/autoInvest.ts)
- Wire set_auto_invest_rule / disable_auto_invest / AutoInvestExecuted events through lib/api and useAutoInvest
- Build AutoInvestSettingsPanel with top enable/disable toggle and confirmation modal on disable
- Show the active rule summary and a recent AutoInvestExecuted activity list
- Mount the panel in investor settings and link it from the investor dashboard
- Cover validation, optimistic save/disable rollback and panel states with tests
@solomonadzape95
solomonadzape95 force-pushed the feature/476-auto-invest-settings branch from 7175147 to 125be40 Compare October 18, 2026 10:07
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.

Implement auto-invest configuration panel in investor settings

1 participant