Updated the referral earnings system from a percentage-based model to a flat fee model.
- Referrer earned 25% of 1.5% transaction fee
- Earnings = Transaction Amount × 0.015 × 0.25
- Variable earnings based on transaction size
- Referrer earns flat $0.25 USD per offramp transaction
- Earnings = $0.25 (constant)
- Fixed earnings regardless of transaction size
- Removed:
calculateFee()method (no longer needed) - Removed:
calculateReferrerEarnings(fee: number)method - Added:
getReferrerEarnings()method - returns flat $0.25 - Added:
FLAT_REFERRAL_EARNINGS_USDconstant = 0.25 - Updated:
processTransactionEarnings()to use flat fee- Now credits exactly $0.25 per transaction
feeAmountin EarningsTransaction now equals earnings (both $0.25)
- Updated:
feeAmountfield description- Old: "Original transaction fee (1.5% of transaction amount)"
- New: "Flat referral earnings amount ($0.25 USD per transaction)"
- Removed: Tests for
calculateFee()method - Removed: Tests for
calculateReferrerEarnings()method - Added: Tests for
getReferrerEarnings()method - Updated: All property-based tests to verify flat $0.25 earnings
- Property 9: Verifies earnings are always $0.25
- Property 11: Verifies balance increases by $0.25 per transaction
- Property 14: Verifies flat earnings precision
- Updated: Integration test expectations to use $0.25 flat fee
The referral earnings are processed in:
services/crypto-off-ramp/TransactionManager.ts- CallshandleOfframpTransactionafter successful offrampwebhooks/controllers/referral.controller.ts- Handles the webhook and callsprocessTransactionEarningsservices/EarningsService.ts- Credits $0.25 to referrer's points balance
services/crypto-off-ramp/TransactionManager.ts- No changes needed (already passes transaction data)webhooks/controllers/referral.controller.ts- No changes needed (interface unchanged)
All tests updated to reflect the new flat fee model:
- Unit tests verify
getReferrerEarnings()returns 0.25 - Property-based tests verify earnings are always $0.25 regardless of transaction amount
- Integration tests verify balance increases by exactly $0.25 per transaction
- Existing
EarningsTransactionrecords remain valid - The
feeAmountfield now represents the flat $0.25 instead of calculated percentage - Historical data interpretation may need adjustment for analytics
- No database migrations required
- No environment variable changes needed
- Existing referral relationships continue to work
- 30-day earning period remains unchanged