Systems
Introduction
Med.Fun features three integrated earning systems that reward users for engagement, trading activity, and community growth. These systems work together to create a comprehensive gamification and rewards ecosystem.
Systems Overview
1. Referral System
Share your unique referral code and earn commission on your referrals' trading activity. Features tier-based rewards with increasing commission rates.
Primary Benefit: Passive income through referral commissions How to Earn: Share your referral link with friends Min Payout: $1.00 USD
2. Points System
Earn points for platform engagement and unlock badges as you level up. A gamification layer that rewards user activity across the platform.
Primary Benefit: Levels, badges, and recognition How to Earn: Daily login, trading, creating tokens, referring friends Min Payout: N/A (progression-based)
3. Rewards System
Earn cashback on trading fees with tier-based multipliers. The more you trade, the higher your tier and cashback rate.
Primary Benefit: Trading fee cashback How to Earn: Trade tokens to increase volume Min Payout: $1.00 USD
Quick Comparison
Referral
Commission on referrals
Share link
$1.00
Yes (4 tiers)
Points
Levels & Badges
Platform engagement
N/A
Yes (50+ levels)
Rewards
Trading cashback
Trade volume
$1.00
Yes (5 tiers)
System Integration
All three systems are integrated into a unified dashboard that provides:
Aggregated Earnings: Combined view of referral commissions and trading cashback
Real-time Updates: Live updates via Supabase subscriptions
Mobile-Responsive: Optimized for both desktop and mobile interfaces
Single Hook:
useEarnings()combines data from all three systems
Common Features
Backend Architecture
Database: Supabase PostgreSQL with Row Level Security (RLS)
Real-time Sync: Supabase subscriptions for instant updates
Data Validation: Database-level constraints and triggers
Type Safety: Full TypeScript integration
Frontend Architecture
React Hooks: Custom hooks for each system (
useReferrals,usePoints,useRewards)State Management: Local state with Supabase real-time sync
UI Components: Radix UI primitives with Tailwind CSS
Responsive Design: Mobile-first with Sheet/Dialog patterns
Security
RLS Policies: User-scoped data access
Wallet-Based Auth: Secure authentication via Privy
Server-Side Validation: Backend validation for all operations
Audit Trails: Complete transaction history
Documentation Structure
Referral System - Complete referral program documentation
Points System - Points and leveling system documentation
Rewards System - Trading rewards and cashback documentation
Unified Dashboard - Combined earnings dashboard
Getting Started
For developers looking to understand or extend these systems, we recommend reading the documentation in this order:
Start with the README (this page) for an overview
Read the Unified Dashboard documentation to understand integration
Deep dive into individual systems based on your needs
Review database schemas in each system's documentation
Developer Resources
Key Files
/src/hooks/useReferrals.tsx- Referral system hook/src/hooks/usePoints.tsx- Points system hook/src/hooks/useRewards.tsx- Rewards system hook/src/hooks/useEarnings.tsx- Unified earnings hook/src/components/ReferralDashboard.tsx- Referral UI/src/components/PointsDashboard.tsx- Points UI/src/components/TradingRewardsDashboard.tsx- Rewards UI/src/components/UnifiedEarningsDashboard.tsx- Combined UI
Database Tables
referral_codes,user_referrals,referral_earnings,referral_tiers,referral_settingsuser_points,point_transactionsreward_tiers,user_trading_stats,cashback_earnings
Support
For questions or issues related to these systems, please refer to the individual system documentation or contact the development team.
Last updated
Was this helpful?