Skip to content

[fix] Depositor yield history clamps negative yield to zero, hiding real losses #1856

Closed

Description

@K1NGD4VID

File/location: backend/src/services/yieldHistoryService.ts:262

Description:
buildDepositorYieldHistory computes netYield = Math.max(0, currentValue - depositedValue), so any bucket where a depositor's current position is worth less than their cost basis (e.g. after emergency-withdrawal share loss or a pool value decline) is reported as netYield: 0 instead of the actual negative value, misrepresenting the depositor's real performance on the yield-history chart/API response.

Acceptance Criteria:

  • netYield reflects the true signed difference (currentValue - depositedValue), including negative values, in the returned YieldHistoryPoint[]
  • A test constructs a scenario where currentValue < depositedValue (e.g. a large withdrawal after a value drop) and asserts the returned netYield is negative, not 0

Notes:
yieldHistoryService.test.ts:109 already comments 'may be slightly negative due to share price' while asserting only >= -1, which passes trivially against the current always->=0 behavior and does not actually catch this.


Filed via automated codebase sweep (backend / fix).

Activity

  1. added
    bugSomething isn't working
    backendIssues related to backend development
    on Sep 27, 2026
  2. davidchike587-cmyk commented on Sep 28, 2026

    @davidchike587-cmyk

    @davidchike587-cmyk has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hello Maintainer, I've understood the issue and I'm confident I can come up with a clean and efficient fix for it.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @davidchike587-cmyk to this issue.

  3. Jubilee-001 commented on Sep 29, 2026

    @Jubilee-001
    Contributor

    @Jubilee-001 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi maintainer please assign me to this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Jubilee-001 to this issue.

  4. drips-wave commented on Sep 29, 2026

    @drips-wave

    Congratulations, @Jubilee-001! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @Jubilee-001: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  5. drips-wave commented on Oct 13, 2026

    @drips-wave

    This issue has been marked as completed by a Drips Wave moderator for @Jubilee-001 as part of the Stellar Wave Program's 9th Wave 🥳

    Moderator's reason: [Auto-assessed] PR #1969 is merged (mergedAt timestamp 2026-10-10T10:06:49Z), cleanly removing the Math.max(0) clamp on netYield and adding unit tests covering negative yield scenarios as requested by issue #1856. There are no maintainer objections across any channel.

    😎 @Jubilee-001: You earned 150 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

    ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendIssues related to backend developmentbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions