Skip to content

feat: add funding event tracking with cursor-based pagination#2

Merged
pcfreak30 merged 1 commit intomasterfrom
funding-tracking
May 5, 2026
Merged

feat: add funding event tracking with cursor-based pagination#2
pcfreak30 merged 1 commit intomasterfrom
funding-tracking

Conversation

@pcfreak30
Copy link
Copy Markdown
Member

@pcfreak30 pcfreak30 commented May 5, 2026

  • Capture actual funded deltas (AccountDeposit + ContractID) from funding loop
  • Record funding events to funding_events table with amount_sc, estimated upload/download bytes
  • Add cursor-based (created_at, id) pagination for funding history API
  • Add GET /funding/events admin endpoint with Go client support
  • Add SQL migration for funding_events table with composite indexes
  • Calculate estimated bytes from SC amount using host sector costs at funding time
  • Cap estimatedBytes overflow at math.MaxInt64

Add funding event tracking with cursor-based pagination

This PR introduces tracking of account funding events, recording each deposit made during the funding process along with estimated upload and download byte coverage. A new admin API endpoint (GET /funding/events) allows querying these events using cursor-based pagination.

Key changes:

  • FundingEvent model: New struct capturing account key, host key, contract ID, amount, estimated upload/download bytes, and creation timestamp
  • FundedDeposit type: The FundAccounts method now returns deposit details alongside funded/drained counts, enabling downstream recording of individual deposits
  • Event recording: After funding accounts (both service and regular), deposits are converted to funding events with estimated byte coverage (calculated from host pricing assuming a 50/50 read/write split) and persisted
  • Cursor-based pagination: New FundingCursor (timestamp + ID) enables stable pagination through events ordered by creation time
  • Database: New funding_events table with indexes for account+host lookups, host+time queries, and cursor-based pagination; includes migration
  • Admin API: New GET /funding/events endpoint with after, id, and limit query parameters

@kody-ai

This comment has been minimized.

- Capture actual funded deltas (AccountDeposit + ContractID) from funding loop
- Record funding events to funding_events table with amount_sc, estimated upload/download bytes
- Add cursor-based (created_at, id) pagination for funding history API
- Add GET /funding/events admin endpoint with Go client support
- Add SQL migration for funding_events table with composite indexes
- Calculate estimated bytes from SC amount using host sector costs at funding time
- Cap estimatedBytes overflow at math.MaxInt64
@pcfreak30 pcfreak30 force-pushed the funding-tracking branch from d86c0fc to b258e1a Compare May 5, 2026 07:12
@kody-ai
Copy link
Copy Markdown

kody-ai Bot commented May 5, 2026

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@pcfreak30 pcfreak30 merged commit 6467046 into master May 5, 2026
3 checks 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.

1 participant