The Group Resilience Rating Engine is a smart contract component that calculates and maintains health scores for SoroSusu groups (circles). This system provides prospective members with transparent due diligence information about group health before joining, encouraging self-moderation and healthy group dynamics.
The GroupHealthScore is calculated using a weighted algorithm:
- Aggregate Reputation (40%): Average trust score of all active members
- Payment Consistency (35%): On-time payment rate and late payment frequency
- Member Stability (15%): Member turnover and default rates
- Historical Performance (10%): Completed cycles and milestone achievements
Groups are categorized into five health ratings:
- Excellent (80-100%): Very healthy groups with strong performance
- Good (60-79%): Healthy groups with minor areas for improvement
- Fair (40-59%): Moderately healthy groups with some concerns
- Poor (20-39%): Unhealthy groups with significant issues
- Critical (0-19%): Very unhealthy groups at high risk
The rating engine provides several public search functions:
search_healthy_groups(): Find groups above a minimum health ratingget_groups_at_risk(): Identify groups that need interventionget_top_performing_groups(): Get the highest-rated groupsget_health_score_history(): Track health trends over time
Comprehensive health information for a group including:
- Individual component scores
- Overall health score and rating
- Member statistics
- Payment performance metrics
- Historical performance data
Detailed payment consistency tracking:
- Total, on-time, and late payment counts
- Average lateness metrics
- Payment consistency trends over time
Member turnover and stability analysis:
- Member turnover rate
- Default rate
- Average member tenure
- Retention metrics
Long-term performance tracking:
- Completed and successful cycles
- Milestone achievements
- Crisis recovery capabilities
- Health streak tracking
The rating engine integrates with the main SoroSusu contract through:
- Member Data: Access to member information and status
- Social Capital: Trust scores and reputation data
- Payment History: Contribution and payment records
- Milestone Data: Achievement and performance metrics
let metrics = rating_engine.calculate_group_health_score(env, circle_id);
println!("Group {} Health Score: {} ({})",
circle_id,
metrics.health_score,
metrics.rating);let healthy_groups = rating_engine.search_healthy_groups(
env,
GroupHealthRating::Good,
10
);let at_risk_groups = rating_engine.get_groups_at_risk(
env,
GroupHealthRating::Poor,
5
);- Transparency: Clear visibility into group health before joining
- Risk Assessment: Data-driven decision making
- Due Diligence: Comprehensive group performance metrics
- Self-Moderation: Incentive to maintain healthy group dynamics
- Reputation Building: High health scores attract quality members
- Performance Tracking: Identify and address issues proactively
- Quality Control: Automatic filtering of low-quality groups
- Risk Management: Early identification of problematic groups
- Trust Building: Transparent reputation system
GroupHealthMetrics: Primary health score storagePaymentHistory: Payment consistency dataMemberStabilityMetrics: Member turnover trackingHistoricalPerformance: Long-term performance dataHealthScoreHistory: Time-series health score tracking
The health score calculation uses a weighted average approach with basis points (bps) for precision:
health_score = (
(aggregate_reputation * 4000) / 10000 +
(payment_consistency * 3500) / 10000 +
(member_stability * 1500) / 10000 +
(historical_performance * 1000) / 10000
).min(10000)Health scores are updated when:
- New members join or leave
- Payments are made (on-time or late)
- Members default or are ejected
- Milestones are achieved
- Manual recalculation is requested
- Read-Only Public Access: Health scores are publicly readable but only authorized updates
- Data Integrity: All calculations use verified data from the main contract
- Manipulation Resistance: Multiple data points make score manipulation difficult
- Transparent Logic: Open calculation methodology builds trust
- Machine Learning: Advanced pattern recognition for health prediction
- Social Graph Analysis: Network effects on group health
- Economic Factors: Market conditions impact on group performance
- Dynamic Weights: Adaptive weighting based on group characteristics
- Predictive Analytics: Early warning system for potential issues
Comprehensive test suite covering:
- Health score calculation accuracy
- Rating determination logic
- Search functionality
- Data integrity
- Edge cases and error handling
Run tests with:
cargo test group_resilience_rating_engine_testsThe rating engine is deployed as a separate contract that interacts with the main SoroSusu contract through contract clients. This modular approach allows for independent updates and maintenance.
The Group Resilience Rating Engine provides a robust, transparent, and data-driven system for evaluating group health in the SoroSusu platform. It creates incentives for healthy group behavior while giving prospective members the information they need to make informed decisions about joining groups.