Skip to content

fix: remove Math.max(0) clamp on netYield in depositor yield history - #1969

Merged
K1NGD4VID merged 12 commits into
LabsCrypt:mainfrom
Jubilee-001:feat/yeild-negative-zero
Oct 10, 2026
Merged

K1NGD4VID merged 12 commits into
LabsCrypt:mainfrom
Jubilee-001:feat/yeild-negative-zero

Conversation

@Jubilee-001

Copy link
Copy Markdown
Contributor

Removes the Math.max(0, ...) clamp on netYield in buildDepositorYieldHistory so that the returned YieldHistoryPoint[] reflects the true signed difference (currentValue - depositedValue), including negative values. Previously, any bucket where a depositor's current position was worth less than their cost basis was reported as netYield: 0, hiding real losses from the yield-history chart/API response.
Changes:

  • backend/src/services/yieldHistoryService.ts — removed Math.max(0, ...) clamp on netYield (line 262)
  • backend/src/services/tests/yieldHistoryService.test.ts — updated existing assertion to expect true negative value (-250); added new test verifying negative netYield (-500) when currentValue < depositedValue
    Testing:
  • Lint (touched files): 0 errors, 0 warnings
  • Full test suite: 752 passed, 9 failed (all 9 failures are pre-existing in idempotency/auditLogService suites, unrelated to this change)
  • Baseline was 751 passed / 9 failed — no regressions, +1 new passing test

closes #1856

…ncy.namespace

- auditLogService.pagination.test.ts: Fixed mock setup order (imports after unstable_mockModule), pageQuery() to return last SELECT call, cursor parsing with decodeCursor(), filter count expectation (7 not 8), SQL trim(), and cursor ID value (299 not 298)
- idempotency.namespace.test.ts: Already had correct per-wallet namespacing mock setup; passes when run without test interference
Comment thread backend/src/services/__tests__/auditLogService.pagination.test.ts Fixed
const cacheKeysRead = () =>
asMock(cacheService.get).mock.calls.map(([key]) => String(key));
const aliceCacheKey = `idemp:${ALICE}:shared-key`;
const aliceLockKey = `idemp:${ALICE}:shared-key:lock`;
Comment thread backend/src/tests/idempotency.namespace.test.ts Fixed
Comment thread backend/src/services/__tests__/auditLogService.pagination.test.ts Fixed
return request;
};

const aliceCacheKey = `idemp:${ALICE}:shared-key`;

const aliceCacheKey = `idemp:${ALICE}:shared-key`;
const aliceLockKey = `idemp:${ALICE}:shared-key:lock`;
const bobCacheKey = `idemp:${BOB}:shared-key`;
const aliceCacheKey = `idemp:${ALICE}:shared-key`;
const aliceLockKey = `idemp:${ALICE}:shared-key:lock`;
const bobCacheKey = `idemp:${BOB}:shared-key`;
const bobLockKey = `idemp:${BOB}:shared-key:lock`;
@K1NGD4VID
K1NGD4VID merged commit 3053f5a into LabsCrypt:main Oct 10, 2026
14 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.

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

3 participants