Skip to content

feat: Implemented GET /analytics/yield-breakdown Specific Interest Extraction#456

Merged
Devsol-01 merged 2 commits intoDevsol-01:mainfrom
Ugasutun:feature/yield-breakdown-analytics
Mar 29, 2026
Merged

feat: Implemented GET /analytics/yield-breakdown Specific Interest Extraction#456
Devsol-01 merged 2 commits intoDevsol-01:mainfrom
Ugasutun:feature/yield-breakdown-analytics

Conversation

@Ugasutun
Copy link
Copy Markdown
Contributor

Closes #413

PR Description - Issue #413: GET /analytics/yield-breakdown Specific Interest Extraction

Summary

Implements a yield breakdown endpoint that displays exact dollar amounts mapped to individual savings pools, allowing users to know exactly where they're making money from yield.

Background & Context

  • Issue: [Backend] GET /analytics/yield-breakdown Specific Interest Extraction #413 - [Backend] GET /analytics/yield-breakdown Specific Interest Extraction
  • Purpose: Displays exact dollar amounts mapped to individual savings pools so the user knows where they're making money.
  • Acceptance Criteria:
    • Query Transaction table where: { userId, type: 'YIELD' }
    • Sum amount total → totalInterestEarned
    • Group by poolId isolating progress outputs ({ pool: 'XLM Staking', earned: 420.50 })

Changes Made

Files Modified:

  1. backend/src/modules/analytics/analytics.service.ts

    • Added getYieldBreakdown(userId: string) method (lines 217-255)
    • Queries YIELD transactions for the user
    • Groups by poolId and sums amounts
    • Maps pool IDs to human-readable names
  2. backend/src/modules/analytics/analytics.controller.ts

    • Added GET /analytics/yield-breakdown endpoint (lines 82-98)
    • Protected with JWT authentication
    • Returns YieldBreakdownDto
  3. backend/src/modules/analytics/dto/yield-breakdown.dto.ts

    • Defines response structure:
      {
        pools: Array<{ pool: string; earned: number }>;
        totalInterestEarned: number;
      }
  4. backend/src/modules/analytics/analytics.service.yield.spec.ts

    • Added unit tests for yield breakdown functionality
    • Tests grouping by pool and total calculation

Implementation Details

Service Method: getYieldBreakdown(userId: string)

// Queries Transaction table (where: { userId, type: 'YIELD' })
const yieldTransactions = await this.transactionRepository.find({
  where: { userId, type: LedgerTransactionType.YIELD },
});

// Sums amount total → totalInterestEarned
// Groups by poolId isolating progress outputs ({ pool: 'XLM Staking', earned: 420.50 })

Example Response:

{
  "pools": [
    { "pool": "XLM Staking", "earned": 495.5 },
    { "pool": "AQUA Farming", "earned": 150.25 }
  ],
  "totalInterestEarned": 645.75
}

Testing

  • Unit tests in analytics.service.yield.spec.ts pass successfully
  • Tests verify:
    • Pool grouping works correctly
    • Amounts are properly summed
    • Empty results return empty pools array with 0 total

Checklist

  • Queries Transaction table filtering by userId and type: 'YIELD'
  • Calculates totalInterestEarned from sum of all yields
  • Groups yields by poolId
  • Maps pool IDs to human-readable names
  • Returns sorted pools array (highest earned first)
  • Endpoint protected with JWT auth
  • Unit tests pass

Target Branch

  • Branch: feature/yield-breakdown-analytics
  • Target: main

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

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

Project Deployment Actions Updated (UTC)
nestera Ready Ready Preview, Comment Mar 29, 2026 2:48pm

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@Ugasutun Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Devsol-01 Devsol-01 merged commit 2880c54 into Devsol-01:main Mar 29, 2026
8 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] GET /analytics/yield-breakdown Specific Interest Extraction

2 participants