telegram link : t.me/nullifiersystem
1. Summary & Core Promise
Velo's spatial indexing in apps/api/src/lib/h3-spatial-index.ts and order allocation in apps/api/src/lib/order-allocator.ts match cash requests to nearby providers using flat distance metrics. In high-demand zones (e.g. transit hubs or event venues), provider liquidity quickly exhausts while adjacent cells remain over-capitalized.
This feature implements a Dynamic Geo-Spatial Liquidity Provider Rebalancing & Hotspot Incentive Engine. It calculates spatial demand density across Uber H3 hex cells (resolution = 7), dynamically boosts provider fee share multipliers (1.1x to 2.0x) in high-demand "hotspots", and updates provider allocation weights in PostgreSQL (SELECT FOR UPDATE).
2. Background & Architectural Risks
- Spatial Liquidity Desert: Popular geographic cells run out of active cash providers while nearby cells have idle liquidity.
- Dynamic Fee Manipulation: Malicious providers spoofing locations to artificially trigger hotspot fee multipliers without fulfilling local trades.
3. Database Layer Specifications
Migration SQL (031_add_spatial_hotspot_incentives.sql)
CREATE TABLE spatial_h3_cell_metrics (
h3_index VARCHAR(15) PRIMARY KEY,
active_requests_count INT NOT NULL DEFAULT 0,
available_providers_count INT NOT NULL DEFAULT 0,
demand_ratio NUMERIC(5,2) NOT NULL DEFAULT 1.00,
fee_multiplier NUMERIC(3,2) NOT NULL DEFAULT 1.00,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_h3_demand ON spatial_h3_cell_metrics(demand_ratio DESC);
Data Locking (SELECT FOR UPDATE)
BEGIN;
SELECT h3_index, demand_ratio, fee_multiplier
FROM spatial_h3_cell_metrics
WHERE h3_index = $1
FOR UPDATE;
-- Recalculate demand ratio and fee multiplier...
COMMIT;
4. Backend Route & Service Layer Specifications
Route: GET /api/v1/spatial/hotspots
- Queries high-demand H3 cells where
demand_ratio > 2.0.
- Computes dynamic fee multiplier
min(1.0 + (demand_ratio * 0.1), 2.0).
- Returns geoJSON spatial hotspot overlay layer for mobile clients.
5. Background Processors / Workers
H3 Spatial Metrics Recalculator Worker (apps/api/src/lib/workers/spatialMetricsWorker.ts)
- Runs every 30 seconds. Aggregates active cash requests per H3 cell and updates
fee_multiplier scores.
6. Frontend / UI Component Specifications
Component: mobile/frontend/src/components/SpatialHotspotMapOverlay.tsx
- Renders interactive H3 spatial hex map overlay showing high-yield hotspot zones (color-coded green -> orange -> red) to guide providers where to relocate for higher fee earnings.
7. Rigor & Test Plan
- Unit Tests (
h3-spatial-index.ts): Verify H3 cell aggregation and demand ratio calculation.
- Concurrency Stress Test (
tests/concurrency/spatial_hotspot_stress.test.ts): Simulate 100 simultaneous cash requests in a single H3 cell; assert fee multiplier caps at 2.0x cleanly.
8. Relevant Files Inventory
New Files to Create
apps/api/src/db/migrations/031_add_spatial_hotspot_incentives.sql
apps/api/src/routes/spatial-hotspots.ts
apps/api/src/lib/workers/spatialMetricsWorker.ts
tests/concurrency/spatial_hotspot_stress.test.ts
mobile/frontend/src/components/SpatialHotspotMapOverlay.tsx
Existing Files to Modify
apps/api/src/lib/h3-spatial-index.ts
apps/api/src/lib/order-allocator.ts
apps/api/src/routes/provider.ts
apps/api/src/app.ts
mobile/frontend/src/pages/Home.tsx
9. Acceptance Criteria
10. Contributor Notes
- ⚠️ Geofence Verification: ALWAYS verify provider GPS coordinates against H3 cell boundaries before granting hotspot fee multipliers.
telegram link : t.me/nullifiersystem
1. Summary & Core Promise
Velo's spatial indexing in
apps/api/src/lib/h3-spatial-index.tsand order allocation inapps/api/src/lib/order-allocator.tsmatch cash requests to nearby providers using flat distance metrics. In high-demand zones (e.g. transit hubs or event venues), provider liquidity quickly exhausts while adjacent cells remain over-capitalized.This feature implements a Dynamic Geo-Spatial Liquidity Provider Rebalancing & Hotspot Incentive Engine. It calculates spatial demand density across Uber H3 hex cells (
resolution = 7), dynamically boosts provider fee share multipliers (1.1x to 2.0x) in high-demand "hotspots", and updates provider allocation weights in PostgreSQL (SELECT FOR UPDATE).2. Background & Architectural Risks
3. Database Layer Specifications
Migration SQL (
031_add_spatial_hotspot_incentives.sql)Data Locking (
SELECT FOR UPDATE)4. Backend Route & Service Layer Specifications
Route:
GET /api/v1/spatial/hotspotsdemand_ratio > 2.0.min(1.0 + (demand_ratio * 0.1), 2.0).5. Background Processors / Workers
H3 Spatial Metrics Recalculator Worker (
apps/api/src/lib/workers/spatialMetricsWorker.ts)fee_multiplierscores.6. Frontend / UI Component Specifications
Component:
mobile/frontend/src/components/SpatialHotspotMapOverlay.tsx7. Rigor & Test Plan
h3-spatial-index.ts): Verify H3 cell aggregation and demand ratio calculation.tests/concurrency/spatial_hotspot_stress.test.ts): Simulate 100 simultaneous cash requests in a single H3 cell; assert fee multiplier caps at 2.0x cleanly.8. Relevant Files Inventory
New Files to Create
apps/api/src/db/migrations/031_add_spatial_hotspot_incentives.sqlapps/api/src/routes/spatial-hotspots.tsapps/api/src/lib/workers/spatialMetricsWorker.tstests/concurrency/spatial_hotspot_stress.test.tsmobile/frontend/src/components/SpatialHotspotMapOverlay.tsxExisting Files to Modify
apps/api/src/lib/h3-spatial-index.tsapps/api/src/lib/order-allocator.tsapps/api/src/routes/provider.tsapps/api/src/app.tsmobile/frontend/src/pages/Home.tsx9. Acceptance Criteria
10. Contributor Notes