Skip to content

feat: thorchain affiliate fees endpoint - #1227

Merged
kaladinlight merged 1 commit into
developfrom
thorchain-affiliate-fees
Dec 11, 2025
Merged

feat: thorchain affiliate fees endpoint#1227
kaladinlight merged 1 commit into
developfrom
thorchain-affiliate-fees

Conversation

@kaladinlight

@kaladinlight kaladinlight commented Dec 11, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added a new API endpoint for querying affiliate fee history. Users can retrieve fee data with optional date range filtering using start and end query parameters.
  • Documentation

    • Updated API documentation and schema to reflect the new affiliate fees endpoint, including parameter descriptions and response structure.

✏️ Tip: You can customize this high-level summary in your review settings.

@kaladinlight
kaladinlight requested a review from a team as a code owner December 11, 2025 17:21
@kaladinlight
kaladinlight merged commit 7c3e396 into develop Dec 11, 2025
2 of 3 checks passed
@coderabbitai

coderabbitai Bot commented Dec 11, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes introduce a new API endpoint /api/v1/affiliate/fees that retrieves affiliate fees within a specified time range. The implementation includes query parameter parsing for start and end timestamps, filtering logic in the handler layer, and corresponding Swagger documentation. JSON serialization tags are added to the AffiliateFee struct to support proper encoding.

Changes

Cohort / File(s) Summary
Struct serialization
go/coinstacks/thorchain/api/affiliateFees.go
Added JSON struct tags to all fields of AffiliateFee (amount, asset, blockHeight, blockHash, timestamp, address, txId) for consistent JSON serialization.
API endpoint and route
go/coinstacks/thorchain/api/api.go
Added GET endpoint handler AffiliateFees() wired to /api/v1/affiliate/fees. Introduced GetAffiliateFeesParams type with Start and End query fields. Implemented query parameter parsing with defaults (start=0, end=current time in ms). Includes Swagger annotations.
Business logic and models
go/coinstacks/thorchain/api/handler.go
Added AffiliateFees model containing a Fees slice. Implemented GetAffiliateFees(start, end) method that filters affiliate fees by timestamp range from the indexer.
API documentation
go/coinstacks/thorchain/api/swagger.json
Added /api/v1/affiliate/fees GET endpoint definition with start/end query parameters. Defined AffiliateFee and AffiliateFees schemas with all fields and response types (200, 400, 500).

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as API Handler
    participant Handler
    participant Indexer

    Client->>API: GET /api/v1/affiliate/fees?start=X&end=Y
    activate API
    API->>API: Parse query parameters<br/>(default: start=0, end=now)
    API->>Handler: GetAffiliateFees(start, end)
    deactivate API
    
    activate Handler
    Handler->>Indexer: AffiliateFees (get all)
    activate Indexer
    Indexer-->>Handler: []*AffiliateFee
    deactivate Indexer
    
    Handler->>Handler: Filter by timestamp<br/>(start ≤ ts ≤ end)
    Handler-->>API: AffiliateFees{Fees: filtered}
    deactivate Handler
    
    activate API
    API-->>Client: 200 OK<br/>{ "fees": [...] }
    deactivate API
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • The feature follows standard API patterns (endpoint handler, query parsing, model definition).
  • The filtering logic in handler.go is straightforward timestamp-range comparison with no complex business rules.
  • All changes are consistent and isolated to the affiliate fees feature.
  • Swagger documentation is auto-generated schema mappings.

Possibly related PRs

Poem

🐰 A new endpoint hops into place,
/affiliate/fees shows its face!
With start and end, we filter with grace,
Through indexed data at rabbiting pace,
JSON tags dance in their proper case! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch thorchain-affiliate-fees

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a71d7c1 and a905943.

📒 Files selected for processing (4)
  • go/coinstacks/thorchain/api/affiliateFees.go (1 hunks)
  • go/coinstacks/thorchain/api/api.go (2 hunks)
  • go/coinstacks/thorchain/api/handler.go (1 hunks)
  • go/coinstacks/thorchain/api/swagger.json (2 hunks)

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.

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