Skip to content

feat: view data provider incentives in indexer#1333

Merged
MicBun merged 1 commit intomainfrom
viewDpReward
Mar 11, 2026
Merged

feat: view data provider incentives in indexer#1333
MicBun merged 1 commit intomainfrom
viewDpReward

Conversation

@MicBun
Copy link
Member

@MicBun MicBun commented Mar 11, 2026

resolves: https://github.com/truflation/website/issues/3441
resolves: https://github.com/truflation/website/issues/3419

Data Provider incentives can now be seen on
http://ec2-52-15-66-172.us-east-2.compute.amazonaws.com:8080/v0/prediction-market/participants/0xc11Ff6d3cC60823EcDCAB1089F1A4336053851EF/rewards

It is now recorded in indexer so we Data Provider can view how much they earn

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Data Providers and Validators are now automatically registered as system participants during order book operations if they don't already exist, ensuring complete fee distribution tracking and settlement processing.

@MicBun MicBun requested a review from pr-time-tracker March 11, 2026 10:17
@MicBun MicBun self-assigned this Mar 11, 2026
@MicBun MicBun added the type: feat New feature or request label Mar 11, 2026
@holdex
Copy link

holdex bot commented Mar 11, 2026

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 4h 30min Update time Mar 11, 2026, 10:24 AM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

The changes add automatic creation of participant records for Data Providers and Validators in the order book settlement flow, ensuring participants exist before recording net impacts, alongside comprehensive test coverage validating this behavior and correct fee distribution.

Changes

Cohort / File(s) Summary
Migration Logic
internal/migrations/033-order-book-settlement.sql
Adds conditional insertion of ob_participants records for Data Provider and Validator before recording their net impacts, retrying ID retrieval after insertion to ensure proper linkage to ob_net_impacts.
Test Coverage
tests/streams/order_book/fee_distribution_test.go
Introduces test testDistributionDPValidatorAutoParticipant verifying auto-creation of DP and Validator as ob_participants, correct fee allocation (12.5% to DP), corresponding ob_net_impacts entries, and audit trail consistency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

type: test

Suggested reviewers

  • pr-time-tracker

Poem

🐰 A rabbit tends the ledgers deep,
Auto-births for records to keep,
Validators and Providers new,
Fee shares split so fair and true,
Order books now complete and right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title describes viewing data provider incentives in an indexer, but the actual changes implement auto-creation of participant records and fee distribution logic in migrations and tests. Update the title to reflect the actual changes, such as 'fix: auto-create participant records for data providers and validators in fee distribution' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch viewDpReward

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/streams/order_book/fee_distribution_test.go (1)

1108-1111: Consider adding ob_rewards cleanup verification for consistency.

Other tests in this file (e.g., lines 247-249, 447-449, 856-858) verify that ob_rewards is cleared after distribution. This test should include the same verification for consistency with the test suite pattern:

🔧 Suggested addition before the final return
 		t.Logf("Audit verified: DP fees=%s, Validator fees=%s", totalDPFeesStr, totalValFeesStr)
 
+		// Verify ob_rewards table is cleaned up
+		rewardsAfter, err := getRewards(ctx, platform, int(marketID), 1000)
+		require.NoError(t, err)
+		require.Empty(t, rewardsAfter, "ob_rewards table should be empty after distribution")
+
 		return nil
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/streams/order_book/fee_distribution_test.go` around lines 1108 - 1111,
Add a final assertion before the function's "return nil" that verifies the
ob_rewards state is cleared after distribution: query the ob_rewards entries
(e.g., using the same keeper or store access used elsewhere in this file to
check ob_rewards) and assert it's empty (use require.Empty / assert.Len == 0 or
expect no iterator entries). Place this check just before "return nil" so this
test matches the other tests (lines ~247, ~447, ~856) that confirm ob_rewards is
cleared after distribution.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/streams/order_book/fee_distribution_test.go`:
- Around line 1108-1111: Add a final assertion before the function's "return
nil" that verifies the ob_rewards state is cleared after distribution: query the
ob_rewards entries (e.g., using the same keeper or store access used elsewhere
in this file to check ob_rewards) and assert it's empty (use require.Empty /
assert.Len == 0 or expect no iterator entries). Place this check just before
"return nil" so this test matches the other tests (lines ~247, ~447, ~856) that
confirm ob_rewards is cleared after distribution.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 119b379e-fbc1-4ff6-84db-aad692cfaba6

📥 Commits

Reviewing files that changed from the base of the PR and between b0f9323 and 6857479.

📒 Files selected for processing (2)
  • internal/migrations/033-order-book-settlement.sql
  • tests/streams/order_book/fee_distribution_test.go

@MicBun MicBun merged commit 78fc2b9 into main Mar 11, 2026
9 checks passed
@MicBun MicBun deleted the viewDpReward branch March 11, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant