referral-engine

Distribute order value across three referral generations with BigInt arithmetic and ledger entries.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/hobbong21/nuxia2 --skill referral-engine
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: referral-engine
Source: https://github.com/hobbong21/nuxia2/tree/main/.claude/skills/referral-engine
Command: npx skills add https://github.com/hobbong21/nuxia2 --skill referral-engine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

The Referral Engine addresses the need to automatically allocate revenue across a three-generation referral tree, ensuring predictable, auditable payouts while preventing common abuse vectors.

Core Features & Use Cases

  • Distributes order value to up to three generations at fixed rates: 3% to the direct referrer, 5% to the second-generation, and 17% to the third-generation, with 25% total payout. It uses precise integer arithmetic to avoid rounding and supports reversible adjustments for refunds. It also includes abuse prevention (self-referral, cycles, multi-account) and integrates with the payout ledger and batch processing.
  • Use Case: A commerce platform wants to reward a chain of referrals on each order and automatically adjust payouts when refunds occur, while maintaining audit trails.

Quick Start

Initialize the engine with a test order and verify that ledger entries show 3%, 5%, and 17% allocations for the direct, second, and third generations.

Frequently Asked Questions about referral-engine

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate referral payouts across multiple generations in a hierarchical tree?

Calculations for referral payouts use precise BigInt arithmetic to distribute order value across three generations, preventing floating-point rounding errors and ensuring exact integer payouts for direct, second, and third-generation referrers.

How do I prevent referral abuse like self-referrals and multi-account cycles?

Referral abuse prevention is handled by built-in safeguards that block self-referrals, detect cycles, and prevent multi-account manipulation during the order approval process.

How do I handle referral payout reversals when an order refund occurs?

Referral payout reversals during refunds are handled via a REVERT mechanism that automatically adjusts ledger entries, reversing the 3%, 5%, and 17% distributions previously granted to the referral tree.

Does Prisma support recursive CTEs for hierarchical referral tree calculations?

Yes, Prisma supports recursive CTEs for hierarchical referral tree calculations by executing raw SQL queries to locate ancestors, enabling the engine to traverse up to three generations for payout distribution.

How do I ensure referral ledger entries are auditable and prevent duplicate payouts?

Auditable referral ledger entries and duplicate payout prevention are achieved by recording unique ledger entries for each transaction, ensuring every 3%, 5%, and 17% distribution is traceable and cannot be duplicated.