Skip to content

Track entry fees in UserJoinedEvent and surface them in prize pool#990

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
AJtheManager:bac
Jun 18, 2026
Merged

Track entry fees in UserJoinedEvent and surface them in prize pool#990
Olowodarey merged 1 commit into
Arena1X:mainfrom
AJtheManager:bac

Conversation

@AJtheManager

Copy link
Copy Markdown
Contributor

The contract's join_event (contract Issue 7) charges event.entry_fee (if
non-zero) from the joining user and adds it to event.prize_pool. The indexer's
UserJoinedEvent handling previously only tracked participant_count, so the
cached creator_events.prize_pool did not reflect entry fees collected as users
joined.

This PR captures the entry fee paid in each UserJoinedEvent, adds it to the
cached prize_pool, and maintains a running total of fees collected
(total_entry_fees_collected) for transparency. The new totals are exposed via
the event stats endpoint.

Changes

  • Indexer payload extraction (src/indexer/indexer.service.ts)
    • extractEventData() 'UserJoinedEvent' case now reads entry_fee_paid
      using readUnsignedBigInt (defaults to "0" for free events / missing
      fields).
  • Entity column (src/matches/entities/creator-event.entity.ts,
    src/creator-events/entities/creator-event.entity.ts)
    • Added total_entry_fees_collected: string (bigint, default '0'). Both
      entities map to the creator_events table, so the column is added to both
      for consistency.
  • Fee accounting (src/indexer/indexer.service.ts)
    • handleUserJoinedEvent() now, after incrementing participant_count, adds
      the paid fee (only when non-zero) using BigInt arithmetic:
      event.prize_pool = (BigInt(event.prize_pool) + BigInt(entry_fee_paid)).toString();
      event.total_entry_fees_collected = (BigInt(event.total_entry_fees_collected) + BigInt(entry_fee_paid)).toString();
  • API response (src/creator-events/dto/event-stats-response.dto.ts,
    src/creator-events/creator-events.service.ts)
    • EventStatsResponseDto gains prizePool and totalEntryFeesCollected,
      populated in getEventStats() from the cached CreatorEvent (default "0"
      when no cache row exists).
  • Migration (src/migrations/1775900000000-AddTotalEntryFeesCollected.ts)
    • Adds the total_entry_fees_collected column (BIGINT DEFAULT '0'),
      backfills existing rows, and sets it NOT NULL. Reversible down.

Acceptance Criteria

  • A UserJoinedEvent with entry_fee_paid: "10000000" (1 XLM in stroops)
    adds 10000000 to both prize_pool and total_entry_fees_collected
    (e.g. 50000000005010000000).
  • A UserJoinedEvent with no entry_fee_paid (free event) leaves
    prize_pool and total_entry_fees_collected unchanged.
  • prize_pool arithmetic uses BigInt and is correct for large stroop
    values.

Tests

  • Added indexer unit tests:
    • extraction of entry_fee_paid from the payload,
    • default "0" for free events,
    • fee added to both prize_pool and total_entry_fees_collected,
    • free events leave both totals untouched.
  • Updated EventStatsResponseDto consumers and added assertions for the new
    prizePool / totalEntryFeesCollected fields (including the default-to-"0"
    path).

All affected suites pass (44 tests) and the production build typechecks clean.

Notes / Follow-ups

  • This relies on the contract emitting entry_fee_paid in UserJoinedEvent
    (contract Issue 7). If the deployed contract uses a different field name, the
    indexer will read "0"; the field name should be confirmed against the
    on-chain event.

closes #959

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Jun 18, 2026 6:59am

@Olowodarey

Copy link
Copy Markdown
Collaborator

clean job

@Olowodarey Olowodarey merged commit a87fd51 into Arena1X:main Jun 18, 2026
5 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.

[Backend] — Entry fee: grow prize_pool on UserJoinedEvent

2 participants