Skip to content

fix: correct investment capacity calculation and analytics funding timestamp - #647

Closed
maikNeta wants to merge 2 commits into
StellarState:mainfrom
maikNeta:fix/issues-587-588-589-596-bugs
Closed

maikNeta wants to merge 2 commits into
StellarState:mainfrom
maikNeta:fix/issues-587-588-589-596-bugs

Conversation

@maikNeta

@maikNeta maikNeta commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Comprehensive fixes and enhancements for the auto-invest rule engine and issuer analytics features:

🐛 Critical Bugs Fixed

Auto-Invest Investment Capacity Bug (#596)

  • Issue: Used invoice.netAmount (discounted amount) to calculate available investment capacity
  • Fix: Calculate actual available capacity as invoice.amount - total_invested, then cap by rule.maxPerInvoice
  • Impact: Auto-invest rules now correctly invest based on remaining invoice capacity, not just discount rate

Analytics Funding Timestamp Bug (#587)

  • Issue: Used latest investment creation timestamp as funding completion, unreliable if created out-of-order
  • Fix: Use invoice.updatedAt when invoice status is FUNDED/SETTLED (the actual status change time)
  • Impact: Average days to full funding metric is now accurate and reliable

✨ Feature Enhancements

Complete Auto-Invest Rule CRUD (#596)

  • Added PATCH /api/v1/auto-invest/rules/:ruleId endpoint to update rule criteria
  • Support partial updates: only changed fields need to be provided
  • New capability to toggle enabled status without deleting/recreating rules
  • Full input validation for all numeric fields and constraints

Implementation Status

  • ✅ Auto-invest rule engine with criteria matching
  • ✅ Document bulk export with ZIP packaging
  • ✅ Stellar network selector middleware (testnet/mainnet routing)
  • ✅ Issuer analytics API with invoice performance metrics
  • ✅ Rule management endpoints (create, read, update, delete)

Closes #596
Closes #587
Closes #589
Closes #588

…mestamp

- Auto-invest: Use actual available invoice capacity (amount - invested) instead of netAmount (discounted amount) to correctly determine investment capacity
- Analytics: Use invoice.updatedAt instead of latest investment createdAt for more accurate funding completion timestamp

Closes StellarState#596
Closes StellarState#587
- Add PATCH /auto-invest/rules/:ruleId endpoint to update rule criteria or toggle enabled status
- Add comprehensive input validation for all numeric fields
- Support partial updates without requiring all fields
- Maintain ownership validation for rule modifications

Completes issue StellarState#596
@maikNeta

Copy link
Copy Markdown
Contributor Author

Closing — PR should target dev, not main. Reopening with correct base.

@maikNeta maikNeta closed this Oct 17, 2026
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.

1 participant