Skip to content

[#637] Align trade price calculation between real-time and cron indexers#654

Merged
realproject7 merged 1 commit intomainfrom
task/637-price-consistency
Mar 30, 2026
Merged

[#637] Align trade price calculation between real-time and cron indexers#654
realproject7 merged 1 commit intomainfrom
task/637-price-consistency

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Real-time indexer (/api/index/trade): Replaced priceForNextMint (marginal bonding curve price) with batch average (reserveAmount / tokenAmount) to match the cron indexer.
  • Removed unused priceForNextMintFunction import and extra RPC call.
  • Both indexers now produce identical price_per_token values for the same trade.

Fixes #637
Tracks realproject7/agent-os#317

Test plan

  • Both indexers use same price calculation (batch average)
  • Trade history price_per_token is consistent regardless of which indexer runs
  • No extra priceForNextMint RPC call in real-time path
  • Build passes

🤖 Generated with Claude Code

Real-time indexer used priceForNextMint (marginal bonding curve price)
while cron indexer used batch average (reserveAmount / tokenAmount).

Switched real-time to batch average to match cron:
- Reflects actual cost paid, not marginal price
- Removes extra priceForNextMint RPC call
- Deterministic and consistent regardless of which path runs first

Fixes #637

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Mar 30, 2026 8:17pm

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The realtime trade indexer now uses the same batch-average price_per_token calculation as the cron trade-history route, so the two paths will stop producing divergent values for the same trade. The change is minimal and stays within the scope of the ticket.

Findings

  • No blocking findings.

Decision

Approving because the updated realtime calculation matches the cron path and resolves the consistency issue described in Queue #637 / agent-os#317.

@realproject7 realproject7 merged commit 18d2f59 into main Mar 30, 2026
5 checks passed
@realproject7 realproject7 deleted the task/637-price-consistency branch March 30, 2026 20:21
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.

Fix price inconsistency between real-time and cron trade indexers

2 participants