Skip to content

Add a withdrawal audit trail to LiquidityService.withdrawLiquidity distinct from the balance mutation itselfΒ #154

Description

@Jagadeeshftw

πŸ“Œ Description

LiquidityService.withdrawLiquidity mutates (or removes) the LiquidityEntry for an anchor/asset pair but keeps no record of the withdrawal event itself β€” once a balance reaches zero and the entry is removed via this.repo.remove(anchor, asset), there is no trace anywhere (besides the generic mutating-request auditLog.ts middleware, which only records method/path/status, not amounts) of how much was withdrawn or when.

🧩 Requirements and context

  • Add an in-memory withdrawal history (e.g. a BoundedHistory<WithdrawalRecord> in LiquidityService, mirroring the pattern already used by routes/metrics.ts) recording { anchor, asset, amount, remainingBalance, timestamp } for every successful withdrawal.
  • Expose the history via a new read method, e.g. LiquidityService.listWithdrawals().
  • Add a corresponding GET /api/v1/liquidity/withdrawals route.

πŸ› οΈ Suggested execution

  • Modify src/services/liquidityService.ts to record a withdrawal entry using src/utils/history.ts's BoundedHistory inside withdrawLiquidity.
  • Add the GET /withdrawals route to src/routes/liquidity.ts.
  • Update src/openapi.ts with the new path.
  • Add tests in src/services/liquidityService.test.ts and src/routes/liquidity.test.ts.

βœ… Acceptance criteria

  • Every successful withdrawal is recorded with amount, resulting balance, and timestamp.
  • GET /api/v1/liquidity/withdrawals returns the recorded history, bounded by the same pattern as other BoundedHistory usages.
  • New tests pass; existing withdrawLiquidity tests unaffected.

πŸ”’ Security notes

N/A β€” additive read-only audit trail improving traceability of a mutating financial operation, itself a security-positive change.

πŸ“‹ Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuebackendBackend service workenhancementNew feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions