Referral System

xendune implements a two-tier referral system managed by the InviteRegistry contract. Referral rewards are automatically distributed from the platform fee to the seller's invite chain on order settlement.

How It Works

Registration

  1. New user calls InviteRegistry.register(inviterAddress) to bind an inviter
  2. InviteRegistry records on-chain: the direct inviter (L1) and the inviter's inviter (L2)
  3. Each address can only register once (immutable once set)
  4. Cannot invite yourself, cannot invite a contract address, no circular chains

Reward Distribution

On every order settlement, the business contract transfers the fee into InviteRegistry and calls distributeFee(seller, feeAmount, token):

  1. Check if the seller has an L1 inviter → transfer L1 reward
  2. Check if the seller has an L2 inviter → transfer L2 reward
  3. Remaining fee distributed to the platform via PlatformFeeSplitter (3-way split)
Note: Rewards are based on the seller's invite chain only — the buyer's inviter is not involved.

Reward Rates

Tier Rate (of platform fee) Source
L1 (seller's direct inviter) 20% PlatformSettings.level1Rate = 2000
L2 (seller's second-tier inviter) 10% PlatformSettings.level2Rate = 1000
Platform 70% PlatformSettings.platformRate = 7000

The three rates must sum to 10000 (100%). The owner can adjust via setInviteRates(), but the sum is always validated.

Fee Flow Example

For a 100 USDT order with 3% platform fee (e.g., physical or virtual goods):

  1. Platform fee: 3 USDT
  2. Seller's L1 inviter reward: 0.60 USDT (3 USDT × 20%)
  3. Seller's L2 inviter reward: 0.30 USDT (3 USDT × 10%)
  4. Platform net income: 2.10 USDT (distributed via PlatformFeeSplitter 3-way split)
  5. Seller receives: 97 USDT

If the seller has no inviter, the corresponding reward goes to the platform. If L2 does not exist, the L2 share also goes to the platform.

Security