From efca18bf579310dbc3c5af2337fa5ef587172a47 Mon Sep 17 00:00:00 2001 From: Sadeequ <70214653+Sadeequ@users.noreply.github.com> Date: Sat, 27 Jun 2026 08:20:14 +0000 Subject: [PATCH] Fixed concentration risk alert and validator implementation [skip ci] --- validator_implmt.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 validator_implmt.md diff --git a/validator_implmt.md b/validator_implmt.md new file mode 100644 index 00000000..2052d90a --- /dev/null +++ b/validator_implmt.md @@ -0,0 +1,20 @@ +I implemented depositor concentration risk alerts and a withdrawal queue with fair ordering as requested. + +For depositor concentration alerts: + +Created RiskService in src/analytics/risk.service.ts that calculates depositor concentration hourly using SQL aggregation +Added depositorConcentrationThreshold column to Vault entity (default 0.5 for 50% threshold) +Extended NotificationType enum with DEPOSITOR_CONCENTRATION type +Integrated RiskService into AnalyticsModule and exposed via GET /vaults/:id/risk-metrics endpoint +Service sends notifications to vault owners when any depositor exceeds the threshold +For withdrawal queue with fair ordering: + +Added QUEUED status to WithdrawalStatus enum +Created WithdrawalQueueService to manage FIFO processing of withdrawals when liquidity is insufficient +Modified VaultsService.withdrawFromVault to: +Process withdrawals immediately when sufficient liquidity exists +Queue withdrawals (set status QUEUED) when insufficient liquidity +Process queue after successful deposits +Added controller endpoints for queue position and estimated wait time +Updated VaultsModule to include WithdrawalQueueService +The validation pipe was already properly configured in main.ts with ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true, transformOptions: { enableImplicitConversion: true } }), so no changes were needed there. \ No newline at end of file