Feature/platform enhancements#250
Merged
parkerwinner merged 6 commits intoJul 4, 2026
Merged
Conversation
- Add FeeConfig and FeeAuditLog models with GORM soft-delete support - Add SQL migration 0013 creating fee_configs and fee_audit_logs tables - Implement FeeService with tiered volume discount calculation using basis points, configurable per fee type (marketplace, transfer, staking, liquidity) - Implement FeeAdminHandler with full CRUD for admin users, audit log endpoint, and public preview/active-config endpoints - Register FeeConfig and FeeAuditLog in AutoMigrate - Wire admin fee routes under authenticated admin group in router - Wire public /fees/preview and /fees/active into v1 group - Add unit tests covering create, list, update, deactivate, tiered discounts, fee preview with and without tier, and validation error cases
|
@Mosas2000 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
fix conflicts @Mosas2000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement real-time blockchain event indexing, liquidity pool analytics, GDPR-compliant data export, and dynamic fee configuration
Closes #180
Closes #179
Closes #178
Closes #177
Overview
This PR implements four backend features across the feature/platform-enhancements branch. Each feature is self-contained with its own models, SQL migration, service layer, HTTP handlers, and unit tests.
#180 — Real-time blockchain event indexing
Files: models/indexed_event.go, migrations/sql/0027_create_event_index.up.sql, services/event_indexer.go
Adds IndexedEvent and EventCheckpoint GORM models to persist indexed on-chain events and track the last processed ledger per contract
SQL migration creates indexed_events and event_checkpoints tables with appropriate indexes
EventIndexer service polls Horizon/Soroban RPC on a configurable ticker interval with a channel-based worker pool (3 workers) for concurrent event processing
Handles chain reorganisations by comparing stored ledger sequences against the checkpoint; missed events are recovered on the next poll cycle
Retry logic with exponential backoff on transient RPC failures
Indexer is started as a background goroutine in router.go at server boot
#179 — Comprehensive analytics for liquidity pools
Files: models/pool_metrics.go, services/pool_analytics.go, handlers/liquidity.go, handlers/liquidity_test.go
Adds PoolMetrics and PoolComparison value types for computed analytics
PoolAnalyticsService calculates TVL, 24h/7d/30d volume, fees, APY, and impermanent loss ratio from swap history
GET /api/v1/liquidity/pools/:id/analytics returns full metrics for a single pool
GET /api/v1/liquidity/pools/compare?pool_a=:id&pool_b=:id returns a side-by-side comparison with APY and TVL deltas
Unit tests verify APY and volume calculations and the comparison response shape
#178 — GDPR-compliant data export for users
Files: models/export_job.go, services/data_export_service.go, handlers/gdpr.go, handlers/gdpr_test.go
Adds ExportJob model tracking async export state (pending → processing → completed / failed)
DataExportService gathers all user personal data (profile, KYC record, balances, listings, transactions), serialises to JSON or CSV-in-ZIP, and encrypts at rest using AES-256-GCM
A unique download token (32 random bytes, hex-encoded) is generated per job with a 7-day expiry
POST /api/v1/legal/gdpr/export initiates the job asynchronously; the user receives a download link by email on completion
GET /api/v1/legal/gdpr/export/:id returns current job status
GET /api/v1/legal/gdpr/export/download/:token decrypts and streams the archive; expired or invalid tokens are rejected with 400
Unit tests cover JSON export, CSV/ZIP export, and expired-link rejection
#177 — Dynamic fee configuration with admin interface
Files: models/fee_config.go, migrations/sql/0013_create_fee_config.up.sql, services/fee_service.go, handlers/fee_admin.go, handlers/fee_admin_test.go
Adds FeeConfig model supporting four fee types (marketplace, transfer, staking, liquidity) with BaseBasisPoints, MinBasisPoints, MaxBasisPoints, and a JSON-stored VolumeTier slice for graduated discounts
Adds FeeAuditLog model; every create, update, and deactivation writes a full JSON diff with the acting admin ID and an optional reason
FeeService exposes CRUD, CalculateFee (selects the highest matching volume tier and clamps to min/max), GetActiveFeeConfig, and paginated audit log retrieval
Admin endpoints under POST|GET|PUT|DELETE /api/v1/admin/fees (requires role=admin)
Public endpoints GET /api/v1/fees/preview and GET /api/v1/fees/active allow clients to display the effective fee before submitting a transaction
Configs are soft-deactivated rather than deleted to preserve the audit trail
Unit tests cover create/list, update with audit diff, deactivation, fee preview with and without tier discount, and validation error cases