Skip to content

feat: Persist Vault Contract Events into Prisma#27

Merged
robertocarlous merged 5 commits intoNeurowealth:mainfrom
caxtonacollins:feat/vault-events-persistence
Mar 29, 2026
Merged

feat: Persist Vault Contract Events into Prisma#27
robertocarlous merged 5 commits intoNeurowealth:mainfrom
caxtonacollins:feat/vault-events-persistence

Conversation

@caxtonacollins
Copy link
Copy Markdown
Contributor

@caxtonacollins caxtonacollins commented Mar 26, 2026

Persist Vault Contract Events into Prisma (Idempotent)

Closes #23

Summary

Implements idempotent vault contract event persistence with automatic deduplication and ledger cursor tracking for reliable event processing and recovery.

Changes

  • Schema: Added EventCursor and ProcessedEvent models for tracking and deduplication
  • Events: Implemented deposit/withdraw/rebalance event handlers with database persistence
  • Idempotency: Unique constraint on (contractId, txHash, eventType, ledger) prevents duplicates
  • Cursor: Persists last processed ledger for resumption on restart
  • Tests: Comprehensive unit and integration tests with mocked RPC

Acceptance Criteria

✅ Deposit events mark transactions CONFIRMED and update balances
✅ Withdraw events update positions correctly
✅ Rebalance events record protocol rates
✅ No duplicate processing via deduplication logic
✅ Listener resumes from last processed ledger on restart
✅ All tests pass with proper mocking

Files Changed

  • prisma/schema.prisma - Added EventCursor and ProcessedEvent models
  • prisma/migrations/20260326152030_add_event_tracking/migration.sql - Migration for new tables
  • src/stellar/events.ts - Full implementation of event persistence
  • tests/unit/stellar/events.test.ts - Unit tests
  • tests/integration/stellar/events.test.ts - Integration tests

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 26, 2026

@caxtonacollins 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

@robertocarlous robertocarlous merged commit 63d6e86 into Neurowealth:main Mar 29, 2026
1 check passed
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.

Persist Vault Contract Events into Prisma (Idempotent)

2 participants