npm run validate-referralThis will show you:
- How earnings compare between old ($0.25 flat) and new (1%) models
- Break-even point ($25)
- Sample calculations for various transaction amounts
Expected Output:
Transaction | Old Model | New Model | Difference | Better For
------------|-----------|-----------|------------|------------
$1.00 | $0.2500 | $0.0100 | -0.2400 | Old ($0.25)
$25.00 | $0.2500 | $0.2500 | +0.0000 | Equal
$100.00 | $0.2500 | $1.0000 | +0.7500 | New (1%)
$1000.00 | $0.2500 | $10.0000 | +9.7500 | New (1%)
📊 Break-even point: $25.00
npm run validate-referral:liveThis will:
- Analyze your recent earnings transactions
- Show total earnings comparison
- Generate a CSV report in
output/directory - Validate points balance integrity
Look for:
- ✅ All calculations match expected (1% of volume)
- ✅ No invalid balances reported
- ✅ CSV report generated successfully
⚠️ Any warnings or errors
Break-Even Point: $25
- Transactions < $25: Old model pays more
- Transactions = $25: Both models equal
- Transactions > $25: New model pays more
Impact on Different Transaction Sizes:
| Volume | Old Earnings | New Earnings | Change |
|---|---|---|---|
| $10 | $0.25 | $0.10 | -60% |
| $25 | $0.25 | $0.25 | 0% |
| $50 | $0.25 | $0.50 | +100% |
| $100 | $0.25 | $1.00 | +300% |
| $500 | $0.25 | $5.00 | +1900% |
| $1,000 | $0.25 | $10.00 | +3900% |
If your average transaction is around $50-$100:
- ~20-30% of transactions will earn less (small transactions)
- ~70-80% of transactions will earn more (medium-large transactions)
- Overall earnings will likely increase significantly
- Calculations are accurate (earnings = volume × 0.01)
- No invalid balances
- CSV report generated
- Most transactions show higher earnings
- Invalid balances (totalEarned < currentBalance)
- Calculation mismatches
- Database connection errors
- Unexpected earnings amounts
- Review the CSV report for any anomalies
- Check the transaction distribution
- Verify break-even point makes sense for your use case
- Test in staging environment
- Deploy to production
- Monitor first few live transactions
- Review error messages carefully
- Check the specific transactions with issues
- Verify
sellAmountUsdcalculation in TransactionManager - Ensure exchange rate is correct (NGN/USD not USD/NGN)
- Test with known transaction amounts
- Fix issues before deploying
- Normal if database is empty
- Expected in development environment
- Run sample mode instead:
npm run validate-referral
- Check MongoDB is running
- Verify MONGODB_URI in .env
- Try:
MONGODB_URI=mongodb://localhost:27017/chainpaye npm run validate-referral:live
- Data integrity issue
- totalEarned should always be ≥ currentBalance
- Investigate and fix before deploying
Earnings = $0.25 (always)
Earnings = Transaction Volume (USD) × 0.01
Examples:
- $10 transaction → $10 × 0.01 = $0.10
- $50 transaction → $50 × 0.01 = $0.50
- $100 transaction → $100 × 0.01 = $1.00
- $1,000 transaction → $1,000 × 0.01 = $10.00
Old Earnings = New Earnings
$0.25 = Volume × 0.01
Volume = $0.25 / 0.01
Volume = $25
Therefore, $25 is the break-even point
Before deploying, ensure:
- Sample validation runs successfully
- All calculations are accurate (1% of volume)
- No invalid balances in database
- Break-even point is $25
- CSV report looks correct
- EarningsService tests pass
- Integration tests pass
- Staging environment tested
If you encounter issues:
- Check
scripts/VALIDATION_README.mdfor detailed documentation - Review error messages in console output
- Check CSV report in
output/directory - Verify database connection
- Test with sample data first
# Test with sample data (no DB needed)
npm run validate-referral
# Compare old vs new models
npm run validate-referral:compare
# Validate against live database
npm run validate-referral:live
# Validate specific number of transactions
npm run validate-referral:live -- --limit=100
# With custom MongoDB URI
MONGODB_URI=mongodb://localhost:27017/chainpaye npm run validate-referral:liveAfter successful validation:
- ✅ Run tests:
npm test services/EarningsService.test.ts - ✅ Check diagnostics: Review any TypeScript errors
- ✅ Test in staging: Deploy to staging environment
- ✅ Monitor closely: Watch first few live transactions
- ✅ Update documentation: Inform users of new model
- ✅ Celebrate: You've successfully updated the referral system! 🎉