feat(spatial): Dynamic Geo-Spatial Liquidity Provider Rebalancing & Hotspot Incentive Engine (#421) - #423
Conversation
…otspot incentive engine (Nullifier-Systems#421)
|
@bamiebot-maker is attempting to deploy a commit to the jotelfootball-tech's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jotel-dev
left a comment
There was a problem hiding this comment.
Thanks @bamiebot-maker nice work. A few quick fixes before approving:
Reconcile the fee-multiplier formula between code and PR text (or centralize the constants).
Either allow a 1‑ring neighbor in verifyProviderGeofence or document why you require strict cell equality.
Confirm the background worker persists metrics and how multi-instance consistency/locking is handled.
Add tests for multiplier edge cases and concurrent request increment/decrement.
Remove unused imports and make thresholds/weights configurable (and consider pruning cached metrics).
Ping me after you update and I’ll re-review.
…ce, add multi-instance distributed locking, and stale metric pruning
|
Hi @jotel-dev, thanks for the review! I have addressed all your feedback points in commit \d1e5c57:
Ready for re-review! Thank you! |
jotel-dev
left a comment
There was a problem hiding this comment.
Thanks for confirming @bamiebot-maker
You did a great job.
Summary
Closes #421
This PR implements the Dynamic Geo-Spatial Liquidity Provider Rebalancing & Hotspot Incentive Engine on Uber H3 spatial resolution 7 cells (~1.22km edge length) to eliminate liquidity exhaustion in high-demand zones (e.g. transit hubs and event venues).
Core Components & Implementation:
apps/api/src/db/migrations/031_add_spatial_hotspot_incentives.sqldefiningspatial_h3_cell_metricswith composite primary key(h3_index, timestamp_bucket)and indexidx_h3_demandfor fast temporal spatial queries.apps/api/src/lib/h3-spatial-index.tswith demand ratio calculation (demandRatio = activeUnmatchedOrders / max(1, onlineProviders)).1.0 + min(1.0, max(0.0, (demandRatio - 1.5) * 0.2))yielding fee share boosts from1.1xto2.0xwhen demand ratio exceeds1.5.verifyProviderGeofence) ensuring providers are physically inside the H3 cell or within 1 k-ring neighbor before claiming boosted multipliers.apps/api/src/lib/workers/spatialMetricsWorker.tsrunning recurring 30-second recalculations with transaction locking (SELECT ... FOR UPDATE) and fallback memory caching.apps/api/src/routes/spatial-hotspots.ts(GET /api/v1/spatial/hotspots) returning GeoJSONFeatureCollectionpolygon features with bounding box filtering, tier classification (low,moderate,high,extreme), demand ratios, and provider counts.apps/api/src/lib/matching-engine.tswith scoring weight factorw5_hotspotIncentiveprioritizing providers repositioning into active hotspot cells.apps/api/src/routes/provider.tsto surface live hotspot multipliers on provider dashboards.mobile/frontend/src/components/SpatialHotspotMapOverlay.tsxwith color-coded demand hex badges, relocation recommendations, and dynamic fee multiplier indicators.Home.tsxand styled inindex.css.mobile/frontend/src/i18n/locales/en.jsonandes.json.Testing
All tests and validation suites pass cleanly:
Validation Results:
Checklist