π 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
π 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
π Description
LiquidityService.withdrawLiquiditymutates (or removes) theLiquidityEntryfor an anchor/asset pair but keeps no record of the withdrawal event itself β once a balance reaches zero and the entry is removed viathis.repo.remove(anchor, asset), there is no trace anywhere (besides the generic mutating-requestauditLog.tsmiddleware, which only records method/path/status, not amounts) of how much was withdrawn or when.π§© Requirements and context
BoundedHistory<WithdrawalRecord>inLiquidityService, mirroring the pattern already used byroutes/metrics.ts) recording{ anchor, asset, amount, remainingBalance, timestamp }for every successful withdrawal.LiquidityService.listWithdrawals().GET /api/v1/liquidity/withdrawalsroute.π οΈ Suggested execution
src/services/liquidityService.tsto record a withdrawal entry usingsrc/utils/history.ts'sBoundedHistoryinsidewithdrawLiquidity.GET /withdrawalsroute tosrc/routes/liquidity.ts.src/openapi.tswith the new path.src/services/liquidityService.test.tsandsrc/routes/liquidity.test.ts.β Acceptance criteria
GET /api/v1/liquidity/withdrawalsreturns the recorded history, bounded by the same pattern as otherBoundedHistoryusages.withdrawLiquiditytests unaffected.π Security notes
N/A β additive read-only audit trail improving traceability of a mutating financial operation, itself a security-positive change.
π Guidelines