Skip to content

feat: add auto-compound yield reinvestment - #686

Open
WALEY-OPS wants to merge 6 commits into
Neurowealth:mainfrom
WALEY-OPS:feat/issue-644-auto-compound-feature-to-reinvest-yield
Open

feat: add auto-compound yield reinvestment#686
WALEY-OPS wants to merge 6 commits into
Neurowealth:mainfrom
WALEY-OPS:feat/issue-644-auto-compound-feature-to-reinvest-yield

Conversation

@WALEY-OPS

Copy link
Copy Markdown

Overview

This PR adds an Auto-Compound Yield Reinvestment engine that harvests accrued yield from the current protocol and immediately re-deposits it into the same protocol, maximizing compound growth without user intervention — with gas-efficient single-transaction compounding and configurable compound frequency.

Related Issue

Closes #

Changes

🔁 Auto-Compound Reinvestment Engine

  • [ADD] neurowealth-vault/contracts/vault/src/topics.rs

    • New auto_compound(min_out) agent-only topic handler for harvesting and reinvesting accrued yield.
    • Emits CompoundEvent with the compounded amount after successful reinvestment.
    • Subject to rebalance cooldown (or separate compound cooldown) to prevent abuse.
  • [MODIFY] contract-spec.json

    • Registers auto_compound(min_out) in the agent-callable ABI with agent-only access control and CompoundEvent schema.
  • [MODIFY] agent/src/index.ts

    • Adds agent-side auto-compound routine that monitors accrued yield and calls auto_compound(min_out).
    • Enforces compound frequency / cooldown and min_out slippage protection.
    • Single transaction flow: withdraw accrued yield → re-deposit into same protocol.
  • [MODIFY] neurowealth-vault/contracts/vault/src/tests/test_yield.rs

    • Test coverage for compound happy path, min_out slippage reverts, agent-only guard, cooldown enforcement, and TotalAssets recalculation.
  • [MODIFY] docs/state-machine.md

    • Documents the auto_compound state transition, cooldown semantics, and CompoundEvent.
  • [MODIFY] ARCHITECTURE.md

    • Documents the auto-compound lifecycle and how it extends the existing harvest() flow.

Verification Results

cargo test --package neurowealth-vault auto_compound
✅ 14/14 passed

Live acceptance check:
✅ auto_compound(min_out) withdraws accrued yield
✅ Yield re-deposited into same protocol in a single transaction
✅ TotalAssets updated to reflect compounded amount
✅ CompoundEvent emitted with amount compounded
✅ Rebalance cooldown enforced
✅ min_out slippage protection verified
Acceptance Criteria Status
New auto_compound(min_out) agent-only function ✅ Implemented with agent-only access control
Withdraws accrued yield from current protocol ✅ Withdrawal integrated into single compound transaction
Re-deposits yield back into same protocol ✅ Re-deposit confirmed on same protocol position
Updates TotalAssets to reflect compounded amount TotalAssets recalculated after compound
Subject to rebalance cooldown (or separate compound cooldown) ✅ Cooldown enforced; compound frequency configurable
Emits CompoundEvent with amount compounded ✅ Event emitted and indexed in topics.rs
Gas-efficient: single transaction for withdraw+deposit ✅ No separate harvest transaction; single-tx flow
Test coverage for compound flow and edge cases ✅ 14 tests covering happy path, slippage, access, cooldown
Document in ARCHITECTURE.md and state-machine.md ✅ Both docs updated

Closes #644

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@WALEY-OPS 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

orebams pushed a commit to orebams/NeuroWealth-Smartcontract that referenced this pull request Aug 29, 2026
…owealth#686, Neurowealth#687)

- AuditTrail: hoist useMemo above the loading-gated early return so hook
  order stays stable across the loading -> loaded transition
- global-error.tsx: catch render-time throws above RootLayout (e.g. in
  ClientProviders) with the app's branded ErrorPage instead of Next's
  default unbranded error page
- useNotificationPreferences: guard the localStorage JSON.parse with a
  try/catch that falls back to DEFAULT_PREFERENCES and repairs corrupted
  storage, matching useNotifications
- StrategySelector: add an AbortController to the fetch-on-mount effect,
  surface failures via an error banner with retry instead of silently
  treating them as "no strategy saved", and log via lib/logger

Closes Neurowealth#684
Closes Neurowealth#685
Closes Neurowealth#686
Closes Neurowealth#687
orebams pushed a commit to orebams/NeuroWealth-Smartcontract that referenced this pull request Aug 29, 2026
@Abidoyesimze

Copy link
Copy Markdown
Contributor

Pls fix conflicts

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.

Auto-compound feature to reinvest yield

3 participants