Skip to content

Fix/stats webhook improvements#455

Open
Mac-5 wants to merge 4 commits into
Vatix-Protocol:mainfrom
Mac-5:fix/stats-webhook-improvements
Open

Fix/stats webhook improvements#455
Mac-5 wants to merge 4 commits into
Vatix-Protocol:mainfrom
Mac-5:fix/stats-webhook-improvements

Conversation

@Mac-5

@Mac-5 Mac-5 commented Jun 28, 2026

Copy link
Copy Markdown

Summary

closes #357
closes #358
closes #359
closes #360

Issue 1 — Stats: feeApr from pool fees
stats.worker.ts: replaced the approximation volume24h × (feeTier/1_000_000) with a sum of actual swap.feeAmount fields from 24h swaps, multiplied by the token price, then annualised. Tests updated with feeAmount on mock swaps and two new assertions verifying the real-fee-based result.

Issue 2 — Webhooks: large_swap threshold from env
webhooks.service.ts: largeSwapUsd default now reads LARGE_SWAP_THRESHOLD_USD from the environment (parseFloat(process.env.LARGE_SWAP_THRESHOLD_USD ?? '10000')). Explicit caller value still takes precedence.

Issue 3 — Webhooks: retry failed webhook deliveries

  • webhook.processor.ts: WEBHOOK_RETRY_ATTEMPTS is now configurable via process.env.WEBHOOK_RETRY_ATTEMPTS (default 3). Added retryFailedDeliveries(webhookId) which fetches failed BullMQ jobs and calls .retry() on matching ones.
  • webhooks.service.ts: retryDeliveries(webhookId, ownerWallet) verifies ownership then delegates to the worker.
  • webhooks.controller.ts: POST /webhooks/:id/retry endpoint added.

Issue 4 — Webhooks: webhook signature HMAC verification
webhook.types.ts: verifyWebhookSignature(body, signature, secret) exported — uses timingSafeEqual with a length pre-check and guards against empty/invalid inputs. POST /webhooks/verify-signature endpoint exposed in the controller.

Related issue

  • Closes #

Type of change

  • Bug fix
  • New feature
  • Docs update
  • Chore / refactor

Checklist

  • CI passes (lint + tests + build)
  • Self-reviewed the diff
  • Added or updated tests where relevant
  • Docs updated if needed

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.

Webhook signature HMAC verification Retry failed webhook deliveries LARGE_SWAP threshold from env feeApr calculation from pool fees

1 participant